r283716 - [x86][inline-asm][clang] accept 'v' constraint

2016-10-09 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Oct 10 00:45:54 2016
New Revision: 283716

URL: http://llvm.org/viewvc/llvm-project?rev=283716=rev
Log:
[x86][inline-asm][clang] accept 'v' constraint

Commit in the name of: Coby Tayree 

1.'v' constraint for (x86) non-avx arch imitates the already implemented 'x' 
constraint, i.e. allows XMM{0-15} & YMM{0-15} depending on the apparent arch & 
mode (32/64).
2.for the avx512 arch it allows [X,Y,Z]MM{0-31} (mode dependent)

This patch applies the needed changes to clang
 LLVM patch: https://reviews.llvm.org/D25005

Differential Revision: D25004 


Added:
cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c   (with props)
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=283716=283715=283716=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Oct 10 00:45:54 2016
@@ -4005,6 +4005,7 @@ X86TargetInfo::validateAsmConstraint(con
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -4045,6 +4046,7 @@ bool X86TargetInfo::validateOperandSize(
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.

Added: cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c?rev=283716=auto
==
--- cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c (added)
+++ cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c Mon Oct 10 00:45:54 
2016
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes 
AVX512,AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", 
"=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+}
+
+// AVX512: call <16 x float> asm "vpternlogd $$0, $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(<16 x float> %0, <16 x float> %1)
+__m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
+#ifdef AVX512
+  __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
+#endif
+  return _zmm0;
+}

Propchange: cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGen/x86-inline-asm-v-constraint.c
--
svn:mime-type = text/plain


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


[libcxx] r283715 - Provide a constexpr addressof with GCC 7.

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 10 00:34:18 2016
New Revision: 283715

URL: http://llvm.org/viewvc/llvm-project?rev=283715=rev
Log:
Provide a constexpr addressof with GCC 7.

__builtin_addressof was added to the GCC trunk in the past week. This patch
teaches libc++ about it so it can correctly provide constexpr addressof.

Unfortunately this patch will break users of earlier GCC 7 builds, since
we expect __builtin_addressof but one won't be provided. One option would be
to only use __builtin_addressof for GCC 7.1 and above, but that means
waiting for another release.

Instead I've specifically chosen to break older GCC 7 versions. Since GCC 7
has yet to be released, and the 7.0 release is a development release, I
believe that anybody currently using GCC 7.0 will have no issue upgrading.

Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/libcxx/test/config.py

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=283715=283714=283715=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Oct 10 00:34:18 2016
@@ -425,7 +425,7 @@ template  us
 #endif
 
 // addressof
-#if __has_builtin(__builtin_addressof)
+#if __has_builtin(__builtin_addressof) || _GNUC_VER >= 700
 
 template 
 inline _LIBCPP_CONSTEXPR_AFTER_CXX14

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=283715=283714=283715=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Mon Oct 10 00:34:18 2016
@@ -179,6 +179,7 @@ class Configuration(object):
 assert self.cxx.version is not None
 maj_v, min_v, _ = self.cxx.version
 self.config.available_features.add(cxx_type)
+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))
 

Modified: 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp?rev=283715=283714=283715=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
 Mon Oct 10 00:34:18 2016
@@ -8,7 +8,7 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// XFAIL: gcc
+// XFAIL: gcc-4, gcc-5, gcc-6
 
 // 
 


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


[libcxx] r283714 - Workaround missing C++14 constexpr semantics in filesystem

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct 10 00:19:59 2016
New Revision: 283714

URL: http://llvm.org/viewvc/llvm-project?rev=283714=rev
Log:
Workaround missing C++14 constexpr semantics in filesystem

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=283714=283713=283714=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Mon Oct 10 00:19:59 
2016
@@ -536,7 +536,8 @@ constexpr auto min_time_t = numeric_limi
 #pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
 #endif
 
