Re: [libcxx] r291331 - thread: implement sleep_for on Windows

2017-01-06 Thread Asiri Rathnayake via cfe-commits
Wouldn't it be better to introduce a __libcpp_thread_nanosleep() API call
here?

I bumped into a similar issue with a custom thread implementation and have
a downstream patch like that.

Cheers,

/ Asiri


On 7 Jan 2017 2:59 a.m., "Saleem Abdulrasool via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: compnerd
Date: Fri Jan  6 20:48:30 2017
New Revision: 291331

URL: http://llvm.org/viewvc/llvm-project?rev=291331=rev
Log:
thread: implement sleep_for on Windows

Windows does not provide an implementation of `nanosleep`.  Round up the
time duration to the nearest ms and use `Sleep`.  Although this may
over-sleep, there is no hard real-time guarantee on the wake, so
sleeping a bit more is better than under-sleeping as it within the
specification.

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/
thread.cpp?rev=291331=291330=291331=diff

==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Fri Jan  6 20:48:30 2017
@@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)
 using namespace chrono;
 if (ns > nanoseconds::zero())
 {
+#if defined(_LIBCPP_WIN32API)
+milliseconds ms = duration_cast(ns);
+if (ns > duration_cast(ms))
+  ++ms;
+Sleep(ms.count());
+#else
 seconds s = duration_cast(ns);
 timespec ts;
 typedef decltype(ts.tv_sec) ts_sec;
@@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)

 while (nanosleep(, ) == -1 && errno == EINTR)
 ;
+#endif
 }
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows

2017-01-06 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added inline comments.



Comment at: lib/CMakeLists.txt:108-109
+if (LIBCXX_TARGETING_WINDOWS)
+  add_compile_flags(/Zl)
+  add_link_flags(/nodefaultlib)
+  add_library_flags(ucrt) # Universal C runtime

smeenai wrote:
> These should be guarded under a check for a cl or cl-like frontend rather 
> than `LIBCXX_TARGETING_WINDOWS` (since in theory we could be using the 
> regular clang frontend to compile for Windows as well).
Regular clang supports both gcc-like and cl-like options (there are 2 
compilers: clang.exe and clang-cl.exe). I think it is not worth it to support 
both considering they differ only in command line options handling.



Comment at: lib/CMakeLists.txt:111
+  add_library_flags(ucrt) # Universal C runtime
+  add_library_flags(vcruntime) # C++ runtime
+  add_library_flags(msvcrt) # C runtime startup files

smeenai wrote:
> Idk if there's anything specific to C++ in vcruntime; it's more compiler 
> runtime functions as far as I know.
It contains exception handling stuff.


https://reviews.llvm.org/D28441



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28442: [libc++] Implement terminate(), unexpected() and uncaught_exceptions() on Windows

2017-01-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

Hooray for Microsoft for putting all these in msvcrt (their **C** runtime 
library) instead of msvcprt (their C++ runtime library), I guess :p




Comment at: src/exception.cpp:53
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::set_unexpected(func);
+#else

MSDN says "unexpected is not used in the current C++ exception-handling 
implementation", which is maybe not the most desirable thing in the world, but 
I guess this is going away in C++17 anyway :D



Comment at: src/exception.cpp:139
+#elif defined(_LIBCPP_ABI_MICROSOFT)
+return __uncaught_exceptions();
+#else

Yay undocumented APIs (at least as far as I can see).


https://reviews.llvm.org/D28442



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows

2017-01-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: CMakeLists.txt:43
+if (WIN32 AND NOT MINGW)
+  set(LIBCXX_TARGETING_WINDOWS ON)
+else()

Not the biggest fan of this name, since it's not obvious why MinGW shouldn't 
count as targeting Windows. I thought of `LIBCXX_TARGETING_NATIVE_WINDOWS` or 
`LIBCXX_TARGETING_MSVCRT` instead, but MinGW is also native Windows and targets 
MSVCRT, so those names aren't any better from that perspective either. I can't 
think of anything else at the moment, but I'm sure there's a better name.



Comment at: CMakeLists.txt:388
+# non-debug DLLs
+remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md" "/RTC1")
+

cl (and presumably clang-cl) also accepts all these flags with a leading dash 
instead of a leading slash, and cmake at least has a tendency to do `-D` 
instead of `/D`, so you might need to take those into account as well. Also, 
what about the other potential `/RTC` options?



Comment at: lib/CMakeLists.txt:108-109
+if (LIBCXX_TARGETING_WINDOWS)
+  add_compile_flags(/Zl)
+  add_link_flags(/nodefaultlib)
+  add_library_flags(ucrt) # Universal C runtime

These should be guarded under a check for a cl or cl-like frontend rather than 
`LIBCXX_TARGETING_WINDOWS` (since in theory we could be using the regular clang 
frontend to compile for Windows as well).



Comment at: lib/CMakeLists.txt:111
+  add_library_flags(ucrt) # Universal C runtime
+  add_library_flags(vcruntime) # C++ runtime
+  add_library_flags(msvcrt) # C runtime startup files

Idk if there's anything specific to C++ in vcruntime; it's more compiler 
runtime functions as far as I know.



Comment at: lib/CMakeLists.txt:113
+  add_library_flags(msvcrt) # C runtime startup files
+  add_library_flags(iso_stdio_wide_specifiers)
+endif()

Maybe add a comment explaining the purpose of this one as well?


https://reviews.llvm.org/D28441



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291337 - Explicitly specify MSVC mangling of iostream globals. Patch from Dave Lee

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Jan  7 00:09:12 2017
New Revision: 291337

URL: http://llvm.org/viewvc/llvm-project?rev=291337=rev
Log:
Explicitly specify MSVC mangling of iostream globals. Patch from Dave Lee

Modified:
libcxx/trunk/src/iostream.cpp

Modified: libcxx/trunk/src/iostream.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/iostream.cpp?rev=291337=291336=291337=diff
==
--- libcxx/trunk/src/iostream.cpp (original)
+++ libcxx/trunk/src/iostream.cpp Sat Jan  7 00:09:12 2017
@@ -14,32 +14,64 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifndef _LIBCPP_HAS_NO_STDIN
-_ALIGNAS_TYPE (istream)  _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
-_ALIGNAS_TYPE (__stdinbuf ) static char __cin [sizeof(__stdinbuf 
)];
+_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?cin@__1@std@@3V?$basic_istream@DU?$char_traits@D@__1@std@@@12@A")
+#endif
+;
+_ALIGNAS_TYPE (__stdinbuf ) static char __cin[sizeof(__stdinbuf )];
 static mbstate_t mb_cin;
-_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)];
-_ALIGNAS_TYPE (__stdinbuf ) static char __wcin [sizeof(__stdinbuf 
)];
+_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?wcin@__1@std@@3V?$basic_istream@_WU?$char_traits@_W@__1@std@@@12@A")
+#endif
+;
+_ALIGNAS_TYPE (__stdinbuf ) static char __wcin[sizeof(__stdinbuf 
)];
 static mbstate_t mb_wcin;
 #endif
 
 #ifndef _LIBCPP_HAS_NO_STDOUT
-_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char cout[sizeof(ostream)];
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?cout@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+#endif
+;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__cout[sizeof(__stdoutbuf)];
 static mbstate_t mb_cout;
-_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)];
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?wcout@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+#endif
+;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__wcout[sizeof(__stdoutbuf)];
 static mbstate_t mb_wcout;
 #endif
 
-_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?cerr@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+#endif
+;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__cerr[sizeof(__stdoutbuf)];
 static mbstate_t mb_cerr;
-_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)];
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?wcerr@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+#endif
+;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__wcerr[sizeof(__stdoutbuf)];
 static mbstate_t mb_wcerr;
 
-_ALIGNAS_TYPE (ostream)  _LIBCPP_FUNC_VIS char clog[sizeof(ostream)];
-_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)];
+_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?clog@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+#endif
+;
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]
+#if defined(_MSC_VER) && defined(__clang__)
+__asm__("?wclog@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+#endif
+;
 
 ios_base::Init __start_std_streams;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24688: Introduce "hosted" module flag.

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D24688#638835, @pcc wrote:

> Didn't we figure out in the end that this could be a function attribute 
> instead?


We did? You wrote in PR30403: "I had a brief look at what it would take to have 
a per-function TLI, and I'm not convinced that it would be worth the effort."


https://reviews.llvm.org/D24688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24688: Introduce "hosted" module flag.

2017-01-06 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Didn't we figure out in the end that this could be a function attribute instead?


https://reviews.llvm.org/D24688



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28441: [libc++] [CMake] Link with /nodefaultlibs on Windows

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Adding cfe-commits


https://reviews.llvm.org/D28441



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28442: [libc++] Implement terminate(), unexpected() and uncaught_exceptions() on Windows

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: compnerd, smeenai, rnk, majnemer.
EricWF added a subscriber: cfe-commits.

This patch implements the following functions on Windows by forwarding to the 
MSVCRT:

- `get_terminate()`
- `set_terminate()`
- `terminate()`
- `set_unexpected()`
- `get_unexpected()`
- `unexpected()`
- `uncaught_exception()`

- `uncaught_exceptions()`


https://reviews.llvm.org/D28442

Files:
  src/exception.cpp


Index: src/exception.cpp
===
--- src/exception.cpp
+++ src/exception.cpp
@@ -12,7 +12,10 @@
 #include "exception"
 #include "new"
 
-#if defined(__APPLE__) && !defined(LIBCXXRT) && \
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#include 
+#include 
+#elif defined(__APPLE__) && !defined(LIBCXXRT) && \
 !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
   #include 
 
@@ -46,13 +49,21 @@
 unexpected_handler
 set_unexpected(unexpected_handler func) _NOEXCEPT
 {
-return __sync_lock_test_and_set(&__unexpected_handler, func);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::set_unexpected(func);
+#else
+  return __sync_lock_test_and_set(&__unexpected_handler, func);
+#endif
 }
 
 unexpected_handler
 get_unexpected() _NOEXCEPT
 {
-return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::_get_unexpected();
+#else
+  return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
+#endif
 }
 
 _LIBCPP_NORETURN
@@ -67,13 +78,21 @@
 terminate_handler
 set_terminate(terminate_handler func) _NOEXCEPT
 {
-return __sync_lock_test_and_set(&__terminate_handler, func);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::set_terminate(func);
+#else
+  return __sync_lock_test_and_set(&__terminate_handler, func);
+#endif
 }
 
 terminate_handler
 get_terminate() _NOEXCEPT
 {
-return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::_get_terminate();
+#else
+  return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
+#endif
 }
 
 #ifndef __EMSCRIPTEN__ // We provide this in JS
@@ -103,6 +122,7 @@
 #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
 
 #if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
+
 bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
 
 int uncaught_exceptions() _NOEXCEPT
@@ -115,7 +135,9 @@
 # else
 return __cxa_uncaught_exception() ? 1 : 0;
 # endif
-#else  // __APPLE__
+#elif defined(_LIBCPP_ABI_MICROSOFT)
+return __uncaught_exceptions();
+#else
 #   if defined(_MSC_VER) && ! defined(__clang__)
 _LIBCPP_WARNING("uncaught_exceptions not yet implemented")
 #   else


Index: src/exception.cpp
===
--- src/exception.cpp
+++ src/exception.cpp
@@ -12,7 +12,10 @@
 #include "exception"
 #include "new"
 
-#if defined(__APPLE__) && !defined(LIBCXXRT) && \
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#include 
+#include 
+#elif defined(__APPLE__) && !defined(LIBCXXRT) && \
 !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
   #include 
 
@@ -46,13 +49,21 @@
 unexpected_handler
 set_unexpected(unexpected_handler func) _NOEXCEPT
 {
-return __sync_lock_test_and_set(&__unexpected_handler, func);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::set_unexpected(func);
+#else
+  return __sync_lock_test_and_set(&__unexpected_handler, func);
+#endif
 }
 
 unexpected_handler
 get_unexpected() _NOEXCEPT
 {
-return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::_get_unexpected();
+#else
+  return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
+#endif
 }
 
 _LIBCPP_NORETURN
@@ -67,13 +78,21 @@
 terminate_handler
 set_terminate(terminate_handler func) _NOEXCEPT
 {
-return __sync_lock_test_and_set(&__terminate_handler, func);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::set_terminate(func);
+#else
+  return __sync_lock_test_and_set(&__terminate_handler, func);
+#endif
 }
 
 terminate_handler
 get_terminate() _NOEXCEPT
 {
-return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  return ::_get_terminate();
+#else
+  return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
+#endif
 }
 
 #ifndef __EMSCRIPTEN__ // We provide this in JS
@@ -103,6 +122,7 @@
 #endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
 
 #if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
+
 bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
 
 int uncaught_exceptions() _NOEXCEPT
@@ -115,7 +135,9 @@
 # else
 return __cxa_uncaught_exception() ? 1 : 0;
 # endif
-#else  // __APPLE__
+#elif defined(_LIBCPP_ABI_MICROSOFT)
+return __uncaught_exceptions();
+#else
 #   if defined(_MSC_VER) && ! defined(__clang__)
 

[PATCH] D24688: Introduce "hosted" module flag.

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83510.
mehdi_amini added a comment.

Rebase


https://reviews.llvm.org/D24688

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/nobuiltin.c
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenCXX/strict-vtable-pointers.cpp
  lld/test/ELF/lto/undefined-puts.ll
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/LTO/UpdateCompilerUsed.cpp
  llvm/test/Analysis/GlobalsModRef/indirect-global.ll
  llvm/test/Analysis/GlobalsModRef/memset-escape.ll
  llvm/test/Analysis/TypeBasedAliasAnalysis/memcpyopt.ll
  llvm/test/CodeGen/AArch64/arm64-fcopysign.ll
  llvm/test/CodeGen/AArch64/arm64-rounding.ll
  llvm/test/CodeGen/AArch64/arm64-sincos.ll
  llvm/test/CodeGen/AArch64/floatdp_1source.ll
  llvm/test/CodeGen/AArch64/round-conv.ll
  llvm/test/CodeGen/AMDGPU/complex-folding.ll
  llvm/test/CodeGen/AMDGPU/fabs.f64.ll
  llvm/test/CodeGen/AMDGPU/fabs.ll
  llvm/test/CodeGen/AMDGPU/floor.ll
  llvm/test/CodeGen/AMDGPU/fneg-fabs.f64.ll
  llvm/test/CodeGen/AMDGPU/fneg-fabs.ll
  llvm/test/CodeGen/AMDGPU/llvm.SI.fs.interp.ll
  llvm/test/CodeGen/AMDGPU/r600-infinite-loop-bug-while-reorganizing-vector.ll
  llvm/test/CodeGen/AMDGPU/schedule-if-2.ll
  llvm/test/CodeGen/ARM/apcs-vfp.ll
  llvm/test/CodeGen/ARM/arm32-round-conv.ll
  llvm/test/CodeGen/ARM/arm32-rounding.ll
  llvm/test/CodeGen/ARM/fabs-to-bfc.ll
  llvm/test/CodeGen/ARM/fabss.ll
  llvm/test/CodeGen/ARM/fcopysign.ll
  llvm/test/CodeGen/ARM/floorf.ll
  llvm/test/CodeGen/ARM/fparith.ll
  llvm/test/CodeGen/ARM/ifcvt10.ll
  llvm/test/CodeGen/ARM/sincos.ll
  llvm/test/CodeGen/ARM/v7k-libcalls.ll
  llvm/test/CodeGen/ARM/v7k-sincos.ll
  llvm/test/CodeGen/ARM/vfp.ll
  llvm/test/CodeGen/Hexagon/fminmax.ll
  llvm/test/CodeGen/Hexagon/opt-fabs.ll
  llvm/test/CodeGen/Mips/f16abs.ll
  llvm/test/CodeGen/Mips/fabs.ll
  llvm/test/CodeGen/Mips/fcopysign-f32-f64.ll
  llvm/test/CodeGen/Mips/fcopysign.ll
  llvm/test/CodeGen/Mips/llvm-ir/sqrt.ll
  llvm/test/CodeGen/Mips/mips64-f128.ll
  llvm/test/CodeGen/Mips/optimize-fp-math.ll
  llvm/test/CodeGen/PowerPC/copysignl.ll
  llvm/test/CodeGen/PowerPC/fabs.ll
  llvm/test/CodeGen/PowerPC/fcpsgn.ll
  llvm/test/CodeGen/PowerPC/fnabs.ll
  llvm/test/CodeGen/PowerPC/rounding-ops.ll
  llvm/test/CodeGen/PowerPC/vsx-elementary-arith.ll
  llvm/test/CodeGen/SPARC/64abi.ll
  llvm/test/CodeGen/SystemZ/fp-copysign-01.ll
  llvm/test/CodeGen/SystemZ/fp-sincos-01.ll
  llvm/test/CodeGen/SystemZ/fp-sqrt-01.ll
  llvm/test/CodeGen/SystemZ/fp-sqrt-02.ll
  llvm/test/CodeGen/SystemZ/memchr-01.ll
  llvm/test/CodeGen/SystemZ/memchr-02.ll
  llvm/test/CodeGen/SystemZ/memcmp-01.ll
  llvm/test/CodeGen/SystemZ/memcmp-02.ll
  llvm/test/CodeGen/SystemZ/strcmp-01.ll
  llvm/test/CodeGen/SystemZ/strcmp-02.ll
  llvm/test/CodeGen/SystemZ/strcpy-01.ll
  llvm/test/CodeGen/SystemZ/strlen-01.ll
  llvm/test/CodeGen/SystemZ/strlen-02.ll
  llvm/test/CodeGen/X86/avx512-arith.ll
  llvm/test/CodeGen/X86/fabs.ll
  llvm/test/CodeGen/X86/fmaxnum.ll
  llvm/test/CodeGen/X86/fminnum.ll
  llvm/test/CodeGen/X86/fnabs.ll
  llvm/test/CodeGen/X86/fp-in-intregs.ll
  llvm/test/CodeGen/X86/fp128-cast.ll
  llvm/test/CodeGen/X86/fp128-i128.ll
  llvm/test/CodeGen/X86/memcmp.ll
  llvm/test/CodeGen/X86/mempcpy.ll
  llvm/test/CodeGen/X86/pr13577.ll
  llvm/test/CodeGen/X86/pr2656.ll
  llvm/test/CodeGen/X86/pr26625.ll
  llvm/test/CodeGen/X86/rounding-ops.ll
  llvm/test/CodeGen/X86/sincos-opt.ll
  llvm/test/CodeGen/X86/sincos.ll
  llvm/test/CodeGen/X86/stack-align.ll
  llvm/test/Instrumentation/AddressSanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/BoundsChecking/simple.ll
  llvm/test/Instrumentation/EfficiencySanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/MemorySanitizer/str-nobuiltin.ll
  llvm/test/Instrumentation/ThreadSanitizer/str-nobuiltin.ll
  llvm/test/LTO/X86/runtime-library.ll
  llvm/test/LTO/X86/triple-init.ll
  llvm/test/Transforms/ConstProp/calls.ll
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/DeadStoreElimination/2016-07-17-UseAfterFree.ll
  llvm/test/Transforms/DeadStoreElimination/calloc-store.ll
  llvm/test/Transforms/DeadStoreElimination/fence.ll
  llvm/test/Transforms/DeadStoreElimination/free.ll
  llvm/test/Transforms/DeadStoreElimination/libcalls.ll
  llvm/test/Transforms/DeadStoreElimination/operand-bundles.ll
  llvm/test/Transforms/DeadStoreElimination/simple.ll
  llvm/test/Transforms/GVN/calloc-load-removal.ll
  llvm/test/Transforms/GVN/malloc-load-removal.ll
  llvm/test/Transforms/GVN/no_speculative_loads_with_asan.ll
  llvm/test/Transforms/GVN/nonescaping-malloc.ll
  llvm/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
  llvm/test/Transforms/GlobalOpt/MallocSROA-section.ll
  llvm/test/Transforms/GlobalOpt/ctor-list-opt.ll
  

[PATCH] D28344: [AVR] Add support for the full set of inline asm constraints

2017-01-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay marked an inline comment as done.
dylanmckay added inline comments.



Comment at: lib/Basic/Targets.cpp:8506
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+  case 'O': // Integer constant (Range: 8, 16, 24)

ahatanak wrote:
> Is this meant to fall through or do you need a "break" here?
Nice catch, fixed


https://reviews.llvm.org/D28344



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28344: [AVR] Add support for the full set of inline asm constraints

2017-01-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 83507.
dylanmckay added a comment.

Add tests for inline assembly constraints


https://reviews.llvm.org/D28344

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avr-inline-asm-constraints.c

Index: test/CodeGen/avr-inline-asm-constraints.c
===
--- /dev/null
+++ test/CodeGen/avr-inline-asm-constraints.c
@@ -0,0 +1,114 @@
+// REQUIRES: avr-registered-target
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+int data;
+
+void a() {
+  // CHECK: call void asm sideeffect "add r5, $0", "a"(i16 %0)
+  asm("add r5, %0" :: "a"(data));
+}
+
+void b() {
+  // CHECK: call void asm sideeffect "add r5, $0", "b"(i16 %0)
+  asm("add r5, %0" :: "b"(data));
+}
+
+void d() {
+  // CHECK: call void asm sideeffect "add r5, $0", "d"(i16 %0)
+  asm("add r5, %0" :: "d"(data));
+}
+
+void l() {
+  // CHECK: call void asm sideeffect "add r5, $0", "l"(i16 %0)
+  asm("add r5, %0" :: "l"(data));
+}
+
+void e() {
+  // CHECK: call void asm sideeffect "add r5, $0", "e"(i16 %0)
+  asm("add r5, %0" :: "e"(data));
+}
+
+void q() {
+  // CHECK: call void asm sideeffect "add r5, $0", "q"(i16 %0)
+  asm("add r5, %0" :: "q"(data));
+}
+
+void r() {
+  // CHECK: call void asm sideeffect "add r5, $0", "r"(i16 %0)
+  asm("add r5, %0" :: "r"(data));
+}
+
+void w() {
+  // CHECK: call void asm sideeffect "add r5, $0", "w"(i16 %0)
+  asm("add r5, %0" :: "w"(data));
+}
+
+void t() {
+  // CHECK: call void asm sideeffect "add r5, $0", "t"(i16 %0)
+  asm("add r5, %0" :: "t"(data));
+}
+
+void x() {
+  // CHECK: call void asm sideeffect "add r5, $0", "x"(i16 %0)
+  asm("add r5, %0" :: "x"(data));
+}
+
+void y() {
+  // CHECK: call void asm sideeffect "add r5, $0", "y"(i16 %0)
+  asm("add r5, %0" :: "y"(data));
+}
+
+void z() {
+  // CHECK: call void asm sideeffect "add r5, $0", "z"(i16 %0)
+  asm("add r5, %0" :: "z"(data));
+}
+
+void I() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "I"(i16 50)
+  asm("subi r30, %0" :: "I"(50));
+}
+
+void J() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "J"(i16 -50)
+  asm("subi r30, %0" :: "J"(-50));
+}
+
+void K() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "K"(i16 2)
+  asm("subi r30, %0" :: "K"(2));
+}
+
+void L() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "L"(i16 0)
+  asm("subi r30, %0" :: "L"(0));
+}
+
+void M() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "M"(i16 255)
+  asm("subi r30, %0" :: "M"(255));
+}
+
+void O() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "O"(i16 16)
+  asm("subi r30, %0" :: "O"(16));
+}
+
+void P() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "P"(i16 1)
+  asm("subi r30, %0" :: "P"(1));
+}
+
+void R() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "R"(i16 -3)
+  asm("subi r30, %0" :: "R"(-3));
+}
+
+void G() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "G"(i16 50)
+  asm("subi r30, %0" :: "G"(50));
+}
+
+void Q() {
+  // CHECK: call void asm sideeffect "subi r30, $0", "Q"(i16 50)
+  asm("subi r30, %0" :: "Q"(50));
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8468,7 +8468,56 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
-return false;
+// There aren't any multi-character AVR specific constraints.
+if (StringRef(Name).size() > 1) return false;
+
+switch (*Name) {
+  default: return false;
+  case 'a': // Simple upper registers
+  case 'b': // Base pointer registers pairs
+  case 'd': // Upper register
+  case 'l': // Lower registers
+  case 'e': // Pointer register pairs
+  case 'q': // Stack pointer register
+  case 'r': // Any register
+  case 'w': // Special upper register pairs
+  case 't': // Temporary register
+  case 'x': case 'X': // Pointer register pair X
+  case 'y': case 'Y': // Pointer register pair Y
+  case 'z': case 'Z': // Pointer register pair Z
+Info.setAllowsRegister();
+return true;
+  case 'I': // 6-bit positive integer constant
+Info.setRequiresImmediate(0, 63);
+return true;
+  case 'J': // 6-bit negative integer constant
+Info.setRequiresImmediate(-63, 0);
+return true;
+  case 'K': // Integer constant (Range: 2)
+Info.setRequiresImmediate(2);
+return true;
+  case 'L': // Integer constant (Range: 0)
+Info.setRequiresImmediate(0);
+return true;
+  case 'M': // 8-bit integer constant
+Info.setRequiresImmediate(0, 0xff);
+return true;
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+return true;
+  case 'O': // Integer constant (Range: 8, 16, 24)
+Info.setRequiresImmediate({8, 16, 24});
+return 

[libcxx] r291336 - system_error: correct ELAST emulation on Windows

2017-01-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jan  6 23:13:32 2017
New Revision: 291336

URL: http://llvm.org/viewvc/llvm-project?rev=291336=rev
Log:
system_error: correct ELAST emulation on Windows

ELAST should point to the last valid error string value.  However,
`_sys_nerr` provides the number of elements in the errlist array.  Since
the index is 0-based, this is off-by-one.  Adjust it accordingly.

Thanks to David Majnemer for catching this!

Modified:
libcxx/trunk/src/include/config_elast.h

Modified: libcxx/trunk/src/include/config_elast.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/config_elast.h?rev=291336=291335=291336=diff
==
--- libcxx/trunk/src/include/config_elast.h (original)
+++ libcxx/trunk/src/include/config_elast.h Fri Jan  6 23:13:32 2017
@@ -31,7 +31,7 @@
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
 #elif defined(_LIBCPP_MSVCRT)
-#define _LIBCPP_ELAST _sys_nerr
+#define _LIBCPP_ELAST (_sys_nerr - 1)
 #else
 // Warn here so that the person doing the libcxx port has an easier time:
 #warning ELAST for this platform not yet implemented


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r291192 - config_elast: fix typo (NFC)

2017-01-06 Thread Saleem Abdulrasool via cfe-commits
FTR, this wasn't changed with the renaming.

But, taking a look at it does seem that it is off by one.  Well spotted!

On Thu, Jan 5, 2017 at 7:16 PM David Majnemer 
wrote:

> On Thu, Jan 5, 2017 at 3:25 PM, Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: compnerd
>
>
> Date: Thu Jan  5 17:25:44 2017
>
>
> New Revision: 291192
>
>
>
>
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291192=rev
>
>
> Log:
>
>
> config_elast: fix typo (NFC)
>
>
>
>
>
> Missed the original typo which was duplicated.  NFC.
>
>
>
>
>
> Modified:
>
>
> libcxx/trunk/src/include/config_elast.h
>
>
>
>
>
> Modified: libcxx/trunk/src/include/config_elast.h
>
>
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/config_elast.h?rev=291192=291191=291192=diff
>
>
>
> ==
>
>
> --- libcxx/trunk/src/include/config_elast.h (original)
>
>
> +++ libcxx/trunk/src/include/config_elast.h Thu Jan  5 17:25:44 2017
>
>
> @@ -30,7 +30,7 @@
>
>
>  // No _LIBCPP_ELAST needed on Apple
>
>
>  #elif defined(__sun__)
>
>
>  #define _LIBCPP_ELAST ESTALE
>
>
> -#elif defined(_LIBCPP_MSCVRT)
>
>
> +#elif defined(_LIBCPP_MSVCRT)
>
>
>  #define _LIBCPP_ELAST _sys_nerr
>
>
> Isn't ELAST supposed to point to a valid error number? Shouldn't this
> be _sys_nerr-1?
>
>
>
>
>  #else
>
>
>  // Warn here so that the person doing the libcxx port has an easier time:
>
>
>
>
>
>
>
>
> ___
>
>
> cfe-commits mailing list
>
>
> cfe-commits@lists.llvm.org
>
>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28344: [AVR] Add support for the full set of inline asm constraints

2017-01-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 83504.
dylanmckay added a comment.

Fix a few cases of unintentional switch fallthrough


https://reviews.llvm.org/D28344

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8468,7 +8468,56 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
-return false;
+// There aren't any multi-character AVR specific constraints.
+if (StringRef(Name).size() > 1) return false;
+
+switch (*Name) {
+  default: return false;
+  case 'a': // Simple upper registers
+  case 'b': // Base pointer registers pairs
+  case 'd': // Upper register
+  case 'l': // Lower registers
+  case 'e': // Pointer register pairs
+  case 'q': // Stack pointer register
+  case 'r': // Any register
+  case 'w': // Special upper register pairs
+  case 't': // Temporary register
+  case 'x': case 'X': // Pointer register pair X
+  case 'y': case 'Y': // Pointer register pair Y
+  case 'z': case 'Z': // Pointer register pair Z
+Info.setAllowsRegister();
+return true;
+  case 'I': // 6-bit positive integer constant
+Info.setRequiresImmediate(0, 63);
+return true;
+  case 'J': // 6-bit negative integer constant
+Info.setRequiresImmediate(-63, 0);
+return true;
+  case 'K': // Integer constant (Range: 2)
+Info.setRequiresImmediate(2);
+return true;
+  case 'L': // Integer constant (Range: 0)
+Info.setRequiresImmediate(0);
+return true;
+  case 'M': // 8-bit integer constant
+Info.setRequiresImmediate(0, 0xff);
+return true;
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+return true;
+  case 'O': // Integer constant (Range: 8, 16, 24)
+Info.setRequiresImmediate({8, 16, 24});
+return true;
+  case 'P': // Integer constant (Range: 1)
+Info.setRequiresImmediate(1);
+return true;
+  case 'R': // Integer constant (Range: -6 to 5)
+Info.setRequiresImmediate(-6, 5);
+return true;
+  case 'G': // Floating point constant
+  case 'Q': // A memory address based on Y or Z pointer with displacement.
+return true;
+}
   }
 
   IntType getIntTypeByWidth(unsigned BitWidth,


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8468,7 +8468,56 @@
 
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
-return false;
+// There aren't any multi-character AVR specific constraints.
+if (StringRef(Name).size() > 1) return false;
+
+switch (*Name) {
+  default: return false;
+  case 'a': // Simple upper registers
+  case 'b': // Base pointer registers pairs
+  case 'd': // Upper register
+  case 'l': // Lower registers
+  case 'e': // Pointer register pairs
+  case 'q': // Stack pointer register
+  case 'r': // Any register
+  case 'w': // Special upper register pairs
+  case 't': // Temporary register
+  case 'x': case 'X': // Pointer register pair X
+  case 'y': case 'Y': // Pointer register pair Y
+  case 'z': case 'Z': // Pointer register pair Z
+Info.setAllowsRegister();
+return true;
+  case 'I': // 6-bit positive integer constant
+Info.setRequiresImmediate(0, 63);
+return true;
+  case 'J': // 6-bit negative integer constant
+Info.setRequiresImmediate(-63, 0);
+return true;
+  case 'K': // Integer constant (Range: 2)
+Info.setRequiresImmediate(2);
+return true;
+  case 'L': // Integer constant (Range: 0)
+Info.setRequiresImmediate(0);
+return true;
+  case 'M': // 8-bit integer constant
+Info.setRequiresImmediate(0, 0xff);
+return true;
+  case 'N': // Integer constant (Range: -1)
+Info.setRequiresImmediate(-1);
+return true;
+  case 'O': // Integer constant (Range: 8, 16, 24)
+Info.setRequiresImmediate({8, 16, 24});
+return true;
+  case 'P': // Integer constant (Range: 1)
+Info.setRequiresImmediate(1);
+return true;
+  case 'R': // Integer constant (Range: -6 to 5)
+Info.setRequiresImmediate(-6, 5);
+return true;
+  case 'G': // Floating point constant
+  case 'Q': // A memory address based on Y or Z pointer with displacement.
+return true;
+}
   }
 
   IntType getIntTypeByWidth(unsigned BitWidth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

chandlerc wrote:
> mehdi_amini wrote:
> > probinson wrote:
> > > mehdi_amini wrote:
> > > > chandlerc wrote:
> > > > > Is this still at all correct? Why? it seems pretty confusing 
> > > > > especially in conjunction with the code below.
> > > > > 
> > > > > 
> > > > > I think this may force you to either:
> > > > > a) stop early-marking of -Os and -Oz flags with these attributes 
> > > > > (early: prior to calling this routine) and handling all of the -O 
> > > > > flag synthesized attributes here, or
> > > > > b) set optnone for -O0 wher ewe set optsize for -Os and friends, and 
> > > > > then remove it where necessary here.
> > > > > 
> > > > > I don't have any strong opinion about a vs. b.
> > > > I believe it is still correct: during Os/Oz we reach this point and 
> > > > figure that there is `__attribute__((optnone))` in the *source* (not 
> > > > `-O0`), we remove the attributes, nothing changes. Did I miss something?
> > > > 
> > > Hmmm the Os/Oz attributes are added in CGCall.cpp, and are guarded with a 
> > > check on the presence of the Optnone source attribute, so if the Optnone 
> > > source attribute is present we should never see these.  And Os/Oz set 
> > > OptimizationLevel to 2, which is not zero, so we won't come through here 
> > > for ShouldAddOptNone reasons either.
> > > Therefore these 'remove' calls should be no-ops and could be removed.  
> > > (For paranoia you could turn them into asserts, and do some experimenting 
> > > to see whether I'm confused about how this all fits together.)
> > The verifier is already complaining if we get this wrong, and indeed it 
> > complains if I'm removing these.
> > See clang/test/CodeGen/attr-func-def.c:
> > 
> > ```
> > 
> > int foo1(int);
> > 
> > int foo2(int a) {
> >   return foo1(a + 2);
> > }
> > 
> > __attribute__((optnone))
> > int foo1(int a) {
> > return a + 1;
> > }
> > ```
> > 
> > Here we have the attributed optnone on the definition but not the 
> > declaration, and the check you're mentioning in CGCalls is only applying to 
> > the declaration.
> This is all still incredibly confusing code.
> 
> I think what would make me happy with this is to have a separate section for 
> each mutually exclusive group of LLVM attributes added to the function. so:
> 
>   // Add the relevant optimization level to the LLVM function.
>   if (...) {
> B.addAttribute(llvm::Attribute::OptNone);
> F.removeFnAttr(llvm::ATtribute::OptForSize);
> ...
>   } else if (...) {
> B.addAttribute(llvm::Attribute::OptForSize);
>   } else if (...) }
> ...
>   }
> 
>   // Add the inlining control attributes.
>   if (...) {
> 
>   } else if (...) {
> 
>   } else if (...) {
> 
>   }
> 
>   // Add specific semantic attributes such as 'naked' and 'cold'.
>   if (D->hasAttr()) {
> B.addAttribute(...::Naked);
>   }
>   if (D->hasAttr()) {
> ...
>   }
> 
> Even though this means testing the Clang-level attributes multiple times, I 
> think it'll be much less confusing to read and update. We're actually already 
> really close. just need to hoist the non-inlining bits of optnone out, sink 
> the naked attribute down, and hoist the cold sizeopt up.
> 
Since you answer below the example I gave above, I just want to be sure you 
understand that the attributes for the *declarations* are not even handled in 
the same file right?
The "state machine" is cross TU here, and it seems to me what you're describing 
would require some refactoring between CGCall.cpp and CodeGenModule.cpp.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28346: [AVR] Allow specifying the CPU on the command line

2017-01-06 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay updated this revision to Diff 83496.
dylanmckay added a comment.

Add tests

This also defines the '__AVR' and 'AVR' values for all devices, to match what 
AVR-GCC does.


https://reviews.llvm.org/D28346

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avr/target-cpu-defines/atmega328p.c
  test/CodeGen/avr/target-cpu-defines/attiny104.c
  test/CodeGen/avr/target-cpu-defines/common.c
  test/CodeGen/avr/target-cpu-families.c
  test/CodeGen/avr/target-cpus.c

Index: test/CodeGen/avr/target-cpus.c
===
--- /dev/null
+++ test/CodeGen/avr/target-cpus.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu atmega328p -emit-llvm %s -o - | FileCheck %s --check-prefix=ATMEGA328P
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu atxmega192d3 -emit-llvm %s -o - | FileCheck %s --check-prefix=ATXMEGA192D3
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu attiny104 -emit-llvm %s -o - | FileCheck %s --check-prefix=ATTINY104
+
+// ATMEGA328P: hello_world
+// ATXMEGA192D3: hello_world
+// ATTINY104: hello_world
+void hello_world() { }
Index: test/CodeGen/avr/target-cpu-families.c
===
--- /dev/null
+++ test/CodeGen/avr/target-cpu-families.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avr1 -emit-llvm %s -o - | FileCheck %s --check-prefix=AVR1
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avr3 -emit-llvm %s -o - | FileCheck %s --check-prefix=AVR3
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avr31 -emit-llvm %s -o - | FileCheck %s --check-prefix=AVR31
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avr5 -emit-llvm %s -o - | FileCheck %s --check-prefix=AVR5
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avrxmega6 -emit-llvm %s -o - | FileCheck %s --check-prefix=XMEGA6
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu avrtiny -emit-llvm %s -o - | FileCheck %s --check-prefix=TINY
+
+// AVR1: hello_world
+// AVR3: hello_world
+// AVR31: hello_world
+// AVR5: hello_world
+// XMEGA6: hello_world
+// TINY: hello_world
+void hello_world() { }
Index: test/CodeGen/avr/target-cpu-defines/common.c
===
--- /dev/null
+++ test/CodeGen/avr/target-cpu-defines/common.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+#ifndef __AVR
+#error '__AVR' is not defined
+#endif
+
+#ifndef AVR
+#error 'AVR' is not defined
+#endif
+
+#ifndef __AVR__
+#error '__AVR__' is not defind
+#endif
+
+// CHECK-LABEL: hello_world
+void hello_world() { }
Index: test/CodeGen/avr/target-cpu-defines/attiny104.c
===
--- /dev/null
+++ test/CodeGen/avr/target-cpu-defines/attiny104.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu attiny104 -emit-llvm %s -o - | FileCheck %s
+
+#ifndef __AVR_ATtiny104
+#error '__AVR_ATtiny104' is not defined
+#endif
+
+// CHECK-LABEL: hello
+void hello() { }
Index: test/CodeGen/avr/target-cpu-defines/atmega328p.c
===
--- /dev/null
+++ test/CodeGen/avr/target-cpu-defines/atmega328p.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -target-cpu atmega328p -emit-llvm %s -o - | FileCheck %s
+
+#ifndef __AVR_ATmega328P
+#error '__AVR_ATmega328P' is not defined
+#endif
+
+// CHECK-LABEL: hello
+void hello() { }
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8385,6 +8385,254 @@
   }
 };
 
+/// Information about a specific microcontroller.
+struct MCUInfo {
+  const char *Name;
+  const char *DefineName;
+};
+
+// This list should be kept up-to-date with AVRDevices.td in LLVM.
+static ArrayRef AVRMcus = {
+  { "at90s1200", "__AVR_AT90S1200__" },
+  { "attiny11", "__AVR_ATtiny11" },
+  { "attiny12", "__AVR_ATtiny12" },
+  { "attiny15", "__AVR_ATtiny15" },
+  { "attiny28", "__AVR_ATtiny28" },
+  { "at90s2313", "__AVR_AT90S2313" },
+  { "at90s2323", "__AVR_AT90S2323" },
+  { "at90s2333", "__AVR_AT90S2333" },
+  { "at90s2343", "__AVR_AT90S2343" },
+  { "attiny22", "__AVR_ATtiny22" },
+  { "attiny26", "__AVR_ATtiny26" },
+  { "at86rf401", "__AVR_AT86RF401" },
+  { "at90s4414", "__AVR_AT90S4414" },
+  { "at90s4433", "__AVR_AT90S4433" },
+  { "at90s4434", "__AVR_AT90S4434" },
+  { "at90s8515", "__AVR_AT90S8515" },
+  { "at90c8534", "__AVR_AT90c8534" },
+  { "at90s8535", "__AVR_AT90S8535" },
+  { "ata5272", "__AVR_ATA5272" },
+  { "attiny13", "__AVR_ATtiny13" },
+  { "attiny13a", "__AVR_ATtiny13A" },
+  { "attiny2313", "__AVR_ATtiny2313" },
+  { "attiny2313a", "__AVR_ATtiny2313A" },
+  { "attiny24", "__AVR_ATtiny24" },
+  { "attiny24a", "__AVR_ATtiny24A" },
+  { "attiny4313", "__AVR_ATtiny4313" },
+  

[PATCH] D26949: [libc++abi] Clean up visibility

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: src/cxa_new_delete.cpp:34
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void *

EricWF wrote:
> Can we abstract this away to a `_LIBCXXABI_NEW_DELETE_VIS` macro?
Are `operator new` and `operator delete` the only functions that will ever need 
weak linkage?  I think that using a more generic macro would be nicer.  
`_LIBCXXABI_WEAK_LINKAGE` perhaps?


https://reviews.llvm.org/D26949



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28425: Lit C++11 Compatibility Patch - nonthrowing destructors

2017-01-06 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D28425



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291333 - provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jan  6 21:07:45 2017
New Revision: 291333

URL: http://llvm.org/viewvc/llvm-project?rev=291333=rev
Log:
provide Win32 native threading

Add an implementation for the Win32 threading model as a backing API for
the internal c++ threading interfaces.  This uses the Fls* family for
the TLS (which has the support for adding termination callbacks),
CRITICAL_SECTIONs for the recursive mutex, and Slim Reader/Writer locks
(SRW locks) for non-recursive mutexes.  These APIs should all be
available on Vista or newer.

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__threading_support
libcxx/trunk/include/thread

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291333=291332=291333=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan  6 21:07:45 2017
@@ -913,6 +913,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 defined(__CloudABI__) || \
 defined(__sun__)
 #   define _LIBCPP_HAS_THREAD_API_PTHREAD
+# elif defined(_LIBCPP_WIN32API)
+#  define _LIBCPP_HAS_THREAD_API_WIN32
 # else
 #  error "No thread API"
 # endif // _LIBCPP_HAS_THREAD_API

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=291333=291332=291333=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Jan  6 21:07:45 2017
@@ -24,6 +24,13 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#include 
+#include 
+#include 
+#include 
+
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -58,6 +65,33 @@ typedef pthread_t __libcpp_thread_t;
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#else
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute Once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
 #endif
 
 // Mutex
@@ -144,7 +178,8 @@ void __libcpp_thread_yield();
 
 // Thread local storage
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *));
+int __libcpp_tls_create(__libcpp_tls_key* __key,
+void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 void *__libcpp_tls_get(__libcpp_tls_key __key);
@@ -321,6 +356,224 @@ int __libcpp_tls_set(__libcpp_tls_key __
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  EnterCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  TryEnterCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+  LeaveCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  TryAcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+
+  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto abstime =
+  
system_clock::time_point(duration_cast(duration));
+  

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r291333




Comment at: include/__threading_support:29-30
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

majnemer wrote:
> EricWF wrote:
> > I think we agreed that we cannot use this macro.
> Can we do as Reid suggests and not expose users to windows.h?
I think that I would rather do that in a follow up.  This will require a fair 
amount of duplication.


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 83489.
compnerd added a comment.

Rebase for r291329.


Repository:
  rL LLVM

https://reviews.llvm.org/D28212

Files:
  include/typeinfo
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -15,6 +15,47 @@
 
 #include "typeinfo"
 
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#include 
+
+const char* std::type_info::__name(const struct std::type_info::__data* __data)
+{
+  // TODO(compnerd) cache demangled &__data.__decorated_name[1]
+  return &__data->__decorated_name[1];
+}
+
+size_t std::type_info::__hash(const struct std::type_info::__data* __data)
+{
+#if defined(_WIN64)
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037ull;
+  static constexpr const size_t fnv_prime = 10995116282110ull;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261ull;
+  static constexpr const size_t fnv_prime = 16777619ull;
+#endif
+
+  size_t value = fnv_offset_basis;
+  for (const char *c = &__data->__decorated_name[1]; *c; ++c) {
+value ^= static_cast(static_cast(*c));
+value *= fnv_prime;
+  }
+
+#if defined(_WIN64)
+  value ^= value >> 32;
+#endif
+
+  return value;
+}
+
+int std::type_info::__compare(const struct std::type_info::__data* __lhs,
+  const struct std::type_info::__data* __rhs)
+{
+  if (__lhs == __rhs)
+return 0;
+  return strcmp(&__lhs->__decorated_name[1], &__rhs->__decorated_name[1]);
+}
+#endif
+
 #if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
 std::type_info::~type_info()
 {
Index: include/typeinfo
===
--- include/typeinfo
+++ include/typeinfo
@@ -69,11 +69,13 @@
 #pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_ABI_MICROSOFT)
 #if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
 #define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
 #else
 #define _LIBCPP_HAS_UNIQUE_TYPEINFO
 #endif
+#endif
 
 namespace std  // purposefully not using versioning namespace
 {
@@ -89,7 +91,21 @@
 { return __builtin_strcmp(name(), __arg.name()); }
 #endif
 
+#if defined(_LIBCPP_ABI_MICROSOFT)
+  mutable struct __data {
+const char *__undecorated_name;
+const char __decorated_name[1];
+  } __data;
+
+  static const char *__name(const struct type_info::__data *__data);
+  static size_t __hash(const struct type_info::__data *__data);
+  static int __compare(const struct type_info::__data* __lls,
+   const struct type_info::__data* __rhs);
+#endif
+
 protected:
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#else
 #if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 // A const char* with the non-unique RTTI bit possibly set.
 uintptr_t __type_name;
@@ -102,10 +118,28 @@
 _LIBCPP_INLINE_VISIBILITY
 type_info(const char* __n) : __type_name(__n) {}
 #endif
+#endif
 
 public:
 virtual ~type_info();
 
+#if defined(_LIBCPP_ABI_MICROSOFT)
+_LIBCPP_INLINE_VISIBILITY
+const char *name() const _NOEXCEPT
+{ return __name(&__data); }
+
+_LIBCPP_INLINE_VISIBILITY
+bool before(const type_info& __arg) const _NOEXCEPT
+{ return __compare(&__data, &__arg.__data) < 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+size_t hash_code() const _NOEXCEPT
+{ return __hash(&__data); }
+
+_LIBCPP_INLINE_VISIBILITY
+bool operator==(const type_info& __arg) const _NOEXCEPT
+{ return __compare(&__data, &__arg.__data) == 0; }
+#else
 #if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 _LIBCPP_INLINE_VISIBILITY
 const char* name() const _NOEXCEPT
@@ -162,6 +196,7 @@
 bool operator==(const type_info& __arg) const _NOEXCEPT
 { return __type_name == __arg.__type_name; }
 #endif
+#endif
 
 _LIBCPP_INLINE_VISIBILITY
 bool operator!=(const type_info& __arg) const _NOEXCEPT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291332 - [libc++] Tolerate presence of __deallocate macro

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 21:01:24 2017
New Revision: 291332

URL: http://llvm.org/viewvc/llvm-project?rev=291332=rev
Log:
[libc++] Tolerate presence of __deallocate macro

Summary:
On Windows the identifier `__deallocate` is defined as a macro by one of the 
Windows system headers. Previously libc++ worked around this by `#undef 
__deallocate` and generating a warning. However this causes the WIN32 version 
of `__threading_support` to always generate a warning on Windows. This is not 
OK.

This patch renames all usages of `__deallocate` internally as to not conflict 
with the macro.

Reviewers: mclow.lists, majnemer, rnk, rsmith, smeenai, compnerd

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28426

Removed:
libcxx/trunk/include/__undef___deallocate
Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__sso_allocator
libcxx/trunk/include/experimental/dynarray
libcxx/trunk/include/memory
libcxx/trunk/include/module.modulemap
libcxx/trunk/include/new
libcxx/trunk/include/valarray
libcxx/trunk/src/experimental/memory_resource.cpp

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=291332=291331=291332=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Jan  6 21:01:24 2017
@@ -20,7 +20,6 @@
 #include 
 
 #include <__undef_min_max>
-#include <__undef___deallocate>
 
 #include <__debug>
 
@@ -1321,7 +1320,7 @@ private:
 void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
 #endif // _LIBCPP_CXX03_LANG
 
-void __deallocate(__next_pointer __np) _NOEXCEPT;
+void __deallocate_node(__next_pointer __np) _NOEXCEPT;
 __next_pointer __detach() _NOEXCEPT;
 
 template  friend class 
_LIBCPP_TEMPLATE_VIS unordered_map;
@@ -1454,7 +1453,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
  "Predicate must be copy-constructible.");
 static_assert((is_copy_constructible::value),
  "Hasher must be copy-constructible.");
-__deallocate(__p1_.first().__next_);
+__deallocate_node(__p1_.first().__next_);
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__erase_c(this);
 #endif
@@ -1492,7 +1491,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 
 template 
 void
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__next_pointer __np)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer 
__np)
 _NOEXCEPT
 {
 __node_allocator& __na = __node_alloc();
@@ -1599,11 +1598,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 catch (...)
 {
-__deallocate(__cache);
+__deallocate_node(__cache);
 throw;
 }
 #endif  // _LIBCPP_NO_EXCEPTIONS
-__deallocate(__cache);
+__deallocate_node(__cache);
 }
 const_iterator __i = __u.begin();
 while (__u.size() != 0)
@@ -1661,11 +1660,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 catch (...)
 {
-__deallocate(__cache);
+__deallocate_node(__cache);
 throw;
 }
 #endif  // _LIBCPP_NO_EXCEPTIONS
-__deallocate(__cache);
+__deallocate_node(__cache);
 }
 for (; __first != __last; ++__first)
 __insert_unique(*__first);
@@ -1701,11 +1700,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 catch (...)
 {
-__deallocate(__cache);
+__deallocate_node(__cache);
 throw;
 }
 #endif  // _LIBCPP_NO_EXCEPTIONS
-__deallocate(__cache);
+__deallocate_node(__cache);
 }
 for (; __first != __last; ++__first)
 __insert_multi(_NodeTypes::__get_value(*__first));