-constexpr bool is_representable(TimeSpec const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+bool is_representable(TimeSpec const& tm) {
   if (tm.tv_sec >= 0) {
 return (tm.tv_sec < max_seconds) ||
 (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
@@ -546,7 +547,7 @@ constexpr bool is_representable(TimeSpec
 return (tm.tv_sec >= min_seconds);
   }
 }
-
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(is_representable({max_seconds, max_nsec}), "");
 static_assert(!is_representable({max_seconds + 1, 0}), "");
@@ -562,8 +563,10 @@ static_assert(is_representable({max_time
 static_assert(is_representable({max_time_t, 10}), "");
 static_assert(is_representable({min_time_t, 0}), "");
 #endif
+#endif
 
-constexpr bool is_representable(file_time_type const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+bool is_representable(file_time_type const& tm) {
   auto secs = duration_cast(tm.time_since_epoch());
   auto nsecs = duration_cast(tm.time_since_epoch() - secs);
   if (nsecs.count() < 0) {
@@ -575,6 +578,7 @@ constexpr bool is_representable(file_tim
 return secs.count() <= TLim::max();
   return secs.count() >= TLim::min();
 }
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(is_representable(file_time_type::max()), "");
 static_assert(is_representable(file_time_type::min()), "");
@@ -584,9 +588,10 @@ static_assert(!is_representable(file_tim
 static_assert(is_representable(file_time_type(seconds(max_time_t))), "");
 static_assert(is_representable(file_time_type(seconds(min_time_t))), "");
 #endif
+#endif
 
-template  struct Dummy;
-constexpr file_time_type convert_timespec(TimeSpec const& tm) {
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+file_time_type convert_timespec(TimeSpec const& tm) {
   auto adj_msec = duration_cast(nanoseconds(tm.tv_nsec));
   if (tm.tv_sec >= 0) {
 auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
@@ -599,6 +604,7 @@ constexpr file_time_type convert_timespe
 return file_time_type(Dur);
   }
 }
+#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
 #if defined(__LP64__)
 static_assert(convert_timespec({max_seconds, max_nsec}) == 
file_time_type::max(), "");
 static_assert(convert_timespec({max_seconds, max_nsec - 1}) < 
file_time_type::max(), "");
@@ -609,6 +615,7 @@ static_assert(convert_timespec({min_seco
 #else
 // FIXME add tests for 32 bit builds
 #endif
+#endif
 
 #if !defined(__LP64__) && defined(__clang__)
 #pragma clang diagnostic pop


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


[PATCH] D25426: [Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25426

Files:
  clang/include/clang/Analysis/AnalysisContext.h
  clang/lib/Analysis/AnalysisDeclContext.cpp


Index: clang/lib/Analysis/AnalysisDeclContext.cpp
===
--- clang/lib/Analysis/AnalysisDeclContext.cpp
+++ clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -81,9 +81,7 @@
   cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator;
 }
 
-void AnalysisDeclContextManager::clear() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+void AnalysisDeclContextManager::clear() { Contexts.clear(); }
 
 static BodyFarm (ASTContext , CodeInjector *injector = nullptr) {
   static BodyFarm *BF = new BodyFarm(C, injector);
@@ -307,10 +305,10 @@
 D = FD;
   }
 
-  AnalysisDeclContext * = Contexts[D];
+  std::unique_ptr  = Contexts[D];
   if (!AC)
-AC = new AnalysisDeclContext(this, D, cfgBuildOptions);
-  return AC;
+AC = llvm::make_unique(this, D, cfgBuildOptions);
+  return AC.get();
 }
 
 const StackFrameContext *
@@ -606,9 +604,7 @@
   }
 }
 
-AnalysisDeclContextManager::~AnalysisDeclContextManager() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+AnalysisDeclContextManager::~AnalysisDeclContextManager() {}
 
 LocationContext::~LocationContext() {}
 
Index: clang/include/clang/Analysis/AnalysisContext.h
===
--- clang/include/clang/Analysis/AnalysisContext.h
+++ clang/include/clang/Analysis/AnalysisContext.h
@@ -406,7 +406,8 @@
 };
 
 class AnalysisDeclContextManager {
-  typedef llvm::DenseMap ContextMap;
+  typedef llvm::DenseMap>
+  ContextMap;
 
   ContextMap Contexts;
   LocationContextManager LocContexts;


Index: clang/lib/Analysis/AnalysisDeclContext.cpp
===
--- clang/lib/Analysis/AnalysisDeclContext.cpp
+++ clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -81,9 +81,7 @@
   cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator;
 }
 
-void AnalysisDeclContextManager::clear() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+void AnalysisDeclContextManager::clear() { Contexts.clear(); }
 
 static BodyFarm (ASTContext , CodeInjector *injector = nullptr) {
   static BodyFarm *BF = new BodyFarm(C, injector);
@@ -307,10 +305,10 @@
 D = FD;
   }
 
-  AnalysisDeclContext * = Contexts[D];
+  std::unique_ptr  = Contexts[D];
   if (!AC)
-AC = new AnalysisDeclContext(this, D, cfgBuildOptions);
-  return AC;
+AC = llvm::make_unique(this, D, cfgBuildOptions);
+  return AC.get();
 }
 
 const StackFrameContext *
@@ -606,9 +604,7 @@
   }
 }
 
-AnalysisDeclContextManager::~AnalysisDeclContextManager() {
-  llvm::DeleteContainerSeconds(Contexts);
-}
+AnalysisDeclContextManager::~AnalysisDeclContextManager() {}
 
 LocationContext::~LocationContext() {}
 
Index: clang/include/clang/Analysis/AnalysisContext.h
===
--- clang/include/clang/Analysis/AnalysisContext.h
+++ clang/include/clang/Analysis/AnalysisContext.h
@@ -406,7 +406,8 @@
 };
 
 class AnalysisDeclContextManager {
-  typedef llvm::DenseMap ContextMap;
+  typedef llvm::DenseMap>
+  ContextMap;
 
   ContextMap Contexts;
   LocationContextManager LocContexts;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25425: [AST] Convert Marshallers to use unique_ptr.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D25425

Files:
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp

Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -31,43 +31,45 @@
 
 using internal::MatcherDescriptor;
 
-typedef llvm::StringMap ConstructorMap;
+typedef llvm::StringMap ConstructorMap;
 class RegistryMaps {
 public:
   RegistryMaps();
   ~RegistryMaps();
 
   const ConstructorMap () const { return Constructors; }
 
 private:
-  void registerMatcher(StringRef MatcherName, MatcherDescriptor *Callback);
+  void registerMatcher(StringRef MatcherName,
+   std::unique_ptr Callback);
+
   ConstructorMap Constructors;
 };
 
-void RegistryMaps::registerMatcher(StringRef MatcherName,
-   MatcherDescriptor *Callback) {
+void RegistryMaps::registerMatcher(
+StringRef MatcherName, std::unique_ptr Callback) {
   assert(Constructors.find(MatcherName) == Constructors.end());
-  Constructors[MatcherName] = Callback;
+  Constructors[MatcherName] = std::move(Callback);
 }
 
 #define REGISTER_MATCHER(name) \
   registerMatcher(#name, internal::makeMatcherAutoMarshall(\
  ::clang::ast_matchers::name, #name));
 
 #define SPECIFIC_MATCHER_OVERLOAD(name, Id)\
-  static_cast< ::clang::ast_matchers::name##_Type##Id>(\
+  static_cast<::clang::ast_matchers::name##_Type##Id>( \
   ::clang::ast_matchers::name)
 
 #define REGISTER_OVERLOADED_2(name)\
   do { \
-MatcherDescriptor *Callbacks[] = { \
-  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),\
-#name),\
-  internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1),\
-#name) \
-}; \
-registerMatcher(#name, \
-new internal::OverloadedMatcherDescriptor(Callbacks)); \
+std::unique_ptr Callbacks[] = { \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 0),  \
+  #name),  \
+internal::makeMatcherAutoMarshall(SPECIFIC_MATCHER_OVERLOAD(name, 1),  \
+  #name)}; \
+registerMatcher(   \
+#name, \
+llvm::make_unique(Callbacks));  \
   } while (0)
 
 /// \brief Generate a registry map with all the known matchers.
@@ -426,21 +428,18 @@
   REGISTER_MATCHER(withInitializer);
 }
 
-RegistryMaps::~RegistryMaps() {
-  llvm::DeleteContainerSeconds(Constructors);
-}
+RegistryMaps::~RegistryMaps() {}
 
 static llvm::ManagedStatic RegistryData;
 
 } // anonymous namespace
 
 // static
 llvm::Optional Registry::lookupMatcherCtor(StringRef MatcherName) {
-  ConstructorMap::const_iterator it =
-  RegistryData->constructors().find(MatcherName);
+  auto it = RegistryData->constructors().find(MatcherName);
   return it == RegistryData->constructors().end()
  ? llvm::Optional()
- : it->second;
+ : it->second.get();
 }
 
 namespace {
@@ -499,7 +498,7 @@
 
   // Search the registry for acceptable matchers.
   for (const auto  : RegistryData->constructors()) {
-const auto *Matcher = M.getValue();
+const std::unique_ptr& Matcher = M.getValue();
 StringRef Name = M.getKey();
 
 std::set RetKinds;
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -480,8 +480,8 @@
   typename FromTypes, typename ToTypes>
 class AdaptativeOverloadCollector {
 public:
-  AdaptativeOverloadCollector(StringRef Name,
-  std::vector )
+  AdaptativeOverloadCollector(
+  StringRef Name, std::vector )
   : Name(Name), Out(Out) {
 collect(FromTypes());
   }
@@ -499,7 +499,7 @@
   inline void collect(FromTypeList);
 
   StringRef Name;
-  

[PATCH] D25424: Use unique_ptr for VTableBuilder::VBaseInfo map.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25424

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/lib/AST/VTableBuilder.cpp


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -3388,9 +3388,7 @@
   return Changed;
 }
 
-MicrosoftVTableContext::~MicrosoftVTableContext() {
-  llvm::DeleteContainerSeconds(VBaseInfo);
-}
+MicrosoftVTableContext::~MicrosoftVTableContext() {}
 
 namespace {
 typedef llvm::SetVectorVBPtrPaths);
@@ -3690,10 +3689,10 @@
   if (const CXXRecordDecl *VBPtrBase = Layout.getBaseSharingVBPtr()) {
 // If the Derived class shares the vbptr with a non-virtual base, the 
shared
 // virtual bases come first so that the layout is the same.
-const VirtualBaseInfo *BaseInfo =
+const VirtualBaseInfo  =
 computeVBTableRelatedInformation(VBPtrBase);
-VBI->VBTableIndices.insert(BaseInfo->VBTableIndices.begin(),
-   BaseInfo->VBTableIndices.end());
+VBI->VBTableIndices.insert(BaseInfo.VBTableIndices.begin(),
+   BaseInfo.VBTableIndices.end());
   }
 
   // New vbases are added to the end of the vbtable.
@@ -3705,19 +3704,19 @@
   VBI->VBTableIndices[CurVBase] = VBTableIndex++;
   }
 
-  return VBI;
+  return *VBI;
 }
 
 unsigned MicrosoftVTableContext::getVBTableIndex(const CXXRecordDecl *Derived,
  const CXXRecordDecl *VBase) {
-  const VirtualBaseInfo *VBInfo = computeVBTableRelatedInformation(Derived);
-  assert(VBInfo->VBTableIndices.count(VBase));
-  return VBInfo->VBTableIndices.find(VBase)->second;
+  const VirtualBaseInfo  = computeVBTableRelatedInformation(Derived);
+  assert(VBInfo.VBTableIndices.count(VBase));
+  return VBInfo.VBTableIndices.find(VBase)->second;
 }
 
 const VPtrInfoVector &
 MicrosoftVTableContext::enumerateVBTables(const CXXRecordDecl *RD) {
-  return computeVBTableRelatedInformation(RD)->VBPtrPaths;
+  return computeVBTableRelatedInformation(RD).VBPtrPaths;
 }
 
 const VPtrInfoVector &
Index: clang/include/clang/AST/VTableBuilder.h
===
--- clang/include/clang/AST/VTableBuilder.h
+++ clang/include/clang/AST/VTableBuilder.h
@@ -484,7 +484,8 @@
   VFTableLayoutMapTy;
   VFTableLayoutMapTy VFTableLayouts;
 
-  llvm::DenseMap VBaseInfo;
+  llvm::DenseMap>
+  VBaseInfo;
 
   void enumerateVFPtrs(const CXXRecordDecl *ForClass, VPtrInfoVector );
 
@@ -494,7 +495,7 @@
const MethodVFTableLocationsTy ,
raw_ostream &);
 
-  const VirtualBaseInfo *
+  const VirtualBaseInfo &
   computeVBTableRelatedInformation(const CXXRecordDecl *RD);
 
   void computeVTablePaths(bool ForVBTables, const CXXRecordDecl *RD,


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -3388,9 +3388,7 @@
   return Changed;
 }
 
-MicrosoftVTableContext::~MicrosoftVTableContext() {
-  llvm::DeleteContainerSeconds(VBaseInfo);
-}
+MicrosoftVTableContext::~MicrosoftVTableContext() {}
 
 namespace {
 typedef llvm::SetVectorVBPtrPaths);
@@ -3690,10 +3689,10 @@
   if (const CXXRecordDecl *VBPtrBase = Layout.getBaseSharingVBPtr()) {
 // If the Derived class shares the vbptr with a non-virtual base, 

[PATCH] D25423: Use unique_ptr for VTableBuilder::VFTableLayouts map.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25423

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/lib/AST/VTableBuilder.cpp


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -3389,7 +3389,6 @@
 }
 
 MicrosoftVTableContext::~MicrosoftVTableContext() {
-  llvm::DeleteContainerSeconds(VFTableLayouts);
   llvm::DeleteContainerSeconds(VBaseInfo);
 }
 
@@ -3592,7 +3591,7 @@
 assert(VFTableLayouts.count(id) == 0);
 SmallVector VTableThunks(
 Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
-VFTableLayouts[id] = new VTableLayout(
+VFTableLayouts[id] = llvm::make_unique(
 Builder.getNumVTableComponents(), Builder.vtable_component_begin(),
 VTableThunks.size(), VTableThunks.data(), EmptyAddressPointsMap, true);
 Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
Index: clang/include/clang/AST/VTableBuilder.h
===
--- clang/include/clang/AST/VTableBuilder.h
+++ clang/include/clang/AST/VTableBuilder.h
@@ -480,7 +480,8 @@
   VFPtrLocationsMapTy VFPtrLocations;
 
   typedef std::pair VFTableIdTy;
-  typedef llvm::DenseMap VFTableLayoutMapTy;
+  typedef llvm::DenseMap
+  VFTableLayoutMapTy;
   VFTableLayoutMapTy VFTableLayouts;
 
   llvm::DenseMap VBaseInfo;


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -3389,7 +3389,6 @@
 }
 
 MicrosoftVTableContext::~MicrosoftVTableContext() {
-  llvm::DeleteContainerSeconds(VFTableLayouts);
   llvm::DeleteContainerSeconds(VBaseInfo);
 }
 
@@ -3592,7 +3591,7 @@
 assert(VFTableLayouts.count(id) == 0);
 SmallVector VTableThunks(
 Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
-VFTableLayouts[id] = new VTableLayout(
+VFTableLayouts[id] = llvm::make_unique(
 Builder.getNumVTableComponents(), Builder.vtable_component_begin(),
 VTableThunks.size(), VTableThunks.data(), EmptyAddressPointsMap, true);
 Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
Index: clang/include/clang/AST/VTableBuilder.h
===
--- clang/include/clang/AST/VTableBuilder.h
+++ clang/include/clang/AST/VTableBuilder.h
@@ -480,7 +480,8 @@
   VFPtrLocationsMapTy VFPtrLocations;
 
   typedef std::pair VFTableIdTy;
-  typedef llvm::DenseMap VFTableLayoutMapTy;
+  typedef llvm::DenseMap
+  VFTableLayoutMapTy;
   VFTableLayoutMapTy VFTableLayouts;
 
   llvm::DenseMap VBaseInfo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25422: Use unique_ptr for VPtrLocationsMap and VPtrInfoVector.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25422

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/lib/AST/VTableBuilder.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp

Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -96,7 +96,7 @@
 const ASTRecordLayout  = Context.getASTRecordLayout(RD);
 
 const VBTableGlobals  = enumerateVBTables(RD);
-for (const VPtrInfo *VBT : *VBGlobals.VBTables) {
+for (const std::unique_ptr  : *VBGlobals.VBTables) {
   const ASTRecordLayout  =
   Context.getASTRecordLayout(VBT->IntroducingObject);
   CharUnits Offs = VBT->NonVirtualOffset;
@@ -122,7 +122,7 @@
   void emitBeginCatch(CodeGenFunction , const CXXCatchStmt *C) override;
 
   llvm::GlobalVariable *getMSCompleteObjectLocator(const CXXRecordDecl *RD,
-   const VPtrInfo *Info);
+   const VPtrInfo );
 
   llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) override;
   CatchTypeInfo
@@ -254,7 +254,7 @@
   CXXDtorType Type, bool ForVirtualBase,
   bool Delegating, Address This) override;
 
-  void emitVTableTypeMetadata(VPtrInfo *Info, const CXXRecordDecl *RD,
+  void emitVTableTypeMetadata(const VPtrInfo , const CXXRecordDecl *RD,
   llvm::GlobalVariable *VTable);
 
   void emitVTableDefinitions(CodeGenVTables ,
@@ -1214,7 +1214,7 @@
 
   const VBTableGlobals  = enumerateVBTables(RD);
   for (unsigned I = 0, E = VBGlobals.VBTables->size(); I != E; ++I) {
-const VPtrInfo *VBT = (*VBGlobals.VBTables)[I];
+const std::unique_ptr  = (*VBGlobals.VBTables)[I];
 llvm::GlobalVariable *GV = VBGlobals.Globals[I];
 const ASTRecordLayout  =
 Context.getASTRecordLayout(VBT->IntroducingObject);
@@ -1509,7 +1509,7 @@
 getFromDtorType(Type));
 }
 
-void MicrosoftCXXABI::emitVTableTypeMetadata(VPtrInfo *Info,
+void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo ,
  const CXXRecordDecl *RD,
  llvm::GlobalVariable *VTable) {
   if (!CGM.getCodeGenOpts().PrepareForLTO)
@@ -1524,20 +1524,20 @@
 getContext().getTargetInfo().getPointerWidth(0))
   : CharUnits::Zero();
 
-  if (Info->PathToIntroducingObject.empty()) {
+  if (Info.PathToIntroducingObject.empty()) {
 CGM.AddVTableTypeMetadata(VTable, AddressPoint, RD);
 return;
   }
 
   // Add a bitset entry for the least derived base belonging to this vftable.
   CGM.AddVTableTypeMetadata(VTable, AddressPoint,
-Info->PathToIntroducingObject.back());
+Info.PathToIntroducingObject.back());
 
   // Add a bitset entry for each derived class that is laid out at the same
   // offset as the least derived base.
-  for (unsigned I = Info->PathToIntroducingObject.size() - 1; I != 0; --I) {
-const CXXRecordDecl *DerivedRD = Info->PathToIntroducingObject[I - 1];
-const CXXRecordDecl *BaseRD = Info->PathToIntroducingObject[I];
+  for (unsigned I = Info.PathToIntroducingObject.size() - 1; I != 0; --I) {
+const CXXRecordDecl *DerivedRD = Info.PathToIntroducingObject[I - 1];
+const CXXRecordDecl *BaseRD = Info.PathToIntroducingObject[I];
 
 const ASTRecordLayout  =
 getContext().getASTRecordLayout(DerivedRD);
@@ -1553,16 +1553,16 @@
   }
 
   // Finally do the same for the most derived class.
-  if (Info->FullOffsetInMDC.isZero())
+  if (Info.FullOffsetInMDC.isZero())
 CGM.AddVTableTypeMetadata(VTable, AddressPoint, RD);
 }
 
 void MicrosoftCXXABI::emitVTableDefinitions(CodeGenVTables ,
 const CXXRecordDecl *RD) {
   MicrosoftVTableContext  = CGM.getMicrosoftVTableContext();
   const VPtrInfoVector  = VFTContext.getVFPtrOffsets(RD);
 
-  for (VPtrInfo *Info : VFPtrs) {
+  for (const std::unique_ptr& Info : VFPtrs) {
 llvm::GlobalVariable *VTable = getAddrOfVTable(RD, Info->FullOffsetInMDC);
 if (VTable->hasInitializer())
   continue;
@@ -1573,13 +1573,13 @@
 llvm::Constant *RTTI = nullptr;
 if (any_of(VTLayout.vtable_components(),
[](const VTableComponent ) { return VTC.isRTTIKind(); }))
-  RTTI = getMSCompleteObjectLocator(RD, Info);
+  RTTI = getMSCompleteObjectLocator(RD, *Info);
 
 llvm::Constant *Init = CGVT.CreateVTableInitializer(VTLayout, RTTI);
 
 VTable->setInitializer(Init);
 
-emitVTableTypeMetadata(Info, RD, VTable);
+emitVTableTypeMetadata(*Info, RD, VTable);
   }
 }
 
@@ -1600,10 +1600,10 @@
 }
 
 static void mangleVFTableName(MicrosoftMangleContext ,
-  const 

[PATCH] D25421: [AST] Use unique_ptr for VTableLayout.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25421

Files:
  clang/include/clang/AST/VTableBuilder.h
  clang/lib/AST/VTableBuilder.cpp


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -2234,9 +2234,7 @@
 ItaniumVTableContext::ItaniumVTableContext(ASTContext )
 : VTableContextBase(/*MS=*/false) {}
 
-ItaniumVTableContext::~ItaniumVTableContext() {
-  llvm::DeleteContainerSeconds(VTableLayouts);
-}
+ItaniumVTableContext::~ItaniumVTableContext() {}
 
 uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
   MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
@@ -2280,21 +2278,20 @@
   return I->second;
 }
 
-static VTableLayout *CreateVTableLayout(const ItaniumVTableBuilder ) {
+static std::unique_ptr
+CreateVTableLayout(const ItaniumVTableBuilder ) {
   SmallVector
 VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
 
-  return new VTableLayout(Builder.getNumVTableComponents(),
-  Builder.vtable_component_begin(),
-  VTableThunks.size(),
-  VTableThunks.data(),
-  Builder.getAddressPoints(),
-  /*IsMicrosoftABI=*/false);
+  return llvm::make_unique(
+  Builder.getNumVTableComponents(), Builder.vtable_component_begin(),
+  VTableThunks.size(), VTableThunks.data(), Builder.getAddressPoints(),
+  /*IsMicrosoftABI=*/false);
 }
 
 void
 ItaniumVTableContext::computeVTableRelatedInformation(const CXXRecordDecl *RD) 
{
-  const VTableLayout * = VTableLayouts[RD];
+  std::unique_ptr  = VTableLayouts[RD];
 
   // Check if we've computed this information before.
   if (Entry)
@@ -2330,7 +2327,8 @@
   }
 }
 
-VTableLayout *ItaniumVTableContext::createConstructionVTableLayout(
+std::unique_ptr
+ItaniumVTableContext::createConstructionVTableLayout(
 const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
 bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass) {
   ItaniumVTableBuilder Builder(*this, MostDerivedClass, MostDerivedClassOffset,
Index: clang/include/clang/AST/VTableBuilder.h
===
--- clang/include/clang/AST/VTableBuilder.h
+++ clang/include/clang/AST/VTableBuilder.h
@@ -313,8 +313,9 @@
   typedef llvm::DenseMap MethodVTableIndicesTy;
   MethodVTableIndicesTy MethodVTableIndices;
 
-  typedef llvm::DenseMap
-VTableLayoutMapTy;
+  typedef llvm::DenseMap>
+  VTableLayoutMapTy;
   VTableLayoutMapTy VTableLayouts;
 
   typedef std::pair createConstructionVTableLayout(
+  const CXXRecordDecl *MostDerivedClass, CharUnits MostDerivedClassOffset,
+  bool MostDerivedClassIsVirtual, const CXXRecordDecl *LayoutClass);
 
   /// \brief Locate a virtual function in the vtable.
   ///


Index: clang/lib/AST/VTableBuilder.cpp
===
--- clang/lib/AST/VTableBuilder.cpp
+++ clang/lib/AST/VTableBuilder.cpp
@@ -2234,9 +2234,7 @@
 ItaniumVTableContext::ItaniumVTableContext(ASTContext )
 : VTableContextBase(/*MS=*/false) {}
 
-ItaniumVTableContext::~ItaniumVTableContext() {
-  llvm::DeleteContainerSeconds(VTableLayouts);
-}
+ItaniumVTableContext::~ItaniumVTableContext() {}
 
 uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
   MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
@@ -2280,21 +2278,20 @@
   return I->second;
 }
 
-static VTableLayout *CreateVTableLayout(const ItaniumVTableBuilder ) {
+static std::unique_ptr
+CreateVTableLayout(const ItaniumVTableBuilder ) {
   SmallVector
 VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
 
-  return new VTableLayout(Builder.getNumVTableComponents(),
-  Builder.vtable_component_begin(),
-  VTableThunks.size(),
-  VTableThunks.data(),
-  Builder.getAddressPoints(),
-  /*IsMicrosoftABI=*/false);
+  return llvm::make_unique(
+  Builder.getNumVTableComponents(), Builder.vtable_component_begin(),
+  VTableThunks.size(), VTableThunks.data(), Builder.getAddressPoints(),
+  /*IsMicrosoftABI=*/false);
 }
 
 void
 ItaniumVTableContext::computeVTableRelatedInformation(const CXXRecordDecl *RD) {
-  const VTableLayout * = VTableLayouts[RD];
+  std::unique_ptr  = VTableLayouts[RD];
 
   // Check if we've computed this information before.
   if (Entry)
@@ -2330,7 +2327,8 @@
   }
 }
 
-VTableLayout *ItaniumVTableContext::createConstructionVTableLayout(
+std::unique_ptr
+ItaniumVTableContext::createConstructionVTableLayout(
 const 

[PATCH] D25420: [AST] Convert MangleNumberingContext to a unique_ptr.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

It doesn't need to be refcounted anymore, either.


https://reviews.llvm.org/D25420

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/MangleNumberingContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/CXXABI.h
  clang/lib/AST/ItaniumCXXABI.cpp
  clang/lib/AST/MicrosoftCXXABI.cpp

Index: clang/lib/AST/MicrosoftCXXABI.cpp
===
--- clang/lib/AST/MicrosoftCXXABI.cpp
+++ clang/lib/AST/MicrosoftCXXABI.cpp
@@ -143,8 +143,9 @@
 const_cast(TD->getCanonicalDecl()));
   }
 
-  MangleNumberingContext *createMangleNumberingContext() const override {
-return new MicrosoftNumberingContext();
+  std::unique_ptr
+  createMangleNumberingContext() const override {
+return llvm::make_unique();
   }
 };
 }
Index: clang/lib/AST/ItaniumCXXABI.cpp
===
--- clang/lib/AST/ItaniumCXXABI.cpp
+++ clang/lib/AST/ItaniumCXXABI.cpp
@@ -163,8 +163,9 @@
 return nullptr;
   }
 
-  MangleNumberingContext *createMangleNumberingContext() const override {
-return new ItaniumNumberingContext();
+  std::unique_ptr
+  createMangleNumberingContext() const override {
+return llvm::make_unique();
   }
 };
 }
Index: clang/lib/AST/CXXABI.h
===
--- clang/lib/AST/CXXABI.h
+++ clang/lib/AST/CXXABI.h
@@ -43,7 +43,8 @@
   virtual bool isNearlyEmpty(const CXXRecordDecl *RD) const = 0;
 
   /// Returns a new mangling number context for this C++ ABI.
-  virtual MangleNumberingContext *createMangleNumberingContext() const = 0;
+  virtual std::unique_ptr
+  createMangleNumberingContext() const = 0;
 
   /// Adds a mapping from class to copy constructor for this C++ ABI.
   virtual void addCopyConstructorForExceptionObject(CXXRecordDecl *,
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -794,8 +794,6 @@
 
   for (const auto  : ModuleInitializers)
 Value.second->~PerModuleInitializers();
-
-  llvm::DeleteContainerSeconds(MangleNumberingContexts);
 }
 
 void ASTContext::ReleaseParentMapEntries() {
@@ -8982,13 +8980,14 @@
 MangleNumberingContext &
 ASTContext::getManglingNumberContext(const DeclContext *DC) {
   assert(LangOpts.CPlusPlus);  // We don't need mangling numbers for plain C.
-  MangleNumberingContext * = MangleNumberingContexts[DC];
+  std::unique_ptr  = MangleNumberingContexts[DC];
   if (!MCtx)
 MCtx = createMangleNumberingContext();
   return *MCtx;
 }
 
-MangleNumberingContext *ASTContext::createMangleNumberingContext() const {
+std::unique_ptr
+ASTContext::createMangleNumberingContext() const {
   return ABI->createMangleNumberingContext();
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -876,7 +876,7 @@
 ///
 /// This mangling information is allocated lazily, since most contexts
 /// do not have lambda expressions or block literals.
-IntrusiveRefCntPtr MangleNumbering;
+std::unique_ptr MangleNumbering;
 
 /// \brief If we are processing a decltype type, a set of call expressions
 /// for which we have deferred checking the completeness of the return type.
Index: clang/include/clang/AST/MangleNumberingContext.h
===
--- clang/include/clang/AST/MangleNumberingContext.h
+++ clang/include/clang/AST/MangleNumberingContext.h
@@ -29,7 +29,7 @@
 
 /// \brief Keeps track of the mangled names of lambda expressions and block
 /// literals within a particular context.
-class MangleNumberingContext : public RefCountedBase {
+class MangleNumberingContext {
 public:
   virtual ~MangleNumberingContext() {}
 
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -407,7 +407,7 @@
   /// \brief Mapping from each declaration context to its corresponding
   /// mangling numbering context (used for constructs like lambdas which
   /// need to be consistently numbered for the mangler).
-  llvm::DenseMap
+  llvm::DenseMap>
   MangleNumberingContexts;
 
   /// \brief Side-table of mangling numbers for declarations which rarely
@@ -2470,7 +2470,7 @@
   /// DeclContext.
   MangleNumberingContext (const DeclContext *DC);
 
-  MangleNumberingContext *createMangleNumberingContext() const;
+  std::unique_ptr createMangleNumberingContext() const;
 
   /// \brief Used by ParmVarDecl to store on the side the
   /// index of the parameter when it exceeds the size of the normal bitfield.

[PATCH] D25419: Use unique_ptr in LLVMContextImpl's constant maps.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.

https://reviews.llvm.org/D25419

Files:
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h

Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -1049,10 +1049,12 @@
   LLVMContext::YieldCallbackTy YieldCallback;
   void *YieldOpaqueHandle;
 
-  typedef DenseMap IntMapTy;
+  typedef DenseMap
+  IntMapTy;
   IntMapTy IntConstants;
 
-  typedef DenseMap FPMapTy;
+  typedef DenseMap
+  FPMapTy;
   FPMapTy FPConstants;
 
   FoldingSet AttrsSet;
@@ -1078,7 +1080,7 @@
   // them on context teardown.
   std::vector DistinctMDNodes;
 
-  DenseMap CAZConstants;
+  DenseMap> CAZConstants;
 
   typedef ConstantUniqueMap ArrayConstantsTy;
   ArrayConstantsTy ArrayConstants;
@@ -1088,11 +1090,11 @@
   
   typedef ConstantUniqueMap VectorConstantsTy;
   VectorConstantsTy VectorConstants;
-  
-  DenseMap CPNConstants;
 
-  DenseMap UVConstants;
-  
+  DenseMap> CPNConstants;
+
+  DenseMap> UVConstants;
+
   StringMap CDSConstants;
 
   DenseMap
Index: llvm/lib/IR/LLVMContextImpl.cpp
===
--- llvm/lib/IR/LLVMContextImpl.cpp
+++ llvm/lib/IR/LLVMContextImpl.cpp
@@ -94,12 +94,13 @@
   ArrayConstants.freeConstants();
   StructConstants.freeConstants();
   VectorConstants.freeConstants();
-  DeleteContainerSeconds(CAZConstants);
-  DeleteContainerSeconds(CPNConstants);
-  DeleteContainerSeconds(UVConstants);
   InlineAsms.freeConstants();
-  DeleteContainerSeconds(IntConstants);
-  DeleteContainerSeconds(FPConstants);
+
+  CAZConstants.clear();
+  CPNConstants.clear();
+  UVConstants.clear();
+  IntConstants.clear();
+  FPConstants.clear();
 
   for (auto  : CDSConstants)
 delete CDSConstant.second;
Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -545,14 +545,14 @@
 ConstantInt *ConstantInt::get(LLVMContext , const APInt ) {
   // get an existing value or the insertion position
   LLVMContextImpl *pImpl = Context.pImpl;
-  ConstantInt * = pImpl->IntConstants[V];
+  std::unique_ptr  = pImpl->IntConstants[V];
   if (!Slot) {
 // Get the corresponding integer type for the bit width of the value.
 IntegerType *ITy = IntegerType::get(Context, V.getBitWidth());
-Slot = new ConstantInt(ITy, V);
+Slot.reset(new ConstantInt(ITy, V));
   }
   assert(Slot->getType() == IntegerType::get(Context, V.getBitWidth()));
-  return Slot;
+  return Slot.get();
 }
 
 Constant *ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) {
@@ -685,7 +685,7 @@
 ConstantFP* ConstantFP::get(LLVMContext , const APFloat& V) {
   LLVMContextImpl* pImpl = Context.pImpl;
 
-  ConstantFP * = pImpl->FPConstants[V];
+  std::unique_ptr  = pImpl->FPConstants[V];
 
   if (!Slot) {
 Type *Ty;
@@ -704,10 +704,10 @@
  "Unknown FP format");
   Ty = Type::getPPC_FP128Ty(Context);
 }
-Slot = new ConstantFP(Ty, V);
+Slot.reset(new ConstantFP(Ty, V));
   }
 
-  return Slot;
+  return Slot.get();
 }
 
 Constant *ConstantFP::getInfinity(Type *Ty, bool Negative) {
@@ -1259,12 +1259,13 @@
 ConstantAggregateZero *ConstantAggregateZero::get(Type *Ty) {
   assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
  "Cannot create an aggregate zero of non-aggregate type!");
-  
-  ConstantAggregateZero * = Ty->getContext().pImpl->CAZConstants[Ty];
-  if (!Entry)
-Entry = new ConstantAggregateZero(Ty);
 
-  return Entry;
+  std::unique_ptr  =
+  Ty->getContext().pImpl->CAZConstants[Ty];
+  if (!Entry)
+Entry.reset(new ConstantAggregateZero(Ty));
+
+  return Entry.get();
 }
 
 /// Remove the constant from the constant table.
@@ -1325,24 +1326,25 @@
 //
 
 ConstantPointerNull *ConstantPointerNull::get(PointerType *Ty) {
-  ConstantPointerNull * = Ty->getContext().pImpl->CPNConstants[Ty];
+  std::unique_ptr  =
+  Ty->getContext().pImpl->CPNConstants[Ty];
   if (!Entry)
-Entry = new ConstantPointerNull(Ty);
+Entry.reset(new ConstantPointerNull(Ty));
 
-  return Entry;
+  return Entry.get();
 }
 
 /// Remove the constant from the constant table.
 void ConstantPointerNull::destroyConstantImpl() {
   getContext().pImpl->CPNConstants.erase(getType());
 }
 
 UndefValue *UndefValue::get(Type *Ty) {
-  UndefValue * = Ty->getContext().pImpl->UVConstants[Ty];
+  std::unique_ptr  = Ty->getContext().pImpl->UVConstants[Ty];
   if (!Entry)
- 

[PATCH] D25417: [libcxxabi] Fix alignment of allocated exceptions in 32 bit builds

2016-10-09 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: mclow.lists, danalbert, jroelofs, compnerd.
EricWF added a subscriber: cfe-commits.

In 32 bit builds on a 64 bit system `std::malloc` does not return correctly 
aligned memory.  This leads to undefined behavior.

This patch switches to using `posix_memalign` to allocate correctly aligned 
memory instead.


https://reviews.llvm.org/D25417

Files:
  src/cxa_exception.cpp
  src/fallback_malloc.cpp
  test/test_exception_address_alignment.pass.cpp


Index: test/test_exception_address_alignment.pass.cpp
===
--- /dev/null
+++ test/test_exception_address_alignment.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Test that the address of the exception object is properly aligned to the
+// largest supported alignment for the system.
+
+#include 
+#include 
+
+struct __attribute__((aligned)) AlignedType {};
+struct MinAligned {  };
+static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
+
+int main() {
+  for (int i=0; i < 10; ++i) {
+try {
+  throw MinAligned{};
+} catch (MinAligned const& ref) {
+  assert(reinterpret_cast() % alignof(AlignedType) == 0);
+}
+  }
+}
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -196,11 +196,13 @@
 
 #pragma GCC visibility push(hidden)
 
+struct __attribute__((aligned)) __aligned_type  {};
+
 void * __malloc_with_fallback(size_t size) {
-void *ptr = std::malloc(size);
-if (NULL == ptr) // if malloc fails, fall back to emergency stash
-ptr = fallback_malloc(size);
-return ptr;
+void* dest;
+if (::posix_memalign(, alignof(__aligned_type), size) == 0)
+return dest;
+return fallback_malloc(size);
 }
 
 void * __calloc_with_fallback(size_t count, size_t size) {
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -65,12 +65,16 @@
 return cxa_exception_from_thrown_object(unwind_exception + 1 );
 }
 
-static
-inline
-size_t
-cxa_exception_size_from_exception_thrown_size(size_t size)
-{
-return size + sizeof (__cxa_exception);
+// Round s up to next multiple of a.
+static inline
+size_t aligned_allocation_size(size_t s, size_t a) {
+return (s + a - 1) & ~(a - 1);
+}
+
+static inline
+size_t cxa_exception_size_from_exception_thrown_size(size_t size) {
+return aligned_allocation_size(size + sizeof (__cxa_exception),
+   alignof(__cxa_exception));
 }
 
 static void setExceptionClass(_Unwind_Exception* unwind_exception) {


Index: test/test_exception_address_alignment.pass.cpp
===
--- /dev/null
+++ test/test_exception_address_alignment.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Test that the address of the exception object is properly aligned to the
+// largest supported alignment for the system.
+
+#include 
+#include 
+
+struct __attribute__((aligned)) AlignedType {};
+struct MinAligned {  };
+static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
+
+int main() {
+  for (int i=0; i < 10; ++i) {
+try {
+  throw MinAligned{};
+} catch (MinAligned const& ref) {
+  assert(reinterpret_cast() % alignof(AlignedType) == 0);
+}
+  }
+}
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -196,11 +196,13 @@
 
 #pragma GCC visibility push(hidden)
 
+struct __attribute__((aligned)) __aligned_type  {};
+
 void * __malloc_with_fallback(size_t size) {
-void *ptr = std::malloc(size);
-if (NULL == ptr) // if malloc fails, fall back to emergency stash
-ptr = fallback_malloc(size);
-return ptr;
+void* dest;
+if (::posix_memalign(, alignof(__aligned_type), size) == 0)
+return dest;
+return fallback_malloc(size);
 }
 
 void * __calloc_with_fallback(size_t count, size_t size) {
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -65,12 +65,16 

[libcxx] r283712 - Remove use of int128_t inside the filesystem implementation

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct  9 23:22:58 2016
New Revision: 283712

URL: http://llvm.org/viewvc/llvm-project?rev=283712=rev
Log:
Remove use of int128_t inside the filesystem implementation

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=283712=283711=283712=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Sun Oct  9 23:22:58 
2016
@@ -488,6 +488,8 @@ bool __fs_is_empty(const path& p, std::e
 
 namespace detail { namespace {
 
+using namespace std::chrono;
+
 template 
 bool checked_set(CType* out, ChronoType time) {
 using Lim = numeric_limits;
@@ -497,8 +499,120 @@ bool checked_set(CType* out, ChronoType
 return true;
 }
 
-constexpr long long min_seconds = file_time_type::duration::min().count()
-/ file_time_type::period::den;
+using TimeSpec = struct ::timespec;
+using StatT = struct ::stat;
+
+#if defined(__APPLE__)
+TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
+TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
+#else
+TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
+__attribute__((unused)) // Suppress warning
+TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
+#endif
+
+constexpr auto max_seconds = duration_cast(
+file_time_type::duration::max()).count();
+
+constexpr auto max_nsec = duration_cast(
+file_time_type::duration::max() - seconds(max_seconds)).count();
+
+constexpr auto min_seconds = duration_cast(
+file_time_type::duration::min()).count();
+
+constexpr auto min_nsec_timespec = duration_cast(
+(file_time_type::duration::min() - seconds(min_seconds)) + 
seconds(1)).count();
+
+// Static assert that these values properly round trip.
+static_assert((seconds(min_seconds) + 
duration_cast(nanoseconds(min_nsec_timespec)))
+  - duration_cast(seconds(1))
+  == file_time_type::duration::min(), "");
+
+constexpr auto max_time_t = numeric_limits::max();
+constexpr auto min_time_t = numeric_limits::min();
+
+#if !defined(__LP64__) && defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
+#endif
+
+constexpr bool is_representable(TimeSpec const& tm) {
+  if (tm.tv_sec >= 0) {
+return (tm.tv_sec < max_seconds) ||
+(tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
+  } else if (tm.tv_sec == (min_seconds - 1)) {
+ return tm.tv_nsec >= min_nsec_timespec;
+  } else {
+return (tm.tv_sec >= min_seconds);
+  }
+}
+
+#if defined(__LP64__)
+static_assert(is_representable({max_seconds, max_nsec}), "");
+static_assert(!is_representable({max_seconds + 1, 0}), "");
+static_assert(!is_representable({max_seconds, max_nsec + 1}), "");
+static_assert(!is_representable({max_time_t, 0}), "");
+static_assert(is_representable({min_seconds, 0}), "");
+static_assert(is_representable({min_seconds - 1, min_nsec_timespec}), "");
+static_assert(is_representable({min_seconds - 1, min_nsec_timespec + 1}), "");
+static_assert(!is_representable({min_seconds - 1, min_nsec_timespec - 1}), "");
+static_assert(!is_representable({min_time_t, 9}), "");
+#else
+static_assert(is_representable({max_time_t, 9}), "");
+static_assert(is_representable({max_time_t, 10}), "");
+static_assert(is_representable({min_time_t, 0}), "");
+#endif
+
+constexpr bool is_representable(file_time_type const& tm) {
+  auto secs = duration_cast(tm.time_since_epoch());
+  auto nsecs = duration_cast(tm.time_since_epoch() - secs);
+  if (nsecs.count() < 0) {
+secs = secs +  seconds(1);
+nsecs = nsecs + seconds(1);
+  }
+  using TLim = numeric_limits;
+  if (secs.count() >= 0)
+return secs.count() <= TLim::max();
+  return secs.count() >= TLim::min();
+}
+#if defined(__LP64__)
+static_assert(is_representable(file_time_type::max()), "");
+static_assert(is_representable(file_time_type::min()), "");
+#else
+static_assert(!is_representable(file_time_type::max()), "");
+static_assert(!is_representable(file_time_type::min()), "");
+static_assert(is_representable(file_time_type(seconds(max_time_t))), "");
+static_assert(is_representable(file_time_type(seconds(min_time_t))), "");
+#endif
+
+template  struct Dummy;
+constexpr file_time_type convert_timespec(TimeSpec const& tm) {
+  auto adj_msec = duration_cast(nanoseconds(tm.tv_nsec));
+  if (tm.tv_sec >= 0) {
+auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
+return file_time_type(Dur);
+  } else if (duration_cast(nanoseconds(tm.tv_nsec)).count() == 
0) {
+return file_time_type(seconds(tm.tv_sec));
+  } else { // tm.tv_sec < 0
+auto adj_subsec = duration_cast(seconds(1) - 

[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-09 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

How does this play with existing binaries?  Applications that expect these 
functions to exist in the dylib?


Repository:
  rL LLVM

https://reviews.llvm.org/D24991



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


[libcxx] r283701 - Remove debug output from gen_linker_script.py

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct  9 16:43:30 2016
New Revision: 283701

URL: http://llvm.org/viewvc/llvm-project?rev=283701=rev
Log:
Remove debug output from gen_linker_script.py

Modified:
libcxx/trunk/utils/gen_link_script/gen_link_script.py

Modified: libcxx/trunk/utils/gen_link_script/gen_link_script.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/gen_link_script/gen_link_script.py?rev=283701=283700=283701=diff
==
--- libcxx/trunk/utils/gen_link_script/gen_link_script.py (original)
+++ libcxx/trunk/utils/gen_link_script/gen_link_script.py Sun Oct  9 16:43:30 
2016
@@ -52,9 +52,7 @@ def parse_args():
 if len(args) < 2:
 usage_and_exit()
 symlink_file = args[0]
-del args[0]
-public_libs = list(args)
-print('%r' % public_libs)
+public_libs = args[1:]
 return dryrun, symlink_file, public_libs
 
 def main():


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


Re: [libcxx] r283659 - [cmake] Split linked libraries into private & public, for linker script

2016-10-09 Thread Eric Fiselier via cfe-commits
Hi Renato, Hal,

I've hopefully fixed this in r283700. I'll be watching the bots to ensure
everything works.

Sorry about the breakage.

/Eric

On Sun, Oct 9, 2016 at 6:05 AM, Renato Golin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 9 October 2016 at 03:59, Hal Finkel via cfe-commits
>  wrote:
> >> and now it doesn't because you no longer use SCRIPT_ABI_LIBNAME as
> >> the argument to gen_link_script.py. Let me see if I can fix this...
> >
> > r283684
>
> Hi Hal,
>
> Thanks for looking into this, but, we're not there yet. :)
>
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-
> libunwind-arm-linux/builds/206
>
> cheers,
> --renato
> ___
> 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


[libcxx] r283700 - Fix linker script generation for in-tree builds

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct  9 16:34:03 2016
New Revision: 283700

URL: http://llvm.org/viewvc/llvm-project?rev=283700=rev
Log:
Fix linker script generation for in-tree builds

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/utils/gen_link_script/gen_link_script.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=283700=283699=283700=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Sun Oct  9 16:34:03 2016
@@ -270,13 +270,13 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB
 # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
 # LIBCXX_COMPILE_FLAGS: Compile only flags.
 # LIBCXX_LINK_FLAGS: Linker only flags.
-# LIBCXX_LIBRARIES: Private libraries libc++ is linked to.
-# LIBCXX_LIBRARIES_PUBLIC: Public libraries libc++ is linked to,
-#  also exposed in the linker script.
+# LIBCXX_LIBRARIES: libraries libc++ is linked to.
+# LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++
+# There libraries are exposed in the linker script.
 set(LIBCXX_COMPILE_FLAGS "")
 set(LIBCXX_LINK_FLAGS "")
 set(LIBCXX_LIBRARIES "")
-set(LIBCXX_LIBRARIES_PUBLIC "")
+set(LIBCXX_INTERFACE_LIBRARIES "")
 
 # Include macros for adding and removing libc++ flags.
 include(HandleLibcxxFlags)

Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake?rev=283700=283699=283700=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Sun Oct  9 16:34:03 2016
@@ -188,6 +188,14 @@ macro(add_library_flags_if condition)
   endif()
 endmacro()
 
+# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
+macro(add_interface_library)
+  foreach(lib ${ARGN})
+list(APPEND LIBCXX_LIBRARIES ${lib})
+list(APPEND LIBCXX_INTERFACE_LIBRARIES ${lib})
+  endforeach()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=283700=283699=283700=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Sun Oct  9 16:34:03 2016
@@ -33,16 +33,19 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
+if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+  set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
+endif()
+
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
   add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
   add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
   add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
-elseif (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
-   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
-  # Apple re-exports libc++abi in libc++, so don't make it public
+elseif (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
   add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
-else()
-  list(APPEND LIBCXX_LIBRARIES_PUBLIC "${LIBCXX_CXX_ABI_LIBRARY}")
+else ()
+ add_interface_library("${LIBCXX_CXX_ABI_LIBRARY}")
 endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
@@ -85,7 +88,13 @@ add_library_flags_if(LIBCXX_HAVE_CXX_ATO
 
 # Add the unwinder library.
 if (LIBCXXABI_USE_LLVM_UNWINDER)
-  list(APPEND LIBCXX_LIBRARIES_PUBLIC unwind)
+  if (TARGET unwind_shared)
+add_interface_library(unwind_shared)
+  elseif (TARGET unwind_static)
+add_interface_library(unwind_static)
+  else()
+add_interface_library(unwind)
+  endif()
 endif()
 
 # Setup flags.
@@ -94,8 +103,7 @@ if (NOT WIN32)
 endif()
 add_link_flags_if_supported(-nodefaultlibs)
 
-if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
-LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
   if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
 set(LIBCXX_LIBCPPABI_VERSION "2") # Default value
 execute_process(
@@ -164,9 +172,7 @@ set(LIBCXX_TARGETS)
 # Build the shared library.
 if (LIBCXX_ENABLE_SHARED)
   add_library(cxx_shared SHARED $)
-  target_link_libraries(cxx_shared
-PRIVATE ${LIBCXX_LIBRARIES}
-PUBLIC ${LIBCXX_LIBRARIES_PUBLIC})
+  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
   set_target_properties(cxx_shared
 PROPERTIES
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
@@ -180,9 

patch: clean up in EmitValueForIvarAtOffset

2016-10-09 Thread Nick Lewycky via cfe-commits
The attached patch makes the LValue created in EmitValueForIvarAtOffset
have the same Qualifiers in the LValue as the QualType in the LValue.
Noticed when auditing for reasons the QualType would different from the
Qualifiers in an LValue. No functionality change.

Please review!

Nick


lvalue-qualifiers-1.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r283699 - [libc++abi] Fix bug which cased the static libunwind to always be chosen

2016-10-09 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sun Oct  9 15:44:48 2016
New Revision: 283699

URL: http://llvm.org/viewvc/llvm-project?rev=283699=rev
Log:
[libc++abi] Fix bug which cased the static libunwind to always be chosen

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=283699=283698=283699=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Sun Oct  9 15:44:48 2016
@@ -54,14 +54,14 @@ if (LIBCXXABI_ENABLE_THREADS)
 endif()
 
 append_if(libraries LIBCXXABI_HAS_C_LIB c)
-
 if (LIBCXXABI_USE_LLVM_UNWINDER)
-  if (NOT LIBCXXABI_STANDALONE_BUILD)
-if (LIBUNWIND_ENABLE_SHARED)
-  list(APPEND libraries unwind_shared)
-else()
-  list(APPEND libraries unwind_static)
-endif()
+  # Prefer using the in-tree version of libunwind, either shared or static. If
+  # none are found fall back to using -lunwind.
+  # FIXME: Is it correct to prefer the static version of libunwind?
+  if (TARGET unwind_shared)
+list(APPEND libraries unwind_shared)
+  elseif(TARGET unwind_static)
+list(APPEND libraries unwind_static)
   else()
 list(APPEND libraries unwind)
   endif()


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


[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-09 Thread Steve O'Brien via cfe-commits
elsteveogrande added a comment.

ping :)  Wanted to get sign off on this (simplified) diff if possible.

Thanks!  Sorry to nag.  (This would be one part of the solution for really long 
build times for us.)


https://reviews.llvm.org/D25153



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


[PATCH] D25405: [Sema] Use unique_ptr instead of raw pointers in the late-parsed templates map.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: timshen.
jlebar added a subscriber: cfe-commits.
jlebar added a dependency: D25404: [ADT] Let MapVector handle non-copyable 
values..

This is possible now that MapVector supports move-only values.

Depends on https://reviews.llvm.org/D25404.


https://reviews.llvm.org/D25405

Files:
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4001,14 +4001,14 @@
 return;
 
   RecordData Record;
-  for (auto LPTMapEntry : LPTMap) {
+  for (auto  : LPTMap) {
 const FunctionDecl *FD = LPTMapEntry.first;
-LateParsedTemplate *LPT = LPTMapEntry.second;
+LateParsedTemplate  = *LPTMapEntry.second;
 AddDeclRef(FD, Record);
-AddDeclRef(LPT->D, Record);
-Record.push_back(LPT->Toks.size());
+AddDeclRef(LPT.D, Record);
+Record.push_back(LPT.Toks.size());
 
-for (const auto  : LPT->Toks) {
+for (const auto  : LPT.Toks) {
   AddToken(Tok, Record);
 }
   }
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -7547,12 +7547,13 @@
 }
 
 void ASTReader::ReadLateParsedTemplates(
-llvm::MapVector ) {
+llvm::MapVector>
+) {
   for (unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
/* In loop */) {
 FunctionDecl *FD = cast(GetDecl(LateParsedTemplates[Idx++]));
 
-LateParsedTemplate *LT = new LateParsedTemplate;
+auto LT = llvm::make_unique();
 LT->D = GetDecl(LateParsedTemplates[Idx++]);
 
 ModuleFile *F = getOwningModuleFile(LT->D);
@@ -7563,7 +7564,7 @@
 for (unsigned T = 0; T < TokN; ++T)
   LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
 
-LPTMap.insert(std::make_pair(FD, LT));
+LPTMap.insert(std::make_pair(FD, std::move(LT)));
   }
 
   LateParsedTemplates.clear();
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3622,9 +3622,10 @@
 if (PatternDecl->isFromASTFile())
   ExternalSource->ReadLateParsedTemplates(LateParsedTemplateMap);
 
-LateParsedTemplate *LPT = LateParsedTemplateMap.lookup(PatternDecl);
-assert(LPT && "missing LateParsedTemplate");
-LateTemplateParser(OpaqueParser, *LPT);
+auto LPTIter = LateParsedTemplateMap.find(PatternDecl);
+assert(LPTIter != LateParsedTemplateMap.end() &&
+   "missing LateParsedTemplate");
+LateTemplateParser(OpaqueParser, *LPTIter->second);
 Pattern = PatternDecl->getBody(PatternDecl);
   }
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8668,12 +8668,12 @@
   if (!FD)
 return;
 
-  LateParsedTemplate *LPT = new LateParsedTemplate;
+  auto LPT = llvm::make_unique();
 
   // Take tokens to avoid allocations
   LPT->Toks.swap(Toks);
   LPT->D = FnD;
-  LateParsedTemplateMap.insert(std::make_pair(FD, LPT));
+  LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
 
   FD->setLateTemplateParsed(true);
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -259,7 +259,6 @@
 }
 
 Sema::~Sema() {
-  llvm::DeleteContainerSeconds(LateParsedTemplateMap);
   if (VisContext) FreeVisContext();
   // Kill all the active scopes.
   for (unsigned I = 1, E = FunctionScopes.size(); I != E; ++I)
Index: clang/lib/Sema/MultiplexExternalSemaSource.cpp
===
--- clang/lib/Sema/MultiplexExternalSemaSource.cpp
+++ clang/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -285,7 +285,8 @@
 }
 
 void MultiplexExternalSemaSource::ReadLateParsedTemplates(
-llvm::MapVector ) {
+llvm::MapVector>
+) {
   for (size_t i = 0; i < Sources.size(); ++i)
 Sources[i]->ReadLateParsedTemplates(LPTMap);
 }
Index: clang/include/clang/Serialization/ASTReader.h
===
--- clang/include/clang/Serialization/ASTReader.h
+++ clang/include/clang/Serialization/ASTReader.h
@@ -1873,8 +1873,8 @@

[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Although these pass the CUDA test-suite tests (which I haven't yet committed 
because they're broken without this change), I could use some help running the 
libcxx tests.

I cannot find any documentation explaining how to run the libcxx tests with 
just-built clang.  Presumably this is supported and I just cannot figure it 
out.  Anyway I figured I'd try to make a new objdir and point it to my 
just-built clang.

  $ mkdir objdir-libcxx
  $ cd objdir-libcxx
  $ cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_C_COMPILER=$HOME/llvm/release/bin/clang 
-DCMAKE_CXX_COMPILER=$HOME/llvm/release/bin/clang -DLLVM_ENABLE_ASSERTIONS=On 
../llvm

This also doesn't work.  Building one of cmake's atomic tests fails with linker 
errors.

  Run Build Command:"/usr/local/google/home/jlebar/bin/ninja" "cmTC_0c40a"
  [1/2] Building CXX object CMakeFiles/cmTC_0c40a.dir/src.cxx.o
  [2/2] Linking CXX executable cmTC_0c40a
  FAILED: cmTC_0c40a
  : && /usr/local/google/home/jlebar/llvm/release/bin/clang   
-DHAVE_CXX_ATOMICS_WITH_LIB -std=c++11   CMakeFiles/cmTC_0c40a.dir/src.cxx.o  
-o cmTC_0c40a  -lm -latomic && :
  CMakeFiles/cmTC_0c40a.dir/src.cxx.o:src.cxx:function __clang_call_terminate: 
error: undefined reference to '__cxa_begin_catch'
  CMakeFiles/cmTC_0c40a.dir/src.cxx.o:src.cxx:function __clang_call_terminate: 
error: undefined reference to 'std::terminate()'
  CMakeFiles/cmTC_0c40a.dir/src.cxx.o(.eh_frame+0x143): error: undefined 
reference to '__gxx_personality_v0'
  clang-4.0: error: linker command failed with exit code 1 (use -v to see 
invocation)
  ninja: build stopped: subcommand failed.
  
  Source file was:
  
  #include 
  std::atomic x;
  int main() {
return x;
  }

I presume there is some Right Way to do this, and I'm just not doing it.


https://reviews.llvm.org/D25403



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


Re: r283680 - [CUDA] Support and std::min/max on the device.

2016-10-09 Thread Justin Lebar via cfe-commits
https://reviews.llvm.org/D25403 for adding constexpr to the new libc++
functions.

On Sat, Oct 8, 2016 at 8:56 PM, Justin Lebar  wrote:
>> > The fix is not as simple as simply changing our implementation of
>> e.g.
>> std::isnan to call __builtin_isnanf, because we also would want to
>> fix
>> ::isnanf,
>>
>> No, if I understand what you're saying, you specifically wouldn't.
>
> I understand how this is feasible on the CPU, because ::isnan is a
> library function that can never be inlined.  But on the GPU, these
> library functions are (at the moment) always declared inline.  That
> seems to complicate this idea.
>
> Right now ::isnan(x) is going to call __nv_isnan(x), which computes
> abs(x).  If we pass -ffast-math, the compiler will be able to assume
> that abs(x) is not nan.  I guess you're saying that we would need to
> special-case __nv_isnan so that -ffast-math is always off
> (essentially).  But, what if it gets inlined?
>
> It looks like libstdc++'s std::isnan calls __builtin_isnan (same for
> its std::isinf), and its ::isnan is an alias for std::isnan.  So
> libstdc++'s isnan is going to return false with -ffast-math (or anyway
> it will do the same thing as the builtin functions, which aiui is what
> you're proposing libc++'s isnan *not* do).
>
>> This is important for use cases where, for example, even though the user 
>> might want fast math, they still need to check their inputs for NaNs.
>
> Since this isn't going to work with libstdc++, and it relies on not
> doing anything that the compiler might construe as "arithmetic" on the
> value, this seems pretty dicey to me.  One could instead compile a
> separate TU without -ffast-math and do all their validation there?
> I'd have a lot more confidence in that working today, continuing to
> work tomorrow, and being portable across compilers and standard
> libraries.
>
> I don't mean to relitigate https://reviews.llvm.org/D18639, but I am
> not convinced that libc++'s isnan should have a path that returns true
> with -ffast-math, given that
>
>  * libstdc++'s isnan will always return false with -ffast-math,
>  * it's at best complicated for us to make this work if you can inline
> the body of isnan (as we can on the GPU),
>  * it's at best complicated for users to write "correct" C++ that
> calls isnan with -ffast-math, especially if they want their code to
> continue to work in the future in the face of changing compilers
> (-ffast-math is not specified anywhere, so who knows what it means),
> and
>  * there's a relatively simple workaround (use a separate TU) that
> sidesteps all these problems.
>
> I'm not saying we should go in and change libc++'s CPU implementation
> of isnan to call the builtin.  I'll leave that up to people who care
> about CPU code.  But at least on the GPU, it still makes sense to me
> to fix the problem you originally identified by making
> std::/::isnan/isinf always return false/true with -ffast-math.  Which
> I think we should be able to do with the intrinsic upgrade I
> originally suggested.
>
> On a separate note: Can we make __libcpp_isnan and __libcpp_isinf
> constexpr?  This will make them implicitly host+device functions,
> solving the problem on the GPU.  Otherwise I may have to reimplement
> these functions in a header, and that's lame.  Although I am clearly
> not above that.  :)
>
> On Sat, Oct 8, 2016 at 6:50 PM, Hal Finkel  wrote:
>> - Original Message -
>>> From: "Justin Lebar" 
>>> To: "Hal Finkel" 
>>> Cc: "Clang Commits" 
>>> Sent: Saturday, October 8, 2016 6:16:12 PM
>>> Subject: Re: r283680 - [CUDA] Support  and std::min/max on the 
>>> device.
>>>
>>> Hal,
>>>
>>> On NVPTX, these functions eventually get resolved to function calls
>>> in
>>> libdevice, e.g. __nv_isinff and __nv_isnanf.
>>>
>>> llvm does not do a good job understanding the body of e.g.
>>> __nvvm_isnanf, because it uses nvptx-specific intrinsic functions,
>>> notably @llvm.nvvm.fabs.f.  These are opaque to the LLVM optimizer.
>>>
>>> The fix is not as simple as simply changing our implementation of
>>> e.g.
>>> std::isnan to call __builtin_isnanf, because we also would want to
>>> fix
>>> ::isnanf,
>>
>> No, if I understand what you're saying, you specifically wouldn't. We had a 
>> discussion about this on the review thread(s) that led to r283051, and while 
>> we want to elide the checks inside the mathematical functions, we don't want 
>> to replace isnan itself with something that will get optimized away. We want 
>> to keep the ability for the user to explicitly check for NaNs, etc. even if 
>> we don't want those checks to appear inside of mathematical operations. This 
>> is important for use cases where, for example, even though the user might 
>> want fast math, they still need to check their inputs for NaNs.
>>
>>  -Hal
>>
>>> but we can't override that implementation without some
>>> major
>>> surgery on the nvptx 

[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-09 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: hfinkel.
jlebar added a subscriber: cfe-commits.

This makes these functions available on host and device, which is
necessary to compile  for the device.


https://reviews.llvm.org/D25403

Files:
  libcxx/include/cmath


Index: libcxx/include/cmath
===
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -560,7 +560,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isnan)
@@ -572,15 +572,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 return isnan(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isinf)
@@ -592,15 +592,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 return isinf(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isfinite)
@@ -612,7 +612,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 return isfinite(__lcpp_x);


Index: libcxx/include/cmath
===
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -560,7 +560,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isnan)
@@ -572,15 +572,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 return isnan(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isinf)
@@ -592,15 +592,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 return isinf(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isfinite)
@@ -612,7 +612,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 return isfinite(__lcpp_x);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25004: [x86][inline-asm][clang] accept 'v' constraint

2016-10-09 Thread coby via cfe-commits
coby removed rL LLVM as the repository for this revision.
coby updated this revision to Diff 74060.

https://reviews.llvm.org/D25004

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86-inline-asm-v-constraint.c


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes 
AVX512,AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", 
"=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+}
+
+// AVX512: call <16 x float> asm "vpternlogd $$0, $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"(<16 x float> %0, <16 x float> %1)
+__m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
+#ifdef AVX512
+  __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
+#endif
+  return _zmm0;
+}


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", "=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+}
+
+// AVX512: call 

[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

2016-10-09 Thread Ziv Izhar via cfe-commits
zizhar updated this revision to Diff 74068.
zizhar added a comment.

I hope this last update finishes it,
Thanks for the review :)


https://reviews.llvm.org/D15075

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/Headers/intrin.h
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -28,6 +28,16 @@
   asm ("nop" : : : "204"); // expected-error {{unknown register name '204' in asm}}
   asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
   asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+  register void *clobber_conflict asm ("%rcx");
+  register void *no_clobber_conflict asm ("%rax");
+  int a,b,c;
+  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=c" (a) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (no_clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=r" (clobber_conflict) : "c" (c) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
+  asm ("nop" : "=a" (a) : "b" (b) : "%rcx", "%rbx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}} 
 }
 
 // rdar://6094010
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -22,6 +22,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/MC/MCParser/MCAsmParser.h"
 using namespace clang;
 using namespace sema;
@@ -137,6 +138,57 @@
   return false;
 }
 
+// Extracting the register name from the Expression value,
+// if there is no register name to extract, returns ""
+StringRef ExtractRegisterName(const Expr *Expression,
+  const TargetInfo ) {
+  Expression = Expression->IgnoreImpCasts();
+  if (const DeclRefExpr *AsmDeclRef = dyn_cast(Expression)) {
+// Handle cases where the expression is a variable
+const VarDecl *Variable = dyn_cast(AsmDeclRef->getDecl());
+if (Variable && Variable->getStorageClass() == SC_Register) {
+  if (AsmLabelAttr *Attr = Variable->getAttr())
+if (Target.isValidGCCRegisterName(Attr->getLabel()))
+  return Target.getNormalizedGCCRegisterName(Attr->getLabel());
+}
+  }
+  return "";
+}
+
+// Checks if there is a conflict between the input and output lists with the
+// clobbers list. If there's a conflict, returns the location of the
+// conflicted clobber, else returns nullptr
+SourceLocation
+GetClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints,
+   StringLiteral **Clobbers, int NumClobbers,
+   const TargetInfo , ASTContext ) {
+  llvm::StringSet<> InOutVars;
+  // Collect all the input and output registers from the extended asm
+  // statement
+  // in order to check for conflicts with the clobber list
+  for (int i = 0; i < Exprs.size(); ++i) {
+StringRef Constraint = Constraints[i]->getString();
+StringRef InOutReg = Target.getConstraintRegister(
+Constraint, ExtractRegisterName(Exprs[i], Target));
+if (InOutReg != "")
+  InOutVars.insert(InOutReg);
+  }
+  // Check for each item in the clobber list if it conflicts with the input
+  // or output
+  for (int i = 0; i < NumClobbers; ++i) {
+StringRef Clobber = Clobbers[i]->getString();
+// We only check registers, therefore we don't check cc and memory
+// clobbers
+if (Clobber == "cc" || Clobber == "memory")
+  continue;
+Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
+// Go over the output's registers we collected
+if (InOutVars.count(Clobber))
+  return Clobbers[i]->getLocStart();
+  }
+  return SourceLocation();
+}
+
 StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
  bool IsVolatile, unsigned NumOutputs,
  unsigned NumInputs, IdentifierInfo **Names,
@@ -543,6 +595,13 @@
 return StmtError();
   }
 
+  // Check 

[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-09 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

BTW I think changing the commit name by removing bug ID would be good, because 
it would be more clear that this is a feature commit, not a bug fix. 
You can move t he bug id, or the link to bug to the summary section.


https://reviews.llvm.org/D25316



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-09 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.



Comment at: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp:25
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with 
a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  ll = static_cast(l);
+  unsigned long long ull = static_cast(l);

malcolm.parsons wrote:
> Prazek wrote:
> > malcolm.parsons wrote:
> > > Prazek wrote:
> > > > Is it possible to simply fix the double spaces?
> > > The existing modernize-use-auto tests have the same problem.
> > > My codebase is clang-formatted regularly so it doesn't bother me.
> > I agree that it is not huge problem with clang-format and of course it is 
> > not required to fix it to push this patch upstream. It would be good to 
> > leave a comment somewhere with FIXME: about this, so it would be easier for 
> > some other contributor to fix it (or if it simple, just fix it in this 
> > patch :))
> There's a FIXME comment in one of the existing modernize-use-auto test files.
Yes, but I am talking about FIXME comment in check code. IF someone reads the 
code, it is much more clear for them that this thing doesn't work completely, 
than if the programmer would see the error and would have to look at tests or 
execute clang-tidy to make sure that he understand code well.


https://reviews.llvm.org/D25316



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-09 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D25316#565574, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D25316#565567, @Prazek wrote:
>
> >   functionDecl(hasName(LEXICAL_CAST_NAME),
>
>
> I was trying to avoid specifying the name of the function so that it works 
> for any templated function/member function that returns its first template 
> type.


Good idea. I am not sure how it will work when you will run it on big codebase, 
so I wanted to make it configurable for any function name. But if it will work 
for 99% of useful cases, then it will be great!


https://reviews.llvm.org/D25316



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


[PATCH] D25316: [clang-tidy] Fix PR25499: Enhance modernize-use-auto to casts

2016-10-09 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D25316#565567, @Prazek wrote:

>   functionDecl(hasName(LEXICAL_CAST_NAME),


I was trying to avoid specifying the name of the function so that it works for 
any templated function/member function that returns its first template type.




Comment at: test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp:25
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with 
a cast to avoid duplicating the type name
+  // CHECK-FIXES: auto  ll = static_cast(l);
+  unsigned long long ull = static_cast(l);

Prazek wrote:
> malcolm.parsons wrote:
> > Prazek wrote:
> > > Is it possible to simply fix the double spaces?
> > The existing modernize-use-auto tests have the same problem.
> > My codebase is clang-formatted regularly so it doesn't bother me.
> I agree that it is not huge problem with clang-format and of course it is not 
> required to fix it to push this patch upstream. It would be good to leave a 
> comment somewhere with FIXME: about this, so it would be easier for some 
> other contributor to fix it (or if it simple, just fix it in this patch :))
There's a FIXME comment in one of the existing modernize-use-auto test files.


https://reviews.llvm.org/D25316



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-09 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

I don't agree with the motivation for this change, BTW. Whether -lunwind is 
needed or not is an implementation detail of the way the ABI implementation is 
linked. That's why libc++ is now a linker script, to hide this kinds of 
implementation details.


https://reviews.llvm.org/D25402



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-09 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

No, they are not desirable, in fact, they pretty much break clang. That's why I 
wanted to see the test diff...


https://reviews.llvm.org/D25402



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


[PATCH] D24933: Enable configuration files in clang

2016-10-09 Thread Michał Górny via cfe-commits
mgorny resigned from this revision.
mgorny removed a reviewer: mgorny.
mgorny added a comment.

I have no further comments. However, I'm quite a fresh contributor, so I'm not 
really in a position to accept it.


https://reviews.llvm.org/D24933



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-09 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74063.
mgorny added a comment.

I'm sorry, I mixed branches up. Here's the correct patch with both updates.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/montavista-gcc-toolchain.c
  test/Driver/print-libgcc-file-name-clangrt.c
  test/Driver/print-libgcc-file-name-libgcc.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -375,6 +375,11 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('utf8-capable-terminal')
 
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+config.available_features.add('libgcc')
+
 # Native compilation: Check if triples match.
 # FIXME: Consider cases that target can be executed
 # even if host_triple were different from target_triple.
Index: test/Driver/print-libgcc-file-name-libgcc.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
Index: test/Driver/print-libgcc-file-name-clangrt.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-clangrt.c
@@ -0,0 +1,11 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-montavista-linux \
 // RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
 // RUN:   | FileCheck %s
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-09 Thread Michał Górny via cfe-commits
mgorny added a reviewer: ggreif.
mgorny updated this revision to Diff 74062.
mgorny added a comment.

Including a fix for montavista toolchain checks that miss passing -rtlib= and 
therefore could fail depending on DEFAULT_* value.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/montavista-gcc-toolchain.c
  test/Driver/print-libgcc-file-name.c


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-montavista-linux \
 // RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
 // RUN:   | FileCheck %s
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: 

[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.

2016-10-09 Thread Elad Cohen via cfe-commits
eladcohen added a comment.

Hi Bruno,

The short answer is yes. Essentially it can be done, but we would actually like 
for all the users to always get this behavior, implicitly.

The long answer is that there is a history of problems regarding the intrinsic 
files:
http://lists.llvm.org/pipermail/cfe-dev/2016-May/048837.html
http://lists.llvm.org/pipermail/cfe-dev/2016-September/050943.html
Mainly compatibility issues because MSVC makes all the intrinsics available all 
the time, while in clang this is not always the case (On Windows the different 
h files are not-included unless asked for explicitly since AVX512 was added 
which impacted compile-time).
A suggestion was made to try and mitigate this by reducing the compile time 
using modules (only for the x86 intrinsics). This patch aims at adding this 
option. The new compile flag is just a milestone - if all goes well, we can 
turn this on by default (Then we won't actually need to use a specific compile 
flag, and we could always include all the intrinsic h files without their long 
compile time).


https://reviews.llvm.org/D25337



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