@@ -1765,7 +1764,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 {
 if (size() > 0)
 {
-__deallocate(__p1_.first().__next_);
+__deallocate_node(__p1_.first().__next_);
 __p1_.first().__next_ = nullptr;
 size_type __bc = bucket_count();
 for (size_type __i = 0; __i < __bc; ++__i)

Modified: libcxx/trunk/include/__sso_allocator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__sso_allocator?rev=291332=291331=291332=diff
==
--- libcxx/trunk/include/__sso_allocator (original)
+++ libcxx/trunk/include/__sso_allocator Fri Jan  6 21:01:24 2017
@@ -15,8 +15,6 @@
 #include 
 #include 
 
-#include <__undef___deallocate>
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -64,7 +62,7 @@ public:
 if (__p == (pointer)_)
 __allocated_ = false;
 else
-_VSTD::__deallocate(__p);
+_VSTD::__libcpp_deallocate(__p);
 }
  

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM. I just successfully built this on Windows.


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28426: [libc++] Tolerate presence of __deallocate macro

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

This is a really nice cleanup!


https://reviews.llvm.org/D28426



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291331 - thread: implement sleep_for on Windows

2017-01-06 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Jan  6 20:48:30 2017
New Revision: 291331

URL: http://llvm.org/viewvc/llvm-project?rev=291331=rev
Log:
thread: implement sleep_for on Windows

Windows does not provide an implementation of `nanosleep`.  Round up the
time duration to the nearest ms and use `Sleep`.  Although this may
over-sleep, there is no hard real-time guarantee on the wake, so
sleeping a bit more is better than under-sleeping as it within the
specification.

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=291331=291330=291331=diff
==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Fri Jan  6 20:48:30 2017
@@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)
 using namespace chrono;
 if (ns > nanoseconds::zero())
 {
+#if defined(_LIBCPP_WIN32API)
+milliseconds ms = duration_cast(ns);
+if (ns > duration_cast(ms))
+  ++ms;
+Sleep(ms.count());
+#else
 seconds s = duration_cast(ns);
 timespec ts;
 typedef decltype(ts.tv_sec) ts_sec;
@@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)
 
 while (nanosleep(, ) == -1 && errno == EINTR)
 ;
+#endif
 }
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291330 - [libc++] Correct macro name in documenation

2017-01-06 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Jan  6 20:45:35 2017
New Revision: 291330

URL: http://llvm.org/viewvc/llvm-project?rev=291330=rev
Log:
[libc++] Correct macro name in documenation

The macro is named `_LIBCPP_TEMPLATE_VIS`, not `_LIBCPP_TEMPLATE_ONLY`.
No functional change.

Modified:
libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst

Modified: libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst?rev=291330=291329=291330=diff
==
--- libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst (original)
+++ libcxx/trunk/docs/DesignDocs/VisibilityMacros.rst Fri Jan  6 20:45:35 2017
@@ -49,7 +49,7 @@ Visibility Macros
   attribute. With GCC the `visibility(...)` attribute is used and member
   functions are affected.
 
-**_LIBCPP_TEMPLATE_ONLY**
+**_LIBCPP_TEMPLATE_VIS**
   The same as `_LIBCPP_TYPE_VIS` except that it may be applied to class
   templates.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291329 - Add _LIBCPP_ABI_[ITANIUM|MICROSOFT] macros.

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 20:43:58 2017
New Revision: 291329

URL: http://llvm.org/viewvc/llvm-project?rev=291329=rev
Log:
Add _LIBCPP_ABI_[ITANIUM|MICROSOFT] macros.

This patch adds a libc++ configuration macro for the ABI we
are targeting, either Itanium or Microsoft. For now we configure
for the Microsoft ABI when on Windows with a compiler that defines
_MSC_VER. However this is only temporary until Clang implements
builtin macros we can use.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291329=291328=291329=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan  6 20:43:58 2017
@@ -111,6 +111,15 @@
 #define _LIBCPP_COMPILER_IBM
 #endif
 
+// FIXME: ABI detection should be done via compiler builtin macros. This
+// is just a placeholder until Clang implements such macros. For now assume
+// that Windows compilers pretending to be MSVC++ target the microsoft ABI.
+#if defined(_WIN32) && defined(_MSC_VER)
+# define _LIBCPP_ABI_MICROSOFT
+#else
+# define _LIBCPP_ABI_ITANIUM
+#endif
+
 // Need to detect which libc we're using if we're on Linux.
 #if defined(__linux__)
 #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

mehdi_amini wrote:
> probinson wrote:
> > mehdi_amini wrote:
> > > chandlerc wrote:
> > > > Is this still at all correct? Why? it seems pretty confusing especially 
> > > > in conjunction with the code below.
> > > > 
> > > > 
> > > > I think this may force you to either:
> > > > a) stop early-marking of -Os and -Oz flags with these attributes 
> > > > (early: prior to calling this routine) and handling all of the -O flag 
> > > > synthesized attributes here, or
> > > > b) set optnone for -O0 wher ewe set optsize for -Os and friends, and 
> > > > then remove it where necessary here.
> > > > 
> > > > I don't have any strong opinion about a vs. b.
> > > I believe it is still correct: during Os/Oz we reach this point and 
> > > figure that there is `__attribute__((optnone))` in the *source* (not 
> > > `-O0`), we remove the attributes, nothing changes. Did I miss something?
> > > 
> > Hmmm the Os/Oz attributes are added in CGCall.cpp, and are guarded with a 
> > check on the presence of the Optnone source attribute, so if the Optnone 
> > source attribute is present we should never see these.  And Os/Oz set 
> > OptimizationLevel to 2, which is not zero, so we won't come through here 
> > for ShouldAddOptNone reasons either.
> > Therefore these 'remove' calls should be no-ops and could be removed.  (For 
> > paranoia you could turn them into asserts, and do some experimenting to see 
> > whether I'm confused about how this all fits together.)
> The verifier is already complaining if we get this wrong, and indeed it 
> complains if I'm removing these.
> See clang/test/CodeGen/attr-func-def.c:
> 
> ```
> 
> int foo1(int);
> 
> int foo2(int a) {
>   return foo1(a + 2);
> }
> 
> __attribute__((optnone))
> int foo1(int a) {
> return a + 1;
> }
> ```
> 
> Here we have the attributed optnone on the definition but not the 
> declaration, and the check you're mentioning in CGCalls is only applying to 
> the declaration.
This is all still incredibly confusing code.

I think what would make me happy with this is to have a separate section for 
each mutually exclusive group of LLVM attributes added to the function. so:

  // Add the relevant optimization level to the LLVM function.
  if (...) {
B.addAttribute(llvm::Attribute::OptNone);
F.removeFnAttr(llvm::ATtribute::OptForSize);
...
  } else if (...) {
B.addAttribute(llvm::Attribute::OptForSize);
  } else if (...) }
...
  }

  // Add the inlining control attributes.
  if (...) {

  } else if (...) {

  } else if (...) {

  }

  // Add specific semantic attributes such as 'naked' and 'cold'.
  if (D->hasAttr()) {
B.addAttribute(...::Naked);
  }
  if (D->hasAttr()) {
...
  }

Even though this means testing the Clang-level attributes multiple times, I 
think it'll be much less confusing to read and update. We're actually already 
really close. just need to hoist the non-inlining bits of optnone out, sink the 
naked attribute down, and hoist the cold sizeopt up.



https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r291123 - CodeGen: plumb header search down to the IAS

2017-01-06 Thread Eric Christopher via cfe-commits
On Fri, Jan 6, 2017 at 5:56 AM Hal Finkel  wrote:

>
> On 01/05/2017 08:30 PM, Eric Christopher via cfe-commits wrote:
>
> Ok, thanks. I agree that it's a problem. I'm definitely open for testing
> ideas here. There are a few other things in the
> TargetOptions/MCTargetOptions area that are already problematic to test.
>
>
> I think that we need to add serialization for these structures, and a
> printing option for them, so that we can test these kinds of things. That
> having been said, a lot of these things need to end up in attributes so
> that they work correctly with LTO. Is this one of them?
>
>
We definitely need to figure out testing for this, but I don't know that
serializing them to std::out is right. Might want to come up with either a
gtest or gmock way?

That said, ultimately anything that involves parsing at code generation
time could involve putting it into a module - that said, I really disagree
with all of the include paths etc being serialized into the module.

-eric



>  -Hal
>
>
>
> -eric
>
> On Thu, Jan 5, 2017 at 6:27 PM Saleem Abdulrasool 
> wrote:
>
> This was certainly the problem that I had.  The test really needs a way to
> check that the field was set.  As you state, this is a problematic area.
> The backend already has a test to ensure that the paths are honored, but, I
> didn't see any way to actually ensure that it was getting sent to the
> backend otherwise.
>
> The module itself doesnt encode the search path, nor is the information in
> the command line.  I can see the argument that the test itself doesn't add
> much value especially with the backend side testing that the processing of
> the inclusion does occur correctly.  I'll go ahead and remove the test
> (which already has ended up being a pain to test).
>
> On Thu, Jan 5, 2017 at 6:11 PM, Eric Christopher 
> wrote:
>
> Hi Saleem,
>
> Love that you wanted to add a test for it, but I'd really prefer that you
> not engage the backend here in order to do it. You can verify some of it
> from the backend and just that the module is correct via the front end if
> you'd like. Ensuring the paths are correct is a bit of a sticky problem,
> but this is an API boundary that we just have problems with.
>
> TL;DR: Would you mind splitting this test into front end and back end
> tests and avoid using the backend in clang's test harness?
>
> Thanks!
>
> -eric
>
> On Thu, Jan 5, 2017 at 8:13 AM Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: compnerd
> Date: Thu Jan  5 10:02:32 2017
> New Revision: 291123
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
> Log:
> CodeGen: plumb header search down to the IAS
>
> inline assembly may use the `.include` directive to include other
> content into the file.  Without the integrated assembler, the `-I` group
> gets passed to the assembler.  Emulate this by collecting the header
> search paths and passing them to the IAS.
>
> Resolves PR24811!
>
> Added:
> cfe/trunk/test/CodeGen/include/
> cfe/trunk/test/CodeGen/include/function.x
> cfe/trunk/test/CodeGen/include/module.x
> cfe/trunk/test/CodeGen/inline-asm-inclusion.c
> Modified:
> cfe/trunk/include/clang/CodeGen/BackendUtil.h
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
> +++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
> @@ -21,6 +21,7 @@ namespace llvm {
>
>  namespace clang {
>class DiagnosticsEngine;
> +  class HeaderSearchOptions;
>class CodeGenOptions;
>class TargetOptions;
>class LangOptions;
> @@ -34,7 +35,8 @@ namespace clang {
>  Backend_EmitObj///< Emit native object files
>};
>
> -  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions
> ,
> +  void EmitBackendOutput(DiagnosticsEngine , const
> HeaderSearchOptions &,
> + const CodeGenOptions ,
>   const TargetOptions , const LangOptions
> ,
>   const llvm::DataLayout , llvm::Module *M,
>   BackendAction Action,
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
> @@ -14,6 +14,7 @@
>  #include "clang/Frontend/CodeGenOptions.h"
>  #include 

[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2017-01-06 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a reviewer: scanon.
echristo added a comment.

Adding Steve in an attempt to get him to review :)


https://reviews.llvm.org/D27872



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83480.
mehdi_amini added a comment.

Forgot to update test/CodeGen/attr-naked.c


https://reviews.llvm.org/D28404

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-shifts.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/address-safety-attr-kasan.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/arm-crc32.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-neon-vget.c
  clang/test/CodeGen/arm64-lanes.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/attr-coldhot.c
  clang/test/CodeGen/attr-naked.c
  clang/test/CodeGen/builtins-arm-exclusive.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/static-init-wasm.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/Driver/darwin-iphone-defaults.m

Index: clang/test/Driver/darwin-iphone-defaults.m
===
--- clang/test/Driver/darwin-iphone-defaults.m
+++ clang/test/Driver/darwin-iphone-defaults.m
@@ -26,4 +26,4 @@
   [I1 alloc];
 }
 
-// CHECK: attributes [[F0]] = { noinline ssp{{.*}} }
+// CHECK: attributes [[F0]] = { noinline  optnone ssp{{.*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -141,26 +141,26 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind optnone "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind optnone "amdgpu-num-vgpr"="64"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-vgpr"="64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { noinline 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

probinson wrote:
> mehdi_amini wrote:
> > chandlerc wrote:
> > > Is this still at all correct? Why? it seems pretty confusing especially 
> > > in conjunction with the code below.
> > > 
> > > 
> > > I think this may force you to either:
> > > a) stop early-marking of -Os and -Oz flags with these attributes (early: 
> > > prior to calling this routine) and handling all of the -O flag 
> > > synthesized attributes here, or
> > > b) set optnone for -O0 wher ewe set optsize for -Os and friends, and then 
> > > remove it where necessary here.
> > > 
> > > I don't have any strong opinion about a vs. b.
> > I believe it is still correct: during Os/Oz we reach this point and figure 
> > that there is `__attribute__((optnone))` in the *source* (not `-O0`), we 
> > remove the attributes, nothing changes. Did I miss something?
> > 
> Hmmm the Os/Oz attributes are added in CGCall.cpp, and are guarded with a 
> check on the presence of the Optnone source attribute, so if the Optnone 
> source attribute is present we should never see these.  And Os/Oz set 
> OptimizationLevel to 2, which is not zero, so we won't come through here for 
> ShouldAddOptNone reasons either.
> Therefore these 'remove' calls should be no-ops and could be removed.  (For 
> paranoia you could turn them into asserts, and do some experimenting to see 
> whether I'm confused about how this all fits together.)
The verifier is already complaining if we get this wrong, and indeed it 
complains if I'm removing these.
See clang/test/CodeGen/attr-func-def.c:

```

int foo1(int);

int foo2(int a) {
  return foo1(a + 2);
}

__attribute__((optnone))
int foo1(int a) {
return a + 1;
}
```

Here we have the attributed optnone on the definition but not the declaration, 
and the check you're mentioning in CGCalls is only applying to the declaration.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

EricWF wrote:
> smeenai wrote:
> > EricWF wrote:
> > > EricWF wrote:
> > > > smeenai wrote:
> > > > > EricWF wrote:
> > > > > > > Can we do as Reid suggests and not expose users to windows.h?
> > > > > > 
> > > > > > I was about to ask the same question.  These includes are dragging 
> > > > > > in the `__deallocate` macro and I would love to avoid that.
> > > > > I feel like we would end up with a //lot// of duplication if we went 
> > > > > down this route, since this is using a fair amount of Windows APIs. 
> > > > > @rnk suggested having a test for prototype mismatches, but even with 
> > > > > those checks there could be a high maintenance burden to the 
> > > > > duplication.
> > > > > 
> > > > > Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be 
> > > > > problematic for modules? If we're including `windows.h`, it seems 
> > > > > strictly preferable to include it with `WIN32_LEAN_AND_MEAN` than 
> > > > > without, since we'll pull in a lot less that way. Including 
> > > > > `windows.h` without `WIN32_LEAN_AND_MEAN` can also interact with 
> > > > > other headers badly sometimes, e.g. 
> > > > > [`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).
> > > > It seems that dragging in the `__deallocate` macro is inevitable :-( 
> > > > 
> > > > I submitted a patch to work around `__deallocate` here: 
> > > > https://reviews.llvm.org/D28426
> > > > Was the main objection to WIN32_LEAN_AND_MEAN that it would be 
> > > > problematic for modules? If we're including windows.h, it seems 
> > > > strictly preferable to include it with WIN32_LEAN_AND_MEAN than 
> > > > without, since we'll pull in a lot less that way. Including windows.h 
> > > > without WIN32_LEAN_AND_MEAN can also interact with other headers badly 
> > > > sometimes, e.g. winsock2.h.
> > > 
> > > The objection is that it breaks user code. For example:
> > > 
> > > ```
> > > #include 
> > > #include  // Windows.h already included as lean and mean.
> > > 
> > > typedef NonLeanAndMeanSymbol foo; // ERROR NonLeanAndMeanSymbol not 
> > > defined
> > > 
> > > ```
> > > 
> > But without the `WIN32_LEAN_AND_MEAN`, we're gonna break
> > 
> > ```
> > #include 
> > #include 
> > ```
> > 
> > (you could fix this by reordering the includes, which would also fix your 
> > example, or by defining `WIN32_LEAN_AND_MEAN` yourself, but it doesn't seem 
> > great either)
> I would much rather break that code. The fact that `Windows.h` doesn't play 
> nice with other Windows headers is a problem for Windows not libc++.
Although I think avoiding the `Windows.h` include all together would be better 
(if possible). However I think that can be fixed after committing this.


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

smeenai wrote:
> EricWF wrote:
> > EricWF wrote:
> > > smeenai wrote:
> > > > EricWF wrote:
> > > > > > Can we do as Reid suggests and not expose users to windows.h?
> > > > > 
> > > > > I was about to ask the same question.  These includes are dragging in 
> > > > > the `__deallocate` macro and I would love to avoid that.
> > > > I feel like we would end up with a //lot// of duplication if we went 
> > > > down this route, since this is using a fair amount of Windows APIs. 
> > > > @rnk suggested having a test for prototype mismatches, but even with 
> > > > those checks there could be a high maintenance burden to the 
> > > > duplication.
> > > > 
> > > > Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be 
> > > > problematic for modules? If we're including `windows.h`, it seems 
> > > > strictly preferable to include it with `WIN32_LEAN_AND_MEAN` than 
> > > > without, since we'll pull in a lot less that way. Including `windows.h` 
> > > > without `WIN32_LEAN_AND_MEAN` can also interact with other headers 
> > > > badly sometimes, e.g. 
> > > > [`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).
> > > It seems that dragging in the `__deallocate` macro is inevitable :-( 
> > > 
> > > I submitted a patch to work around `__deallocate` here: 
> > > https://reviews.llvm.org/D28426
> > > Was the main objection to WIN32_LEAN_AND_MEAN that it would be 
> > > problematic for modules? If we're including windows.h, it seems strictly 
> > > preferable to include it with WIN32_LEAN_AND_MEAN than without, since 
> > > we'll pull in a lot less that way. Including windows.h without 
> > > WIN32_LEAN_AND_MEAN can also interact with other headers badly sometimes, 
> > > e.g. winsock2.h.
> > 
> > The objection is that it breaks user code. For example:
> > 
> > ```
> > #include 
> > #include  // Windows.h already included as lean and mean.
> > 
> > typedef NonLeanAndMeanSymbol foo; // ERROR NonLeanAndMeanSymbol not defined
> > 
> > ```
> > 
> But without the `WIN32_LEAN_AND_MEAN`, we're gonna break
> 
> ```
> #include 
> #include 
> ```
> 
> (you could fix this by reordering the includes, which would also fix your 
> example, or by defining `WIN32_LEAN_AND_MEAN` yourself, but it doesn't seem 
> great either)
I would much rather break that code. The fact that `Windows.h` doesn't play 
nice with other Windows headers is a problem for Windows not libc++.


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28427: Allow constexpr construction of subobjects unconditionally, not just in C++14.

2017-01-06 Thread David L. Jones via Phabricator via cfe-commits
dlj created this revision.
dlj added a reviewer: rsmith.
dlj added subscribers: cfe-commits, EricWF.

Per https://wg21.link/CWG1677, the C++11 standard did not clarify that constant
initialization of an object allowed constexpr brace-or-equal initialization of
subobjects:

  struct foo_t { union { int i; volatile int j; } u; };
  
  __attribute__((__require_constant_initialization__))
  static const foo_t x = {{0}};

Because foo_t::u has a volatile member, the initializer for x fails. However,
there is really no good reason, because this:

  union foo_u { int i; volatile int j; };
  __attribute__((__require_constant_initialization__))
  static const foo_u x = {0};

does have a constant initializer.

(This was triggered by musl's pthread_mutex_t type when building under C++11.)


https://reviews.llvm.org/D28427

Files:
  lib/AST/ExprConstant.cpp


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1627,8 +1627,17 @@
   // C++1y: A constant initializer for an object o [...] may also invoke
   // constexpr constructors for o and its subobjects even if those objects
   // are of non-literal class types.
-  if (Info.getLangOpts().CPlusPlus14 && This &&
-  Info.EvaluatingDecl == This->getLValueBase())
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+  if (This && Info.EvaluatingDecl == This->getLValueBase())
 return true;
 
   // Prvalue constant expressions must be of literal types.


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -1627,8 +1627,17 @@
   // C++1y: A constant initializer for an object o [...] may also invoke
   // constexpr constructors for o and its subobjects even if those objects
   // are of non-literal class types.
-  if (Info.getLangOpts().CPlusPlus14 && This &&
-  Info.EvaluatingDecl == This->getLValueBase())
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+  if (This && Info.EvaluatingDecl == This->getLValueBase())
 return true;
 
   // Prvalue constant expressions must be of literal types.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28426: [libc++] Tolerate presence of __deallocate macro

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D28426#638596, @smeenai wrote:

> I'm guessing always defining `_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS` on 
> Windows isn't considered an acceptable workaround either?


Not really, since that still breaks users of the `__deallocate` since we 
`#undef` it.

PS. I think Windows is the only platform where `__deallocate` is an issue, so 
defining `_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS` on Windows just makes the 
warnings dead code on all platforms.


https://reviews.llvm.org/D28426



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-06 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 83473.
hamzasood added a comment.

- Modify the environment in some cases in buildLinker to keep link.exe happy.

Thanks @rnk for taking the time to look at this. As suggested:

- Replaced the confusing unique_ptr usage with a struct.
- Renamed llvmArchToSubDirectoryName to llvmArchToWindowsSDKArch.
- Replaced the nested function in getSubDirectoryPath with a static helper.

With regard to _set_com_error_handler, it's a documented 
 function so 
it is supported. It's not part of the actual COM API, just a wrapper library 
that sits on top of it. That library is a header only library with inline 
functions, so you can see how it's used. It checks the HRESULTs before 
returning them and if the result isn't successful then it calls the error 
handler; the original HRESULT still gets returned afterwards. You can also see 
from the headers that it isn't being relied on to process any kind of internal 
error, so it should be perfectly safe to block out for a bit.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,16 +10809,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10843,33 +10837,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1155,6 +1155,15 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+  std::string getSubDirectoryPath(SubDirectoryType Type,
+  llvm::Triple::ArchType TargetArch) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
@@ -1163,19 +1172,12 @@
   llvm::opt::ArgStringList ) const override;
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const 

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

EricWF wrote:
> EricWF wrote:
> > smeenai wrote:
> > > EricWF wrote:
> > > > > Can we do as Reid suggests and not expose users to windows.h?
> > > > 
> > > > I was about to ask the same question.  These includes are dragging in 
> > > > the `__deallocate` macro and I would love to avoid that.
> > > I feel like we would end up with a //lot// of duplication if we went down 
> > > this route, since this is using a fair amount of Windows APIs. @rnk 
> > > suggested having a test for prototype mismatches, but even with those 
> > > checks there could be a high maintenance burden to the duplication.
> > > 
> > > Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be 
> > > problematic for modules? If we're including `windows.h`, it seems 
> > > strictly preferable to include it with `WIN32_LEAN_AND_MEAN` than 
> > > without, since we'll pull in a lot less that way. Including `windows.h` 
> > > without `WIN32_LEAN_AND_MEAN` can also interact with other headers badly 
> > > sometimes, e.g. 
> > > [`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).
> > It seems that dragging in the `__deallocate` macro is inevitable :-( 
> > 
> > I submitted a patch to work around `__deallocate` here: 
> > https://reviews.llvm.org/D28426
> > Was the main objection to WIN32_LEAN_AND_MEAN that it would be problematic 
> > for modules? If we're including windows.h, it seems strictly preferable to 
> > include it with WIN32_LEAN_AND_MEAN than without, since we'll pull in a lot 
> > less that way. Including windows.h without WIN32_LEAN_AND_MEAN can also 
> > interact with other headers badly sometimes, e.g. winsock2.h.
> 
> The objection is that it breaks user code. For example:
> 
> ```
> #include 
> #include  // Windows.h already included as lean and mean.
> 
> typedef NonLeanAndMeanSymbol foo; // ERROR NonLeanAndMeanSymbol not defined
> 
> ```
> 
But without the `WIN32_LEAN_AND_MEAN`, we're gonna break

```
#include 
#include 
```

(you could fix this by reordering the includes, which would also fix your 
example, or by defining `WIN32_LEAN_AND_MEAN` yourself, but it doesn't seem 
great either)


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

EricWF wrote:
> smeenai wrote:
> > EricWF wrote:
> > > > Can we do as Reid suggests and not expose users to windows.h?
> > > 
> > > I was about to ask the same question.  These includes are dragging in the 
> > > `__deallocate` macro and I would love to avoid that.
> > I feel like we would end up with a //lot// of duplication if we went down 
> > this route, since this is using a fair amount of Windows APIs. @rnk 
> > suggested having a test for prototype mismatches, but even with those 
> > checks there could be a high maintenance burden to the duplication.
> > 
> > Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be 
> > problematic for modules? If we're including `windows.h`, it seems strictly 
> > preferable to include it with `WIN32_LEAN_AND_MEAN` than without, since 
> > we'll pull in a lot less that way. Including `windows.h` without 
> > `WIN32_LEAN_AND_MEAN` can also interact with other headers badly sometimes, 
> > e.g. 
> > [`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).
> It seems that dragging in the `__deallocate` macro is inevitable :-( 
> 
> I submitted a patch to work around `__deallocate` here: 
> https://reviews.llvm.org/D28426
> Was the main objection to WIN32_LEAN_AND_MEAN that it would be problematic 
> for modules? If we're including windows.h, it seems strictly preferable to 
> include it with WIN32_LEAN_AND_MEAN than without, since we'll pull in a lot 
> less that way. Including windows.h without WIN32_LEAN_AND_MEAN can also 
> interact with other headers badly sometimes, e.g. winsock2.h.

The objection is that it breaks user code. For example:

```
#include 
#include  // Windows.h already included as lean and mean.

typedef NonLeanAndMeanSymbol foo; // ERROR NonLeanAndMeanSymbol not defined

```



https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28426: [libc++] Tolerate presence of __deallocate macro

2017-01-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I'm guessing always defining `_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS` on 
Windows isn't considered an acceptable workaround either?


https://reviews.llvm.org/D28426



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

smeenai wrote:
> EricWF wrote:
> > > Can we do as Reid suggests and not expose users to windows.h?
> > 
> > I was about to ask the same question.  These includes are dragging in the 
> > `__deallocate` macro and I would love to avoid that.
> I feel like we would end up with a //lot// of duplication if we went down 
> this route, since this is using a fair amount of Windows APIs. @rnk suggested 
> having a test for prototype mismatches, but even with those checks there 
> could be a high maintenance burden to the duplication.
> 
> Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be problematic 
> for modules? If we're including `windows.h`, it seems strictly preferable to 
> include it with `WIN32_LEAN_AND_MEAN` than without, since we'll pull in a lot 
> less that way. Including `windows.h` without `WIN32_LEAN_AND_MEAN` can also 
> interact with other headers badly sometimes, e.g. 
> [`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).
It seems that dragging in the `__deallocate` macro is inevitable :-( 

I submitted a patch to work around `__deallocate` here: 
https://reviews.llvm.org/D28426


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

EricWF wrote:
> > Can we do as Reid suggests and not expose users to windows.h?
> 
> I was about to ask the same question.  These includes are dragging in the 
> `__deallocate` macro and I would love to avoid that.
I feel like we would end up with a //lot// of duplication if we went down this 
route, since this is using a fair amount of Windows APIs. @rnk suggested having 
a test for prototype mismatches, but even with those checks there could be a 
high maintenance burden to the duplication.

Was the main objection to `WIN32_LEAN_AND_MEAN` that it would be problematic 
for modules? If we're including `windows.h`, it seems strictly preferable to 
include it with `WIN32_LEAN_AND_MEAN` than without, since we'll pull in a lot 
less that way. Including `windows.h` without `WIN32_LEAN_AND_MEAN` can also 
interact with other headers badly sometimes, e.g. 
[`winsock2.h`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx).


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291322 - [libcxx] [test] Strip trailing whitespace. NFC, no code review.

2017-01-06 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Jan  6 19:12:15 2017
New Revision: 291322

URL: http://llvm.org/viewvc/llvm-project?rev=291322=rev
Log:
[libcxx] [test] Strip trailing whitespace. NFC, no code review.

Modified:
libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp
libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp?rev=291322=291321=291322=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/iterators.pass.cpp Fri Jan 
 6 19:12:15 2017
@@ -132,10 +132,10 @@ int main()
 static_assert ( std::rbegin(c)  != std::rend(c), "");
 static_assert ( std::cbegin(c)  != std::cend(c), "");
 static_assert ( std::crbegin(c) != std::crend(c), "");
-
+
 static_assert ( *c.begin()  == 0, "");
 static_assert ( *c.rbegin()  == 4, "");
-
+
 static_assert ( *std::begin(c)   == 0, "" );
 static_assert ( *std::cbegin(c)  == 0, "" );
 static_assert ( *std::rbegin(c)  == 4, "" );

Modified: libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp?rev=291322=291321=291322=diff
==
--- libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp Fri Jan  
6 19:12:15 2017
@@ -179,10 +179,10 @@ int main(){
 static_assert ( std::rbegin(c)  != std::rend(c), "");
 static_assert ( std::cbegin(c)  != std::cend(c), "");
 static_assert ( std::crbegin(c) != std::crend(c), "");
-
+
 static_assert ( *c.begin()  == 0, "");
 static_assert ( *c.rbegin()  == 4, "");
-
+
 static_assert ( *std::begin(c)   == 0, "" );
 static_assert ( *std::cbegin(c)  == 0, "" );
 static_assert ( *std::rbegin(c)  == 4, "" );
@@ -191,7 +191,7 @@ int main(){
 
 {
 static constexpr const int c[] = {0,1,2,3,4};
-
+
 static_assert ( *std::begin(c)   == 0, "" );
 static_assert ( *std::cbegin(c)  == 0, "" );
 static_assert ( *std::rbegin(c)  == 4, "" );

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod%3Dduration.pass.cpp?rev=291322=291321=291322=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
 Fri Jan  6 19:12:15 2017
@@ -38,7 +38,7 @@ int main()
 us1 %= std::chrono::milliseconds(3);
 assert(us1.count() == 2);
 }
-
+
 #if TEST_STD_VER > 14
 static_assert(test_constexpr(), "");
 #endif

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod%3Drep.pass.cpp?rev=291322=291321=291322=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
 Fri Jan  6 19:12:15 2017
@@ -34,7 +34,7 @@ int main()
 us %= 3;
 assert(us.count() == 2);
 }
-
+
 #if TEST_STD_VER > 14
 static_assert(test_constexpr(), "");
 #endif

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times%3D.pass.cpp?rev=291322=291321=291322=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
 (original)
+++ 

[PATCH] D28426: [libc++] Tolerate presence of __deallocate macro

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: compnerd, smeenai, mclow.lists, majnemer, rnk, rsmith.
EricWF added a subscriber: cfe-commits.

On Windows the identifier `__deallocate` is defined as a macro by one of the 
Windows system headers. Previously libc++ worked around this by `#undef 
__deallocate` and generating a warning. However this causes the WIN32 version 
of `__threading_support` to always generate a warning on Windows. This is not 
OK.

This patch renames all usages of `__deallocate` internally as to not conflict 
with the macro.


https://reviews.llvm.org/D28426

Files:
  include/__hash_table
  include/__sso_allocator
  include/__undef___deallocate
  include/experimental/dynarray
  include/memory
  include/module.modulemap
  include/new
  include/valarray
  src/experimental/memory_resource.cpp

Index: src/experimental/memory_resource.cpp
===
--- src/experimental/memory_resource.cpp
+++ src/experimental/memory_resource.cpp
@@ -34,7 +34,7 @@
 { return __allocate(__size); }
 
 virtual void do_deallocate(void * __p, size_t, size_t)
-{ __deallocate(__p); }
+{ _VSTD::__libcpp_deallocate(__p); }
 
 virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT
 { return &__other == this; }
Index: include/valarray
===
--- include/valarray
+++ include/valarray
@@ -348,7 +348,6 @@
 #include 
 
 #include <__undef_min_max>
-#include <__undef___deallocate>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -3697,7 +3696,7 @@
 {
 while (__end_ != __begin_)
 (--__end_)->~value_type();
-_VSTD::__deallocate(__begin_);
+_VSTD::__libcpp_deallocate(__begin_);
 __begin_ = __end_ = nullptr;
 }
 if (__n)
Index: include/new
===
--- include/new
+++ include/new
@@ -92,8 +92,6 @@
 #include 
 #endif
 
-#include <__undef___deallocate>
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -217,7 +215,7 @@
 #endif
 }
 
-inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
+inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void *__ptr) {
 #ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
   ::operator delete(__ptr);
 #else
Index: include/module.modulemap
===
--- include/module.modulemap
+++ include/module.modulemap
@@ -485,7 +485,6 @@
   module __tree { header "__tree" export * }
   module __tuple { header "__tuple" export * }
   module __undef_min_max { header "__undef_min_max" export * }
-  module __undef___deallocate { header "__undef___deallocate" export * }
 
   module experimental {
 requires cplusplus11
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -644,7 +644,6 @@
 #endif
 
 #include <__undef_min_max>
-#include <__undef___deallocate>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -1772,7 +1771,7 @@
 return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));
 }
 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
-{_VSTD::__deallocate((void*)__p);}
+{_VSTD::__libcpp_deallocate((void*)__p);}
 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
 {return size_type(~0) / sizeof(_Tp);}
 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
@@ -1868,7 +1867,7 @@
 return static_cast(_VSTD::__allocate(__n * sizeof(_Tp)));
 }
 _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
-{_VSTD::__deallocate((void*)__p);}
+{_VSTD::__libcpp_deallocate((void*)__p);}
 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
 {return size_type(~0) / sizeof(_Tp);}
 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
Index: include/experimental/dynarray
===
--- include/experimental/dynarray
+++ include/experimental/dynarray
@@ -11,9 +11,6 @@
 #ifndef _LIBCPP_DYNARRAY
 #define _LIBCPP_DYNARRAY
 
-#include <__config>
-#if _LIBCPP_STD_VER > 11
-
 /*
 dynarray synopsis
 
@@ -96,16 +93,16 @@
 }}  // std::experimental
 
 */
+#include <__config>
+#if _LIBCPP_STD_VER > 11
 
 #include <__functional_base>
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#include <__undef___deallocate>
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -143,9 +140,9 @@
 return static_cast (_VSTD::__allocate (sizeof(value_type) * count));
 }
 
-static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
+static 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

mehdi_amini wrote:
> chandlerc wrote:
> > Is this still at all correct? Why? it seems pretty confusing especially in 
> > conjunction with the code below.
> > 
> > 
> > I think this may force you to either:
> > a) stop early-marking of -Os and -Oz flags with these attributes (early: 
> > prior to calling this routine) and handling all of the -O flag synthesized 
> > attributes here, or
> > b) set optnone for -O0 wher ewe set optsize for -Os and friends, and then 
> > remove it where necessary here.
> > 
> > I don't have any strong opinion about a vs. b.
> I believe it is still correct: during Os/Oz we reach this point and figure 
> that there is `__attribute__((optnone))` in the *source* (not `-O0`), we 
> remove the attributes, nothing changes. Did I miss something?
> 
Hmmm the Os/Oz attributes are added in CGCall.cpp, and are guarded with a check 
on the presence of the Optnone source attribute, so if the Optnone source 
attribute is present we should never see these.  And Os/Oz set 
OptimizationLevel to 2, which is not zero, so we won't come through here for 
ShouldAddOptNone reasons either.
Therefore these 'remove' calls should be no-ops and could be removed.  (For 
paranoia you could turn them into asserts, and do some experimenting to see 
whether I'm confused about how this all fits together.)


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28425: Lit C++11 Compatibility Patch - nonthrowing destructors

2017-01-06 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge created this revision.
tigerleapgorge added reviewers: rjmccall, rsmith.
tigerleapgorge added a subscriber: cfe-commits.

Hi everyone,

I am Charles Li at Sony Playstation.
I am refactoring my existing C++11 compatibility patches to make them easier to 
review.
This patch is a subset of the previous #11 patch  
(https://reviews.llvm.org/D24812)
This patch contains 7 tests.
The changes to each test are nearly identical:
LLVM IR invocation for the destructors has changed from “invoke” to “call”.

My colleague Paul Robinson has submitted a similar patch 
(https://reviews.llvm.org/D27936).
To quote his explanation:

  "If a dtor has no interesting members, then it ends up being nothrow, which 
affects the generated IR.
  Modify some tests to tolerate this difference between C++03 and C++11.
  
  In C++11, a destructor without an explicit exception-spec gets an implicit 
exception-spec.
  If the dtor has a body, the implicit exception-spec permits throwing exactly 
the set of types thrown by anything the dtor calls.
  If the dtor doesn't have a body, use what would be the default dtor's body to 
determine the implicit exception-spec.
  If there are no calls, the implicit exception-spec is nothrow."


https://reviews.llvm.org/D28425

Files:
  test/CodeGenCXX/arm.cpp
  test/CodeGenCXX/debug-info-class.cpp
  test/CodeGenCXX/eh-aggregate-copy-destroy.cpp
  test/CodeGenCXX/exceptions.cpp
  test/CodeGenCXX/goto.cpp
  test/OpenMP/atomic_codegen.cpp
  test/OpenMP/threadprivate_codegen.cpp

Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -275,7 +275,7 @@
 // CHECK:  {{.*}}[[ARR_LOOP]]{{.*}}
 // CHECK-NEXT: [[ARR_ELEMENTPAST:%.*]] = phi [[S1]]* [ [[ARR_CUR]], {{.*}} ], [ [[ARR_ELEMENT:%.*]], {{.*}} ]
 // CHECK-NEXT: [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]], [[S1]]* [[ARR_ELEMENTPAST]], i{{.*}} -1
-// CHECK-NEXT: invoke {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]])
+// CHECK-NEXT: {{call|invoke}} {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]])
 // CHECK:  [[ARR_DONE:%.*]] = icmp eq [[S1]]* [[ARR_ELEMENT]], [[ARR_BEGIN]]
 // CHECK-NEXT: br i1 [[ARR_DONE]], label %[[ARR_EXIT:.*]], label %[[ARR_LOOP]]
 // CHECK:  {{.*}}[[ARR_EXIT]]{{.*}}
Index: test/OpenMP/atomic_codegen.cpp
===
--- test/OpenMP/atomic_codegen.cpp
+++ test/OpenMP/atomic_codegen.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++11 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
 // expected-no-diagnostics
 
@@ -21,14 +23,15 @@
   // CHECK: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]])
   // CHECK: [[SCALAR_VAL:%.+]] = load atomic i32, i32* [[SCALAR_ADDR]] monotonic
   // CHECK: store i32 [[SCALAR_VAL]], i32* @b
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK98: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK11: call void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
 #pragma omp atomic read
   b = St().get();
   // CHECK-DAG: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]])
   // CHECK-DAG: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]])
   // CHECK-DAG: [[B_VAL:%.+]] = load i32, i32* @b
   // CHECK: store atomic i32 [[B_VAL]], i32* [[SCALAR_ADDR]] monotonic
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
 #pragma omp atomic write
   St().get() = b;
   // CHECK: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]])
@@ -46,7 +49,7 @@
   // CHECK: [[COND:%.+]] = extractvalue { i32, i1 } [[RES]], 1
   // CHECK: br i1 [[COND]], label %[[OMP_DONE:.+]], label %[[OMP_UPDATE]]
   // CHECK: [[OMP_DONE]]
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
 #pragma omp atomic
   St().get() %= b;
 #pragma omp atomic
@@ -67,7 +70,7 @@
   // CHECK: br i1 [[COND]], label %[[OMP_DONE:.+]], label %[[OMP_UPDATE]]
   // CHECK: [[OMP_DONE]]
   // CHECK: store i32 [[NEW_CALC_VAL]], i32* @a,
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd removed rL LLVM as the repository for this revision.
compnerd updated this revision to Diff 83469.
compnerd marked 2 inline comments as done.
compnerd added a comment.

remove `WIN32_LEAN_AND_MEAN`, fix decoration, remove inline decorations


https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -148,7 +148,8 @@
 __thread_specific_ptr(const __thread_specific_ptr&);
 __thread_specific_ptr& operator=(const __thread_specific_ptr&);
 
-static void __at_thread_exit(void*);
+static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
+
 public:
 typedef _Tp* pointer;
 
@@ -164,21 +165,19 @@
 };
 
 template 
-void
+void _LIBCPP_TLS_DESTRUCTOR_CC
 __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
 {
 delete static_cast(__p);
 }
 
 template 
 __thread_specific_ptr<_Tp>::__thread_specific_ptr()
 {
-int __ec = __libcpp_tls_create(
-&__key_,
-&__thread_specific_ptr::__at_thread_exit);
-if (__ec)
-__throw_system_error(__ec,
-   "__thread_specific_ptr construction failed");
+  int __ec =
+  __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+  if (__ec)
+__throw_system_error(__ec, "__thread_specific_ptr construction failed");
 }
 
 template 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -24,6 +24,13 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#include 
+#include 
+#include 
+#include 
+
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -58,6 +65,33 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#else
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute Once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
 #endif
 
 // Mutex
@@ -144,7 +178,8 @@
 
 // Thread local storage
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *));
+int __libcpp_tls_create(__libcpp_tls_key* __key,
+void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 void *__libcpp_tls_get(__libcpp_tls_key __key);
@@ -321,6 +356,224 @@
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  EnterCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  TryEnterCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+  LeaveCriticalSection(__m);
+  return 0;
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  TryAcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+
+  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto abstime =
+  system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+
+  if (!SleepConditionVariableSRW(__cv, __m,
+   

RE: [cfe-dev] Testcase for LLVM PR9350

2017-01-06 Thread Andrew Rogers via cfe-commits
Hi,

 

This is a (tested!) patch to add checks that both pre-increment and 
pre-decrement don’t overflow, for both char and short integer types (since 
they’re both narrower than int), as per the problem fixed in PR9350.

 

Thanks, Andrew R

 

From: Friedman, Eli [mailto:efrie...@codeaurora.org] 
Sent: 4 January 2017 6:42 pm
To: andrew.rog...@cantab.net; cfe-...@lists.llvm.org
Subject: Re: [cfe-dev] Testcase for LLVM PR9350

 

On 1/3/2017 2:28 PM, via cfe-dev wrote:

Hi clang devs, 

 

I was looking at PR9350 and saw that Eli added a test to check LLVM doesn't 
overflow on [signed] char increment:

 

--- cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:43:30 126815
+++ cfe/trunk/test/CodeGen/integer-overflow.c 2011/03/02 01:49:12 126816
@@ -50,11 +50,17 @@
   // TRAPV_HANDLER: foo(
   --a;
   
-  
   // -fwrapv should turn off inbounds for GEP's, PR9256
   extern int* P;
   ++P;
   // DEFAULT: getelementptr inbounds i32*
   // WRAPV: getelementptr i32*
   // TRAPV: getelementptr inbounds i32*
+
+  // PR9350: char increment never overflows.
+  extern volatile signed char PR9350;
+  // DEFAULT: add i8 {{.*}}, 1
+  // WRAPV: add i8 {{.*}}, 1
+  // TRAPV: add i8 {{.*}}, 1
+  ++PR9350;
}

 

http://llvm.org/viewvc/llvm-project?view=revision 
 
=126816

 

Presumably the logic about promotion to int applies the same as in the argument 
John gave in PR9350 since 6.5.3.1 §3 says "the prefix -- operator is analogous 
to the prefix ++ operator, except that the value of the operand is decremented".

 

Would it therefore make sense to add the equivalent test to integer-overflow.c 
that decrement of a [signed] char didn't ever cause underflow:

 

  // DEFAULT: sub i8 {{.*}}, 1
  // WRAPV: sub i8 {{.*}}, 1
  // TRAPV: sub i8 {{.*}}, 1
  --PR9350;

 


Yes, it probably makes sense to add a testcase like that.  Patch welcome.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project


llvm-pr9350-test-improvement.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83468.
mehdi_amini added a comment.

Address Paul's comment (remove useless block and add period to end comment)


https://reviews.llvm.org/D28404

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-shifts.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/address-safety-attr-kasan.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/arm-crc32.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-neon-vget.c
  clang/test/CodeGen/arm64-lanes.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/attr-coldhot.c
  clang/test/CodeGen/builtins-arm-exclusive.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/static-init-wasm.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/Driver/darwin-iphone-defaults.m

Index: clang/test/Driver/darwin-iphone-defaults.m
===
--- clang/test/Driver/darwin-iphone-defaults.m
+++ clang/test/Driver/darwin-iphone-defaults.m
@@ -26,4 +26,4 @@
   [I1 alloc];
 }
 
-// CHECK: attributes [[F0]] = { noinline ssp{{.*}} }
+// CHECK: attributes [[F0]] = { noinline  optnone ssp{{.*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -141,26 +141,26 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind optnone "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind optnone "amdgpu-num-vgpr"="64"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-vgpr"="64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { noinline 

r291319 - PR20090: Add (passing) test from this bug; it's been fixed for a while.

2017-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan  6 18:52:10 2017
New Revision: 291319

URL: http://llvm.org/viewvc/llvm-project?rev=291319=rev
Log:
PR20090: Add (passing) test from this bug; it's been fixed for a while.

Modified:
cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp

Modified: cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp?rev=291319=291318=291319=diff
==
--- cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp (original)
+++ cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp Fri Jan  6 18:52:10 
2017
@@ -252,3 +252,10 @@ namespace NoInstantiationWhenSelectingOv
   void h() { (void)sizeof(char{f(0)}); }
   void i() { (void)sizeof(char{f("oops")}); } // expected-note {{instantiation 
of}}
 }
+
+namespace PR20090 {
+  template  constexpr T fact(T n) {
+return n == 0 ? 1 : [=] { return n * fact(n - 1); }();
+  }
+  static_assert(fact(0) == 1, "");
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291318 - PR23135: Don't instantiate constexpr functions referenced in unevaluated operands where possible.

2017-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan  6 18:48:55 2017
New Revision: 291318

URL: http://llvm.org/viewvc/llvm-project?rev=291318=rev
Log:
PR23135: Don't instantiate constexpr functions referenced in unevaluated 
operands where possible.

This implements something like the current direction of DR1581: we use a narrow
syntactic check to determine the set of places where a constant expression
could be evaluated, and only instantiate a constexpr function or variable if
it's referenced in one of those contexts, or is odr-used.

It's not yet clear whether this is the right set of syntactic locations; we
currently consider all contexts within templates that would result in odr-uses
after instantiation, and contexts within list-initialization (narrowing
conversions take another victim...), as requiring instantiation. We could in
principle restrict the former cases more (only const integral / reference
variable initializers, and contexts in which a constant expression is required,
perhaps). However, this is sufficient to allow us to accept libstdc++ code,
which relies on GCC's behavior (which appears to be somewhat similar to this
approach).

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
cfe/trunk/test/CXX/temp/temp.param/p5.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/test/SemaCXX/implicit-exception-spec.cpp
cfe/trunk/test/SemaCXX/member-init.cpp
cfe/trunk/test/SemaTemplate/constexpr-instantiate.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
cfe/trunk/test/SemaTemplate/instantiate-init.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291318=291317=291318=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan  6 18:48:55 2017
@@ -807,6 +807,12 @@ public:
 /// run time.
 Unevaluated,
 
+/// \brief The current expression occurs within a braced-init-list within
+/// an unevaluated operand. This is mostly like a regular unevaluated
+/// context, except that we still instantiate constexpr functions that are
+/// referenced here so that we can perform narrowing checks correctly.
+UnevaluatedList,
+
 /// \brief The current expression occurs within a discarded statement.
 /// This behaves largely similarly to an unevaluated operand in preventing
 /// definitions from being required, but not in other ways.
@@ -899,7 +905,8 @@ public:
 MangleNumberingContext (ASTContext );
 
 bool isUnevaluated() const {
-  return Context == Unevaluated || Context == UnevaluatedAbstract;
+  return Context == Unevaluated || Context == UnevaluatedAbstract ||
+ Context == UnevaluatedList;
 }
   };
 
@@ -10194,6 +10201,22 @@ public:
 IsDecltype);
   }
 
+  enum InitListTag { InitList };
+  EnterExpressionEvaluationContext(Sema , InitListTag,
+   bool ShouldEnter = true)
+  : Actions(Actions), Entered(false) {
+// In C++11 onwards, narrowing checks are performed on the contents of
+// braced-init-lists, even when they occur within unevaluated operands.
+// Therefore we still need to instantiate constexpr functions used in such
+// a context.
+if (ShouldEnter && Actions.isUnevaluatedContext() &&
+Actions.getLangOpts().CPlusPlus11) {
+  Actions.PushExpressionEvaluationContext(Sema::UnevaluatedList, nullptr,
+  false);
+  Entered = true;
+}
+  }
+
   ~EnterExpressionEvaluationContext() {
 if (Entered)
   Actions.PopExpressionEvaluationContext();

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=291318=291317=291318=diff
==
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Fri Jan  6 18:48:55 2017
@@ -404,6 +404,10 @@ ExprResult Parser::ParseBraceInitializer
 return Actions.ActOnInitList(LBraceLoc, None, ConsumeBrace());
   }
 
+  // Enter an appropriate expression evaluation context for an initializer 
list.
+  EnterExpressionEvaluationContext EnterContext(
+  Actions, EnterExpressionEvaluationContext::InitList);
+
   bool InitExprsOk = true;
 
   while (1) {

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=291318=291317=291318=diff

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:30
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

> Can we do as Reid suggests and not expose users to windows.h?

I was about to ask the same question.  These includes are dragging in the 
`__deallocate` macro and I would love to avoid that.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini marked 2 inline comments as done.
mehdi_amini added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:900
+  ShouldAddOptNone &= !D->hasAttr();
+  if (ShouldAddOptNone) {
+B.addAttribute(llvm::Attribute::OptimizeNone);

probinson wrote:
> This block is redundant now?  The same things are added in the next if block.
Oh right! Will remove, thanks!


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:580
+int __libcpp_tls_create(__libcpp_tls_key* __key,
+void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
+{

The `_LIBCPP_TLS_DESTRUCTOR_CC` needs to appear an the initial declaration as 
well.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:896
+  !CodeGenOpts.DisableO0ImplyOptNone && CodeGenOpts.OptimizationLevel == 0;
+  // We can't add optnone in the following cases, it won't pass the verifier
+  ShouldAddOptNone &= !D->hasAttr();

Period at the end of a comment.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:900
+  ShouldAddOptNone &= !D->hasAttr();
+  if (ShouldAddOptNone) {
+B.addAttribute(llvm::Attribute::OptimizeNone);

This block is redundant now?  The same things are added in the next if block.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: include/__threading_support:29-30
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 

EricWF wrote:
> I think we agreed that we cannot use this macro.
Can we do as Reid suggests and not expose users to windows.h?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/__threading_support:29
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 

I think we agreed that we cannot use this macro.



Comment at: include/__threading_support:426
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)

DO NOT ANNOTATE THESE DEFINITIONS!! The forward declarations are already 
properly declared.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Just tried the updated patch and I still get one build error:

  C:\Users\Eric\workspace\libcxx\src\thread.cpp(135,16):  error: use of 
undeclared identifier 'nanosleep'
  while (nanosleep(, ) == -1 && errno == EINTR)


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini marked 6 inline comments as done.
mehdi_amini added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:760-762
   Fn->removeFnAttr(llvm::Attribute::NoInline);
+  Fn->removeFnAttr(llvm::Attribute::OptimizeNone);
   Fn->addFnAttr(llvm::Attribute::AlwaysInline);

chandlerc wrote:
> At point where we are in numerous places doing 3 coupled calls, we should add 
> some routine to do this... Maybe we should have when I added the noinline bit.
> 
> I don't have a good idea of where best to do this -- as part of or as an 
> alternative to `SetInternalFunctionAttributes`? Something else?
> 
> I'm imagining something like `SetAlwaysInlinedRuntimeFunctionAttributes` or 
> something. Need a clang IRGen person to help push the organization in the 
> right direction.
Yes some refactoring of all this custom handling would be welcome. I'll take 
any pointer to how to do it in clang (I'm not familiar enough with clang).



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:892
 
+  // -O0 adds the optnone attribute, except if specific attributes prevents it.
+  bool ShouldAddOptNone =

chandlerc wrote:
> attributes prevents -> attributes prevent
> 
> ACtually, what do you mean by attributes here? Or should this comment instead 
> go below, where we start to branch on the actual 'hasAttr' calls?
> 
> After reading below, I understand better. Maybe:
> 
>   // Track whether we need to add the optnone LLVM attribute,
>   // starting with the default for this optimization level.
Actually I instead moved it all together.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

chandlerc wrote:
> Is this still at all correct? Why? it seems pretty confusing especially in 
> conjunction with the code below.
> 
> 
> I think this may force you to either:
> a) stop early-marking of -Os and -Oz flags with these attributes (early: 
> prior to calling this routine) and handling all of the -O flag synthesized 
> attributes here, or
> b) set optnone for -O0 wher ewe set optsize for -Os and friends, and then 
> remove it where necessary here.
> 
> I don't have any strong opinion about a vs. b.
I believe it is still correct: during Os/Oz we reach this point and figure that 
there is `__attribute__((optnone))` in the *source* (not `-O0`), we remove the 
attributes, nothing changes. Did I miss something?




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:962
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline);

chandlerc wrote:
> why is optnone incompatible with *cold*
The source attribute "Cold" adds `llvm::Attribute::OptimizeForSize` even at O0 
right now, I changed this and now we emit `optnone` at O0 in this case.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83459.
mehdi_amini added a comment.

Address comments: reorganize the way ShouldAddOptNone is handled, hopefully 
make it more easy to track.

Also after talking with Chandler on IRC, the source attribute "cold" does
not add the LLVM IR attribute "optsize" at O0, we add "optnone" instead.


https://reviews.llvm.org/D28404

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-shifts.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/address-safety-attr-kasan.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/arm-crc32.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-neon-vget.c
  clang/test/CodeGen/arm64-lanes.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/attr-coldhot.c
  clang/test/CodeGen/builtins-arm-exclusive.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/static-init-wasm.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/Driver/darwin-iphone-defaults.m

Index: clang/test/Driver/darwin-iphone-defaults.m
===
--- clang/test/Driver/darwin-iphone-defaults.m
+++ clang/test/Driver/darwin-iphone-defaults.m
@@ -26,4 +26,4 @@
   [I1 alloc];
 }
 
-// CHECK: attributes [[F0]] = { noinline ssp{{.*}} }
+// CHECK: attributes [[F0]] = { noinline  optnone ssp{{.*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -141,26 +141,26 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind optnone "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind optnone "amdgpu-num-vgpr"="64"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-vgpr"="64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes 

[libcxx] r291311 - Get all tuple tests passing on Windows

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 18:10:42 2017
New Revision: 291311

URL: http://llvm.org/viewvc/llvm-project?rev=291311=rev
Log:
Get all tuple tests passing on Windows

Modified:
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/support/disable_missing_braces_warning.h

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=291311=291310=291311=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan  6 18:10:42 2017
@@ -217,8 +217,7 @@ class Configuration(object):
 def _configure_clang_cl(self, clang_path):
 assert self.cxx_is_clang_cl
 # FIXME: don't hardcode the target
-flags = ['-fms-compatibility-version=19.00',
- '--target=i686-unknown-windows']
+flags = ['--target=i686-pc-windows']
 compile_flags = []
 link_flags = ['-fuse-ld=lld']
 if 'INCLUDE' in os.environ:

Modified: libcxx/trunk/test/support/disable_missing_braces_warning.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/disable_missing_braces_warning.h?rev=291311=291310=291311=diff
==
--- libcxx/trunk/test/support/disable_missing_braces_warning.h (original)
+++ libcxx/trunk/test/support/disable_missing_braces_warning.h Fri Jan  6 
18:10:42 2017
@@ -13,6 +13,8 @@
 // Disable the missing braces warning for this reason.
 #if defined(__GNUC__)
 #pragma GCC diagnostic ignored "-Wmissing-braces"
+#elif defined(__clang__)
+#pragma clang diagnostic ignored "-Wmissing-braces"
 #endif
 
 #endif // SUPPORT_DISABLE_MISSING_BRACES_WARNING_H


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291310 - [ThinLTO] Specify target triple in new test

2017-01-06 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Jan  6 18:09:42 2017
New Revision: 291310

URL: http://llvm.org/viewvc/llvm-project?rev=291310=rev
Log:
[ThinLTO] Specify target triple in new test

This should fix bot failures in this test.

Modified:
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291310=291309=291310=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Fri Jan  6 18:09:42 2017
@@ -15,7 +15,7 @@
 ; Ensure we ignore empty index file under -ignore-empty-index-file, and run
 ; non-ThinLTO compilation which would not import f2
 ; RUN: touch %t4.thinlto.bc
-; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc 
-mllvm -ignore-empty-index-file
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t1.o -c 
-fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
 ; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291309 - Fix linking of DLL's on Windows

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 18:01:55 2017
New Revision: 291309

URL: http://llvm.org/viewvc/llvm-project?rev=291309=rev
Log:
Fix linking of DLL's on Windows

On Windows the runtime search path for DLL's is the same as PATH.
This patch changes the test suite to add the libc++ build directory
to the runtime PATH.

Modified:
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/executor.py
libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=291309=291308=291309=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Fri Jan  6 18:01:55 2017
@@ -67,7 +67,8 @@ class Configuration(object):
 self.cxx_library_root = None
 self.cxx_runtime_root = None
 self.abi_library_root = None
-self.env = {}
+self.link_shared = self.get_lit_bool('enable_shared', default=True)
+self.exec_env = {}
 self.use_target = False
 self.use_system_cxx_lib = False
 self.use_clang_verify = False
@@ -146,7 +147,7 @@ class Configuration(object):
 # Print as list to prevent "set([...])" from being printed.
 self.lit_config.note('Using available_features: %s' %
  list(self.config.available_features))
-self.lit_config.note('Using environment: %r' % self.env)
+self.lit_config.note('Using environment: %r' % self.exec_env)
 
 def get_test_format(self):
 return LibcxxTestFormat(
@@ -154,7 +155,7 @@ class Configuration(object):
 self.use_clang_verify,
 self.execute_external,
 self.executor,
-exec_env=self.env)
+exec_env=self.exec_env)
 
 def configure_executor(self):
 exec_str = self.get_lit_conf('executor', "None")
@@ -207,6 +208,11 @@ class Configuration(object):
 self.config.available_features.add('%s-%s' % (cxx_type, maj_v))
 self.config.available_features.add('%s-%s.%s' % (
 cxx_type, maj_v, min_v))
+self.cxx.compile_env = dict(os.environ)
+# 'CCACHE_CPP2' prevents ccache from stripping comments while
+# preprocessing. This is required to prevent stripping of '-verify'
+# comments.
+self.cxx.compile_env['CCACHE_CPP2'] = '1'
 
 def _configure_clang_cl(self, clang_path):
 assert self.cxx_is_clang_cl
@@ -555,7 +561,7 @@ class Configuration(object):
 if not os.path.isdir(dynamic_env):
 os.makedirs(dynamic_env)
 self.cxx.compile_flags += 
['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="%s"' % dynamic_env]
-self.env['LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env)
+self.exec_env['LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % 
dynamic_env)
 
 dynamic_helper = os.path.join(self.libcxx_src_root, 'test', 'support',
   'filesystem_dynamic_test_helper.py')
@@ -577,7 +583,7 @@ class Configuration(object):
 self.cxx.link_flags += ['-nodefaultlibs']
 # FIXME: Handle MSVCRT as part of the ABI library handling.
 if self.is_windows:
-self.cxx.link_flags += ['-nostdlib', '-lmsvcrtd']
+self.cxx.link_flags += ['-nostdlib']
 self.configure_link_flags_cxx_library()
 self.configure_link_flags_abi_library()
 self.configure_extra_library_flags()
@@ -602,8 +608,14 @@ class Configuration(object):
 if not self.use_system_cxx_lib:
 if self.cxx_library_root:
 self.cxx.link_flags += ['-L' + self.cxx_library_root]
-if self.cxx_runtime_root and not self.is_windows:
-self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
+if self.is_windows and self.link_shared:
+self.add_path(self.cxx.compile_env, self.cxx_library_root)
+if self.cxx_runtime_root:
+if not self.is_windows:
+self.cxx.link_flags += ['-Wl,-rpath,' +
+self.cxx_runtime_root]
+elif self.is_windows and self.link_shared:
+self.add_path(self.exec_env, self.cxx_runtime_root)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.
@@ -612,14 +624,15 @@ class Configuration(object):
 self.cxx.link_flags += ['-L' + self.abi_library_root]
 if not self.is_windows:
 self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root]
+else:
+self.add_path(self.exec_env, self.abi_library_root)
 
 def configure_link_flags_cxx_library(self):
 libcxx_experimental = 

[libcxx] r291306 - Configure default ABI library as NONE on Windows

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 17:59:52 2017
New Revision: 291306

URL: http://llvm.org/viewvc/llvm-project?rev=291306=rev
Log:
Configure default ABI library as NONE on Windows

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=291306=291305=291306=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Fri Jan  6 17:59:52 2017
@@ -116,7 +116,12 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
-set(LIBCXX_CXX_ABI_LIBNAME "default")
+if (WIN32 AND NOT MINGW)
+  # FIXME: Figure out how to configure the ABI library on Windows.
+  set(LIBCXX_CXX_ABI_LIBNAME "none")
+else()
+  set(LIBCXX_CXX_ABI_LIBNAME "default")
+endif()
   endif()
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:962
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline);

chandlerc wrote:
> why is optnone incompatible with *cold*
Because cold implies OptimizeForSize (just above this).  I take no position on 
whether that is reasonable.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd set the repository for this revision to rL LLVM.
compnerd updated this revision to Diff 83453.

Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -148,7 +148,8 @@
 __thread_specific_ptr(const __thread_specific_ptr&);
 __thread_specific_ptr& operator=(const __thread_specific_ptr&);
 
-static void __at_thread_exit(void*);
+static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
+
 public:
 typedef _Tp* pointer;
 
@@ -164,21 +165,19 @@
 };
 
 template 
-void
+void _LIBCPP_TLS_DESTRUCTOR_CC
 __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
 {
 delete static_cast(__p);
 }
 
 template 
 __thread_specific_ptr<_Tp>::__thread_specific_ptr()
 {
-int __ec = __libcpp_tls_create(
-&__key_,
-&__thread_specific_ptr::__at_thread_exit);
-if (__ec)
-__throw_system_error(__ec,
-   "__thread_specific_ptr construction failed");
+  int __ec =
+  __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+  if (__ec)
+__throw_system_error(__ec, "__thread_specific_ptr construction failed");
 }
 
 template 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -24,6 +24,14 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 
+#include 
+
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -58,6 +66,33 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#else
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute Once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
 #endif
 
 // Mutex
@@ -321,6 +356,249 @@
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  EnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  TryEnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+  LeaveCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  TryAcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+
+  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto abstime =
+  system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+
+  if (!SleepConditionVariableSRW(__cv, __m,
+ timeout_ms.count() > 0 ? timeout_ms.count()
+: 0,
+ 0))
+return 

Re: [libcxx] r291275 - [libc++] Cleanup and document <__threading_support>

2017-01-06 Thread David Blaikie via cfe-commits
Thanks!

On Fri, Jan 6, 2017 at 3:26 PM Eric Fiselier  wrote:

> Should be fixed in r291298. Sorry for the breakage.
>
> /Eric
>
> On Fri, Jan 6, 2017 at 4:18 PM, Eric Fiselier  wrote:
>
> Hi David,
>
> Thanks for the information. Looking into it now.
>
> /Eric
>
> On Fri, Jan 6, 2017 at 4:02 PM, David Blaikie  wrote:
>
>
>
> On Fri, Jan 6, 2017 at 12:16 PM Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ericwf
> Date: Fri Jan  6 14:05:40 2017
> New Revision: 291275
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291275=rev
> Log:
> [libc++] Cleanup and document <__threading_support>
>
> Summary:
> This patch attempts to clean up the macro configuration mess in
> `<__threading_support>`, specifically the mess involving external threading
> variants. Additionally this patch adds design documentation for
> `<__threading_support>` and the configuration macros it uses.
>
> The primary change in this patch is separating the idea of an "external
> API" provided by `<__external_threading>` and the idea of having an
> external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means
> that libc++ should use `<__external_threading>` and that the header is
> expected to exist.  Additionally the new macro
> `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for using an
> "external library"  with the default threading API.
>
> Reviewers: compnerd, rmaprath
>
> Subscribers: smeenai, cfe-commits, mgorny
>
> Differential Revision: https://reviews.llvm.org/D28316
>
> Added:
> libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/docs/index.rst
> libcxx/trunk/include/__config
> libcxx/trunk/include/__config_site.in
> libcxx/trunk/include/__threading_support
> libcxx/trunk/lib/CMakeLists.txt
> libcxx/trunk/test/CMakeLists.txt
> libcxx/trunk/test/lit.site.cfg.in
> libcxx/trunk/test/support/external_threads.cpp
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=291275=291274=291275=diff
>
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Fri Jan  6 14:05:40 2017
> @@ -169,6 +169,9 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore au
>  option(LIBCXX_HAS_EXTERNAL_THREAD_API
>"Build libc++ with an externalized threading API.
> This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
> +option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> +"Build libc++ with an externalized threading library.
> + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
>
>  # Misc options
> 
>  # FIXME: Turn -pedantic back ON. It is currently off because it warns
> @@ -230,6 +233,17 @@ if(NOT LIBCXX_ENABLE_THREADS)
>  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set
> to ON"
>  " when LIBCXX_ENABLE_THREADS is also set to ON.")
>endif()
> +  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
> +message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be
> set "
> +"to ON when LIBCXX_ENABLE_THREADS is also set to
> ON.")
> +  endif()
> +
> +endif()
> +
> +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND
> LIBCXX_HAS_EXTERNAL_THREAD_API)
> +  message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> and "
> +  "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON
> at "
> +  "the same time")
>  endif()
>
>  if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
> @@ -520,6 +534,7 @@ config_define_if_not(LIBCXX_ENABLE_THREA
>
>  config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
>  config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API
> _LIBCPP_HAS_THREAD_API_EXTERNAL)
> +config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
>  config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
>
>  # By default libc++ on Windows expects to use a shared library, which
> requires
>
> Added: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst?rev=291275=auto
>
> ==
> --- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (added)
> +++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Fri Jan  6
> 14:05:40 2017
> @@ -0,0 +1,70 @@
> +=
> +Threading Support API
> +=
> +
> +.. contents::
> +   :local:
> +
> +Overview
> +
> +
> +Libc++ supports using multiple different threading models and
> configurations
> +to implement the threading parts of libc++, including  and
> .
> +These different 

[PATCH] D27424: Add the diagnose_if attribute to clang.

2017-01-06 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

> We do: 
> http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

Awesome. Thanks!

> Btw, there's a question in there about late parsing that Phab won't let me 
> delete, feel free to ignore it. ;-)

OK. The answer is "yes" anyway. :)


https://reviews.llvm.org/D27424



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28419: clang-tools-extra: add gitattributes to disable EOL conversions on checkout of test source files

2017-01-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano created this revision.
amaiorano added reviewers: malcolm.parsons, ioeric.
amaiorano added a subscriber: cfe-commits.

Certain tests expect their input files to have LF line endings, while others 
expect CRLF. On Windows, when using Git with core.autocrlf=true, these tests 
fail because all source files are checked out with CRLF line endings. This 
change makes sure that these files are not converted at all on checkout.


https://reviews.llvm.org/D28419

Files:
  .gitattributes


Index: .gitattributes
===
--- /dev/null
+++ .gitattributes
@@ -0,0 +1,5 @@
+text=auto
+
+# Disable eol conversions as certain tests rely on specific line endings
+test/**/*.h -text
+test/**/*.cpp -text


Index: .gitattributes
===
--- /dev/null
+++ .gitattributes
@@ -0,0 +1,5 @@
+text=auto
+
+# Disable eol conversions as certain tests rely on specific line endings
+test/**/*.h -text
+test/**/*.cpp -text
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27424: Add the diagnose_if attribute to clang.

2017-01-06 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv updated this revision to Diff 83412.
george.burgess.iv marked 2 inline comments as done.
george.burgess.iv added a comment.

Addressed feedback. Thanks!


https://reviews.llvm.org/D27424

Files:
  include/clang/AST/Expr.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Initialization.h
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/Sema/diagnose_if.c
  test/SemaCXX/diagnose_if.cpp

Index: test/SemaCXX/diagnose_if.cpp
===
--- /dev/null
+++ test/SemaCXX/diagnose_if.cpp
@@ -0,0 +1,460 @@
+// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14
+
+#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
+
+namespace type_dependent {
+template 
+void neverok() _diagnose_if(!T(), "oh no", "error") {} // expected-note 4{{from 'diagnose_if'}}
+
+template 
+void alwaysok() _diagnose_if(T(), "oh no", "error") {}
+
+template 
+void alwayswarn() _diagnose_if(!T(), "oh no", "warning") {} // expected-note 4{{from 'diagnose_if'}}
+
+template 
+void neverwarn() _diagnose_if(T(), "oh no", "warning") {}
+
+void runAll() {
+  alwaysok();
+  alwaysok();
+
+  {
+void (*pok)() = alwaysok;
+pok = ;
+  }
+
+  neverok(); // expected-error{{oh no}}
+  neverok(); // expected-error{{oh no}}
+
+  {
+void (*pok)() = neverok; // expected-error{{oh no}}
+  }
+  {
+void (*pok)();
+pok = ; // expected-error{{oh no}}
+  }
+
+  alwayswarn(); // expected-warning{{oh no}}
+  alwayswarn(); // expected-warning{{oh no}}
+  {
+void (*pok)() = alwayswarn; // expected-warning{{oh no}}
+pok = ; // expected-warning{{oh no}}
+  }
+
+  neverwarn();
+  neverwarn();
+  {
+void (*pok)() = neverwarn;
+pok = ;
+  }
+}
+
+template 
+void errorIf(T a) _diagnose_if(T() != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+
+template 
+void warnIf(T a) _diagnose_if(T() != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+
+void runIf() {
+  errorIf(0);
+  errorIf(1); // expected-error{{call to unavailable function}}
+
+  warnIf(0);
+  warnIf(1); // expected-warning{{oh no}}
+}
+}
+
+namespace value_dependent {
+template 
+void neverok() _diagnose_if(N == 0 || N != 0, "oh no", "error") {} // expected-note 4{{from 'diagnose_if'}}
+
+template 
+void alwaysok() _diagnose_if(N == 0 && N != 0, "oh no", "error") {}
+
+template 
+void alwayswarn() _diagnose_if(N == 0 || N != 0, "oh no", "warning") {} // expected-note 4{{from 'diagnose_if'}}
+
+template 
+void neverwarn() _diagnose_if(N == 0 && N != 0, "oh no", "warning") {}
+
+void runAll() {
+  alwaysok<0>();
+  alwaysok<1>();
+
+  {
+void (*pok)() = alwaysok<0>;
+pok = <0>;
+  }
+
+  neverok<0>(); // expected-error{{oh no}}
+  neverok<1>(); // expected-error{{oh no}}
+
+  {
+void (*pok)() = neverok<0>; // expected-error{{oh no}}
+  }
+  {
+void (*pok)();
+pok = <0>; // expected-error{{oh no}}
+  }
+
+  alwayswarn<0>(); // expected-warning{{oh no}}
+  alwayswarn<1>(); // expected-warning{{oh no}}
+  {
+void (*pok)() = alwayswarn<0>; // expected-warning{{oh no}}
+pok = <0>; // expected-warning{{oh no}}
+  }
+
+  neverwarn<0>();
+  neverwarn<1>();
+  {
+void (*pok)() = neverwarn<0>;
+pok = <0>;
+  }
+}
+
+template 
+void errorIf(int a) _diagnose_if(N != a, "oh no", "error") {} // expected-note {{candidate disabled: oh no}}
+
+template 
+void warnIf(int a) _diagnose_if(N != a, "oh no", "warning") {} // expected-note {{from 'diagnose_if'}}
+
+void runIf() {
+  errorIf<0>(0);
+  errorIf<0>(1); // expected-error{{call to unavailable function}}
+
+  warnIf<0>(0);
+  warnIf<0>(1); // expected-warning{{oh no}}
+}
+}
+
+namespace no_overload_interaction {
+void foo(int) _diagnose_if(1, "oh no", "error"); // expected-note{{from 'diagnose_if'}}
+void foo(short);
+
+void bar(int);
+void bar(short) _diagnose_if(1, "oh no", "error");
+
+void fooArg(int a) _diagnose_if(a, "oh no", "error"); // expected-note{{candidate disabled: oh no}}
+void fooArg(short); // expected-note{{candidate function}}
+
+void barArg(int);
+void barArg(short a) _diagnose_if(a, "oh no", "error");
+
+void runAll() {
+  foo(1); // expected-error{{oh no}}
+  bar(1);
+
+  fooArg(1); // expected-error{{call to unavailable function}}
+  barArg(1);
+
+  auto p = foo; // expected-error{{incompatible initializer of type ''}}
+}
+}
+
+namespace with_default_args {
+void foo(int a = 0) _diagnose_if(a, "oh no", "warning"); // expected-note 1{{from 'diagnose_if'}}
+void bar(int a = 1) _diagnose_if(a, "oh no", "warning"); // expected-note 2{{from 'diagnose_if'}}
+
+void runAll() {
+  foo();
+  foo(0);
+  foo(1); // 

[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-06 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291303: [ThinLTO] Optionally ignore empty index file 
(authored by tejohnson).

Changed prior to commit:
  https://reviews.llvm.org/D28362?vs=83405=83450#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28362

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/thinlto_backend.ll


Index: cfe/trunk/test/CodeGen/thinlto_backend.ll
===
--- cfe/trunk/test/CodeGen/thinlto_backend.ll
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,14 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file, and run
+; non-ThinLTO compilation which would not import f2
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc 
-mllvm -ignore-empty-index-file
+; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
+; CHECK-OBJ-IGNORE-EMPTY: T f1
+; CHECK-OBJ-IGNORE-EMPTY: U f2
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -861,21 +861,8 @@
   }
 }
 
-static void runThinLTOBackend(const CodeGenOptions , Module *M,
+static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS) {
-  // If we are performing a ThinLTO importing compile, load the function index
-  // into memory and pass it into thinBackend, which will run the function
-  // importer and invoke LTO passes.
-  Expected IndexOrErr =
-  llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
-  if (!IndexOrErr) {
-logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
-  "Error loading index file '" +
-  CGOpts.ThinLTOIndexFile + "': ");
-return;
-  }
-  std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
-
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -961,8 +948,26 @@
   BackendAction Action,
   std::unique_ptr OS) {
   if (!CGOpts.ThinLTOIndexFile.empty()) {
-runThinLTOBackend(CGOpts, M, std::move(OS));
-return;
+// If we are performing a ThinLTO importing compile, load the function 
index
+// into memory and pass it into runThinLTOBackend, which will run the
+// function importer and invoke LTO passes.
+Expected IndexOrErr =
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+if (!IndexOrErr) {
+  logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
+"Error loading index file '" +
+CGOpts.ThinLTOIndexFile + "': ");
+  return;
+}
+std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+// A null CombinedIndex means we should skip ThinLTO compilation
+// (LLVM will optionally ignore empty index files, returning null instead
+// of an error).
+bool DoThinLTOBackend = CombinedIndex != nullptr;
+if (DoThinLTOBackend) {
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  return;
+}
   }
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);


Index: cfe/trunk/test/CodeGen/thinlto_backend.ll
===
--- cfe/trunk/test/CodeGen/thinlto_backend.ll
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,14 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file, and run
+; non-ThinLTO compilation which would not import f2
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc -mllvm -ignore-empty-index-file
+; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
+; CHECK-OBJ-IGNORE-EMPTY: T f1
+; CHECK-OBJ-IGNORE-EMPTY: U f2
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp

r291303 - [ThinLTO] Optionally ignore empty index file

2017-01-06 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Jan  6 17:37:33 2017
New Revision: 291303

URL: http://llvm.org/viewvc/llvm-project?rev=291303=rev
Log:
[ThinLTO] Optionally ignore empty index file

Summary:
In order to simplify distributed build system integration, where actions
may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.

Fallback is enabled under an option in LLVM (D28410), in which case a
nullptr is returned from llvm::getModuleSummaryIndexForFile. Clang can
just proceed with non-ThinLTO compilation in that case.

I am investigating whether this can be addressed in our build system,
but that is a longer term fix and so this enables a workaround in the
meantime.

Reviewers: mehdi_amini

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28362

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291303=291302=291303=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan  6 17:37:33 2017
@@ -861,21 +861,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-static void runThinLTOBackend(const CodeGenOptions , Module *M,
+static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS) {
-  // If we are performing a ThinLTO importing compile, load the function index
-  // into memory and pass it into thinBackend, which will run the function
-  // importer and invoke LTO passes.
-  Expected IndexOrErr =
-  llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
-  if (!IndexOrErr) {
-logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
-  "Error loading index file '" +
-  CGOpts.ThinLTOIndexFile + "': ");
-return;
-  }
-  std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
-
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -961,8 +948,26 @@ void clang::EmitBackendOutput(Diagnostic
   BackendAction Action,
   std::unique_ptr OS) {
   if (!CGOpts.ThinLTOIndexFile.empty()) {
-runThinLTOBackend(CGOpts, M, std::move(OS));
-return;
+// If we are performing a ThinLTO importing compile, load the function 
index
+// into memory and pass it into runThinLTOBackend, which will run the
+// function importer and invoke LTO passes.
+Expected IndexOrErr =
+llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile);
+if (!IndexOrErr) {
+  logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
+"Error loading index file '" +
+CGOpts.ThinLTOIndexFile + "': ");
+  return;
+}
+std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+// A null CombinedIndex means we should skip ThinLTO compilation
+// (LLVM will optionally ignore empty index files, returning null instead
+// of an error).
+bool DoThinLTOBackend = CombinedIndex != nullptr;
+if (DoThinLTOBackend) {
+  runThinLTOBackend(CombinedIndex.get(), M, std::move(OS));
+  return;
+}
   }
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=291303=291302=291303=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Fri Jan  6 17:37:33 2017
@@ -12,6 +12,14 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file, and run
+; non-ThinLTO compilation which would not import f2
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc 
-mllvm -ignore-empty-index-file
+; RUN: llvm-nm %t4.o | FileCheck --check-prefix=CHECK-OBJ-IGNORE-EMPTY %s
+; CHECK-OBJ-IGNORE-EMPTY: T f1
+; CHECK-OBJ-IGNORE-EMPTY: U f2
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o 

[PATCH] D28418: Fixing test to work when the compiler defaults to a different C++ standard version

2017-01-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.
dyung added a reviewer: ABataev.
dyung added a subscriber: cfe-commits.

This test as originally written fails when run with a compiler that defaults to 
a different C++ standard. This patch fixes up the test and adds testing it 
explicitly using c++98 and c++11.


https://reviews.llvm.org/D28418

Files:
  test/OpenMP/target_teams_distribute_collapse_messages.cpp


Index: test/OpenMP/target_teams_distribute_collapse_messages.cpp
===
--- test/OpenMP/target_teams_distribute_collapse_messages.cpp
+++ test/OpenMP/target_teams_distribute_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -43,6 +48,9 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 
for loops after '#pragma omp target teams distribute', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 // expected-error@+3 2 {{directive '#pragma omp target teams distribute' 
cannot contain more than one 'collapse' clause}}
 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
 // expected-error@+1 2 {{expression is not an integral constant expression}}
@@ -54,7 +62,11 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+1 2 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+4 2 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+2 2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
 #pragma omp target teams distribute collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
@@ -93,10 +105,17 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for 
loops after '#pragma omp target teams distribute', but found only 1}}
 
-#pragma omp target teams distribute collapse (foobool(1) > 0 ? 1 : 2) // 
expected-error {{expression is not an integral constant expression}}
+// expected-error@+4 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
+#pragma omp target teams distribute collapse (foobool(1) > 0 ? 1 : 2)
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
+#if __cplusplus >= 201103L
+  // expected-note@+5{{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 // expected-error@+3 {{expression is not an integral constant expression}}
 // expected-error@+2 2 {{directive '#pragma omp target teams distribute' 
cannot contain more than one 'collapse' clause}}
 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
@@ -108,7 +127,11 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+1 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+4 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
 #pragma omp target teams distribute collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];


Index: test/OpenMP/target_teams_distribute_collapse_messages.cpp
===
--- test/OpenMP/target_teams_distribute_collapse_messages.cpp
+++ test/OpenMP/target_teams_distribute_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -43,6 +48,9 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target teams distribute', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
+#endif
 // expected-error@+3 2 {{directive '#pragma omp target teams distribute' cannot contain 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:760-762
   Fn->removeFnAttr(llvm::Attribute::NoInline);
+  Fn->removeFnAttr(llvm::Attribute::OptimizeNone);
   Fn->addFnAttr(llvm::Attribute::AlwaysInline);

At point where we are in numerous places doing 3 coupled calls, we should add 
some routine to do this... Maybe we should have when I added the noinline bit.

I don't have a good idea of where best to do this -- as part of or as an 
alternative to `SetInternalFunctionAttributes`? Something else?

I'm imagining something like `SetAlwaysInlinedRuntimeFunctionAttributes` or 
something. Need a clang IRGen person to help push the organization in the right 
direction.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:892
 
+  // -O0 adds the optnone attribute, except if specific attributes prevents it.
+  bool ShouldAddOptNone =

attributes prevents -> attributes prevent

ACtually, what do you mean by attributes here? Or should this comment instead 
go below, where we start to branch on the actual 'hasAttr' calls?

After reading below, I understand better. Maybe:

  // Track whether we need to add the optnone LLVM attribute,
  // starting with the default for this optimization level.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:899-900
 
-// OptimizeNone implies noinline; we should not be inlining such functions.
+// OptimizeNone implies noinline; we should not be inlining such
+// functions.
 B.addAttribute(llvm::Attribute::NoInline);

Unrelated (and unnecessary) formatting change?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:910-912
 // OptimizeNone wins over OptimizeForSize and MinSize.
 F->removeFnAttr(llvm::Attribute::OptimizeForSize);
 F->removeFnAttr(llvm::Attribute::MinSize);

Is this still at all correct? Why? it seems pretty confusing especially in 
conjunction with the code below.


I think this may force you to either:
a) stop early-marking of -Os and -Oz flags with these attributes (early: prior 
to calling this routine) and handling all of the -O flag synthesized attributes 
here, or
b) set optnone for -O0 wher ewe set optsize for -Os and friends, and then 
remove it where necessary here.

I don't have any strong opinion about a vs. b.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:962
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !D->hasAttr();
+  ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline);

why is optnone incompatible with *cold*


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D28404#638350, @mehdi_amini wrote:

> In https://reviews.llvm.org/D28404#638299, @probinson wrote:
>
> > In https://reviews.llvm.org/D28404#638221, @mehdi_amini wrote:
> >
> > > In https://reviews.llvm.org/D28404#638217, @probinson wrote:
> > >
> > > > The patch as-is obviously has a massive testing cost, and it's easy to 
> > > > imagine people being tripped up by this in the future.
> > >
> > >
> > > Can you clarify what massive testing cost you're referring to?
> >
> >
> > Well, you just had to modify around 50 tests, and I'd expect some future 
> > tests to have to deal with it too.  Maybe "massive" is overstating it but 
> > it seemed like an unusually large number.
>
>
> There are two things:
>
> - tests are modified: when adding a new option, it does not seems unusual to 
> me


50 seems rather more than usual, but whatever.  Granted it's not hundreds.

> - what impact on future testing. I still don't see any of this future 
> "testing cost" you're referring to right now.

Maybe I worry too much.

I am getting a slightly different set of test failures than you did though.  I 
get these failures:
CodeGen/aarch64-neon-extract.c
CodeGen/aarch64-poly128.c
CodeGen/arm-neon-shifts.c
CodeGen/arm64-crc32.c

And I don't get these failures:
CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
CodeGenCXX/apple-kext-no-staticinit-section.cpp
CodeGenCXX/debug-info-global-ctor-dtor.cpp




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:900
+// OptimizeNone implies noinline; we should not be inlining such
+// functions.
 B.addAttribute(llvm::Attribute::NoInline);

I'd set ShouldAddOptNone = false here, as it's already explicit.



Comment at: clang/test/CodeGen/aarch64-neon-2velem.c:1
-// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-disable-O0-optnone -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
 

Option specified twice.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-06 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google added a comment.

In https://reviews.llvm.org/D28381#637915, @sunfish wrote:

> Would it be difficult to enable atomic.c in Emscripten's compiler-rt build, 
> to define these libcalls (assuming that the problem is just that they're not 
> currently defined)?


Tried it and it seems to work. I needed to add `-mthread-model single` to the 
compiler_rt build flags to get it to build. Which makes me think we'll have 
issues when we actually support "posix".

> Alternatively, could we make the change in the patch guarded by `if 
> (CodeGenOpts.ThreadModel == "single")` or so, so that it doesn't affect the 
> "posix" case?

We don't have access to `GodeGenOpts` in the constructor as far as I know, and 
the only `TargetInfo` method that does is `adjustTargetOptions`, which is 
`const` for the target.

My ideal patch here is to make the smallest change that doesn't need to be 
totally undone later, that also avoids making assumptions about how we'll 
implement wasm atomics down the line.
Talked with @dschuff, and we're probably going to go the compiler-rt route. 
Need to first explore whether it'd be saner to just drop in the real atomic.c 
or to stub one out for now.


https://reviews.llvm.org/D28381



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28385: Add a cc1 option to force disabling lifetime-markers emission from clang

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291300: Add a cc1 option to force disabling lifetime-markers 
emission from clang (authored by mehdi_amini).

Changed prior to commit:
  https://reviews.llvm.org/D28385?vs=83321=83443#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28385

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/lifetime2.c


Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -167,6 +167,9 @@
"frontend by not running any LLVM passes at all">;
 def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
   Alias;
+def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">,
+  HelpText<"Disable lifetime-markers emission even when optimizations are "
+   "enabled">;
 def disable_red_zone : Flag<["-"], "disable-red-zone">,
   HelpText<"Do not emit code that uses the red zone.">;
 def dwarf_column_info : Flag<["-"], "dwarf-column-info">,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -52,6 +52,7 @@
 CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get
  ///< the pristine IR generated by the
  ///< frontend.
+CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
Index: cfe/trunk/test/CodeGen/lifetime2.c
===
--- cfe/trunk/test/CodeGen/lifetime2.c
+++ cfe/trunk/test/CodeGen/lifetime2.c
@@ -1,4 +1,6 @@
 // RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s 
-check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \
+// RUN:   | FileCheck %s -check-prefixes=CHECK,O0
 // RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s 
-check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -520,6 +520,7 @@
 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
+  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
   Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -312,7 +312,8 @@
   // At O0 and O1 we only run the always inliner which is more efficient. At
   // higher optimization levels we run the normal inliner.
   if (CodeGenOpts.OptimizationLevel <= 1) {
-bool InsertLifetimeIntrinsics = CodeGenOpts.OptimizationLevel != 0;
+bool InsertLifetimeIntrinsics = (CodeGenOpts.OptimizationLevel != 0 &&
+ !CodeGenOpts.DisableLifetimeMarkers);
 PMBuilder.Inliner = 
createAlwaysInlinerLegacyPass(InsertLifetimeIntrinsics);
   } else {
 PMBuilder.Inliner = createFunctionInliningPass(
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -42,6 +42,9 @@
 /// markers.
 static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
   const LangOptions ) {
+  if (CGOpts.DisableLifetimeMarkers)
+return false;
+
   // Asan uses markers for use-after-scope checks.
   if (CGOpts.SanitizeAddressUseAfterScope)
 return true;


Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -167,6 +167,9 @@
"frontend by not running any LLVM passes at all">;
 def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
   Alias;
+def 

r291300 - Add a cc1 option to force disabling lifetime-markers emission from clang

2017-01-06 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Jan  6 17:18:09 2017
New Revision: 291300

URL: http://llvm.org/viewvc/llvm-project?rev=291300=rev
Log:
Add a cc1 option to force disabling lifetime-markers emission from clang

Summary: This intended as a debugging/development flag only.

Differential Revision: https://reviews.llvm.org/D28385

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/lifetime2.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=291300=291299=291300=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jan  6 17:18:09 2017
@@ -167,6 +167,9 @@ def disable_llvm_passes : Flag<["-"], "d
"frontend by not running any LLVM passes at all">;
 def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
   Alias;
+def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">,
+  HelpText<"Disable lifetime-markers emission even when optimizations are "
+   "enabled">;
 def disable_red_zone : Flag<["-"], "disable-red-zone">,
   HelpText<"Do not emit code that uses the red zone.">;
 def dwarf_column_info : Flag<["-"], "dwarf-column-info">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=291300=291299=291300=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Jan  6 17:18:09 2017
@@ -52,6 +52,7 @@ CODEGENOPT(DisableGCov   , 1, 0) ///
 CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get
  ///< the pristine IR generated by the
  ///< frontend.
+CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291300=291299=291300=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan  6 17:18:09 2017
@@ -312,7 +312,8 @@ void EmitAssemblyHelper::CreatePasses(le
   // At O0 and O1 we only run the always inliner which is more efficient. At
   // higher optimization levels we run the normal inliner.
   if (CodeGenOpts.OptimizationLevel <= 1) {
-bool InsertLifetimeIntrinsics = CodeGenOpts.OptimizationLevel != 0;
+bool InsertLifetimeIntrinsics = (CodeGenOpts.OptimizationLevel != 0 &&
+ !CodeGenOpts.DisableLifetimeMarkers);
 PMBuilder.Inliner = 
createAlwaysInlinerLegacyPass(InsertLifetimeIntrinsics);
   } else {
 PMBuilder.Inliner = createFunctionInliningPass(

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=291300=291299=291300=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan  6 17:18:09 2017
@@ -42,6 +42,9 @@ using namespace CodeGen;
 /// markers.
 static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
   const LangOptions ) {
+  if (CGOpts.DisableLifetimeMarkers)
+return false;
+
   // Asan uses markers for use-after-scope checks.
   if (CGOpts.SanitizeAddressUseAfterScope)
 return true;

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=291300=291299=291300=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Jan  6 17:18:09 2017
@@ -520,6 +520,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
+  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.ForbidGuardVariables = 

Re: [libcxx] r291275 - [libc++] Cleanup and document <__threading_support>

2017-01-06 Thread Eric Fiselier via cfe-commits
Should be fixed in r291298. Sorry for the breakage.

/Eric

On Fri, Jan 6, 2017 at 4:18 PM, Eric Fiselier  wrote:

> Hi David,
>
> Thanks for the information. Looking into it now.
>
> /Eric
>
> On Fri, Jan 6, 2017 at 4:02 PM, David Blaikie  wrote:
>
>>
>>
>> On Fri, Jan 6, 2017 at 12:16 PM Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Fri Jan  6 14:05:40 2017
>>> New Revision: 291275
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=291275=rev
>>> Log:
>>> [libc++] Cleanup and document <__threading_support>
>>>
>>> Summary:
>>> This patch attempts to clean up the macro configuration mess in
>>> `<__threading_support>`, specifically the mess involving external threading
>>> variants. Additionally this patch adds design documentation for
>>> `<__threading_support>` and the configuration macros it uses.
>>>
>>> The primary change in this patch is separating the idea of an "external
>>> API" provided by `<__external_threading>` and the idea of having an
>>> external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means
>>> that libc++ should use `<__external_threading>` and that the header is
>>> expected to exist.  Additionally the new macro
>>> `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for
>>> using an "external library"  with the default threading API.
>>>
>>> Reviewers: compnerd, rmaprath
>>>
>>> Subscribers: smeenai, cfe-commits, mgorny
>>>
>>> Differential Revision: https://reviews.llvm.org/D28316
>>>
>>> Added:
>>> libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
>>> Modified:
>>> libcxx/trunk/CMakeLists.txt
>>> libcxx/trunk/docs/index.rst
>>> libcxx/trunk/include/__config
>>> libcxx/trunk/include/__config_site.in
>>> libcxx/trunk/include/__threading_support
>>> libcxx/trunk/lib/CMakeLists.txt
>>> libcxx/trunk/test/CMakeLists.txt
>>> libcxx/trunk/test/lit.site.cfg.in
>>> libcxx/trunk/test/support/external_threads.cpp
>>>
>>> Modified: libcxx/trunk/CMakeLists.txt
>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.
>>> txt?rev=291275=291274=291275=diff
>>> 
>>> ==
>>> --- libcxx/trunk/CMakeLists.txt (original)
>>> +++ libcxx/trunk/CMakeLists.txt Fri Jan  6 14:05:40 2017
>>> @@ -169,6 +169,9 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore au
>>>  option(LIBCXX_HAS_EXTERNAL_THREAD_API
>>>"Build libc++ with an externalized threading API.
>>> This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON."
>>> OFF)
>>> +option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>>> +"Build libc++ with an externalized threading library.
>>> + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON"
>>> OFF)
>>>
>>>  # Misc options --
>>> --
>>>  # FIXME: Turn -pedantic back ON. It is currently off because it warns
>>> @@ -230,6 +233,17 @@ if(NOT LIBCXX_ENABLE_THREADS)
>>>  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be
>>> set to ON"
>>>  " when LIBCXX_ENABLE_THREADS is also set to
>>> ON.")
>>>endif()
>>> +  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
>>> +message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only
>>> be set "
>>> +"to ON when LIBCXX_ENABLE_THREADS is also set
>>> to ON.")
>>> +  endif()
>>> +
>>> +endif()
>>> +
>>> +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND
>>> LIBCXX_HAS_EXTERNAL_THREAD_API)
>>> +  message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>>> and "
>>> +  "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be
>>> ON at "
>>> +  "the same time")
>>>  endif()
>>>
>>>  if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
>>> @@ -520,6 +534,7 @@ config_define_if_not(LIBCXX_ENABLE_THREA
>>>
>>>  config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
>>>  config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API
>>> _LIBCPP_HAS_THREAD_API_EXTERNAL)
>>> +config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>>> _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
>>>  config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
>>>
>>>  # By default libc++ on Windows expects to use a shared library, which
>>> requires
>>>
>>> Added: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/Design
>>> Docs/ThreadingSupportAPI.rst?rev=291275=auto
>>> 
>>> ==
>>> --- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (added)
>>> +++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Fri Jan  6
>>> 14:05:40 2017
>>> @@ -0,0 +1,70 @@
>>> +=
>>> +Threading Support API
>>> +=
>>> +
>>> +.. contents::
>>> +   :local:
>>> +
>>> +Overview
>>> +
>>> +
>>> +Libc++ 

[libcxx] r291298 - Fix breakage caused when _LIBCPP_HAS_THREAD_API_PTHREAD is manually defined

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 17:15:16 2017
New Revision: 291298

URL: http://llvm.org/viewvc/llvm-project?rev=291298=rev
Log:
Fix breakage caused when _LIBCPP_HAS_THREAD_API_PTHREAD is manually defined

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291298=291297=291298=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan  6 17:15:16 2017
@@ -894,7 +894,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 // Thread API
-#if !defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # if defined(__FreeBSD__) || \
 defined(__Fuchsia__) || \
 defined(__NetBSD__) || \
@@ -902,9 +903,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 defined(__APPLE__) || \
 defined(__CloudABI__) || \
 defined(__sun__)
-#   ifndef _LIBCPP_HAS_THREAD_API_PTHREAD
-# define _LIBCPP_HAS_THREAD_API_PTHREAD
-#   endif
+#   define _LIBCPP_HAS_THREAD_API_PTHREAD
 # else
 #  error "No thread API"
 # endif // _LIBCPP_HAS_THREAD_API


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28385: Add a cc1 option to force disabling lifetime-markers emission from clang

2017-01-06 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D28385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r291275 - [libc++] Cleanup and document <__threading_support>

2017-01-06 Thread Eric Fiselier via cfe-commits
Hi David,

Thanks for the information. Looking into it now.

/Eric

On Fri, Jan 6, 2017 at 4:02 PM, David Blaikie  wrote:

>
>
> On Fri, Jan 6, 2017 at 12:16 PM Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Fri Jan  6 14:05:40 2017
>> New Revision: 291275
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291275=rev
>> Log:
>> [libc++] Cleanup and document <__threading_support>
>>
>> Summary:
>> This patch attempts to clean up the macro configuration mess in
>> `<__threading_support>`, specifically the mess involving external threading
>> variants. Additionally this patch adds design documentation for
>> `<__threading_support>` and the configuration macros it uses.
>>
>> The primary change in this patch is separating the idea of an "external
>> API" provided by `<__external_threading>` and the idea of having an
>> external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means
>> that libc++ should use `<__external_threading>` and that the header is
>> expected to exist.  Additionally the new macro 
>> `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`
>> is now used to configure for using an "external library"  with the default
>> threading API.
>>
>> Reviewers: compnerd, rmaprath
>>
>> Subscribers: smeenai, cfe-commits, mgorny
>>
>> Differential Revision: https://reviews.llvm.org/D28316
>>
>> Added:
>> libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
>> Modified:
>> libcxx/trunk/CMakeLists.txt
>> libcxx/trunk/docs/index.rst
>> libcxx/trunk/include/__config
>> libcxx/trunk/include/__config_site.in
>> libcxx/trunk/include/__threading_support
>> libcxx/trunk/lib/CMakeLists.txt
>> libcxx/trunk/test/CMakeLists.txt
>> libcxx/trunk/test/lit.site.cfg.in
>> libcxx/trunk/test/support/external_threads.cpp
>>
>> Modified: libcxx/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/
>> CMakeLists.txt?rev=291275=291274=291275=diff
>> 
>> ==
>> --- libcxx/trunk/CMakeLists.txt (original)
>> +++ libcxx/trunk/CMakeLists.txt Fri Jan  6 14:05:40 2017
>> @@ -169,6 +169,9 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore au
>>  option(LIBCXX_HAS_EXTERNAL_THREAD_API
>>"Build libc++ with an externalized threading API.
>> This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
>> +option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>> +"Build libc++ with an externalized threading library.
>> + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON"
>> OFF)
>>
>>  # Misc options --
>> --
>>  # FIXME: Turn -pedantic back ON. It is currently off because it warns
>> @@ -230,6 +233,17 @@ if(NOT LIBCXX_ENABLE_THREADS)
>>  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set
>> to ON"
>>  " when LIBCXX_ENABLE_THREADS is also set to ON.")
>>endif()
>> +  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
>> +message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only
>> be set "
>> +"to ON when LIBCXX_ENABLE_THREADS is also set to
>> ON.")
>> +  endif()
>> +
>> +endif()
>> +
>> +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_HAS_EXTERNAL_THREAD_
>> API)
>> +  message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>> and "
>> +  "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON
>> at "
>> +  "the same time")
>>  endif()
>>
>>  if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
>> @@ -520,6 +534,7 @@ config_define_if_not(LIBCXX_ENABLE_THREA
>>
>>  config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
>>  config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_
>> EXTERNAL)
>> +config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
>> _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
>>  config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
>>
>>  # By default libc++ on Windows expects to use a shared library, which
>> requires
>>
>> Added: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/
>> ThreadingSupportAPI.rst?rev=291275=auto
>> 
>> ==
>> --- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (added)
>> +++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Fri Jan  6
>> 14:05:40 2017
>> @@ -0,0 +1,70 @@
>> +=
>> +Threading Support API
>> +=
>> +
>> +.. contents::
>> +   :local:
>> +
>> +Overview
>> +
>> +
>> +Libc++ supports using multiple different threading models and
>> configurations
>> +to implement the threading parts of libc++, including  and
>> .
>> +These different models provide entirely different interfaces from each
>> +other. To address this libc++ wraps 

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I'm seeing the following build errors on Windows:

  C:\Users\Eric\workspace\libcxx\include\__threading_support(521,3):  warning: 
cannot delete expression with pointer-to-'void' type 'void *' 
[-Wdelete-incomplete]
delete __data;
^  ~~
  C:\Users\Eric\workspace\libcxx\include\__threading_support(530,18):  error: 
assigning to 'void *(*)(void *)' from incompatible type 'void (*)(void *)': 
different return type ('void *' vs 'void')
data->__func = __func;
   ^~
  C:\Users\Eric\workspace\libcxx\include\__threading_support(572,5):  error: 
functions that differ only in their return type cannot be overloaded
  int __libcpp_thread_yield()
  ~~~ ^
  C:\Users\Eric\workspace\libcxx\include\__threading_support(178,6):  note: 
previous declaration is here
  void __libcpp_thread_yield();
   ^
  C:\Users\Eric\workspace\libcxx\include\__threading_support(589,5):  error: 
functions that differ only in their return type cannot be overloaded
  int __libcpp_tls_get(__libcpp_tls_key __key)
  ~~~ ^
  C:\Users\Eric\workspace\libcxx\include\__threading_support(185,7):  note: 
previous declaration is here
  void *__libcpp_tls_get(__libcpp_tls_key __key);
  ~~^
  C:\Users\Eric\workspace\libcxx\include\__threading_support(591,10):  error: 
cannot initialize return object of type 'int' with an rvalue of type 'PVOID' 
(aka 'void *')
return FlsGetValue(__key);


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83441.
mehdi_amini added a comment.
Herald added subscribers: dschuff, jfb.

Fix one more conflicts with always_inline, and change some test check lines


https://reviews.llvm.org/D28404

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-shifts.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/address-safety-attr-kasan.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/arm-crc32.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-neon-vget.c
  clang/test/CodeGen/arm64-lanes.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/builtins-arm-exclusive.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/static-init-wasm.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/Driver/darwin-iphone-defaults.m

Index: clang/test/Driver/darwin-iphone-defaults.m
===
--- clang/test/Driver/darwin-iphone-defaults.m
+++ clang/test/Driver/darwin-iphone-defaults.m
@@ -26,4 +26,4 @@
   [I1 alloc];
 }
 
-// CHECK: attributes [[F0]] = { noinline ssp{{.*}} }
+// CHECK: attributes [[F0]] = { noinline  optnone ssp{{.*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -141,26 +141,26 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind optnone "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind optnone "amdgpu-num-sgpr"="32"
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { noinline nounwind optnone "amdgpu-num-vgpr"="64"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-sgpr"="32"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" "amdgpu-num-vgpr"="64"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { noinline nounwind "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { 

r291295 - Revisit PR10177: don't instantiate a variable if it's only referenced in a

2017-01-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan  6 16:52:53 2017
New Revision: 291295

URL: http://llvm.org/viewvc/llvm-project?rev=291295=rev
Log:
Revisit PR10177: don't instantiate a variable if it's only referenced in a
dependent context and can't be used in a constant expression.

Per C++ [temp.inst]p2, "the instantiation of a static data member does not
occur unless the static data member is used in a way that requires the
definition to exist".

This doesn't /quite/ match that, as we still instantiate static data members
that are usable in constant expressions even if the use doesn't require a
definition. A followup patch will fix that for both variables and functions.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/PR10177.cpp
cfe/trunk/test/SemaCXX/undefined-internal.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291295=291294=291295=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan  6 16:52:53 2017
@@ -27,6 +27,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/ExpressionTraits.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Module.h"
@@ -3801,6 +3802,9 @@ public:
   /// variable will have in the given scope.
   QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc);
 
+  /// Mark all of the declarations referenced within a particular AST node as
+  /// referenced. Used when template instantiation instantiates a non-dependent
+  /// type -- entities referenced by the type are now referenced.
   void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
   void MarkDeclarationsReferencedInExpr(Expr *E,
 bool SkipLocalVariables = false);
@@ -6877,6 +6881,10 @@ public:
   /// Specializations whose definitions are currently being instantiated.
   llvm::DenseSet InstantiatingSpecializations;
 
+  /// Non-dependent types used in templates that have already been instantiated
+  /// by some template instantiation.
+  llvm::DenseSet InstantiatedNonDependentTypes;
+
   /// \brief Extra modules inspected when performing a lookup during a template
   /// instantiation. Computed lazily.
   SmallVector ActiveTemplateInstantiationLookupModules;

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=291295=291294=291295=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jan  6 16:52:53 2017
@@ -14122,48 +14122,13 @@ static void DoMarkVarDeclReferenced(Sema
  "Invalid Expr argument to DoMarkVarDeclReferenced");
   Var->setReferenced();
 
-  TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
-  bool MarkODRUsed = true;
-
-  // If the context is not potentially evaluated, this is not an odr-use and
-  // does not trigger instantiation.
-  if (!IsPotentiallyEvaluatedContext(SemaRef)) {
-if (SemaRef.isUnevaluatedContext())
-  return;
-
-// If we don't yet know whether this context is going to end up being an
-// evaluated context, and we're referencing a variable from an enclosing
-// scope, add a potential capture.
-//
-// FIXME: Is this necessary? These contexts are only used for default
-// arguments, where local variables can't be used.
-const bool RefersToEnclosingScope =
-(SemaRef.CurContext != Var->getDeclContext() &&
- Var->getDeclContext()->isFunctionOrMethod() && 
Var->hasLocalStorage());
-if (RefersToEnclosingScope) {
-  if (LambdaScopeInfo *const LSI =
-  SemaRef.getCurLambda(/*IgnoreCapturedRegions=*/true)) {
-// If a variable could potentially be odr-used, defer marking it so
-// until we finish analyzing the full expression for any
-// lvalue-to-rvalue
-// or discarded value conversions that would obviate odr-use.
-// Add it to the list of potential captures that will be analyzed
-// later (ActOnFinishFullExpr) for eventual capture and odr-use marking
-// unless the variable is a reference that was initialized by a 
constant
-// expression (this will never need to be captured or odr-used).
-assert(E && "Capture variable should be used in an expression.");
-if (!Var->getType()->isReferenceType() ||
-!IsVariableNonDependentAndAConstantExpression(Var, 
SemaRef.Context))
-  LSI->addPotentialCapture(E->IgnoreParens());
-  }
-}
-
-if (!isTemplateInstantiation(TSK))
-  return;
+  if 

Re: [libcxx] r291275 - [libc++] Cleanup and document <__threading_support>

2017-01-06 Thread David Blaikie via cfe-commits
On Fri, Jan 6, 2017 at 12:16 PM Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Jan  6 14:05:40 2017
> New Revision: 291275
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291275=rev
> Log:
> [libc++] Cleanup and document <__threading_support>
>
> Summary:
> This patch attempts to clean up the macro configuration mess in
> `<__threading_support>`, specifically the mess involving external threading
> variants. Additionally this patch adds design documentation for
> `<__threading_support>` and the configuration macros it uses.
>
> The primary change in this patch is separating the idea of an "external
> API" provided by `<__external_threading>` and the idea of having an
> external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means
> that libc++ should use `<__external_threading>` and that the header is
> expected to exist.  Additionally the new macro
> `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for using an
> "external library"  with the default threading API.
>
> Reviewers: compnerd, rmaprath
>
> Subscribers: smeenai, cfe-commits, mgorny
>
> Differential Revision: https://reviews.llvm.org/D28316
>
> Added:
> libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/docs/index.rst
> libcxx/trunk/include/__config
> libcxx/trunk/include/__config_site.in
> libcxx/trunk/include/__threading_support
> libcxx/trunk/lib/CMakeLists.txt
> libcxx/trunk/test/CMakeLists.txt
> libcxx/trunk/test/lit.site.cfg.in
> libcxx/trunk/test/support/external_threads.cpp
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=291275=291274=291275=diff
>
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Fri Jan  6 14:05:40 2017
> @@ -169,6 +169,9 @@ option(LIBCXX_HAS_PTHREAD_API "Ignore au
>  option(LIBCXX_HAS_EXTERNAL_THREAD_API
>"Build libc++ with an externalized threading API.
> This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
> +option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> +"Build libc++ with an externalized threading library.
> + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF)
>
>  # Misc options
> 
>  # FIXME: Turn -pedantic back ON. It is currently off because it warns
> @@ -230,6 +233,17 @@ if(NOT LIBCXX_ENABLE_THREADS)
>  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set
> to ON"
>  " when LIBCXX_ENABLE_THREADS is also set to ON.")
>endif()
> +  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
> +message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be
> set "
> +"to ON when LIBCXX_ENABLE_THREADS is also set to
> ON.")
> +  endif()
> +
> +endif()
> +
> +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND
> LIBCXX_HAS_EXTERNAL_THREAD_API)
> +  message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> and "
> +  "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON
> at "
> +  "the same time")
>  endif()
>
>  if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
> @@ -520,6 +534,7 @@ config_define_if_not(LIBCXX_ENABLE_THREA
>
>  config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
>  config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API
> _LIBCPP_HAS_THREAD_API_EXTERNAL)
> +config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY
> _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
>  config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
>
>  # By default libc++ on Windows expects to use a shared library, which
> requires
>
> Added: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst?rev=291275=auto
>
> ==
> --- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (added)
> +++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Fri Jan  6
> 14:05:40 2017
> @@ -0,0 +1,70 @@
> +=
> +Threading Support API
> +=
> +
> +.. contents::
> +   :local:
> +
> +Overview
> +
> +
> +Libc++ supports using multiple different threading models and
> configurations
> +to implement the threading parts of libc++, including  and
> .
> +These different models provide entirely different interfaces from each
> +other. To address this libc++ wraps the underlying threading API in a new
> and
> +consistent API, which it uses internally to implement threading
> primitives.
> +
> +The ``<__threading_support>`` header is where libc++ defines its internal
> +threading interface. It contains forward declarations of the internal
> 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini updated this revision to Diff 83433.
mehdi_amini added a comment.
Herald added a subscriber: jholewinski.

Fix minsize issue (conditional was reversed)


https://reviews.llvm.org/D28404

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-neon-perm.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-shifts.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/address-safety-attr-kasan.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/arm-crc32.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-neon-vget.c
  clang/test/CodeGen/arm64-lanes.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/attr-coldhot.c
  clang/test/CodeGen/builtins-arm-exclusive.c
  clang/test/CodeGen/builtins-arm.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
  clang/test/CodeGenCXX/apple-kext-linkage.cpp
  clang/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/static-init-wasm.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/Driver/darwin-iphone-defaults.m

Index: clang/test/Driver/darwin-iphone-defaults.m
===
--- clang/test/Driver/darwin-iphone-defaults.m
+++ clang/test/Driver/darwin-iphone-defaults.m
@@ -26,4 +26,4 @@
   [I1 alloc];
 }
 
-// CHECK: attributes [[F0]] = { noinline ssp{{.*}} }
+// CHECK: attributes [[F0]] = { noinline  optnone ssp{{.*}} }
Index: clang/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ clang/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -O0 -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -emit-llvm -verify -o - %s | FileCheck -check-prefix=X86 %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -O0 -disable-O0-optnone -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -disable-O0-optnone -emit-llvm -verify -o - %s | FileCheck -check-prefix=X86 %s
 
 __attribute__((amdgpu_flat_work_group_size(0, 0))) // expected-no-diagnostics
 kernel void flat_work_group_size_0_0() {}
Index: clang/test/CodeGenObjC/gnu-exceptions.m
===
--- clang/test/CodeGenObjC/gnu-exceptions.m
+++ clang/test/CodeGenObjC/gnu-exceptions.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-1.7 -o - %s | FileCheck -check-prefix=NEW-ABI %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -disable-O0-optnone -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -disable-O0-optnone -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gnustep-1.7 -o - %s | FileCheck -check-prefix=NEW-ABI %s
 
 void opaque(void);
 void log(int i);
Index: clang/test/CodeGenCXX/thunks.cpp
===
--- clang/test/CodeGenCXX/thunks.cpp
+++ clang/test/CodeGenCXX/thunks.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONOPT %s
-// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-passes | FileCheck --check-prefix=CHECK 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D28404#638299, @probinson wrote:

> In https://reviews.llvm.org/D28404#638221, @mehdi_amini wrote:
>
> > In https://reviews.llvm.org/D28404#638217, @probinson wrote:
> >
> > > The patch as-is obviously has a massive testing cost, and it's easy to 
> > > imagine people being tripped up by this in the future.
> >
> >
> > Can you clarify what massive testing cost you're referring to?
>
>
> Well, you just had to modify around 50 tests, and I'd expect some future 
> tests to have to deal with it too.  Maybe "massive" is overstating it but it 
> seemed like an unusually large number.


There are two things:

- tests are modified: when adding a new option, it does not seems unusual to me
- what impact on future testing. I still don't see any of this future "testing 
cost" you're referring to right now.

> I don't know that just slapping the option on all these tests is really the 
> most appropriate fix, either, in some cases.  I'll look at it more.

For instance the ARM test are relying on piping the output of clang to mem2reg 
to clean the IR and have simpler check patterns (I assume). This is not 
compatible with optnone obviously.
On the other hand I don't want to update the check lines for > 2 lines in 
testsclang/test/CodeGen/aarch64-neon-intrinsics.c just to save passing an 
option.
It's likely that some of these test could have their check line adapted, but I 
didn't see much interest in doing this.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28415: PCH: fix a regression that reports a module is defined in both pch and pcm

2017-01-06 Thread Manman Ren via Phabricator via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, benlangmuir, doug.gregor.
manmanren added a subscriber: cfe-commits.

In r276159, we started to say that a module X is defined in a pch if we specify 
-fmodule-name when building the pch.
This caused a regression that reports module X is defined in both pch and pcm 
if we generate the pch with -fmodule-name=X and then in a separate clang 
invocation, we include the pch and also import X.pcm.

This patch adds an option CompilingPCH similar to CompilingModule. When we use 
-fmodule-name=X while building a pch, modular headers in X will be textually 
included and the compiler knows that we are not building module X, so we don't 
put module X in SUBMODULE_DEFINITION of the pch.


https://reviews.llvm.org/D28415

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/FrontendActions.h
  lib/Frontend/FrontendActions.cpp
  lib/Lex/PPDirectives.cpp
  lib/Serialization/ASTWriter.cpp
  test/Modules/Inputs/pch-with-module-name/A.h
  test/Modules/Inputs/pch-with-module-name/C.h
  test/Modules/Inputs/pch-with-module-name/C.m
  test/Modules/Inputs/pch-with-module-name/D.h
  test/Modules/Inputs/pch-with-module-name/module.modulemap
  test/Modules/Inputs/pch-with-module-name/test.h
  test/Modules/pch-with-module-name.m

Index: test/Modules/pch-with-module-name.m
===
--- test/Modules/pch-with-module-name.m
+++ test/Modules/pch-with-module-name.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/pch-with-module-name -emit-pch -o %t-A.pch %S/Inputs/pch-with-module-name/test.h -fmodule-name=Contacts -x objective-c-header
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/pch-with-module-name -include-pch %t-A.pch %s -fsyntax-only -fmodule-name=Contacts -verify
+// expected-no-diagnostics 
+#include "C.h"
Index: test/Modules/Inputs/pch-with-module-name/test.h
===
--- test/Modules/Inputs/pch-with-module-name/test.h
+++ test/Modules/Inputs/pch-with-module-name/test.h
@@ -0,0 +1 @@
+#include "A.h"
Index: test/Modules/Inputs/pch-with-module-name/module.modulemap
===
--- test/Modules/Inputs/pch-with-module-name/module.modulemap
+++ test/Modules/Inputs/pch-with-module-name/module.modulemap
@@ -0,0 +1,9 @@
+module CloudKit {
+  header "C.h"
+  export *
+}
+
+module Contacts {
+  header "D.h"
+  export *
+}
Index: test/Modules/Inputs/pch-with-module-name/D.h
===
--- test/Modules/Inputs/pch-with-module-name/D.h
+++ test/Modules/Inputs/pch-with-module-name/D.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/pch-with-module-name/C.m
===
--- test/Modules/Inputs/pch-with-module-name/C.m
+++ test/Modules/Inputs/pch-with-module-name/C.m
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/pch-with-module-name/C.h
===
--- test/Modules/Inputs/pch-with-module-name/C.h
+++ test/Modules/Inputs/pch-with-module-name/C.h
@@ -0,0 +1 @@
+#include "D.h"
Index: test/Modules/Inputs/pch-with-module-name/A.h
===
--- test/Modules/Inputs/pch-with-module-name/A.h
+++ test/Modules/Inputs/pch-with-module-name/A.h
@@ -0,0 +1 @@
+// in pch
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4654,17 +4654,6 @@
   // If we're emitting a module, write out the submodule information.  
   if (WritingModule)
 WriteSubmodules(WritingModule);
-  else if (!getLangOpts().CurrentModule.empty()) {
-// If we're building a PCH in the implementation of a module, we may need
-// the description of the current module.
-//
-// FIXME: We may need other modules that we did not load from an AST file,
-// such as if a module declares a 'conflicts' on a different module.
-Module *M = PP.getHeaderSearchInfo().getModuleMap().findModule(
-getLangOpts().CurrentModule);
-if (M && !M->IsFromModuleFile)
-  WriteSubmodules(M);
-  }
 
   Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes);
 
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -1996,18 +1996,28 @@
 
   // Ask HeaderInfo if we should enter this #include file.  If not, #including
   // this file will have no effect.
+  bool SkipHeader = false;
   if (ShouldEnter &&
   !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
  SuggestedModule.getModule())) {
 ShouldEnter = 

[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added a comment.

LGTM.




Comment at: include/__threading_support:480
+  if (!SleepConditionVariableSRW(__cv, __m,
+ timeout_ms.count() > 0 ? timeout_ms.count()
+: 0,

There is still problem with large timeout but let us fix it later.


https://reviews.llvm.org/D28220



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd removed rL LLVM as the repository for this revision.
compnerd updated this revision to Diff 83432.
compnerd added a comment.

rebase


https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -148,7 +148,8 @@
 __thread_specific_ptr(const __thread_specific_ptr&);
 __thread_specific_ptr& operator=(const __thread_specific_ptr&);
 
-static void __at_thread_exit(void*);
+static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
+
 public:
 typedef _Tp* pointer;
 
@@ -164,21 +165,19 @@
 };
 
 template 
-void
+void _LIBCPP_TLS_DESTRUCTOR_CC
 __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
 {
 delete static_cast(__p);
 }
 
 template 
 __thread_specific_ptr<_Tp>::__thread_specific_ptr()
 {
-int __ec = __libcpp_tls_create(
-&__key_,
-&__thread_specific_ptr::__at_thread_exit);
-if (__ec)
-__throw_system_error(__ec,
-   "__thread_specific_ptr construction failed");
+  int __ec =
+  __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+  if (__ec)
+__throw_system_error(__ec, "__thread_specific_ptr construction failed");
 }
 
 template 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -24,6 +24,14 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 
+#include 
+
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
@@ -58,6 +66,33 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#else
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute Once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
 #endif
 
 // Mutex
@@ -321,6 +356,249 @@
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  EnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  TryEnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+  LeaveCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  TryAcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+
+  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto abstime =
+  system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+
+  if (!SleepConditionVariableSRW(__cv, __m,
+ timeout_ms.count() > 0 ? timeout_ms.count()
+: 0,
+ 

[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config

2017-01-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D26900#638328, @EricWF wrote:

> Is there a way to write this patch so that old `llvm-config`'s continue to 
> work, at least for a little while until everybody upgrades?


Technically it's possible but I think it would add a lot of complexity. So if 
you believe that to be a major issue, I'd rather just wait a few days before 
applying the change. However, I don't think we really have a big market for 
people doing stand-alone builds ;-).


https://reviews.llvm.org/D26900



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28315: Update tools to use new getStyle API

2017-01-06 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

@ioeric Okay, check-clang-tools passes with my changes.

FYI, tests were originally failing for me (without my changes) because I use 
Git, and it's configured to convert line endings to Windows (crlf) on checkout, 
but some of the tools tests specify extract offsets into source files, which 
end up being incorrect if you've got an extra byte per line ;) I'll open a 
ticket/discussion about it separately.

So if you give me the go ahead, I'll submit this change _after_ submitting 
https://reviews.llvm.org/D28081.


https://reviews.llvm.org/D28315



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26900: [cmake] Obtain LLVM_CMAKE_PATH from llvm-config

2017-01-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Is there a way to write this patch so that old `llvm-config`'s continue to 
work, at least for a little while until everybody upgrades?


https://reviews.llvm.org/D26900



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28220: provide Win32 native threading

2017-01-06 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 83430.
compnerd marked an inline comment as done.
compnerd added a comment.

rebase, address negative timeouts, fix thunking for `__libcpp_tls_create`


Repository:
  rL LLVM

https://reviews.llvm.org/D28220

Files:
  include/__config
  include/__threading_support
  include/thread

Index: include/thread
===
--- include/thread
+++ include/thread
@@ -148,7 +148,8 @@
 __thread_specific_ptr(const __thread_specific_ptr&);
 __thread_specific_ptr& operator=(const __thread_specific_ptr&);
 
-static void __at_thread_exit(void*);
+static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
+
 public:
 typedef _Tp* pointer;
 
@@ -164,21 +165,19 @@
 };
 
 template 
-void
+void _LIBCPP_TLS_DESTRUCTOR_CC
 __thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
 {
 delete static_cast(__p);
 }
 
 template 
 __thread_specific_ptr<_Tp>::__thread_specific_ptr()
 {
-int __ec = __libcpp_tls_create(
-&__key_,
-&__thread_specific_ptr::__at_thread_exit);
-if (__ec)
-__throw_system_error(__ec,
-   "__thread_specific_ptr construction failed");
+  int __ec =
+  __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+  if (__ec)
+__throw_system_error(__ec, "__thread_specific_ptr construction failed");
 }
 
 template 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -47,6 +47,14 @@
 defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
 #include 
 #include 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+#include 
+#define WIN32_LEAN_AND_MEAN
+#include 
+#include 
+#include 
+
+#include 
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
@@ -81,6 +89,33 @@
 
 // Thrad Local Storage
 typedef pthread_key_t __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC
+#else
+// Mutex
+typedef SRWLOCK __libcpp_mutex_t;
+#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
+
+typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
+
+// Condition Variable
+typedef CONDITION_VARIABLE __libcpp_condvar_t;
+#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
+
+// Execute Once
+typedef INIT_ONCE __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
+
+// Thread ID
+typedef DWORD __libcpp_thread_id;
+
+// Thread
+typedef HANDLE __libcpp_thread_t;
+
+// Thread Local Storage
+typedef DWORD __libcpp_tls_key;
+
+#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
 #endif
 
 // Mutex
@@ -342,6 +377,249 @@
 return pthread_setspecific(__key, __p);
 }
 
+#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
+
+// Mutex
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
+{
+  InitializeCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  EnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  TryEnterCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
+{
+  LeaveCriticalSection(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
+{
+  AcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
+{
+  TryAcquireSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  ReleaseSRWLockExclusive(__m);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
+{
+  static_cast(__m);
+  return 0;
+}
+
+// Condition Variable
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
+{
+  WakeConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
+{
+  WakeAllConditionVariable(__cv);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
+{
+  SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
+  return 0;
+}
+
+_LIBCPP_ALWAYS_INLINE
+int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
+   timespec *__ts)
+{
+  using namespace _VSTD::chrono;
+
+  auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+  auto abstime =
+  system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+
+  if (!SleepConditionVariableSRW(__cv, __m,
+ timeout_ms.count() > 0 ? timeout_ms.count()
+ 

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-01-06 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D28404#638221, @mehdi_amini wrote:

> In https://reviews.llvm.org/D28404#638217, @probinson wrote:
>
> > The patch as-is obviously has a massive testing cost, and it's easy to 
> > imagine people being tripped up by this in the future.
>
>
> Can you clarify what massive testing cost you're referring to?


Well, you just had to modify around 50 tests, and I'd expect some future tests 
to have to deal with it too.  Maybe "massive" is overstating it but it seemed 
like an unusually large number.

I don't know that just slapping the option on all these tests is really the 
most appropriate fix, either, in some cases.  I'll look at it more.


https://reviews.llvm.org/D28404



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291286 - Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.

2017-01-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Jan  6 15:42:58 2017
New Revision: 291286

URL: http://llvm.org/viewvc/llvm-project?rev=291286=rev
Log:
Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.

This patch refactors the compiler detection done in `__config` by creating a
set of `_LIBCPP_COMPILER_` macros. The goal of this patch is to make
it easier to detect what compiler is being used outside of `__config`.

Additionally this patch removes workarounds for GCC in `__bit_reference`. I
tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it
anymore.

Modified:
libcxx/trunk/include/__bit_reference
libcxx/trunk/include/__config
libcxx/trunk/include/support/win32/support.h
libcxx/trunk/include/type_traits
libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__bit_reference
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bit_reference?rev=291286=291285=291286=diff
==
--- libcxx/trunk/include/__bit_reference (original)
+++ libcxx/trunk/include/__bit_reference Fri Jan  6 15:42:58 2017
@@ -40,11 +40,8 @@ class __bit_reference
 __storage_pointer __seg_;
 __storage_type__mask_;
 
-#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
 friend typename _Cp::__self;
-#else
-friend class _Cp::__self;
-#endif
+
 friend class __bit_const_reference<_Cp>;
 friend class __bit_iterator<_Cp, false>;
 public:
@@ -130,11 +127,7 @@ class __bit_const_reference
 __storage_pointer__seg_;
 __storage_type __mask_;
 
-#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
 friend typename _Cp::__self;
-#else
-friend class _Cp::__self;
-#endif
 friend class __bit_iterator<_Cp, true>;
 public:
 _LIBCPP_INLINE_VISIBILITY
@@ -1221,11 +1214,8 @@ private:
 __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
 : __seg_(__s), __ctz_(__ctz) {}
 
-#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
 friend typename _Cp::__self;
-#else
-friend class _Cp::__self;
-#endif
+
 friend class __bit_reference<_Cp>;
 friend class __bit_const_reference<_Cp>;
 friend class __bit_iterator<_Cp, true>;

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=291286=291285=291286=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jan  6 15:42:58 2017
@@ -101,6 +101,16 @@
 #define __is_identifier(__x) 1
 #endif
 
+#if defined(__clang__)
+#define _LIBCPP_COMPILER_CLANG
+#elif defined(__GNUC__)
+#define _LIBCPP_COMPILER_GCC
+#elif defined(_MSC_VER)
+#define _LIBCPP_COMPILER_MSVC
+#elif defined(__IBMCPP__)
+#define _LIBCPP_COMPILER_IBM
+#endif
+
 // Need to detect which libc we're using if we're on Linux.
 #if defined(__linux__)
 #include 
@@ -164,16 +174,7 @@
 #  define _LIBCPP_LITTLE_ENDIAN 1
 #  define _LIBCPP_BIG_ENDIAN0
 #  define _LIBCPP_SHORT_WCHAR   1
-// Compiler intrinsics (MSVC)
-#  if defined(_MSC_VER) && _MSC_VER >= 1400
-#define _LIBCPP_HAS_IS_BASE_OF
-#  endif
-#  if defined(_MSC_VER) && !defined(__clang__)
-#define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
-#define _LIBCPP_TOSTRING2(x) #x
-#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
-#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" 
_LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
-#  endif
+
 // If mingw not explicitly detected, assume using MS C runtime only.
 #  ifndef __MINGW32__
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
@@ -230,7 +231,7 @@
 #define _LIBCPP_NO_CFI
 #endif
 
-#if defined(__clang__)
+#if defined(_LIBCPP_COMPILER_CLANG)
 
 // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
 // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
@@ -386,7 +387,7 @@ namespace std {
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
 #endif 
 
-#elif defined(__GNUC__)
+#elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
 #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x
@@ -469,8 +470,17 @@ using namespace _LIBCPP_NAMESPACE __attr
 #define _LIBCPP_HAS_NO_ASAN
 #endif
 
-#elif defined(_LIBCPP_MSVC)
+#elif defined(_LIBCPP_COMPILER_MSVC)
 
+#define _LIBCPP_TOSTRING2(x) #x
+#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
+#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" 
_LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
+
+#if _MSC_VER < 1900
+#error "MSVC versions prior to Visual Studio 2015 are not supported"
+#endif
+
+#define _LIBCPP_HAS_IS_BASE_OF
 #define _LIBCPP_HAS_NO_CONSTEXPR
 #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
@@ -493,7 +503,7 @@ namespace std {
 
 #define 

[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-06 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In https://reviews.llvm.org/D28362#638260, @mehdi_amini wrote:

> > In order to simplify distributed build system integration, where actions
> >  may be scheduled before the Thin Link which determines the list of
> >  objects selected by the linker. The gold plugin currently will emit
> >  0-sized index files for objects not selected by the link, to enable
> >  checking for expected output files by the build system. If the build
> >  system then schedules a backend action for these bitcode files, we want
> >  to be able to fall back to normal compilation instead of failing.
>
> Just thought about it: why not emit an empty *index* instead of an empty file?


I thought about that initially. But it will also need some special handling as 
e.g. FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal on the module 
being compiled will complain when it doesn't find summaries for the GVs in that 
module. There might be other places too, that's the first one I found when I 
was thinking about this approach.


https://reviews.llvm.org/D28362



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-06 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

> In order to simplify distributed build system integration, where actions

may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.

Just thought about it: why not emit an empty *index* instead of an empty file?


https://reviews.llvm.org/D28362



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >