[PATCH] D33639: [OpenCL] Use SPIR_CC by default for kernels

2017-06-01 Thread Pekka Jääskeläinen via Phabricator via cfe-commits
pekka.jaaskelainen closed this revision.
pekka.jaaskelainen marked 4 inline comments as done.
pekka.jaaskelainen added a comment.

Committed in r304389.




Comment at: lib/CodeGen/TargetInfo.cpp:400
 
 unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv() const {
+  // OpenCL kernels are called via an explicit runtime API with arguments

Anastasia wrote:
> The lines above are missing... is this for default target?
Yes.


https://reviews.llvm.org/D33639



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


r304391 - Adapt tests after making mcpu=generic the default for armv7-a and armv8-a.

2017-06-01 Thread Kristof Beyls via cfe-commits
Author: kbeyls
Date: Thu Jun  1 02:31:50 2017
New Revision: 304391

URL: http://llvm.org/viewvc/llvm-project?rev=304391&view=rev
Log:
Adapt tests after making mcpu=generic the default for armv7-a and armv8-a.

Modified:
cfe/trunk/test/Driver/arm-cortex-cpus.c
cfe/trunk/test/Driver/gold-lto.c
cfe/trunk/test/Driver/nacl-direct.c

Modified: cfe/trunk/test/Driver/arm-cortex-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-cortex-cpus.c?rev=304391&r1=304390&r2=304391&view=diff
==
--- cfe/trunk/test/Driver/arm-cortex-cpus.c (original)
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c Thu Jun  1 02:31:50 2017
@@ -120,11 +120,11 @@
 
 // RUN: %clang -target armv7a-linux-gnueabi -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V7A %s
 // RUN: %clang -target arm-linux-gnueabi -march=armv7-a -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V7A %s
-// CHECK-V7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}} "-target-cpu" "cortex-a8"
+// CHECK-V7A: "-cc1"{{.*}} "-triple" "armv7-{{.*}} "-target-cpu" "generic"
 
 // RUN: %clang -target armv7a-linux-gnueabi -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V7A-THUMB %s
 // RUN: %clang -target arm-linux-gnueabi -march=armv7-a -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-V7A-THUMB %s
-// CHECK-V7A-THUMB: "-cc1"{{.*}} "-triple" "thumbv7-{{.*}} "-target-cpu" 
"cortex-a8"
+// CHECK-V7A-THUMB: "-cc1"{{.*}} "-triple" "thumbv7-{{.*}} "-target-cpu" 
"generic"
 
 // RUN: %clang -target armv7r-linux-gnueabi -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V7R %s
 // RUN: %clang -target arm-linux-gnueabi -march=armv7-r -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V7R %s
@@ -144,7 +144,7 @@
 // RUN: %clang -target armv8a -mlittle-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8A %s
 // RUN: %clang -target arm -march=armv8a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V8A %s
 // RUN: %clang -target arm -mlittle-endian -march=armv8-a -mlittle-endian -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-V8A %s
-// CHECK-V8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}" "-target-cpu" "cortex-a53"
+// CHECK-V8A: "-cc1"{{.*}} "-triple" "armv8-{{.*}}" "-target-cpu" "generic"
 
 // RUN: %clang -target armv8r-linux-gnueabi -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8R %s
 // RUN: %clang -target arm -march=armv8r -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8R %s
@@ -189,7 +189,7 @@
 // RUN: %clang -target armv8a -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V8A %s
 // RUN: %clang -target arm -march=armebv8a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V8A %s
 // RUN: %clang -target arm -march=armebv8-a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V8A %s
-// CHECK-BE-V8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}" "-target-cpu" 
"cortex-a53"
+// CHECK-BE-V8A: "-cc1"{{.*}} "-triple" "armebv8-{{.*}}" "-target-cpu" 
"generic"
 
 // RUN: %clang -target armv8 -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8A-THUMB %s
 // RUN: %clang -target arm -march=armv8 -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V8A-THUMB %s
@@ -199,7 +199,7 @@
 // RUN: %clang -target arm -march=armv8 -mlittle-endian -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-V8A-THUMB %s
 // RUN: %clang -target armv8a -mlittle-endian -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V8A-THUMB %s
 // RUN: %clang -target arm -march=armv8a -mlittle-endian -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-V8A-THUMB %s
-// CHECK-V8A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8-{{.*}}" "-target-cpu" 
"cortex-a53"
+// CHECK-V8A-THUMB: "-cc1"{{.*}} "-triple" "thumbv8-{{.*}}" "-target-cpu" 
"generic"
 
 // RUN: %clang -target armebv8 -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V8A-THUMB %s
 // RUN: %clang -target armeb -march=armebv8 -mthumb -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V8A-THUMB %s
@@ -209,7 +209,7 @@
 // RUN: %clang -target arm -march=armebv8 -mbig-endian -mthumb -### -c %s 2>&1 
| FileCheck -check-prefix=CHECK-BE-V8A-THUMB %s
 // RUN: %clang -target armv8a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V8A-THUMB %s
 // RUN: %clang -target arm -march=armebv8a -mbig-endian -mthumb -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-BE-V8A-THUMB %s
-// CHECK-BE-V8A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8-{{.*}}" "-target-cpu" 
"cortex-a53"
+// CHECK-BE-V8A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8-{{.*}}" "-target-cpu" 
"generic"
 
 // RUN: %clang -target arm -march=armv8.1a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V81A %s
 // RUN: %clang -target armv8.1a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V81A %s

Modified: cfe/trunk/test/Driver/gold-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gold-lto.c?rev=304391&r1=304390&r2=304391&view=diff
===

r304389 - [OpenCL] Makes kernels use the SPIR_KERNEL CC by default.

2017-06-01 Thread Pekka Jaaskelainen via cfe-commits
Author: pjaaskel
Date: Thu Jun  1 02:18:49 2017
New Revision: 304389

URL: http://llvm.org/viewvc/llvm-project?rev=304389&view=rev
Log:
[OpenCL] Makes kernels use the SPIR_KERNEL CC by default.

Rationale: OpenCL kernels are called via an explicit runtime API
with arguments set with clSetKernelArg(), not as normal sub-functions.
Return SPIR_KERNEL by default as the kernel calling convention to ensure
the fingerprint is fixed such way that each OpenCL argument gets one
matching argument in the produced kernel function argument list to enable
feasible implementation of clSetKernelArg() with aggregates etc. In case
we would use the default C calling conv here, clSetKernelArg() might
break depending on the target-specific conventions; different targets
might split structs passed as values to multiple function arguments etc.

https://reviews.llvm.org/D33639


Added:
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304389&r1=304388&r2=304389&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun  1 02:18:49 2017
@@ -3123,6 +3123,7 @@ public:
 case CC_Swift:
 case CC_X86Pascal:
 case CC_IntelOclBicc:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -4834,6 +4835,7 @@ public:
 case CC_PreserveMost:
 case CC_PreserveAll:
 case CC_X86RegCall:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -4907,6 +4909,7 @@ public:
 case CC_X86_64SysV:
 case CC_Swift:
 case CC_X86RegCall:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -5860,6 +5863,7 @@ public:
 case CC_AAPCS:
 case CC_AAPCS_VFP:
 case CC_Swift:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -6019,6 +6023,7 @@ public:
 case CC_X86VectorCall:
   return CCCR_Ignore;
 case CC_C:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -6329,6 +6334,7 @@ public:
 case CC_Swift:
 case CC_PreserveMost:
 case CC_PreserveAll:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -7380,6 +7386,7 @@ public:
 switch (CC) {
 case CC_C:
 case CC_Swift:
+case CC_OpenCLKernel:
   return CCCR_OK;
 default:
   return CCCR_Warning;
@@ -7663,6 +7670,15 @@ public:
   ArrayRef getGCCRegAliases() const override {
 return None;
   }
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+  default:
+return CCCR_Warning;
+  case CC_C:
+  case CC_OpenCLKernel:
+return CCCR_OK;
+}
+  }
 };
 
 class MipsTargetInfo : public TargetInfo {

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=304389&r1=304388&r2=304389&view=diff
==
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Jun  1 02:18:49 2017
@@ -149,7 +149,6 @@ namespace swiftcall {
   return info->supportsSwift();
 }
   };
-
 }  // end namespace CodeGen
 }  // end namespace clang
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=304389&r1=304388&r2=304389&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jun  1 02:18:49 2017
@@ -707,6 +707,12 @@ CodeGenTypes::arrangeCall(const CGFuncti
  signature.getRequiredArgs());
 }
 
+namespace clang {
+namespace CodeGen {
+void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI);
+}
+}
+
 /// Arrange the argument and result information for an abstract value
 /// of a given function type.  This is the method which all of the
 /// above functions ultimately defer to.
@@ -741,12 +747,16 @@ CodeGenTypes::arrangeLLVMFunctionInfo(Ca
   bool inserted = FunctionsBeingProcessed.insert(FI).second;
   (void)inserted;
   assert(inserted && "Recursively being processed?");
-  
+
   // Compute ABI information.
-  if (info.getCC() != CC_Swift) {
-getABIInfo().computeInfo(*FI);
-  } else {
+  if (CC == llvm::CallingConv::SPIR_KERNEL) {
+// Force target independent argument handling for the host visible
+// kernel functions.
+computeSPIRKernelABIInfo(CGM, *FI);
+  } else if 

[PATCH] D33398: Mangle __unaligned in Itanium ABI

2017-06-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 100974.
rogfer01 added a comment.

Changelog:

- Fix formatting.
- Emit `__unaligned` in the right order (as defined by the Itanium ABI) when 
there are Objective-C++ ARC vendor qualifiers.
- New test for `__unaligned` and ARC's `__weak`, `__strong` and `__autorelease`


https://reviews.llvm.org/D33398

Files:
  lib/AST/ItaniumMangle.cpp
  test/CodeGenCXX/pr33080.cpp
  test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
  test/CodeGenCXX/unaligned-member-qualifier.cpp
  test/CodeGenObjCXX/arc-mangle.mm

Index: test/CodeGenObjCXX/arc-mangle.mm
===
--- test/CodeGenObjCXX/arc-mangle.mm
+++ test/CodeGenObjCXX/arc-mangle.mm
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DTEST_UNALIGNED -fms-extensions -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s --check-prefix=UNALIGNED
 
 // CHECK-LABEL: define {{.*}}void @_Z1fPU8__strongP11objc_object(i8**)
 void f(__strong id *) {}
@@ -32,3 +33,12 @@
 // CHECK-LABEL: define weak_odr {{.*}}void @_Z1gIKvEvP10unsigned_cIXplszv1U8__bridgecvPT_v1U8__bridgecvP11objc_objectcvS3_Li0ELi1EEE
 templatevoid g(unsigned_c*) {}
 template void g(unsigned_c *);
+
+#if TEST_UNALIGNED
+// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU6__weakU11__unalignedP11objc_object(i8**)
+void g(__weak __unaligned id *) {}
+// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU8__strongP11objc_object(i8**)
+void g(__strong __unaligned id *) {}
+// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU15__autoreleasingP11objc_object(i8**)
+void g(__autoreleasing __unaligned id *) {}
+#endif // TEST_UNALIGNED
Index: test/CodeGenCXX/unaligned-member-qualifier.cpp
===
--- /dev/null
+++ test/CodeGenCXX/unaligned-member-qualifier.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm %s -o- | FileCheck %s
+
+struct A {
+  void foo() __unaligned;
+  void foo() const __unaligned;
+  void foo() volatile __unaligned;
+  void foo() const volatile __unaligned;
+};
+
+void A::foo() __unaligned {}
+// CHECK: define void @_ZNU11__unaligned1A3fooEv(
+
+void A::foo() const __unaligned {}
+// CHECK: define void @_ZNU11__unalignedK1A3fooEv(
+
+void A::foo() volatile __unaligned {}
+// CHECK: define void @_ZNU11__unalignedV1A3fooEv(
+
+void A::foo() const volatile __unaligned {}
+// CHECK: define void @_ZNU11__unalignedVK1A3fooEv(
Index: test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
===
--- test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only %s -verify
-
-struct A
-{
-int x;
-void foo() __unaligned;
-void foo();
-};
-
-void A::foo() __unaligned
-{
-this->x++;
-}
-
-void A::foo() // expected-error {{definition with same mangled name as another definition}}
-  // expected-note@-6 {{previous definition is here}}
-{
-this->x++;
-}
-
Index: test/CodeGenCXX/pr33080.cpp
===
--- /dev/null
+++ test/CodeGenCXX/pr33080.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm -o- %s | FileCheck %s
+
+void fa(__unaligned struct A *) {}
+// CHECK: define void @_Z2faPU11__unaligned1A(
+
+void ga(struct A *, struct A *) {}
+// CHECK: define void @_Z2gaP1AS0_(
+
+void gb(__unaligned struct A *, struct A *) {}
+// CHECK: define void @_Z2gbPU11__unaligned1APS_(
+
+void gc(struct A *, __unaligned struct A *) {}
+// CHECK: define void @_Z2gcP1APU11__unalignedS_(
+
+void gd(__unaligned struct A *, __unaligned struct A *) {}
+// CHECK: define void @_Z2gdPU11__unaligned1AS1_(
+
+void hb(__unaligned struct A *, __unaligned const struct A *) {}
+// CHECK: define void @_Z2hbPU11__unaligned1APU11__unalignedKS_(
+
+void ja(__unaligned struct A *, __unaligned struct A *__unaligned *, __unaligned struct A *__unaligned *__unaligned *) {}
+// CHECK: define void @_Z2jaPU11__unaligned1APU11__unalignedS1_PU11__unalignedS3_(
+
+void jb(__unaligned struct A *, __unaligned struct A **, __unaligned struct A *__unaligned *__unaligned *) {}
+// CHECK: @_Z2jbPU11__unaligned1APS1_PU11__unalignedPU11__unalignedS1_(
+
+template 
+void ta(T &, Q *) {}
+
+void ia(__unaligned struct A &a) {
+  ta(a, &a);
+}
+// CHECK: @_Z2taIU11__unaligned1AS1_EvRT_PT0_(
Index: lib/AST/ItaniumMangle.cpp
===
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -1459,8 +1459,6 @@
 // We do not consider restrict a distinguishing attribute for overloading
 // purposes so we must not mangle it.
 MethodQuals.removeRest

[PATCH] D33398: Mangle __unaligned in Itanium ABI

2017-06-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/AST/ItaniumMangle.cpp:2210
+  if (Quals.hasUnaligned())
+  mangleVendorQualifier("__unaligned");
+

rsmith wrote:
> Too much indentation here. Also, the ABI requires the "unordered" vendor 
> qualifiers to be emitted in reverse alphabetical order, so this should be 
> emitted after `__weak` and `__strong` but before `__autoreleasing`.
I think you meant after `__weak` but before `__strong` and `__autoreleasing`? 
Maybe I'm misinterpreting something here.

The current patch emits `__weak`, then `__unaligned` and then the remaining ARC 
ones.


https://reviews.llvm.org/D33398



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


[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-01 Thread Christian Bruel via Phabricator via cfe-commits
chrib added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:569
 
+  if (Triple.getEnvironment() == llvm::Triple::EABI) {
+switch (Triple.getArch()) {

efriedma wrote:
> Specifically checking for "llvm::Triple::EABI" is suspicious... what are you 
> trying to distinguish?
I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by the 
way)

I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is 
probably conservative and stick to what I can test. Do you think this pertains 
to more, for instance to AAPCS-LINUX, without breaking anything ?



https://reviews.llvm.org/D31972



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


[PATCH] D33437: Emit available_externally vtables opportunistically

2017-06-01 Thread Piotr Padlewski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304394: Emit available_externally vtables opportunistically 
(authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D33437?vs=100641&id=100976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33437

Files:
  cfe/trunk/include/clang/AST/VTableBuilder.h
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
  cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -341,6 +341,9 @@
   /// A queue of (optional) vtables to consider emitting.
   std::vector DeferredVTables;
 
+  /// A queue of (optional) vtables that may be emitted opportunistically.
+  std::vector OpportunisticVTables;
+
   /// List of global values which are required to be present in the object file;
   /// bitcast to i8*. This is used for forcing visibility of symbols which may
   /// otherwise be optimized out.
@@ -450,7 +453,7 @@
 
   bool isTriviallyRecursive(const FunctionDecl *F);
   bool shouldEmitFunction(GlobalDecl GD);
-
+  bool shouldOpportunisticallyEmitVTables();
   /// Map used to be sure we don't emit the same CompoundLiteral twice.
   llvm::DenseMap
   EmittedCompoundLiterals;
@@ -1278,6 +1281,12 @@
   /// Emit any needed decls for which code generation was deferred.
   void EmitDeferred();
 
+  /// Try to emit external vtables as available_externally if they have emitted
+  /// all inlined virtual functions.  It runs after EmitDeferred() and therefore
+  /// is not allowed to create new references to things that need to be emitted
+  /// lazily.
+  void EmitVTablesOpportunistically();
+
   /// Call replaceAllUsesWith on all pairs in Replacements.
   void applyReplacements();
 
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -366,20 +366,30 @@
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-   bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
-const auto &VtableLayout =
-CGM.getItaniumVTableContext().getVTableLayout(RD);
-
-for (const auto &VtableComponent : VtableLayout.vtable_components()) {
-  // Skip empty slot.
-  if (!VtableComponent.isUsedFunctionPointerKind())
-continue;
-
-  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
-  if (Method->getCanonicalDecl()->isInlined())
-return true;
-}
-return false;
+   bool hasAnyUnusedVirtualInlineFunction(const CXXRecordDecl *RD) const {
+ const auto &VtableLayout =
+ CGM.getItaniumVTableContext().getVTableLayout(RD);
+
+ for (const auto &VtableComponent : VtableLayout.vtable_components()) {
+   // Skip empty slot.
+   if (!VtableComponent.isUsedFunctionPointerKind())
+ continue;
+
+   const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
+   if (!Method->getCanonicalDecl()->isInlined())
+ continue;
+
+   StringRef Name = CGM.getMangledName(VtableComponent.getGlobalDecl());
+   auto *Entry = CGM.GetGlobalValue(Name);
+   // This checks if virtual inline function has already been emitted.
+   // Note that it is possible that this inline function would be emitted
+   // after trying to emit vtable speculatively. Because of this we do
+   // an extra pass after emitting all deferred vtables to find and emit
+   // these vtables opportunistically.
+   if (!Entry || Entry->isDeclaration())
+ return true;
+ }
+ return false;
   }
 
   bool isVTableHidden(const CXXRecordDecl *RD) const {
@@ -1687,11 +1697,11 @@
   if (CGM.getLangOpts().AppleKext)
 return false;
 
-  // If we don't have any inline virtual functions, and if vtable is not hidden,
-  // then we are safe to emit available_externally copy of vtable.
+  // If we don't have any not emitted inline virtual function, and if vtable is
+  // not hidden, then we are safe to emit available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyVirtualInlineFunction(RD) && !isVTableHidden(RD);
+  return !hasAnyUnusedVirtualInlineFunction(RD) && !isVTableHidden(RD);
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
   Address InitialPtr,
@@ -2576,6 +2586,9 @@
 
   if (!GV) {
 // Create a new global variable.
+// Note for the future: If we would ever like to do deferred em

r304394 - Emit available_externally vtables opportunistically

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 03:04:05 2017
New Revision: 304394

URL: http://llvm.org/viewvc/llvm-project?rev=304394&view=rev
Log:
Emit available_externally vtables opportunistically

Summary:
We can emit vtable definition having inline function
if they are all emitted.

Reviewers: rjmccall, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/VTableBuilder.h
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp

Modified: cfe/trunk/include/clang/AST/VTableBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/VTableBuilder.h?rev=304394&r1=304393&r2=304394&view=diff
==
--- cfe/trunk/include/clang/AST/VTableBuilder.h (original)
+++ cfe/trunk/include/clang/AST/VTableBuilder.h Thu Jun  1 03:04:05 2017
@@ -154,6 +154,27 @@ public:
 
   bool isRTTIKind() const { return isRTTIKind(getKind()); }
 
+  GlobalDecl getGlobalDecl() const {
+assert(isUsedFunctionPointerKind() &&
+   "GlobalDecl can be created only from virtual function");
+
+auto *DtorDecl = dyn_cast(getFunctionDecl());
+switch (getKind()) {
+case CK_FunctionPointer:
+  return GlobalDecl(getFunctionDecl());
+case CK_CompleteDtorPointer:
+  return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
+case CK_DeletingDtorPointer:
+  return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
+case CK_VCallOffset:
+case CK_VBaseOffset:
+case CK_OffsetToTop:
+case CK_RTTI:
+case CK_UnusedFunctionPointer:
+  llvm_unreachable("Only function pointers kinds");
+}
+  }
+
 private:
   static bool isFunctionPointerKind(Kind ComponentKind) {
 return isUsedFunctionPointerKind(ComponentKind) ||

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=304394&r1=304393&r2=304394&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Thu Jun  1 03:04:05 2017
@@ -901,6 +901,8 @@ void CodeGenModule::EmitDeferredVTables(
   for (const CXXRecordDecl *RD : DeferredVTables)
 if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
   VTables.GenerateClassData(RD);
+else if (shouldOpportunisticallyEmitVTables())
+  OpportunisticVTables.push_back(RD);
 
   assert(savedSize == DeferredVTables.size() &&
  "deferred extra vtables during vtable emission?");

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=304394&r1=304393&r2=304394&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jun  1 03:04:05 2017
@@ -382,6 +382,7 @@ void InstrProfStats::reportDiagnostics(D
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  EmitVTablesOpportunistically();
   applyGlobalValReplacements();
   applyReplacements();
   checkAliases();
@@ -1386,6 +1387,24 @@ void CodeGenModule::EmitDeferred() {
   }
 }
 
+void CodeGenModule::EmitVTablesOpportunistically() {
+  // Try to emit external vtables as available_externally if they have emitted
+  // all inlined virtual functions.  It runs after EmitDeferred() and therefore
+  // is not allowed to create new references to things that need to be emitted
+  // lazily. Note that it also uses fact that we eagerly emitting RTTI.
+
+  assert(OpportunisticVTables.empty() || shouldOpportunisticallyEmitVTables() 
&&
+   "Only emit opportunistic vtables with optimizations");
+
+  for (const CXXRecordDecl *RD : OpportunisticVTables) {
+assert(getVTables().isVTableExternal(RD) &&
+   "This queue should only contain external vtables");
+if (getCXXABI().canSpeculativelyEmitVTable(RD))
+  VTables.GenerateClassData(RD);
+  }
+  OpportunisticVTables.clear();
+}
+
 void CodeGenModule::EmitGlobalAnnotations() {
   if (Annotations.empty())
 return;
@@ -1906,6 +1925,10 @@ bool CodeGenModule::shouldEmitFunction(G
   return !isTriviallyRecursive(F);
 }
 
+bool CodeGenModule::shouldOpportunisticallyEmitVTables() {
+  return CodeGenOpts.OptimizationLevel > 0;
+}
+
 void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) 
{
   const auto *D = cast(GD.getDecl());
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=304394&r1=304393&r2=304394&view=diff
=

[PATCH] D33412: Add support for #pragma clang section

2017-06-01 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

After the docs update this looks good to me.

@rnk @jroelofs what do you think? Thanks!


https://reviews.llvm.org/D33412



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-06-01 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 100977.
Prazek marked an inline comment as done.
Prazek added a comment.

Extra test


https://reviews.llvm.org/D31830

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,119 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(&u->b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(&u->a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs &noVptrs) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
+
+struct VirtualInBase : HoldingVirtuals, Empty {
+};
+
+struct VirtualInVBase : virtual Empty, virtual HoldingVirtuals {
+};
+
+// It has vtable by virtual inheritance.
+struct VirtualInheritance : virtual Empty {
+};
+
+union U3 {
+  VirtualInBase v1;
+  VirtualInBase v2;
+  VirtualInheritance v3;
+  int z;
+};
+
+void take(VirtualInBase &);
+void take(VirtualInVBase &);
+void take(VirtualInheritance &);
+
+void UnionsBarrier3(U3 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v1);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v2);
+
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR18VirtualInheritance(
+  take(u.v3);
+}
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3530,6 +3530,25 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto &Base : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   LValueBaseInfo BaseInfo = base.getBaseInfo();
@@ -3572,6 +3591,14 @@
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const a

r304397 - Fixed warnings

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 04:24:36 2017
New Revision: 304397

URL: http://llvm.org/viewvc/llvm-project?rev=304397&view=rev
Log:
Fixed warnings

Modified:
cfe/trunk/include/clang/AST/VTableBuilder.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/AST/VTableBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/VTableBuilder.h?rev=304397&r1=304396&r2=304397&view=diff
==
--- cfe/trunk/include/clang/AST/VTableBuilder.h (original)
+++ cfe/trunk/include/clang/AST/VTableBuilder.h Thu Jun  1 04:24:36 2017
@@ -173,6 +173,7 @@ public:
 case CK_UnusedFunctionPointer:
   llvm_unreachable("Only function pointers kinds");
 }
+llvm_unreachable("Should already return");
   }
 
 private:

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=304397&r1=304396&r2=304397&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jun  1 04:24:36 2017
@@ -1393,8 +1393,8 @@ void CodeGenModule::EmitVTablesOpportuni
   // is not allowed to create new references to things that need to be emitted
   // lazily. Note that it also uses fact that we eagerly emitting RTTI.
 
-  assert(OpportunisticVTables.empty() || shouldOpportunisticallyEmitVTables() 
&&
-   "Only emit opportunistic vtables with optimizations");
+  assert((OpportunisticVTables.empty() || shouldOpportunisticallyEmitVTables())
+ && "Only emit opportunistic vtables with optimizations");
 
   for (const CXXRecordDecl *RD : OpportunisticVTables) {
 assert(getVTables().isVTableExternal(RD) &&


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


[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-06-01 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Ping :)


https://reviews.llvm.org/D30946



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


[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-06-01 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv created this revision.

Previously, the column number in a diagnostic would be the byte position
in the line. This results in incorrect column numbers when a multi-byte
UTF-8 character would be present in the input. By ignoring all bytes
starting with 0b10 the correct column number is created.

This fixes PR21144.


https://reviews.llvm.org/D33765

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  test/Misc/diag-utf8.cpp


Index: test/Misc/diag-utf8.cpp
===
--- /dev/null
+++ test/Misc/diag-utf8.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Foo { int member; };
+
+void f(Foo foo)
+{
+"ideeen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:7:14: error: invalid 
operands to binary expression ('const char *' and 'Foo')
+"ideëen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:8:14: error: invalid 
operands to binary expression ('const char *' and 'Foo')
+}
+
+
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1055,11 +1055,22 @@
   return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
 }
 
+static unsigned correctForMultiByteChars(const char *Buf, unsigned LineStart,
+ unsigned Column)
+{
+unsigned CorrectedColumn = Column;
+for (unsigned I = 0; I < Column; ++I) {
+if ((Buf[LineStart + I] & 0xc0) == 0x80)
+--CorrectedColumn;
+}
+return CorrectedColumn;
+}
 
 /// getColumnNumber - Return the column # for the specified file position.
 /// this is significantly cheaper to compute than the line number.
 unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos,
-bool *Invalid) const {
+bool *Invalid,
+bool BytePosition) const {
   bool MyInvalid = false;
   llvm::MemoryBuffer *MemBuf = getBuffer(FID, &MyInvalid);
   if (Invalid)
@@ -1093,14 +1104,18 @@
 if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
   --FilePos;
   }
-  return FilePos - LineStart + 1;
+  unsigned Column = FilePos - LineStart + 1;
+  return BytePosition ? Column : correctForMultiByteChars(Buf, LineStart,
+  Column);
 }
   }
 
   unsigned LineStart = FilePos;
   while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
 --LineStart;
-  return FilePos-LineStart+1;
+  unsigned Column = FilePos - LineStart + 1;
+  return BytePosition ? Column : correctForMultiByteChars(Buf, LineStart,
+  Column);
 }
 
 // isInvalid - Return the result of calling loc.isInvalid(), and
@@ -1425,7 +1440,8 @@
   unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second, &Invalid);
   if (Invalid)
 return PresumedLoc();
-  unsigned ColNo  = getColumnNumber(LocInfo.first, LocInfo.second, &Invalid);
+  unsigned ColNo  = getColumnNumber(LocInfo.first, LocInfo.second, &Invalid,
+false);
   if (Invalid)
 return PresumedLoc();
   
Index: include/clang/Basic/SourceManager.h
===
--- include/clang/Basic/SourceManager.h
+++ include/clang/Basic/SourceManager.h
@@ -1275,7 +1275,8 @@
   /// on a file sloc, so you must choose a spelling or expansion location
   /// before calling this method.
   unsigned getColumnNumber(FileID FID, unsigned FilePos,
-   bool *Invalid = nullptr) const;
+   bool *Invalid = nullptr,
+   bool BytePosition = true) const;
   unsigned getSpellingColumnNumber(SourceLocation Loc,
bool *Invalid = nullptr) const;
   unsigned getExpansionColumnNumber(SourceLocation Loc,


Index: test/Misc/diag-utf8.cpp
===
--- /dev/null
+++ test/Misc/diag-utf8.cpp
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Foo { int member; };
+
+void f(Foo foo)
+{
+"ideeen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:7:14: error: invalid operands to binary expression ('const char *' and 'Foo')
+"ideëen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:8:14: error: invalid operands to binary expression ('const char *' and 'Foo')
+}
+
+
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1055,11 +1055,22 @@
   return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
 }
 
+static unsigned correctForMultiByteChars(const char *Buf, unsigned LineStart,
+   

[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").

2017-06-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 100994.
fhahn added a comment.

Agreed, ARMTargetInfo is a much better place to do the conversion! Moved 
attribute conversion to ARMTargetInfo::initFeatureMap. Unfortunately 
FeaturesVec is const, so creating a mutable clone seemed the most 
straight-forward thing to do.


https://reviews.llvm.org/D33721

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-target-attr.c


Index: test/CodeGen/arm-target-attr.c
===
--- /dev/null
+++ test/CodeGen/arm-target-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKNEG %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKNEG %s
+
+__attribute__((target("arm"))) void test_target_arm() {
+  // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+}
+
+__attribute__((target("thumb"))) void test_target_thumb() {
+  // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+}
+
+// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}-thumb-mode{{.*}}"
+// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}-thumb-mode{{.*}}"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5435,7 +5435,17 @@
   if (Feature[0] == '+')
 Features[Feature.drop_front(1)] = true;
 
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+// Convert user-provided arm and thumb GNU target attributes to
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto &Feature : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)
+Feature = "-thumb-mode";
+  if (Feature.compare("+thumb") == 0)
+Feature = "+thumb-mode";
+}
+
+return TargetInfo::initFeatureMap(Features, Diags, CPU, 
UpdatedFeaturesVec);
   }
 
   bool handleTargetFeatures(std::vector &Features,


Index: test/CodeGen/arm-target-attr.c
===
--- /dev/null
+++ test/CodeGen/arm-target-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+
+__attribute__((target("arm"))) void test_target_arm() {
+  // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+}
+
+__attribute__((target("thumb"))) void test_target_thumb() {
+  // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+}
+
+// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
+// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5435,7 +5435,17 @@
   if (Feature[0] == '+')
 Features[Feature.drop_front(1)] = true;
 
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+// Convert user-provided arm and thumb GNU target attributes to
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto &Feature : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)
+Feature = "-thumb-mode";
+  if (Feature.compare("+thumb") == 0)
+Feature = "+thumb-mode";
+}
+
+return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
   }
 
   bool handleTargetFeatures(std::vector &Features,
___
cfe-commits mailing list
cfe-commits@lists.llvm.

[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-06-01 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I think that what you're trying to solve is not practically that important, is 
unlikely to improve the handling of comments, and will add a lot of complexity.

From a usability perspective, I think that people are happy enough when their 
comments don't exceed the line limit. I personally wouldn't want the opposite 
to happen. I've even seen style guides that have 80 columns limit for comments 
and 100 for code.

Comments are treated in a somewhat ad-hoc style in clang-format, which is 
because they are inherently free text and don't have a specific format. People 
just expect comments to be handled quite differently than source code. There 
are at least three separate parts in clang-format that make up the formatting 
of comments: the normal parsing and optimization pipeline, the 
BreakableLineCommentSection / BreakableBlockComment classes that are 
responsible for breaking and reflowing inside comment sections, and the 
consecutive trailing comment alignment in the WhitespaceManager. This patch 
takes into account the first aspect but not the consequences for the other 
aspects: for example it allows for the first line comment token in a multiline 
line comment section to get out of the column limit, but will reflow the rest 
of the lines. A WhitespaceManager-related issue is that because a trailing line 
comment for some declaration might not get split, it might not be aligned with 
the surrounding trailing line comments, which I think is a less desirable 
effect.

Optimizing the layout in comment sections by using the optimizing formatter 
sounds good, but because comments mostly contain free text that can be 
structured in unexpected ways, I think that the ad-hoc approach works better. 
Think of not destroying ASCII art and supporting bulleted and numbered lists 
for example. We don't really want to leak lots of comment-related formatting 
tweaks into the general pipeline itself.

I see you point that PenaltyBreakComment and PenaltyExcessCharacter are not 
taken into account while comment placement, but they are taken into account at 
a higher level by treating the whole comment section as a unit. For example, if 
you have a long declaration that has multiple potential split points followed 
by a long trailing comment section, the penalty induced by the number of lines 
that are needed and the number of unbroken characters for the formatting of the 
comment section is taken into account while optimizing the layout of the whole 
code fragment.

The formatted currently supports somewhat limited version of allowing comment 
lines exceeding the column limit, like long hyperlinks for example. I think 
that if there are some other examples which are both widespread and super 
annoying, we may consider them separately.


https://reviews.llvm.org/D33589



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-06-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I have just one comment and i think it'd be good to land.




Comment at: lib/StaticAnalyzer/Core/CheckerHelpers.cpp:104
+  ProgramStateManager &Mgr = State->getStateManager();
+  if (!LHSVal.getAs() && LHSVal.getAs()) {
+LHSVal = Mgr.getStoreManager().getBinding(State->getStore(),

Every `SVal` is either `Unknown` or `Undefined` or `NonLoc` or `Loc`, so the 
check after `&&` is unnecessary.

Also, i believe that it'd be more correct to look at the AST's 
`Expr::isLValue()` (in the caller function, where the expression is still 
available) instead of looking at the `SVal` type here. These approaches are 
significantly different: you need to discriminate between pointer-type rvalues 
and integer-type lvalues, both of which are represented as `Loc` values; in the 
former case, we shouldn't blindly get the binding. I've seen these incorrectly 
discriminated-between in multiple places in the analyzer, and i believe we 
should fix this eventually.


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D30489: [analyzer] catch out of bounds for VLA

2017-06-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

An idea. I believe the safest way to find the bugs you mentioned would be to 
replace extent-as-a-symbol with extent-as-a-trait.

I.e., currently we construct `extent_$3{SymRegion{conj_$1{char *}}}`, assume 
that it is equal to `reg_$0` (which produces a `SymSymExpr`) and then 
catch more `SymSymExpr`s along the path and compare them to the first one.

Instead, i believe that from the start we should have done something like

  REGISTER_MAP_WITH_PROGRAMSTATE(RegionExtent, const SubRegion *, NonLoc);

Then when the VLA is constructed (or memory is malloc'ed or something like 
that), we just set the `RegionExtent` trait directly to `reg_$0` and 
later easily compare it to anything. The region's `getExtent()` method would be 
modified to consult this trait instead of (or, at least, before) constructing a 
new symbol.

Ideologically it is the same thing. Technically it produces simpler symbolic 
expressions, and i believe that both RangeConstraintManager and Z3 would 
benefit from simpler symbolic expressions.


Repository:
  rL LLVM

https://reviews.llvm.org/D30489



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


[PATCH] D30489: [analyzer] catch out of bounds for VLA

2017-06-01 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D30489#769916, @NoQ wrote:

> An idea. I believe the safest way to find the bugs you mentioned would be to 
> replace extent-as-a-symbol with extent-as-a-trait.
>
> I.e., currently we construct `extent_$3{SymRegion{conj_$1{char *}}}`, assume 
> that it is equal to `reg_$0` (which produces a `SymSymExpr`) and then 
> catch more `SymSymExpr`s along the path and compare them to the first one.
>
> Instead, i believe that from the start we should have done something like
>
>   REGISTER_MAP_WITH_PROGRAMSTATE(RegionExtent, const SubRegion *, NonLoc);
>
>
> Then when the VLA is constructed (or memory is malloc'ed or something like 
> that), we just set the `RegionExtent` trait directly to `reg_$0` and 
> later easily compare it to anything. The region's `getExtent()` method would 
> be modified to consult this trait instead of (or, at least, before) 
> constructing a new symbol.
>
> Ideologically it is the same thing. Technically it produces simpler symbolic 
> expressions, and i believe that both RangeConstraintManager and Z3 would 
> benefit from simpler symbolic expressions.


+1, I like this approach!


Repository:
  rL LLVM

https://reviews.llvm.org/D30489



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


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-06-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The code looks good now! A few minor comments and we can commit this :)




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2010
+  const Expr *Mem = CE->getArg(0);
+  const Expr *Const = CE->getArg(1);
+  const Expr *Size = CE->getArg(2);

This variable is unused. It might make buildbots angry.



Comment at: test/Analysis/null-deref-ps-region.c:25
+  memset(x, 0, sizeof(int));
+  int n = 1 / *x;
+  free(x);

Could you mark this as FIXME? Eg:
```
int n = 1 / *x; // FIXME: no-warning
```
Because eventually it should warn.



Comment at: test/Analysis/null-deref-ps-region.c:36
+
+void f531() {
+  int *x = 0;

Can we make function names more fancy?

Eg. "testConcreteNull", "testStackArray", "testHeapSymbol", etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


r304408 - Make the clang-cl test less restrictive.

2017-06-01 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Jun  1 06:41:21 2017
New Revision: 304408

URL: http://llvm.org/viewvc/llvm-project?rev=304408&view=rev
Log:
Make the clang-cl test less restrictive.

Make the test less restrictive to allow directory layout used in our test setup.

Modified:
cfe/trunk/test/Driver/cl-include.c

Modified: cfe/trunk/test/Driver/cl-include.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-include.c?rev=304408&r1=304407&r2=304408&view=diff
==
--- cfe/trunk/test/Driver/cl-include.c (original)
+++ cfe/trunk/test/Driver/cl-include.c Thu Jun  1 06:41:21 2017
@@ -2,10 +2,10 @@
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck %s --check-prefix=BUILTIN
-// BUILTIN: "-internal-isystem" "{{.*lib.*clang.*[0-9]\.[0-9].*include}}"
+// BUILTIN: "-internal-isystem" "{{.*lib.*clang.*include}}"
 
 // RUN: %clang_cl -nobuiltininc -### -- %s 2>&1 | FileCheck %s 
--check-prefix=NOBUILTIN
-// NOBUILTIN-NOT: "-internal-isystem" "{{.*lib.*clang.*[0-9]\.[0-9].*include}}"
+// NOBUILTIN-NOT: "-internal-isystem" "{{.*lib.*clang.*include}}"
 
 // RUN: env INCLUDE=/my/system/inc %clang_cl -### -- %s 2>&1 | FileCheck %s 
--check-prefix=STDINC
 // STDINC: "-internal-isystem" "/my/system/inc"


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


r304396 - [OpenCL] spir_kern by defaul: fix old test cases

2017-06-01 Thread Pekka Jaaskelainen via cfe-commits
Author: pjaaskel
Date: Thu Jun  1 03:19:43 2017
New Revision: 304396

URL: http://llvm.org/viewvc/llvm-project?rev=304396&view=rev
Log:
[OpenCL] spir_kern by defaul: fix old test cases

Modified:
cfe/trunk/test/CodeGenOpenCL/bool_cast.cl
cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl
cfe/trunk/test/CodeGenOpenCL/pipe_types.cl
cfe/trunk/test/CodeGenOpenCL/ptx-calls.cl
cfe/trunk/test/CodeGenOpenCL/ptx-kernels.cl

Modified: cfe/trunk/test/CodeGenOpenCL/bool_cast.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/bool_cast.cl?rev=304396&r1=304395&r2=304396&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/bool_cast.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/bool_cast.cl Thu Jun  1 03:19:43 2017
@@ -4,7 +4,7 @@ typedef unsigned char uchar4 __attribute
 typedef unsigned int int4 __attribute((ext_vector_type(4)));
 typedef float float4 __attribute((ext_vector_type(4)));
 
-// CHECK-LABEL: define void @ker()
+// CHECK-LABEL: define spir_kernel void @ker()
 void kernel ker() {
   bool t = true;
   int4 vec4 = (int4)t;

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl?rev=304396&r1=304395&r2=304396&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl Thu Jun  1 03:19:43 2017
@@ -3,13 +3,13 @@
 typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
 
 kernel  __attribute__((vec_type_hint(int))) 
__attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {}
-// CHECK: define void @kernel1(i32 {{[^%]*}}%a) {{[^{]+}} !vec_type_hint 
![[MD1:[0-9]+]] !reqd_work_group_size ![[MD2:[0-9]+]]
+// CHECK: define spir_kernel void @kernel1(i32 {{[^%]*}}%a) {{[^{]+}} 
!vec_type_hint ![[MD1:[0-9]+]] !reqd_work_group_size ![[MD2:[0-9]+]]
 
 kernel __attribute__((vec_type_hint(uint4))) 
__attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
-// CHECK: define void @kernel2(i32 {{[^%]*}}%a) {{[^{]+}} !vec_type_hint 
![[MD3:[0-9]+]] !work_group_size_hint ![[MD4:[0-9]+]]
+// CHECK: define spir_kernel void @kernel2(i32 {{[^%]*}}%a) {{[^{]+}} 
!vec_type_hint ![[MD3:[0-9]+]] !work_group_size_hint ![[MD4:[0-9]+]]
 
 kernel __attribute__((intel_reqd_sub_group_size(8))) void kernel3(int a) {}
-// CHECK: define void @kernel3(i32 {{[^%]*}}%a) {{[^{]+}} 
!intel_reqd_sub_group_size ![[MD5:[0-9]+]]
+// CHECK: define spir_kernel void @kernel3(i32 {{[^%]*}}%a) {{[^{]+}} 
!intel_reqd_sub_group_size ![[MD5:[0-9]+]]
 
 // CHECK: [[MD1]] = !{i32 undef, i32 1}
 // CHECK: [[MD2]] = !{i32 1, i32 2, i32 4}

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl?rev=304396&r1=304395&r2=304396&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-metadata.cl Thu Jun  1 03:19:43 2017
@@ -6,5 +6,5 @@ void normal_function() {
 __kernel void kernel_function() {
 }
 
-// CHECK: define void @kernel_function() {{[^{]+}} !kernel_arg_addr_space 
![[MD:[0-9]+]] !kernel_arg_access_qual ![[MD]] !kernel_arg_type ![[MD]] 
!kernel_arg_base_type ![[MD]] !kernel_arg_type_qual ![[MD]] {
+// CHECK: define spir_kernel void @kernel_function() {{[^{]+}} 
!kernel_arg_addr_space ![[MD:[0-9]+]] !kernel_arg_access_qual ![[MD]] 
!kernel_arg_type ![[MD]] !kernel_arg_base_type ![[MD]] !kernel_arg_type_qual 
![[MD]] {
 // CHECK: ![[MD]] = !{}

Modified: cfe/trunk/test/CodeGenOpenCL/pipe_types.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_types.cl?rev=304396&r1=304395&r2=304396&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/pipe_types.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Thu Jun  1 03:19:43 2017
@@ -28,7 +28,7 @@ void test5(read_only pipe int4 p) {
 
 typedef read_only pipe int MyPipe;
 kernel void test6(MyPipe p) {
-// CHECK: define void @test6(%opencl.pipe_t* %p)
+// CHECK: define spir_kernel void @test6(%opencl.pipe_t* %p)
 }
 
 struct Person {

Modified: cfe/trunk/test/CodeGenOpenCL/ptx-calls.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/ptx-calls.cl?rev=304396&r1=304395&r2=304396&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/ptx-calls.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/ptx-calls.cl Thu Jun  1 03:19:43 2017
@@ -7,7 +7,7 @@ void device_function() {
 __kernel void kernel_function() {
   device_function();
 }
-// CHECK-LABEL: define void @kernel_function()
+// CHECK-L

[PATCH] D33401: [mips] Add runtime options to enable/disable generation of madd.fmt, msub.fmt

2017-06-01 Thread Stefan Maksimovic via Phabricator via cfe-commits
smaksimovic updated this revision to Diff 101010.
smaksimovic added a comment.

Changed feature name from madd4 to nomadd4 to reflect the change from the 
dependency.
Added macro definition when +nomadd4 is present.


https://reviews.llvm.org/D33401

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/CodeGen/mips-madd4.c

Index: test/CodeGen/mips-madd4.c
===
--- test/CodeGen/mips-madd4.c
+++ test/CodeGen/mips-madd4.c
@@ -0,0 +1,86 @@
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4%s -o -| FileCheck %s -check-prefix=MADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 %s -o -| FileCheck %s -check-prefix=NOMADD4
+// RUN: %clang --target=mips64-unknown-linux -S -mmadd4-fno-honor-nans %s -o -| FileCheck %s -check-prefix=MADD4-NONAN
+// RUN: %clang --target=mips64-unknown-linux -S -mno-madd4 -fno-honor-nans %s -o -| FileCheck %s -check-prefix=NOMADD4-NONAN
+ 
+float madd_s (float f, float g, float h)
+{
+  return (f * g) + h;
+}
+// MADD4:   madd.s
+// NOMADD4: mul.s
+// NOMADD4: add.s
+
+float msub_s (float f, float g, float h)
+{
+  return (f * g) - h;
+}
+// MADD4:   msub.s
+// NOMADD4: mul.s
+// NOMADD4: sub.s
+
+double madd_d (double f, double g, double h)
+{
+  return (f * g) + h;
+}
+// MADD4:   madd.d
+// NOMADD4: mul.d
+// NOMADD4: add.d
+
+double msub_d (double f, double g, double h)
+{
+  return (f * g) - h;
+}
+// MADD4:   msub.d
+// NOMADD4: mul.d
+// NOMADD4: sub.d
+
+
+float nmadd_s (float f, float g, float h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) + h);
+}
+// MADD4-NONAN:   nmadd.s
+// NOMADD4-NONAN: mul.s
+// NOMADD4-NONAN: add.s
+// NOMADD4-NONAN: sub.s
+
+float nmsub_s (float f, float g, float h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) - h);
+}
+// MADD4-NONAN:   nmsub.s
+// NOMADD4-NONAN: mul.s
+// NOMADD4-NONAN: sub.s
+// NOMADD4-NONAN: sub.s
+
+double nmadd_d (double f, double g, double h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) + h);
+}
+// MADD4-NONAN:   nmadd.d
+// NOMADD4-NONAN: mul.d
+// NOMADD4-NONAN: add.d
+// NOMADD4-NONAN: sub.d
+
+double nmsub_d (double f, double g, double h)
+{
+  // FIXME: Zero has been explicitly placed to force generation of a positive
+  // zero in IR until pattern used to match this instruction is changed to
+  // comply with negative zero as well.
+  return 0-((f * g) - h);
+}
+// MADD4-NONAN:   nmsub.d
+// NOMADD4-NONAN: mul.d
+// NOMADD4-NONAN: sub.d
+// NOMADD4-NONAN: sub.d
+
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -298,6 +298,13 @@
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
+
+  if(Arg *A = Args.getLastArg(options::OPT_mmadd4, options::OPT_mno_madd4)) {
+if(A->getOption().matches(options::OPT_mmadd4))
+  Features.push_back("-nomadd4");
+else
+  Features.push_back("+nomadd4");
+  }
 }
 
 mips::NanEncoding mips::getSupportedNanEncoding(StringRef &CPU) {
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7700,6 +7700,7 @@
 NoDSP, DSP1, DSP2
   } DspRev;
   bool HasMSA;
+  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -7710,7 +7711,7 @@
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
 IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
 CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), HasFP64(false) {
+HasMSA(false), DisableMadd4(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -7956,6 +7957,9 @@
 if (HasMSA)
   Builder.defineMacro("__mips_msa", Twine(1));
 
+if (DisableMadd4)
+  Builder.defineMacro("__mips_no_madd4", Twine(1));
+
 Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
 Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
 Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));
@@ -8118,6 +8122,8 @@
 DspRev = std::max(DspRev, DSP2);
   else if (Feature == "+msa")
 HasMSA = true;
+  else if (Feature == "+nomadd4")
+DisableMadd4 = true;
   else if (

[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-06-01 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Hi Artem,

Long time no see! miss you :)

I will update my patch next Thursday! I am doing my work assignment about L4 
 right now.

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Yaron Keren via cfe-commits
Hi Richard,

This broke the tests on the Windows bot:

http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/5266

   1. FAIL: Clang::preprocess-nested.cpp
   

   2. FAIL: Clang::preprocess-module.cpp
   


r304345 was OK
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/5265

Yaron


‫בתאריך יום ד׳, 31 במאי 2017 ב-23:57 מאת ‪Richard Smith via cfe-commits‬‏ <‪
cfe-commits@lists.llvm.org‬‏>:‬

> Author: rsmith
> Date: Wed May 31 15:56:55 2017
> New Revision: 304346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304346&view=rev
> Log:
> [modules] When compiling a preprocessed module map, look for headers
> relative
> to the original module map.
>
> Also use the path and name of the original module map when emitting that
> information into the .pcm file. The upshot of this is that the produced
> .pcm
> file will track information for headers in their original locations (where
> the
> module was preprocessed), not relative to whatever directory the
> preprocessed
> module map was in when it was built.
>
> Modified:
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Frontend/FrontendAction.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
> cfe/trunk/test/Modules/preprocess-nested.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Module.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=304346&r1=304345&r2=304346&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Module.h (original)
> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
> @@ -83,6 +83,10 @@ public:
>/// are found.
>const DirectoryEntry *Directory;
>
> +  /// \brief The presumed file name for the module map defining this
> module.
> +  /// Only non-empty when building from preprocessed source.
> +  std::string PresumedModuleMapFile;
> +
>/// \brief The umbrella header or directory.
>llvm::PointerUnion Umbrella;
>
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=304346&r1=304345&r2=304346&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
> @@ -543,10 +543,13 @@ public:
>/// \param Offset [inout] An offset within ID to start parsing. On exit,
>///filled by the end of the parsed contents (either EOF or the
>///location of an end-of-module-map pragma).
> -  ///
> +  /// \param OriginalModuleMapFile The original path to the module map
> file,
> +  ///used to resolve paths within the module (this is required
> when
> +  ///building the module from preprocessed source).
>/// \returns true if an error occurred, false otherwise.
>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
> - FileID ID = FileID(), unsigned *Offset =
> nullptr);
> + FileID ID = FileID(), unsigned *Offset = nullptr,
> + StringRef OriginalModuleMapFile = StringRef());
>
>/// \brief Collect the set of all known, top-level modules.
>///
>
> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=304346&r1=304345&r2=304346&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>return std::error_code();
>  }
>
> -static bool
> -loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename,
> -bool IsSystem, bool IsPreprocessed,
> -unsigned &Offset) {
> +static bool loadModuleMapForModuleBuild(CompilerInstance &CI,
> +StringRef Filename, bool IsSystem,
> +bool IsPreprocessed,
> +std::string
> &PresumedModuleMapFile,
> +unsigned &Offset) {
>auto &SrcMgr = CI.getSourceManager();
>HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
>
> @@ -388,16 +389,15 @@ loadModuleMapForModuleBuild(CompilerInst
> 

[PATCH] D33774: [CodeGen] Make __attribute__(const) calls speculatable

2017-06-01 Thread Tobias Grosser via Phabricator via cfe-commits
grosser created this revision.
Herald added subscribers: javed.absar, wdng.

Today 'const' functions are only marked 'readnone' and 'nounwind', but lack the
'speculatable' attribute for historic reasons. As 'const' functions are known to
not have any side effects and are intended to enable loop optimizations, they
are indeed 'speculatable' and consequently should be marked as such.

Some history: Back before r44273 (long time ago) readnone was indeed called
const and LLVM was assuming that readnone functions do not contain infinite
loops and can be hoisted. This worked at the beginning, but LLVM learned over
time to infer the readnone attribute from function definitions. As a result,
infinite functions that do not touch memory were marked as readnone, incorrectly
also stating that they are free of infinite loops, because different LLVM passes
still assumed a one-to-one correspondence between '__attribute(const)' and
LLVM's readnone attribute. Over time, we learned that 'readnone' must not imply
absence of infinite loops and other side effects to allow us to derive this
attribute automatically. Hence, the definition of readnone was changed to not
give information about the termination of functions. To still provide
information about side effects outside of memory effects LLVM recently learned
about speculatable function attributes: (https://reviews.llvm.org/D20116)

With 'speculatable' now available, we can pass information about the absence
of non-memory side effects to LLVM-IR.

This idea was taken from earlier discussions where for example Chris suggested
this solution:

"This really only matters when the compiler is able to infer readnone/readonly,
which typically doesn't include cases with indirect calls.  Per #2, I think it
could be handled by making the GCC-style pure/const attributes imply both
readonly/readnone *and* halting. :


https://reviews.llvm.org/D33774

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/function-attributes.c
  test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp


Index: test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
===
--- test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
+++ test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
@@ -5,18 +5,18 @@
 
 // CHECK: define i32 @_Z1fv() [[TF:#[0-9]+]] {
 int f(void) {
-  // CHECK: call i32 @_Z1cv() [[NUW_RN_CALL:#[0-9]+]]
+  // CHECK: call i32 @_Z1cv() [[NUW_RN_SP_CALL:#[0-9]+]]
   // CHECK: call i32 @_Z1pv() [[NUW_RO_CALL:#[0-9]+]]
   return c() + p() + t();
 }
 
-// CHECK: declare i32 @_Z1cv() [[NUW_RN:#[0-9]+]]
+// CHECK: declare i32 @_Z1cv() [[NUW_RN_SP:#[0-9]+]]
 // CHECK: declare i32 @_Z1pv() [[NUW_RO:#[0-9]+]]
 // CHECK: declare i32 @_Z1tv() [[TF2:#[0-9]+]]
 
 // CHECK: attributes [[TF]] = { {{.*}} }
-// CHECK: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
+// CHECK: attributes [[NUW_RN_SP]] = { nounwind readnone speculatable{{.*}} }
 // CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
 // CHECK: attributes [[TF2]] = { {{.*}} }
-// CHECK: attributes [[NUW_RN_CALL]] = { nounwind readnone }
+// CHECK: attributes [[NUW_RN_SP_CALL]] = { nounwind readnone speculatable }
 // CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -44,7 +44,7 @@
 
 // FIXME: We should be setting nounwind on calls.
 // CHECK: call i32 @f10_t()
-// CHECK: [[NUW_RN:#[0-9]+]]
+// CHECK: [[NUW_RN_SP:#[0-9]+]]
 // CHECK: {
 int __attribute__((const)) f10_t(void);
 int f10(void) { return f10_t(); }
@@ -114,5 +114,5 @@
 // CHECK: attributes [[ALIGN]] = { nounwind optsize alignstack=16{{.*}} }
 // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }
 // CHECK: attributes [[NR]] = { noreturn optsize }
-// CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone }
+// CHECK: attributes [[NUW_RN_SP]] = { nounwind optsize readnone speculatable }
 // CHECK: attributes [[RT_CALL]] = { optsize returns_twice }
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1804,6 +1804,7 @@
 if (TargetDecl->hasAttr()) {
   FuncAttrs.addAttribute(llvm::Attribute::ReadNone);
   FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
+  FuncAttrs.addAttribute(llvm::Attribute::Speculatable);
 } else if (TargetDecl->hasAttr()) {
   FuncAttrs.addAttribute(llvm::Attribute::ReadOnly);
   FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);


Index: test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
===
--- test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
+++ test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
@@ -5,18 +5,18 @@
 
 // CHECK: define i32 @_Z1fv() [[TF:#[0-9]+]] {
 int f(void) {
-  // CHECK: call i32 @_Z1cv() [[NUW_R

r304411 - Increase the limit for the number of DiagnosticLexKinds.td diags.

2017-06-01 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Thu Jun  1 07:46:59 2017
New Revision: 304411

URL: http://llvm.org/viewvc/llvm-project?rev=304411&view=rev
Log:
Increase the limit for the number of DiagnosticLexKinds.td diags.
300 was reached in r304190, 400 should be enough for a while.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=304411&r1=304410&r2=304411&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Thu Jun  1 07:46:59 2017
@@ -32,7 +32,7 @@ namespace clang {
   DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
   DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
   DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  300,
+  DIAG_START_PARSE = DIAG_START_LEX +  400,
   DIAG_START_AST   = DIAG_START_PARSE   +  500,
   DIAG_START_COMMENT   = DIAG_START_AST +  110,
   DIAG_START_SEMA  = DIAG_START_COMMENT +  100,


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


[PATCH] D33774: [CodeGen] Make __attribute__(const) calls speculatable

2017-06-01 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Definition of `__attibute__((const))` from 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

> Many functions do not examine any values except their arguments, and have no 
> effects except the return value. Basically this is just slightly more strict 
> class than the pure attribute below, since function is not allowed to read 
> global memory.
>  Note that a function that has pointer arguments and examines the data 
> pointed to must not be declared const. Likewise, a function that calls a 
> non-const function usually must not be const. It does not make sense for a 
> const function to return void.

Definition of `speculatable` from 
http://llvm.org/docs/LangRef.html#function-attributes

> This function attribute indicates that the function does not have any effects 
> besides calculating its result and does not have undefined behavior.


https://reviews.llvm.org/D33774



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


[PATCH] D33776: [libcxx] LWG2221: No formatted output operator for nullptr

2017-06-01 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo created this revision.

With effects equivalent to `os << (const void*)nullptr`.


https://reviews.llvm.org/D33776

Files:
  include/ostream
  
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/nullptr_t.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -356,7 +356,7 @@
  	
 	http://wg21.link/LWG2062";>2062Effect contradictions w/o no-throw guarantee of std::function swapsIssaquahComplete
 	http://wg21.link/LWG2166";>2166Heap property underspecified?Issaquah
-	http://wg21.link/LWG2221";>2221No formatted output operator for nullptrIssaquah
+	http://wg21.link/LWG2221";>2221No formatted output operator for nullptrIssaquahComplete
 	http://wg21.link/LWG2223";>2223shrink_to_fit effect on iterator validityIssaquahComplete
 	http://wg21.link/LWG2261";>2261Are containers required to use their 'pointer' type internally?Issaquah
 	http://wg21.link/LWG2394";>2394locale::name specification unclear - what is implementation-defined?IssaquahComplete
Index: test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/nullptr_t.pass.cpp
===
--- /dev/null
+++ test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/nullptr_t.pass.cpp
@@ -0,0 +1,81 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  >
+//   class basic_ostream;
+
+// operator<<(nullptr_t);
+
+#include 
+#include 
+#include 
+
+template 
+class testbuf
+: public std::basic_streambuf
+{
+typedef std::basic_streambuf base;
+std::basic_string str_;
+public:
+testbuf()
+{
+}
+
+std::basic_string str() const
+{return std::basic_string(base::pbase(), base::pptr());}
+
+protected:
+
+virtual typename base::int_type
+overflow(typename base::int_type __c = base::traits_type::eof())
+{
+if (__c != base::traits_type::eof())
+{
+int n = static_cast(str_.size());
+str_.push_back(static_cast(__c));
+str_.resize(str_.capacity());
+base::setp(const_cast(str_.data()),
+   const_cast(str_.data() + str_.size()));
+base::pbump(n+1);
+}
+return __c;
+}
+};
+
+int main()
+{
+{
+std::ostream os((std::streambuf*)0);
+std::nullptr_t n = nullptr;
+os << n;
+assert(os.bad());
+assert(os.fail());
+}
+{
+testbuf sb;
+std::ostream os(&sb);
+std::nullptr_t n = nullptr;
+os << n;
+assert(os.good());
+std::string s(sb.str());
+
+// Implementation defined. Instead of validating the output,
+// at least ensure that it does not generate an empty string.
+assert(!s.empty());
+}
+{
+testbuf sb;
+std::ostream os(&sb);
+std::nullptr_t const n = nullptr;
+os << n;
+assert(os.good());
+}
+}
Index: include/ostream
===
--- include/ostream
+++ include/ostream
@@ -56,6 +56,7 @@
 basic_ostream& operator<<(double f);
 basic_ostream& operator<<(long double f);
 basic_ostream& operator<<(const void* p);
+basic_ostream& operator<<(nullptr_t);
 basic_ostream& operator<<(basic_streambuf* sb);
 
 // 27.7.2.7 Unformatted output:
@@ -140,6 +141,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -218,6 +220,10 @@
 basic_ostream& operator<<(const void* __p);
 basic_ostream& operator<<(basic_streambuf* __sb);
 
+inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
+basic_ostream& operator<<(nullptr_t)
+{ return *this << (const void*)0; }
+
 // 27.7.2.7 Unformatted output:
 basic_ostream& put(char_type __c);
 basic_ostream& write(const char_type* __s, streamsize __n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 101031.
Anastasia edited reviewers, added: yaxunl; removed: echuraev.
Anastasia removed a subscriber: yaxunl.
Anastasia added a comment.

Use global AS pointer for pipe size.

@Sam, I am moving you to the reviewer to finish this change. Do you think it 
makes sense to add RUN line with some AMD GPU in triple to the test?


https://reviews.llvm.org/D33597

Files:
  lib/AST/ASTContext.cpp
  test/Index/pipe-size.cl


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = 
Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = 
Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D33597#770137, @Anastasia wrote:

> Use global AS pointer for pipe size.
>
> @Sam, I am moving you to the reviewer to finish this change. Do you think it 
> makes sense to add RUN line with some AMD GPU in triple to the test?


I would appreciate that if you can add one RUN line for triple 
amdgcn-amd-amdhsa-amdgizcl. Thanks.


https://reviews.llvm.org/D33597



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


[libcxx] r304425 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:29:42 2017
New Revision: 304425

URL: http://llvm.org/viewvc/llvm-project?rev=304425&view=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libcxx/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304424, libcxx/branches/release_40/

Propchange: libcxx/tags/RELEASE_401/rc2/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Jun  1 11:29:42 2017
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:292013,292091,292607,292990,293154,293197,293581,294133,294142,294431


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


[libcxxabi] r304426 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:29:45 2017
New Revision: 304426

URL: http://llvm.org/viewvc/llvm-project?rev=304426&view=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libcxxabi/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304425, libcxxabi/branches/release_40/

Propchange: libcxxabi/tags/RELEASE_401/rc2/
--
svn:mergeinfo = /libcxxabi/trunk:292135,292418,292638


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


[libunwind] r304432 - Creating release candidate rc2 from release_401 branch

2017-06-01 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Thu Jun  1 11:30:02 2017
New Revision: 304432

URL: http://llvm.org/viewvc/llvm-project?rev=304432&view=rev
Log:
Creating release candidate rc2 from release_401 branch

Added:
libunwind/tags/RELEASE_401/rc2/   (props changed)
  - copied from r304431, libunwind/branches/release_40/

Propchange: libunwind/tags/RELEASE_401/rc2/
--
svn:mergeinfo = /libunwind/trunk:292723,296358-296359


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


[PATCH] D33108: Generate extra .ll files before/after optimization when using -save-temps.

2017-06-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Driver/Driver.cpp:2603-2614
+  // lipo-able.
+  if (!MultiArchUniversalBuild) {
+if (isSaveTempsEnabled() && Phase == phases::Compile) {
+  Actions.push_back(
+  C.MakeAction(Current, types::TY_LLVM_IR));
+}
+if (isSaveTempsEnabled() && Phase == phases::Backend) {

Can this be moved below addHostDependenceToDeviceActions() on line 2626?
See my comment in cuda-options.cu below for the reasons why it may be necessary.



Comment at: test/Driver/cuda-options.cu:197-202
-// Match host-side preprocessor job with -save-temps.
-// HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
-// HOST-SAVE-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
-// HOST-SAVE-NOT: "-fcuda-is-device"
-// HOST-SAVE-SAME: "-x" "cuda"
-

It appears that the new actions you've pushed trigger at least parts of 
host-side compilation to happen before device-side compilation is done. That, 
at the very least, will not work well for CUDA. Compilation will probably 
succeed, but it will be missing device-side code and will fail at runtime.

If it's only host-side preprocessor that happens ahead of device-side actions, 
then may be OK, but in general host actions must be done after device's. 


https://reviews.llvm.org/D33108



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


[PATCH] D33739: [Sema] Improve -Wstrict-prototypes diagnostic message for blocks

2017-06-01 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D33739



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


[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D3#768332, @jyu2 wrote:

> Okay this CFG version of this change.  In this change I am basic using same 
> algorithm with -Winfinite-recursion.
>
> In addition to my original implementation,  I add handler type checking which 
> basic using  https://reviews.llvm.org/D19201 method.


Thank you, I think this is a step in the right direction!

> There are couple things I am worry about this implementation:
>  1> compile time...

Do you have any timing data on whether this has a negative performance impact?

> 2> Correctness...

Your implementation looks reasonable to me, but with further review (and good 
tests), we should have a better grasp on correctness.

> 3> Stack overflow for large CFG...

I would be surprised if that were a problem, but is something we could address 
if it ever arises.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6341
+: Warning<"%0 has a non-throwing exception specification but can still "
+  "throw, may result in unexpected program termination.">, 
+  InGroup;

throw, may -> throw, which may

Also, remove the period at the end of the diagnostic.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6344
+def note_throw_in_dtor 
+: Note<"destructor or deallocator has a (possible implicit) non-throwing "
+  "excepton specification">;

possible -> possibly



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6347
+def note_throw_in_function 
+: Note<"nonthrowing function declare here">;
 def err_seh_try_outside_functions : Error<

nonthrowing -> non-throwing

(to be consistent with other diagnostics.)



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:290
+
+static bool mayThrowBeCaughted(const CXXThrowExpr *Throw,
+   const CXXCatchStmt *Catch) {

Caughted -> Caught



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:292
+   const CXXCatchStmt *Catch) {
+  bool MayCaught = false;
+  const auto *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();

MayCaught -> IsCaught ?



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:293-294
+  bool MayCaught = false;
+  const auto *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  const auto *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+

Please don't use `auto` unless the type is explicitly spelled out in the 
initializer (here and elsewhere).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:298
+return true;
+  if (CaughtType == ThrowType)
+return true;

You can combine this with the above check.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:304
+  if (CaughtAsRecordType && ThrowTypeAsRecordType) {
+if (CaughtAsRecordType == ThrowTypeAsRecordType)
+  MayCaught = true;

This does not seem quite correct. Consider:
```
struct S{};

void f() {
  try {
throw S{};
  } catch (const S *s) {
  }
}
```



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:311
+
+static bool mayThrowBeCaughtedByHandlers(const CXXThrowExpr *CE,
+ const CXXTryStmt *TryStmt) {

mayThrowBeCaughtedByHandlers -> isThrowCaughtByAHandler



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:314
+  bool Caught = false;
+  for (unsigned h = 0; h < TryStmt->getNumHandlers(); ++h) {
+const CXXCatchStmt *CS = TryStmt->getHandler(h);

h -> H (or Idx, or anything else that meets the coding standard).



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:317-318
+if (mayThrowBeCaughted(CE, CS)) {
+  Caught = true;
+  break;
+}

Just return true here instead of setting a local variable. Return false below.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:324
+
+static bool hasThrowOutNothrowingFuncInPath(CFGBlock &Block,
+SourceLocation *OpLoc) {

Perhaps it's more clear as: `doesThrowEscapePath()`?



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:330
+  continue;
+const CXXThrowExpr *CE =
+dyn_cast(B.getAs()->getStmt());

Can use `const auto *` here.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:334
+  continue;
+else
+  HasThrowOutFunc = true;

You can drop the `else` here and just set `HasThrowOutFunc` to true.



Comment at: lib/Sema/AnalysisBasedWarnings.cpp:337
+
+(*OpLoc) = CE->getThrowLoc();
+for (CFGBlock::const_succ_iterator I = Block.succ_begin(),

If OpLoc cannot be null, you should take it by reference. If it can be null, 
then you should guard against 

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33537#765445, @baloghadamsoftware wrote:

> In https://reviews.llvm.org/D33537#764834, @Prazek wrote:
>
> > How is that compared to https://reviews.llvm.org/D19201 and the clang patch 
> > mentioned in this patch?
>
>
> Actually, this check does much more. It does not only check for noexcept (and 
> throw()) functions, but also for destructors, move constructors, move 
> assignments, the main() function, swap() functions and also functions given 
> as option. A more important difference is that we traverse the whole 
> call-chain and check all the throw statements and try-catch blocks so 
> indirectly throwing functions are also reported and no flase positives are 
> caused by throw and catch in the same try block.


I think we should try to get as much of this functionality in 
https://reviews.llvm.org/D3 as possible; there is a considerable amount of 
overlap between that functionality and this functionality. This check can then 
cover only the parts that are not reasonably handled by the frontend check 
instead of duplicating diagnostics the user already receives.


https://reviews.llvm.org/D33537



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-06-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Thanks, LGTM.


https://reviews.llvm.org/D31830



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you help me to understand what problem is being solved with this new 
attribute? Under what circumstances would the first argument be an 
`ImplicitParamDecl` but not an implicit this or self?


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:

> Can you help me to understand what problem is being solved with this new 
> attribute? Under what circumstances would the first argument be an 
> `ImplicitParamDecl` but not an implicit this or self?


For captured regions an outlined function is created, where all parameters are 
ImplicitParamDecls. And the very first parameter is wrongly treated as 'this' 
argument of the member function.


https://reviews.llvm.org/D33735



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


[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-06-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: include/__hash_table:139
 {
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits - 
__clz(__n-1))) : __n;
 }

EricWF wrote:
> Shouldn't this return  `__n + 1` when `__n <= 1`, or even 2 in both cases?
I thought "next_hash_pow2(n)" meant "a hash based on n or the first 
power-of-two GTE n", but I suppose it's actually "first power-of-two GTE than 
n, for hash tables". In this case, returning `1` when `__n <= 1` makes the most 
sense to me, since it's the first power of two GTE 0 and 1. What do you think?


https://reviews.llvm.org/D33588



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


[PATCH] D33788: Return a canonical path from getClangResourcePath()

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.

on POSIX systems, CIndexer::getClangResourcesPath() uses dladdr() to get the 
path of the shared object. It seems that on some systems (in our case, OS X 
10.6.8), dladdr() does not return a canonicalized path. We're getting a path 
like PATH/TO/CLANG/build/bin/../lib/clang/4.0.0. This resource directory path 
is then used to calculate a hash used by CompilerInvocation::getModuleHash(). 
This, in turn, is causing Index/pch-from-libclang.c to fail for us because the 
module cache paths have different names -- the first path is calculated with 
PATH/TO/CLANG/build/lib/clang/4.0.0 and the second path uses 
PATH/TO/CLANG/build/bin/../lib/clang/4.0.0.

Fix this bug by returning a canonicalized path.


https://reviews.llvm.org/D33788

Files:
  tools/libclang/CIndexer.cpp


Index: tools/libclang/CIndexer.cpp
===
--- tools/libclang/CIndexer.cpp
+++ tools/libclang/CIndexer.cpp
@@ -73,6 +73,11 @@
   llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
 
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  SmallString<260> RealPath;
+  if (!llvm::sys::fs::real_path(LibClangPath, RealPath, 
/*expand_tilde=*/false))
+ResourcesPath = RealPath.str();
+  else
+ResourcesPath = LibClangPath.str();
+
   return ResourcesPath;
 }


Index: tools/libclang/CIndexer.cpp
===
--- tools/libclang/CIndexer.cpp
+++ tools/libclang/CIndexer.cpp
@@ -73,6 +73,11 @@
   llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
 
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  SmallString<260> RealPath;
+  if (!llvm::sys::fs::real_path(LibClangPath, RealPath, /*expand_tilde=*/false))
+ResourcesPath = RealPath.str();
+  else
+ResourcesPath = LibClangPath.str();
+
   return ResourcesPath;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33774: [CodeGen] Make __attribute__(const) calls speculatable

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Consider something like this:

  define i32 @div(i32 %x, i32 %y) {
  entry:
%div = sdiv i32 %x, %y
ret i32 %div
  }

We can mark this function readnone, but not speculatable: it doesn't read or 
write memory, but could exhibit undefined behavior.

Consider another function:

  @x = common local_unnamed_addr global i32 0, align 4
  define i32 @get_x() {
  entry:
%0 = load i32, i32* @x, align 4, !tbaa !2
ret i32 %0
  }

We can mark this function speculatable, but not readnone: it doesn't exhibit 
undefined behavior or have side-effects, but it does read memory.

Given that, it seems a little dubious to translate `__attribute__((const))` 
into `speculatable`.


https://reviews.llvm.org/D33774



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D33735#770296, @ABataev wrote:

> In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
>
> > Can you help me to understand what problem is being solved with this new 
> > attribute? Under what circumstances would the first argument be an 
> > `ImplicitParamDecl` but not an implicit this or self?
>
>
> For captured regions an outlined function is created, where all parameters 
> are ImplicitParamDecls. And the very first parameter is wrongly treated as 
> 'this' argument of the member function.


Ah, thank you! That makes sense to me, but it begs the question: why an 
attribute rather than a bit on ImplicitParamDecl?


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote:

> In https://reviews.llvm.org/D33735#770296, @ABataev wrote:
>
> > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
> >
> > > Can you help me to understand what problem is being solved with this new 
> > > attribute? Under what circumstances would the first argument be an 
> > > `ImplicitParamDecl` but not an implicit this or self?
> >
> >
> > For captured regions an outlined function is created, where all parameters 
> > are ImplicitParamDecls. And the very first parameter is wrongly treated as 
> > 'this' argument of the member function.
>
>
> Ah, thank you! That makes sense to me, but it begs the question: why an 
> attribute rather than a bit on ImplicitParamDecl?


I agree: it would make more sense for ImplicitParamDecl to store a Kind that 
would always be provided at construction.


https://reviews.llvm.org/D33735



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


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D33735#770333, @rjmccall wrote:

> In https://reviews.llvm.org/D33735#770318, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D33735#770296, @ABataev wrote:
> >
> > > In https://reviews.llvm.org/D33735#770288, @aaron.ballman wrote:
> > >
> > > > Can you help me to understand what problem is being solved with this 
> > > > new attribute? Under what circumstances would the first argument be an 
> > > > `ImplicitParamDecl` but not an implicit this or self?
> > >
> > >
> > > For captured regions an outlined function is created, where all 
> > > parameters are ImplicitParamDecls. And the very first parameter is 
> > > wrongly treated as 'this' argument of the member function.
> >
> >
> > Ah, thank you! That makes sense to me, but it begs the question: why an 
> > attribute rather than a bit on ImplicitParamDecl?
>
>
> I agree: it would make more sense for ImplicitParamDecl to store a Kind that 
> would always be provided at construction.


Ok, will add a field to ImplicitParamDecl, thanks


https://reviews.llvm.org/D33735



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


[PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Correctly counting columns is a bit more complicated that that... for example, 
consider what happens if you replace `ideëen` with `idez̈en`.  See 
https://stackoverflow.com/questions/3634627/how-to-know-the-preferred-display-width-in-columns-of-unicode-characters
 .


https://reviews.llvm.org/D33765



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


[PATCH] D24371: Add diagnostics to require_constant_initialization

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

Sure, I'll commit it.


https://reviews.llvm.org/D24371



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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Galina Kistanova via cfe-commits
Hello Richard,

This commit broke tests on few of our builders:

Failing Tests (2):
Clang :: Modules/preprocess-module.cpp
Clang :: Modules/preprocess-nested.cpp

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10199
and
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2819

Please have a look at this?

Also I see that email notifications on these failures were sent.

Thanks

Galina


On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed May 31 15:56:55 2017
> New Revision: 304346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304346&view=rev
> Log:
> [modules] When compiling a preprocessed module map, look for headers
> relative
> to the original module map.
>
> Also use the path and name of the original module map when emitting that
> information into the .pcm file. The upshot of this is that the produced
> .pcm
> file will track information for headers in their original locations (where
> the
> module was preprocessed), not relative to whatever directory the
> preprocessed
> module map was in when it was built.
>
> Modified:
> cfe/trunk/include/clang/Basic/Module.h
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Frontend/FrontendAction.cpp
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
> cfe/trunk/test/Modules/preprocess-nested.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Module.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Module.h?rev=304346&r1=304345&r2=304346&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Module.h (original)
> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
> @@ -83,6 +83,10 @@ public:
>/// are found.
>const DirectoryEntry *Directory;
>
> +  /// \brief The presumed file name for the module map defining this
> module.
> +  /// Only non-empty when building from preprocessed source.
> +  std::string PresumedModuleMapFile;
> +
>/// \brief The umbrella header or directory.
>llvm::PointerUnion Umbrella;
>
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Lex/HeaderSearch.h?rev=304346&r1=304345&r2=304346&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
> @@ -543,10 +543,13 @@ public:
>/// \param Offset [inout] An offset within ID to start parsing. On exit,
>///filled by the end of the parsed contents (either EOF or the
>///location of an end-of-module-map pragma).
> -  ///
> +  /// \param OriginalModuleMapFile The original path to the module map
> file,
> +  ///used to resolve paths within the module (this is required
> when
> +  ///building the module from preprocessed source).
>/// \returns true if an error occurred, false otherwise.
>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
> - FileID ID = FileID(), unsigned *Offset =
> nullptr);
> + FileID ID = FileID(), unsigned *Offset = nullptr,
> + StringRef OriginalModuleMapFile = StringRef());
>
>/// \brief Collect the set of all known, top-level modules.
>///
>
> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/FrontendAction.cpp?rev=304346&r1=304345&r2=304346&view=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>return std::error_code();
>  }
>
> -static bool
> -loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename,
> -bool IsSystem, bool IsPreprocessed,
> -unsigned &Offset) {
> +static bool loadModuleMapForModuleBuild(CompilerInstance &CI,
> +StringRef Filename, bool IsSystem,
> +bool IsPreprocessed,
> +std::string
> &PresumedModuleMapFile,
> +unsigned &Offset) {
>auto &SrcMgr = CI.getSourceManager();
>HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();
>
> @@ -388,16 +389,15 @@ loadModuleMapForModuleBuild(CompilerInst
>// line directives are not part of the module map syntax in general.
>Offset = 0;
>if (IsPreprocessed) {
> -std::string PresumedMo

r304444 - Remove late nullptr pointer test (PR32447)

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 13:13:02 2017
New Revision: 30

URL: http://llvm.org/viewvc/llvm-project?rev=30&view=rev
Log:
Remove late nullptr pointer test (PR32447)

IgnoreNarrowingConversion should never return nullptr, but I've added an assert 
just in case.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=30&r1=304443&r2=30&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  1 13:13:02 2017
@@ -330,13 +330,13 @@ StandardConversionSequence::getNarrowing
 } else if (FromType->isIntegralType(Ctx) && ToType->isRealFloatingType()) {
   llvm::APSInt IntConstantValue;
   const Expr *Initializer = IgnoreNarrowingConversion(Converted);
+  assert(Initializer && "Unknown conversion expression");
 
   // If it's value-dependent, we can't tell whether it's narrowing.
   if (Initializer->isValueDependent())
 return NK_Dependent_Narrowing;
 
-  if (Initializer &&
-  Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) {
+  if (Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) {
 // Convert the integer to the floating type.
 llvm::APFloat Result(Ctx.getFloatTypeSemantics(ToType));
 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),


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


r304445 - Strip trailing whitespace. NFCI.

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 13:17:18 2017
New Revision: 304445

URL: http://llvm.org/viewvc/llvm-project?rev=304445&view=rev
Log:
Strip trailing whitespace. NFCI.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=304445&r1=30&r2=304445&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun  1 13:17:18 2017
@@ -49,12 +49,12 @@ static bool functionHasPassObjectSizePar
 static ExprResult
 CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl,
   bool HadMultipleCandidates,
-  SourceLocation Loc = SourceLocation(), 
+  SourceLocation Loc = SourceLocation(),
   const DeclarationNameLoc &LocInfo = 
DeclarationNameLoc()){
   if (S.DiagnoseUseOfDecl(FoundDecl, Loc))
-return ExprError(); 
+return ExprError();
   // If FoundDecl is different from Fn (such as if one is a template
-  // and the other a specialization), make sure DiagnoseUseOfDecl is 
+  // and the other a specialization), make sure DiagnoseUseOfDecl is
   // called on both.
   // FIXME: This would be more comprehensively addressed by modifying
   // DiagnoseUseOfDecl to accept both the FoundDecl and the decl
@@ -79,7 +79,7 @@ static bool IsStandardConversion(Sema &S
  bool CStyle,
  bool AllowObjCWritebackConversion);
 
-static bool IsTransparentUnionStandardConversion(Sema &S, Expr* From, 
+static bool IsTransparentUnionStandardConversion(Sema &S, Expr* From,
  QualType &ToType,
  bool InOverloadResolution,
  StandardConversionSequence 
&SCS,
@@ -852,7 +852,7 @@ namespace {
   Expr *Saved;
 };
 SmallVector Entries;
-
+
   public:
 void save(Sema &S, Expr *&E) {
   assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
@@ -863,7 +863,7 @@ namespace {
 
 void restore() {
   for (SmallVectorImpl::iterator
- i = Entries.begin(), e = Entries.end(); i != e; ++i) 
+ i = Entries.begin(), e = Entries.end(); i != e; ++i)
 *i->Addr = i->Saved;
 }
   };
@@ -1368,9 +1368,9 @@ Sema::TryImplicitConversion(Expr *From,
 bool InOverloadResolution,
 bool CStyle,
 bool AllowObjCWritebackConversion) {
-  return ::TryImplicitConversion(*this, From, ToType, 
+  return ::TryImplicitConversion(*this, From, ToType,
  SuppressUserConversions, AllowExplicit,
- InOverloadResolution, CStyle, 
+ InOverloadResolution, CStyle,
  AllowObjCWritebackConversion,
  /*AllowObjCConversionOnExplicit=*/false);
 }
@@ -1396,7 +1396,7 @@ Sema::PerformImplicitConversion(Expr *Fr
 
   // Objective-C ARC: Determine whether we will allow the writeback conversion.
   bool AllowObjCWritebackConversion
-= getLangOpts().ObjCAutoRefCount && 
+= getLangOpts().ObjCAutoRefCount &&
   (Action == AA_Passing || Action == AA_Sending);
   if (getLangOpts().ObjC1)
 CheckObjCBridgeRelatedConversions(From->getLocStart(),
@@ -1592,15 +1592,15 @@ static bool IsStandardConversion(Sema &S
 // if the function type matches except for [[noreturn]], it's ok
 if (!S.IsFunctionConversion(FromType,
   S.ExtractUnqualifiedFunctionType(ToType), resultTy))
-  // otherwise, only a boolean conversion is standard   
-  if (!ToType->isBooleanType()) 
-return false; 
+  // otherwise, only a boolean conversion is standard
+  if (!ToType->isBooleanType())
+return false;
   }
 
   // Check if the "from" expression is taking the address of an overloaded
   // function and recompute the FromType accordingly. Take advantage of the
   // fact that non-static member functions *must* have such an address-of
-  // expression. 
+  // expression.
   CXXMethodDecl *Method = dyn_cast(Fn);
   if (Method && !Method->isStatic()) {
 assert(isa(From->IgnoreParens()) &&
@@ -1638,7 +1638,7 @@ static bool IsStandardConversion(Sema &S
 SCS.First = ICK_Lvalue_To_Rvalue;
 
 // C11 6.3.2.1p2:
-//   ... if the lvalue has atomic type, the value has the non-atomic 
version 
+//   ... if the lvalue has atomic type, the value has the non-atomic 
version
 //   of the type of the lvalue ...
 if (const AtomicType *Atomic = FromType->getAs())
   FromType = Atomic->getValueType();
@@ -1890,12 +1890,12 @@ static bool I

Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-01 Thread Joerg Sonnenberger via cfe-commits
On Tue, Mar 14, 2017 at 04:00:53AM -, Akira Hatanaka via cfe-commits wrote:
> Author: ahatanak
> Date: Mon Mar 13 23:00:52 2017
> New Revision: 297702
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=297702&view=rev
> Log:
> [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
> correctly.

This results in asserts on the attached test case. Can you have a look,
please?

Joerg
typedef BOOL;
@interface FormatScanner {
  BOOL : 1;
}
@end
@implementation FormatScanner
@end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33726: [driver][netbsd] Build and pass `-L` arguments to the linker

2017-06-01 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

A small subset can be found by searching for LINKER_RPATH_FLAG in pkgsrc. A 
classic offender is Emacs. For more, I would have to systematically search.


Repository:
  rL LLVM

https://reviews.llvm.org/D33726



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


r304448 - Emit invariant.group.barrier when using union field

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 13:39:34 2017
New Revision: 304448

URL: http://llvm.org/viewvc/llvm-project?rev=304448&view=rev
Log:
Emit invariant.group.barrier when using union field

Summary:
We need to emit barrier if the union field
is CXXRecordDecl because it might have vptrs. The testcode
was wrongly devirtualized. It also proves that having different
groups for different dynamic types is not sufficient.

Reviewers: rjmccall, rsmith, mehdi_amini

Subscribers: amharc, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304448&r1=304447&r2=304448&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 13:39:34 2017
@@ -3530,6 +3530,25 @@ static Address emitAddrOfFieldStorage(Co
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto &Base : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   LValueBaseInfo BaseInfo = base.getBaseInfo();
@@ -3572,6 +3591,14 @@ LValue CodeGenFunction::EmitLValueForFie
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const auto FieldType = field->getType();
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+hasAnyVptr(FieldType, getContext()))
+  // Because unions can easily skip invariant.barriers, we need to add
+  // a barrier every time CXXRecord field with vptr is referenced.
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+ addr.getAlignment());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp?rev=304448&r1=304447&r2=304448&view=diff
==
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp Thu Jun  1 13:39:34 
2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 
-fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 
-fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,119 @@ struct DynamicFromStatic;
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(&u->b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(&u->a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs &noVptrs) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NE

[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-06-01 Thread Piotr Padlewski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304448: Emit invariant.group.barrier when using union field 
(authored by Prazek).

Changed prior to commit:
  https://reviews.llvm.org/D31830?vs=100977&id=101058#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31830

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Index: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,119 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(&u->b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(&u->a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs &noVptrs) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
+
+struct VirtualInBase : HoldingVirtuals, Empty {
+};
+
+struct VirtualInVBase : virtual Empty, virtual HoldingVirtuals {
+};
+
+// It has vtable by virtual inheritance.
+struct VirtualInheritance : virtual Empty {
+};
+
+union U3 {
+  VirtualInBase v1;
+  VirtualInBase v2;
+  VirtualInheritance v3;
+  int z;
+};
+
+void take(VirtualInBase &);
+void take(VirtualInVBase &);
+void take(VirtualInheritance &);
+
+void UnionsBarrier3(U3 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v1);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v2);
+
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR18VirtualInheritance(
+  take(u.v3);
+}
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -3530,6 +3530,25 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto &Base : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDec

r304449 - [CodeGen][ObjC] Fix assertion failure in EmitARCStoreStrongCall.

2017-06-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jun  1 13:41:25 2017
New Revision: 304449

URL: http://llvm.org/viewvc/llvm-project?rev=304449&view=rev
Log:
[CodeGen][ObjC] Fix assertion failure in EmitARCStoreStrongCall.

The assertion fails because EmitValueForIvarAtOffset doesn't get the
correct type of the ivar when the class the ivar belongs to is
parameterized. This commit fixes the function to compute the ivar's type
based on the type argument provided to the parameterized class.

rdar://problem/32461723

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

Modified:
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/test/CodeGenObjC/parameterized_classes.m

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=304449&r1=304448&r2=304449&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Thu Jun  1 13:41:25 2017
@@ -90,7 +90,11 @@ LValue CGObjCRuntime::EmitValueForIvarAt
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");

Modified: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/parameterized_classes.m?rev=304449&r1=304448&r2=304449&view=diff
==
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m (original)
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m Thu Jun  1 13:41:25 2017
@@ -68,3 +68,31 @@ void blockTest(NSMutableArray : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end


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


[PATCH] D33698: [CodeGen][ObjC] Fix assertion failure in CodeGenFunction::EmitARCStoreStrongCall

2017-06-01 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304449: [CodeGen][ObjC] Fix assertion failure in 
EmitARCStoreStrongCall. (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D33698?vs=100787&id=101060#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33698

Files:
  cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
  cfe/trunk/test/CodeGenObjC/parameterized_classes.m


Index: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
===
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m
@@ -68,3 +68,31 @@
   // CHECK: call i8* @objc_retainBlock
   // CHECK: ret void
 }
+
+// CHECK-LABEL: define internal void @"\01-[Derived setDest:]
+// CHECK: %[[SELFADDR:.*]] = alloca %[[SELFTY:.*]]*
+// CHECK: %[[AADDR:.*]] = alloca %[[IVARTY:.*]]*
+// CHECK: %[[V2:.*]] = load %[[IVARTY]]*, %[[IVARTY]]** %[[AADDR]]
+// CHECK: %[[V3:.*]] = load %[[SELFTY]]*, %[[SELFTY]]** %[[SELFADDR]]
+// CHECK: %[[IVAR:.*]] = load i64, i64* @"OBJC_IVAR_$_Base._destination"
+// CHECK: %[[V4:.*]] = bitcast %[[SELFTY]]* %[[V3]] to i8*
+// CHECK: %[[ADDPTR:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 
%[[IVAR]]
+// CHECK: %[[V5:.*]] = bitcast i8* %[[ADDPTR]] to %[[IVARTY]]**
+// CHECK: %[[V6:.*]] = bitcast %[[IVARTY]]** %[[V5]] to i8**
+// CHECK: %[[V7:.*]] = bitcast %[[IVARTY]]* %[[V2]] to i8*
+// CHECK: call void @objc_storeStrong(i8** %[[V6]], i8* %[[V7]])
+
+@interface Base : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end
Index: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
@@ -90,7 +90,11 @@
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");


Index: cfe/trunk/test/CodeGenObjC/parameterized_classes.m
===
--- cfe/trunk/test/CodeGenObjC/parameterized_classes.m
+++ cfe/trunk/test/CodeGenObjC/parameterized_classes.m
@@ -68,3 +68,31 @@
   // CHECK: call i8* @objc_retainBlock
   // CHECK: ret void
 }
+
+// CHECK-LABEL: define internal void @"\01-[Derived setDest:]
+// CHECK: %[[SELFADDR:.*]] = alloca %[[SELFTY:.*]]*
+// CHECK: %[[AADDR:.*]] = alloca %[[IVARTY:.*]]*
+// CHECK: %[[V2:.*]] = load %[[IVARTY]]*, %[[IVARTY]]** %[[AADDR]]
+// CHECK: %[[V3:.*]] = load %[[SELFTY]]*, %[[SELFTY]]** %[[SELFADDR]]
+// CHECK: %[[IVAR:.*]] = load i64, i64* @"OBJC_IVAR_$_Base._destination"
+// CHECK: %[[V4:.*]] = bitcast %[[SELFTY]]* %[[V3]] to i8*
+// CHECK: %[[ADDPTR:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 %[[IVAR]]
+// CHECK: %[[V5:.*]] = bitcast i8* %[[ADDPTR]] to %[[IVARTY]]**
+// CHECK: %[[V6:.*]] = bitcast %[[IVARTY]]** %[[V5]] to i8**
+// CHECK: %[[V7:.*]] = bitcast %[[IVARTY]]* %[[V2]] to i8*
+// CHECK: call void @objc_storeStrong(i8** %[[V6]], i8* %[[V7]])
+
+@interface Base : NSObject {
+  DestType _destination;
+}
+@end
+
+@interface Derived : Base
+- (void)setDest:(NSObject *)a;
+@end
+
+@implementation Derived
+- (void)setDest:(NSObject *)a {
+  _destination = a;
+}
+@end
Index: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
@@ -90,7 +90,11 @@
unsigned CVRQualifiers,
llvm::Value *Offset) {
   // Compute (type*) ( (char *) BaseValue + Offset)
-  QualType IvarTy = Ivar->getType().withCVRQualifiers(CVRQualifiers);
+  QualType InterfaceTy{OID->getTypeForDecl(), 0};
+  QualType ObjectPtrTy =
+  CGF.CGM.getContext().getObjCObjectPointerType(InterfaceTy);
+  QualType IvarTy =
+  Ivar->getUsageType(ObjectPtrTy).withCVRQualifiers(CVRQualifiers);
   llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
   llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, CGF.Int8PtrTy);
   V = CGF.Builder.CreateInBoundsGEP(V, Offset, "add.ptr");
___
cfe-commits mailin

[libcxx] r304450 - Remove ubsan XFAILS in two tests

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 13:48:27 2017
New Revision: 304450

URL: http://llvm.org/viewvc/llvm-project?rev=304450&view=rev
Log:
Remove ubsan XFAILS in two tests

These two tests are ubsan-clean now:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/3553/

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304450&r1=304449&r2=304450&view=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Thu Jun  1 13:48:27 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// FIXME: When run under UBSAN this test hits an assertion inside Clang
-// XFAIL: ubsan
-
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304450&r1=304449&r2=304450&view=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Thu Jun  1 13:48:27 2017
@@ -10,9 +10,6 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
-// FIXME: When run under UBSAN this test hits an assertion inside Clang
-// XFAIL: ubsan
-
 #include 
 #include 
 #include 


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


[PATCH] D24371: Add diagnostics to require_constant_initialization

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304451: [SemaCXX] Add diagnostics to 
require_constant_initialization (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D24371?vs=100949&id=101066#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24371

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp

Index: cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
===
--- cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
+++ cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
@@ -7,9 +7,9 @@
 
 #define ATTR __attribute__((require_constant_initialization)) // expected-note 0+ {{expanded from macro}}
 
-int ReturnInt();
+int ReturnInt(); // expected-note 0+ {{declared here}}
 
-struct PODType {
+struct PODType { // expected-note 0+ {{declared here}}
   int value;
   int value2;
 };
@@ -20,20 +20,20 @@
 struct LitType {
   constexpr LitType() : value(0) {}
   constexpr LitType(int x) : value(x) {}
-  LitType(void *) : value(-1) {}
+  LitType(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   int value;
 };
 #endif
 
-struct NonLit {
+struct NonLit { // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201402L
   constexpr NonLit() : value(0) {}
   constexpr NonLit(int x) : value(x) {}
 #else
-  NonLit() : value(0) {}
+  NonLit() : value(0) {} // expected-note 0+ {{declared here}}
   NonLit(int x) : value(x) {}
 #endif
-  NonLit(void *) : value(-1) {}
+  NonLit(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   ~NonLit() {}
   int value;
 };
@@ -43,7 +43,7 @@
   constexpr StoresNonLit() : obj() {}
   constexpr StoresNonLit(int x) : obj(x) {}
 #else
-  StoresNonLit() : obj() {}
+  StoresNonLit() : obj() {} // expected-note 0+ {{declared here}}
   StoresNonLit(int x) : obj(x) {}
 #endif
   StoresNonLit(void *p) : obj(p) {}
@@ -82,23 +82,44 @@
   const int non_global = 42;
   ATTR static const int &local_init = non_global; // expected-error {{variable does not have a constant initializer}}
   // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{reference to 'non_global' is not a constant expression}}
+  // expected-note@-5 {{declared here}}
+#else
+  // expected-note@-6 {{subexpression not valid in a constant expression}}
+#endif
   ATTR static const int &global_init = glvalue_int;
   ATTR static const int &temp_init = 42;
 }
 
 ATTR const int &temp_ref = 42;
 ATTR const int &temp_ref2 = ReturnInt(); // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 ATTR const NonLit &nl_temp_ref = 42; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-literal type 'const NonLit' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 #if __cplusplus >= 201103L
 ATTR const LitType &lit_temp_ref = 42;
 ATTR const int &subobj_ref = LitType{}.value;
 #endif
 
 ATTR const int &nl_subobj_ref = NonLit().value; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+#if __cplusplus >= 201103L
+// expected-note-re@-3 {{non-literal type '{{.*}}' cannot be used in a constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 
 struct TT1 {
   ATTR static const int &no_init;
@@ -116,6 +137,8 @@
 #if __cplusplus >= 201103L
 thread_local const int &TT1::tl_glvalue_init = glvalue_int;
 thread_local const int &TT1::tl_temp_init = 42; // expected-error {{variable does not have a constant initializer}}
+// expected-note@-1 {{reference to temporary is not a constant expression}}
+// expected-note@-2 {{temporary created here}}
 #endif
 
 // [basic.start.static]p2.2
@@ -129,17 +152,25 @@
 #else
   ATTR static PODType pod; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute here}}
+// expected-note@-2 {{non-constexpr constructor 'PODType' cannot be used in a constant expression}}
 #endif
   ATTR static PODType pot2 = {ReturnInt()}; // expected-error {{variable does not have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute her

r304451 - [SemaCXX] Add diagnostics to require_constant_initialization

2017-06-01 Thread Keno Fischer via cfe-commits
Author: kfischer
Date: Thu Jun  1 13:54:16 2017
New Revision: 304451

URL: http://llvm.org/viewvc/llvm-project?rev=304451&view=rev
Log:
[SemaCXX] Add diagnostics to require_constant_initialization

Summary:
This hooks up the detailed diagnostics of why constant initialization was
not possible if require_constant_initialization reports an error.
I have updated the test to account for the new notes.

Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D24371

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304451&r1=304450&r2=304451&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun  1 13:54:16 2017
@@ -6,6 +6,17 @@ void Sema::CheckCompleteVariableDeclarat
   << Init->getSourceRange();
 Diag(attr->getLocation(), 
diag::note_declared_required_constant_init_here)
   << attr->getRange();
+if (getLangOpts().CPlusPlus11) {
+  APValue Value;
+  SmallVector Notes;
+  Init->EvaluateAsInitializer(Value, getASTContext(), var, Notes);
+  for (auto &it : Notes)
+Diag(it.first, it.second);
+} else {
+  Diag(CacheCulprit->getExprLoc(),
+   diag::note_invalid_subexpr_in_const_expr)
+  << CacheCulprit->getSourceRange();
+}
   }
 }
 else if (!var->isConstexpr() && IsGlobal &&

Modified: cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp?rev=304451&r1=304450&r2=304451&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-require-constant-initialization.cpp Thu Jun  1 
13:54:16 2017
@@ -7,9 +7,9 @@
 
 #define ATTR __attribute__((require_constant_initialization)) // expected-note 
0+ {{expanded from macro}}
 
-int ReturnInt();
+int ReturnInt(); // expected-note 0+ {{declared here}}
 
-struct PODType {
+struct PODType { // expected-note 0+ {{declared here}}
   int value;
   int value2;
 };
@@ -20,20 +20,20 @@ struct PODType {
 struct LitType {
   constexpr LitType() : value(0) {}
   constexpr LitType(int x) : value(x) {}
-  LitType(void *) : value(-1) {}
+  LitType(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   int value;
 };
 #endif
 
-struct NonLit {
+struct NonLit { // expected-note 0+ {{declared here}}
 #if __cplusplus >= 201402L
   constexpr NonLit() : value(0) {}
   constexpr NonLit(int x) : value(x) {}
 #else
-  NonLit() : value(0) {}
+  NonLit() : value(0) {} // expected-note 0+ {{declared here}}
   NonLit(int x) : value(x) {}
 #endif
-  NonLit(void *) : value(-1) {}
+  NonLit(void *) : value(-1) {} // expected-note 0+ {{declared here}}
   ~NonLit() {}
   int value;
 };
@@ -43,7 +43,7 @@ struct StoresNonLit {
   constexpr StoresNonLit() : obj() {}
   constexpr StoresNonLit(int x) : obj(x) {}
 #else
-  StoresNonLit() : obj() {}
+  StoresNonLit() : obj() {} // expected-note 0+ {{declared here}}
   StoresNonLit(int x) : obj(x) {}
 #endif
   StoresNonLit(void *p) : obj(p) {}
@@ -82,6 +82,12 @@ void test_basic_start_static_2_1() {
   const int non_global = 42;
   ATTR static const int &local_init = non_global; // expected-error {{variable 
does not have a constant initializer}}
   // expected-note@-1 {{required by 'require_constant_initialization' 
attribute here}}
+#if __cplusplus >= 201103L
+  // expected-note@-3 {{reference to 'non_global' is not a constant 
expression}}
+  // expected-note@-5 {{declared here}}
+#else
+  // expected-note@-6 {{subexpression not valid in a constant expression}}
+#endif
   ATTR static const int &global_init = glvalue_int;
   ATTR static const int &temp_init = 42;
 }
@@ -89,8 +95,18 @@ void test_basic_start_static_2_1() {
 ATTR const int &temp_ref = 42;
 ATTR const int &temp_ref2 = ReturnInt(); // expected-error {{variable does not 
have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute 
here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-constexpr function 'ReturnInt' cannot be used in a 
constant expression}}
+#else
+// expected-note@-5 {{subexpression not valid in a constant expression}}
+#endif
 ATTR const NonLit &nl_temp_ref = 42; // expected-error {{variable does not 
have a constant initializer}}
 // expected-note@-1 {{required by 'require_constant_initialization' attribute 
here}}
+#if __cplusplus >= 201103L
+// expected-note@-3 {{non-literal type 'const NonLit' cannot be used in a 
constant expression}}
+#else
+// expected-note@-5 {{subexpression not val

[PATCH] D33706: CodeGen: Cast temporary variable to proper address space

2017-06-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 101070.
yaxunl marked 2 inline comments as done.
yaxunl retitled this revision from "[AMDGPU] Fix address space for global and 
temporary variables in C++" to "CodeGen: Cast temporary variable to proper 
address space".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Keep changes for temporary variables only.


https://reviews.llvm.org/D33706

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/address-space.c
  test/CodeGen/default-address-space.c
  test/CodeGenCXX/amdgcn-automatic-variable.cpp

Index: test/CodeGenCXX/amdgcn-automatic-variable.cpp
===
--- test/CodeGenCXX/amdgcn-automatic-variable.cpp
+++ test/CodeGenCXX/amdgcn-automatic-variable.cpp
@@ -3,9 +3,10 @@
 // CHECK-LABEL: define void @_Z5func1Pi(i32* %x)
 void func1(int *x) {
   // CHECK: %[[x_addr:.*]] = alloca i32*{{.*}}addrspace(5)
-  // CHECK: store i32* %x, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[x_addr]]
-  // CHECK: store i32 1, i32* %[[r0]]
+  // CHECK: %[[r0:.*]] = addrspacecast i32* addrspace(5)* %[[x_addr]] to i32**
+  // CHECK: store i32* %x, i32** %[[r0]]
+  // CHECK: %[[r1:.*]] = load i32*, i32** %[[r0]]
+  // CHECK: store i32 1, i32* %[[r1]]
   *x = 1;
 }
 
@@ -70,3 +71,12 @@
   // CHECK: call void @_ZN1AD1Ev(%class.A* %[[r0]])
   A a;
 }
+
+// CHECK-LABEL: define void @_Z5func4i
+void func4(int x) {
+  // CHECK: %[[x_addr:.*]] = alloca i32, align 4, addrspace(5)
+  // CHECK: %[[r0:.*]] = addrspacecast i32 addrspace(5)* %[[x_addr]] to i32*
+  // CHECK: store i32 %x, i32* %[[r0]], align 4
+  // CHECK: call void @_Z5func1Pi(i32* %[[r0]])
+  func1(&x);
+}
Index: test/CodeGen/default-address-space.c
===
--- test/CodeGen/default-address-space.c
+++ test/CodeGen/default-address-space.c
@@ -22,9 +22,10 @@
 int test1() { return foo; }
 
 // COM-LABEL: define i32 @test2(i32 %i)
-// PIZ: load i32, i32 addrspace(4)*
+// COM: %[[addr:.*]] = getelementptr
+// PIZ: load i32, i32 addrspace(4)* %[[addr]]
 // PIZ-NEXT: ret i32
-// CHECK: load i32, i32*
+// CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
@@ -42,15 +43,17 @@
 }
 
 // PIZ-LABEL: define void @test4(i32 addrspace(4)* %a)
-// PIZ: %[[a_addr:.*]] = alloca i32 addrspace(4)*
-// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]]
-// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]]
+// PIZ: %[[alloca:.*]] = alloca i32 addrspace(4)*
+// PIZ: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32 addrspace(4)* addrspace(4)*
+// PIZ: store i32 addrspace(4)* %a, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
+// PIZ: %[[r0:.*]] = load i32 addrspace(4)*, i32 addrspace(4)* addrspace(4)* %[[a_addr]]
 // PIZ: %[[arrayidx:.*]] = getelementptr inbounds i32, i32 addrspace(4)* %[[r0]]
 // PIZ: store i32 0, i32 addrspace(4)* %[[arrayidx]]
 // CHECK-LABEL: define void @test4(i32* %a)
-// CHECK: %[[a_addr:.*]] = alloca i32*, align 4, addrspace(5)
-// CHECK: store i32* %a, i32* addrspace(5)* %[[a_addr]]
-// CHECK: %[[r0:.*]] = load i32*, i32* addrspace(5)* %[[a_addr]]
+// CHECK: %[[alloca:.*]] = alloca i32*, align 4, addrspace(5)
+// CHECK: %[[a_addr:.*]] = addrspacecast{{.*}} %[[alloca]] to i32**
+// CHECK: store i32* %a, i32** %[[a_addr]]
+// CHECK: %[[r0:.*]] = load i32*, i32** %[[a_addr]]
 // CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, i32* %[[r0]]
 // CHECK: store i32 0, i32* %[[arrayidx]]
 void test4(int *a) {
Index: test/CodeGen/address-space.c
===
--- test/CodeGen/address-space.c
+++ test/CodeGen/address-space.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -check-prefixes=CHECK,X86,GIZ %s
 // RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -check-prefixes=CHECK,PIZ %s
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,GIZ %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK,AMDGIZ,GIZ %s
 
 // CHECK: @foo = common addrspace(1) global
 int foo __attribute__((address_space(1)));
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1915,13 +1915,32 @@
 LValueBaseInfo *BaseInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
-  /// CreateTempAlloca - This creates a alloca and inserts it into the entry
-  /// block. The caller is responsible for setting an appropriate alignment on
+  /// CreateTempAlloca - Th

r304455 - Fixed broken test (strict-vtable-pointers)

2017-06-01 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Thu Jun  1 14:08:05 2017
New Revision: 304455

URL: http://llvm.org/viewvc/llvm-project?rev=304455&view=rev
Log:
Fixed broken test (strict-vtable-pointers)

Modified:
cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp

Modified: cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp?rev=304455&r1=304454&r2=304455&view=diff
==
--- cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/strict-vtable-pointers.cpp Thu Jun  1 14:08:05 
2017
@@ -209,7 +209,7 @@ void UnionsBarriers(U *u) {
   // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
   // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
   g2(&u->b);
-  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* 
   changeToA(u);
   // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
   // call void @_Z2g2P1A(%struct.A* %a)


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


r304456 - Add compatibility alias for -Wno-#warnings

2017-06-01 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jun  1 14:08:34 2017
New Revision: 304456

URL: http://llvm.org/viewvc/llvm-project?rev=304456&view=rev
Log:
Add compatibility alias for -Wno-#warnings

GCC uses -Wno-cpp for this, so seems reasonable to add an alias to
match.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/test/Misc/diag-mapping2.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=304456&r1=304455&r2=304456&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Jun  1 14:08:34 2017
@@ -733,6 +733,7 @@ def Pedantic : DiagGroup<"pedantic">;
 // Aliases.
 def : DiagGroup<"", [Extra]>;   // -W = -Wextra
 def : DiagGroup<"endif-labels", [ExtraTokens]>; // 
-Wendif-labels=-Wextra-tokens
+def : DiagGroup<"cpp", [PoundWarning]>; // -Wcpp = -W#warnings
 def : DiagGroup<"comments", [Comment]>; // -Wcomments = -Wcomment
 def : DiagGroup<"conversion-null",
 [NullConversion]>; // -Wconversion-null = -Wnull-conversion

Modified: cfe/trunk/test/Misc/diag-mapping2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-mapping2.c?rev=304456&r1=304455&r2=304456&view=diff
==
--- cfe/trunk/test/Misc/diag-mapping2.c (original)
+++ cfe/trunk/test/Misc/diag-mapping2.c Thu Jun  1 14:08:34 2017
@@ -4,6 +4,7 @@
 // This should not emit anything.
 // RUN: %clang_cc1 %s -w 2>&1 | not grep diagnostic
 // RUN: %clang_cc1 %s -Wno-#warnings 2>&1 | not grep diagnostic
+// RUN: %clang_cc1 %s -Wno-cpp 2>&1 | not grep diagnostic
 
 // -Werror can map all warnings to error.
 // RUN: not %clang_cc1 %s -Werror 2>&1 | grep "error: foo"


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


[PATCH] D31972: Do not force the frame pointer by default for ARM EABI

2017-06-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:569
 
+  if (Triple.getEnvironment() == llvm::Triple::EABI) {
+switch (Triple.getArch()) {

chrib wrote:
> efriedma wrote:
> > Specifically checking for "llvm::Triple::EABI" is suspicious... what are 
> > you trying to distinguish?
> I'm targeting the AAPCS for bare toolsets, (we could also test EABIHF by the 
> way)
> 
> I'm not sure about the other ABIs (such as llvm::Triple::OpenBSD) so it is 
> probably conservative and stick to what I can test. Do you think this 
> pertains to more, for instance to AAPCS-LINUX, without breaking anything ?
> 
So... something like isTargetAEABI() in ARMSubtarget.h?

Please clarify the comment, and add a check for EABIHF.


https://reviews.llvm.org/D31972



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


r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 14:22:18 2017
New Revision: 304459

URL: http://llvm.org/viewvc/llvm-project?rev=304459&view=rev
Log:
[ubsan] Add a check for pointer overflow UB

Check pointer arithmetic for overflow.

For some more background on this check, see:

  https://wdtz.org/catching-pointer-overflow-bugs.html
  https://reviews.llvm.org/D20322

Patch by Will Dietz and John Regehr!

This version of the patch is different from the original in a few ways:

  - It introduces the EmitCheckedInBoundsGEP utility which inserts
checks when the pointer overflow check is enabled.

  - It does some constant-folding to reduce instrumentation overhead.

  - It does not check some GEPs in CGExprCXX. I'm not sure that
inserting checks here, or in CGClass, would catch many bugs.

Possible future directions for this check:

  - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
accessing structures.

Testing: Apart from the added lit test, I ran check-llvm and check-clang
with a stage2, ubsan-instrumented clang. Will and John have also done
extensive testing on numerous open source projects.

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

Added:
cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459&r1=304458&r2=304459&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
@@ -106,6 +106,8 @@ Available checks are:
  invalid pointers. These checks are made in terms of
  ``__builtin_object_size``, and consequently may be able to detect more
  problems at higher optimization levels.
+  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
+ overflows.
   -  ``-fsanitize=return``: In C++, reaching the end of a
  value-returning function without returning a value.
   -  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459&r1=304458&r2=304459&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
@@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
 SANITIZER_GROUP("nullability", Nullability,
 NullabilityArg | NullabilityAssign | NullabilityReturn)
 SANITIZER("object-size", ObjectSize)
+SANITIZER("pointer-overflow", PointerOverflow)
 SANITIZER("return", Return)
 SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
 SANITIZER("shift-base", ShiftBase)
@@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
 SANITIZER_GROUP("undefined", Undefined,
 Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
 FloatDivideByZero | IntegerDivideByZero | NonnullAttribute 
|
-Null | ObjectSize | Return | ReturnsNonnullAttribute |
-Shift | SignedIntegerOverflow | Unreachable | VLABound |
-Function | Vptr)
+Null | ObjectSize | PointerOverflow | Return |
+ReturnsNonnullAttribute | Shift | SignedIntegerOverflow |
+Unreachable | VLABound | Function | Vptr)
 
 // -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
 SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304459&r1=304458&r2=304459&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 14:22:18 2017
@@ -3002,9 +3002,10 @@ static llvm::Value *emitArraySubscriptGE
   llvm::Value *ptr,
   ArrayRef indices,
   bool inbounds,
+  SourceLocation loc,
 const llvm::Twine &name = "arrayidx") {
   if (inbounds) {
-return CGF.Builder.CreateInBoundsGEP(ptr, indices, name);
+return CGF.EmitCheckedInBoundsGEP(ptr, indices, loc, name);
   } else {
 return CGF.Builder.CreateGEP(ptr, indices, name);
   }
@@ -3035,8 +3036,9 @@ static QualType getFixedSizeEleme

[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304459: [ubsan] Add a check for pointer overflow UB 
(authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D33305?vs=100475&id=101078#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33305

Files:
  cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
  cfe/trunk/include/clang/Basic/Sanitizers.def
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
  cfe/trunk/test/Driver/fsanitize.c

Index: cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
===
--- cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
+++ cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -w -emit-llvm -o - %s -fsanitize=pointer-overflow | FileCheck %s
+
+// CHECK-LABEL: define void @unary_arith
+void unary_arith(char *p) {
+  // CHECK:  [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], 1, !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 true, i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 true, [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  ++p;
+
+  // CHECK: ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: add i64 {{.*}}, -1, !nosanitize
+  // CHECK: select i1 false{{.*}}, !nosanitize
+  // CHECK-NEXT: and i1 true{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  --p;
+
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p++;
+
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p--;
+}
+
+// CHECK-LABEL: define void @binary_arith
+void binary_arith(char *p, int i) {
+  // CHECK: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %{{.*}}), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  p + i;
+
+  // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
+  // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p - i;
+}
+
+// CHECK-LABEL: define void @fixed_len_array
+void fixed_len_array(int k) {
+  // CHECK: getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* [[ARR:%.*]], i64 0, i64 [[IDXPROM:%.*]]
+  // CHECK-NEXT: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 40, i64 [[IDXPROM]]), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint [10 x [10 x i32]]* [[ARR]] to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[C

Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 11:10, Galina Kistanova  wrote:

> Hello Richard,
>
> This commit broke tests on few of our builders:
>
> Failing Tests (2):
> Clang :: Modules/preprocess-module.cpp
> Clang :: Modules/preprocess-nested.cpp
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
> scei-ps4-windows10pro-fast/builds/10199
> and
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensiv
> e-checks-win/builds/2819
>
> Please have a look at this?
>

Sure, looking.


> Also I see that email notifications on these failures were sent.
>

They certainly did not arrive here. As I've mentioned before, I have not
received any mail from any lab.llvm.org bots since early March.


> Thanks
>
> Galina
>
>
> On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed May 31 15:56:55 2017
>> New Revision: 304346
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304346&view=rev
>> Log:
>> [modules] When compiling a preprocessed module map, look for headers
>> relative
>> to the original module map.
>>
>> Also use the path and name of the original module map when emitting that
>> information into the .pcm file. The upshot of this is that the produced
>> .pcm
>> file will track information for headers in their original locations
>> (where the
>> module was preprocessed), not relative to whatever directory the
>> preprocessed
>> module map was in when it was built.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Module.h
>> cfe/trunk/include/clang/Lex/HeaderSearch.h
>> cfe/trunk/lib/Frontend/FrontendAction.cpp
>> cfe/trunk/lib/Lex/HeaderSearch.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/test/Modules/preprocess-module.cpp
>> cfe/trunk/test/Modules/preprocess-nested.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Module.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/Module.h?rev=304346&r1=304345&r2=304346&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/Module.h (original)
>> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
>> @@ -83,6 +83,10 @@ public:
>>/// are found.
>>const DirectoryEntry *Directory;
>>
>> +  /// \brief The presumed file name for the module map defining this
>> module.
>> +  /// Only non-empty when building from preprocessed source.
>> +  std::string PresumedModuleMapFile;
>> +
>>/// \brief The umbrella header or directory.
>>llvm::PointerUnion Umbrella;
>>
>>
>> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Lex/HeaderSearch.h?rev=304346&r1=304345&r2=304346&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
>> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
>> @@ -543,10 +543,13 @@ public:
>>/// \param Offset [inout] An offset within ID to start parsing. On
>> exit,
>>///filled by the end of the parsed contents (either EOF or the
>>///location of an end-of-module-map pragma).
>> -  ///
>> +  /// \param OriginalModuleMapFile The original path to the module map
>> file,
>> +  ///used to resolve paths within the module (this is required
>> when
>> +  ///building the module from preprocessed source).
>>/// \returns true if an error occurred, false otherwise.
>>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
>> - FileID ID = FileID(), unsigned *Offset =
>> nullptr);
>> + FileID ID = FileID(), unsigned *Offset =
>> nullptr,
>> + StringRef OriginalModuleMapFile = StringRef());
>>
>>/// \brief Collect the set of all known, top-level modules.
>>///
>>
>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/F
>> rontendAction.cpp?rev=304346&r1=304345&r2=304346&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
>> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>>return std::error_code();
>>  }
>>
>> -static bool
>> -loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename,
>> -bool IsSystem, bool IsPreprocessed,
>> -unsigned &Offset) {
>> +static bool loadModuleMapForModuleBuild(CompilerInstance &CI,
>> +StringRef Filename, bool
>> IsSystem,
>> +bool IsPreprocessed,
>> +std::string
>> &PresumedModuleMapFile,
>> +   

[libcxx] r304462 - Mark two coroutine tests as unsupported under ubsan

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 15:00:40 2017
New Revision: 304462

URL: http://llvm.org/viewvc/llvm-project?rev=304462&view=rev
Log:
Mark two coroutine tests as unsupported under ubsan

They appear to crash inside of SelectionDAG on some Linux bots, when
ubsan is enabled.

https://bugs.llvm.org/show_bug.cgi?id=33271

Modified:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp?rev=304462&r1=304461&r2=304462&view=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
 Thu Jun  1 15:00:40 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp?rev=304462&r1=304461&r2=304462&view=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
 Thu Jun  1 15:00:40 2017
@@ -10,6 +10,9 @@
 
 // UNSUPPORTED: c++98, c++03, c++11
 
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
 #include 
 #include 
 #include 


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


r304463 - [Modules] Handle sanitizer feature mismatches when importing modules

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 15:01:01 2017
New Revision: 304463

URL: http://llvm.org/viewvc/llvm-project?rev=304463&view=rev
Log:
[Modules] Handle sanitizer feature mismatches when importing modules

This patch makes it an error to have a mismatch between the enabled
sanitizers in a CU, and in any module being imported into the CU. Only
mismatches between non-modular sanitizers are treated as errors.

This patch also includes non-modular sanitizers in module hashes, in
order to ensure module rebuilds occur when -fsanitize=X is toggled on
and off for non-modular sanitizers, and to cut down on module rebuilds
when the option is toggled for modular sanitizers.

This fixes a longstanding issue with implicit modules and sanitizers,
which Duncan originally diagnosed.

When building with implicit modules it's possible to hit a scenario
where modules are built without -fsanitize=address, and are subsequently
imported into CUs with -fsanitize=address enabled. This causes strange
failures at runtime. The case Duncan found affects libcxx, since its
vector implementation behaves differently when ASan is enabled.

Implicit module builds should "just work" when -fsanitize=X is toggled
on and off across multiple compiler invocations, which is what this
patch does.

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

Added:
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/check.h
cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map
cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
Modified:
cfe/trunk/include/clang/Basic/Sanitizers.h
cfe/trunk/lib/Basic/LangOptions.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/Sanitizers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.h?rev=304463&r1=304462&r2=304463&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.h (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.h Thu Jun  1 15:01:01 2017
@@ -61,8 +61,8 @@ struct SanitizerSet {
 Mask = Value ? (Mask | K) : (Mask & ~K);
   }
 
-  /// \brief Disable all sanitizers.
-  void clear() { Mask = 0; }
+  /// Disable the sanitizers specified in \p K.
+  void clear(SanitizerMask K = SanitizerKind::All) { Mask &= ~K; }
 
   /// \brief Returns true if at least one sanitizer is enabled.
   bool empty() const { return Mask == 0; }
@@ -79,6 +79,12 @@ SanitizerMask parseSanitizerValue(String
 /// this group enables.
 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
 
+/// Return the sanitizers which do not affect preprocessing.
+static inline SanitizerMask getPPTransparentSanitizers() {
+  return SanitizerKind::CFI | SanitizerKind::Integer |
+ SanitizerKind::Nullability | SanitizerKind::Undefined;
+}
+
 }  // end namespace clang
 
 #endif

Modified: cfe/trunk/lib/Basic/LangOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=304463&r1=304462&r2=304463&view=diff
==
--- cfe/trunk/lib/Basic/LangOptions.cpp (original)
+++ cfe/trunk/lib/Basic/LangOptions.cpp Thu Jun  1 15:01:01 2017
@@ -29,9 +29,7 @@ void LangOptions::resetNonModularOptions
   Name = Default;
 #include "clang/Basic/LangOptions.def"
 
-  // FIXME: This should not be reset; modules can be different with different
-  // sanitizer options (this affects __has_feature(address_sanitizer) etc).
-  Sanitize.clear();
+  // These options do not affect AST generation.
   SanitizerBlacklistFiles.clear();
   XRayAlwaysInstrumentFiles.clear();
   XRayNeverInstrumentFiles.clear();

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=304463&r1=304462&r2=304463&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun  1 15:01:01 2017
@@ -2700,6 +2700,13 @@ std::string CompilerInvocation::getModul
 code = ext->hashExtension(code);
   }
 
+  // Extend the signature with the enabled sanitizers, if at least one is
+  // enabled. Sanitizers which cannot affect AST generation aren't hashed.
+  SanitizerSet SanHash = LangOpts->Sanitize;
+  SanHash.clear(getPPTransparentSanitizers());
+  if (!SanHash.empty())
+code = hash_combine(code, SanHash.Mask);
+
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304463&r1=304462&r2=304463&view=diff
==
--- cfe/trunk/lib/Serializa

[PATCH] D32724: [Modules] Handle sanitizer feature mismatches when importing modules

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304463: [Modules] Handle sanitizer feature mismatches when 
importing modules (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D32724?vs=98371&id=101088#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32724

Files:
  cfe/trunk/include/clang/Basic/Sanitizers.h
  cfe/trunk/lib/Basic/LangOptions.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/check.h
  cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map
  cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp

Index: cfe/trunk/include/clang/Basic/Sanitizers.h
===
--- cfe/trunk/include/clang/Basic/Sanitizers.h
+++ cfe/trunk/include/clang/Basic/Sanitizers.h
@@ -61,8 +61,8 @@
 Mask = Value ? (Mask | K) : (Mask & ~K);
   }
 
-  /// \brief Disable all sanitizers.
-  void clear() { Mask = 0; }
+  /// Disable the sanitizers specified in \p K.
+  void clear(SanitizerMask K = SanitizerKind::All) { Mask &= ~K; }
 
   /// \brief Returns true if at least one sanitizer is enabled.
   bool empty() const { return Mask == 0; }
@@ -79,6 +79,12 @@
 /// this group enables.
 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
 
+/// Return the sanitizers which do not affect preprocessing.
+static inline SanitizerMask getPPTransparentSanitizers() {
+  return SanitizerKind::CFI | SanitizerKind::Integer |
+ SanitizerKind::Nullability | SanitizerKind::Undefined;
+}
+
 }  // end namespace clang
 
 #endif
Index: cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
===
--- cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
+++ cfe/trunk/test/Modules/check-for-sanitizer-feature.cpp
@@ -0,0 +1,66 @@
+// RUN: rm -rf %t.1 %t.2
+// RUN: mkdir %t.1 %t.2
+
+// Build and use an ASan-enabled module.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 2
+
+// Force a module rebuild by disabling ASan.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Enable ASan again: check that there is no import failure, and no rebuild.
+// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.1 | count 3
+
+// Some sanitizers can not affect AST generation when enabled. Check that
+// module rebuilds don't occur when these sanitizers are enabled.
+//
+// First, build without any sanitization.
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+//
+// Next, build with sanitization, and check that a new module isn't built.
+// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \
+// RUN:   -fmodules-cache-path=%t.2 \
+// RUN:   -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \
+// RUN:   -I %S/Inputs/check-for-sanitizer-feature -verify %s
+// RUN: ls %t.2 | count 2
+
+// Finally, test that including enabled sanitizers in the module hash isn't
+// required to ensure correctness of module imports.
+//
+// Emit a PCH with ASan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch
+//
+// Import the PCH without ASan enabled (we expect an error).
+// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH
+// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not
+//
+// Emit a PCH with UBSan enabled.
+// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch
+//
+// Import the PCH without UBSan enabled (should work just fine).
+// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify
+
+#include "check.h"
+
+#if __has_feature(address_sanitizer)
+#if HAS_ASAN != 1
+#error Module doesn't have the address_sanitizer feature, but main program does.
+#endif
+#else
+#if HAS_ASAN != 0
+#error Module has the address_sanitizer feature, but main program doesn't.
+#endif
+#endif
+
+// expected-no-diagnostics
Index: cfe/trunk/test/Modules/Inputs/check-for-sanitizer-feature/map
===

[PATCH] D33797: [coroutines] Fix rebuilding of dependent coroutine parameters

2017-06-01 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

We were not handling correctly rebuilding of parameter and were not creating 
copies for them.
With this checking, we will be always rebuilding parameter moves in 
TreeTransform's TransformCoroutineBodyStmt.


https://reviews.llvm.org/D33797

Files:
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-params.cpp


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %x1, %struct.A* 
dereferenceable(512) %x)
+  // CHECK-NEXT: call void 
@_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&);
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in 
TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:


Index: test/CodeGenCoroutines/coro-params.cpp
===
--- test/CodeGenCoroutines/coro-params.cpp
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -93,3 +93,26 @@
   // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
   // CHECK-NEXT: call i8* @llvm.coro.free(
 }
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1AEvT_(%struct.A* %x
+template 
+void dependent_params(T x) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %x1, %struct.A* dereferenceable(512) %x)
+  // CHECK-NEXT: call void @_ZNSt12experimental16coroutine_traitsIJv1AEE12promise_typeC1Ev
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A&&);
+  ~A();
+};
+
+void call_dependent_params() {
+  dependent_params(A{});
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6959,6 +6959,7 @@
   Builder.ReturnStmt = Res.get();
 }
   }
+  Builder.buildParameterMoves();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -822,6 +822,12 @@
   return this->IsValid;
 }
 
+bool CoroutineStmtBuilder::buildParameterMoves() {
+  assert(this->IsValid && "coroutine already invalid");
+  assert(this->ParamMoves.empty() && "param moves already built");
+  return this->IsValid = makeParamMoves();
+}
+
 bool CoroutineStmtBuilder::buildDependentStatements() {
   assert(this->IsValid && "coroutine already invalid");
   assert(!this->IsPromiseDependentType &&
Index: lib/Sema/CoroutineStmtBuilder.h
===
--- lib/Sema/CoroutineStmtBuilder.h
+++ lib/Sema/CoroutineStmtBuilder.h
@@ -51,6 +51,9 @@
   /// name lookup.
   bool buildDependentStatements();
 
+  /// \brief Build just parameter moves. To use for rebuilding in TreeTransform.
+  bool buildParameterMoves();
+
   bool isInvalid() const { return !this->IsValid; }
 
 private:
___
cfe-commits mailing lis

[PATCH] D33398: Mangle __unaligned in Itanium ABI

2017-06-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Looks great, thanks!




Comment at: lib/AST/ItaniumMangle.cpp:2210
+  if (Quals.hasUnaligned())
+  mangleVendorQualifier("__unaligned");
+

rogfer01 wrote:
> rsmith wrote:
> > Too much indentation here. Also, the ABI requires the "unordered" vendor 
> > qualifiers to be emitted in reverse alphabetical order, so this should be 
> > emitted after `__weak` and `__strong` but before `__autoreleasing`.
> I think you meant after `__weak` but before `__strong` and `__autoreleasing`? 
> Maybe I'm misinterpreting something here.
> 
> The current patch emits `__weak`, then `__unaligned` and then the remaining 
> ARC ones.
The alphabet is hard, apparently :) Yes, thanks!



Comment at: lib/AST/ItaniumMangle.cpp:2184
+  //
+  // Note: we emit first __weak to preserve the order as
+  // required by the Itanium ABI.

first `__weak` -> `__weak` first


https://reviews.llvm.org/D33398



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro updated this revision to Diff 101092.
loladiro added a comment.

Finalize all subprograms when we're done emitting them.
The one we're interested in is a side effect, but doing
this uniformly might be cleaner and help avoid similar errors in the future.


https://reviews.llvm.org/D33705

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy &Builder);
+  void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy &Builder);
+  void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

@aprantl @dblaikie See if you like this better.


https://reviews.llvm.org/D33705



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


r304464 - Escape filenames in module map line marker directives, to unbreak Windows build bots.

2017-06-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jun  1 15:10:35 2017
New Revision: 304464

URL: http://llvm.org/viewvc/llvm-project?rev=304464&view=rev
Log:
Escape filenames in module map line marker directives, to unbreak Windows build 
bots.

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=304464&r1=304463&r2=304464&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jun  1 15:10:35 2017
@@ -546,8 +546,11 @@ void PrintPreprocessedAction::ExecuteAct
   // module itself before switching to the input buffer.
   auto &Input = getCurrentInput();
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {
-if (Input.isFile())
-  (*OS) << "# 1 \"" << Input.getFile() << "\"\n";
+if (Input.isFile()) {
+  (*OS) << "# 1 \"";
+  OS->write_escaped(Input.getFile());
+  (*OS) << "\"\n";
+}
 // FIXME: Include additional information here so that we don't need the
 // original source files to exist on disk.
 getCurrentModule()->print(*OS);

Modified: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp?rev=304464&r1=304463&r2=304464&view=diff
==
--- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Thu Jun  1 15:10:35 2017
@@ -200,8 +200,11 @@ void RewriteIncludesAction::ExecuteActio
   // module itself before switching to the input buffer.
   auto &Input = getCurrentInput();
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {
-if (Input.isFile())
-  (*OS) << "# 1 \"" << Input.getFile() << "\"\n";
+if (Input.isFile()) {
+  (*OS) << "# 1 \"";
+  OS->write_escaped(Input.getFile());
+  (*OS) << "\"\n";
+}
 // FIXME: Include additional information here so that we don't need the
 // original source files to exist on disk.
 getCurrentModule()->print(*OS);


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


Re: r304346 - [modules] When compiling a preprocessed module map, look for headers relative

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 12:53, Richard Smith  wrote:

> On 1 June 2017 at 11:10, Galina Kistanova  wrote:
>
>> Hello Richard,
>>
>> This commit broke tests on few of our builders:
>>
>> Failing Tests (2):
>> Clang :: Modules/preprocess-module.cpp
>> Clang :: Modules/preprocess-nested.cpp
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei
>> -ps4-windows10pro-fast/builds/10199
>> and
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensiv
>> e-checks-win/builds/2819
>>
>> Please have a look at this?
>>
>
> Sure, looking.
>

Should be fixed in r304464.


> Also I see that email notifications on these failures were sent.
>>
>
> They certainly did not arrive here. As I've mentioned before, I have not
> received any mail from any lab.llvm.org bots since early March.
>
>
>> Thanks
>>
>> Galina
>>
>>
>> On Wed, May 31, 2017 at 1:56 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Wed May 31 15:56:55 2017
>>> New Revision: 304346
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304346&view=rev
>>> Log:
>>> [modules] When compiling a preprocessed module map, look for headers
>>> relative
>>> to the original module map.
>>>
>>> Also use the path and name of the original module map when emitting that
>>> information into the .pcm file. The upshot of this is that the produced
>>> .pcm
>>> file will track information for headers in their original locations
>>> (where the
>>> module was preprocessed), not relative to whatever directory the
>>> preprocessed
>>> module map was in when it was built.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/Module.h
>>> cfe/trunk/include/clang/Lex/HeaderSearch.h
>>> cfe/trunk/lib/Frontend/FrontendAction.cpp
>>> cfe/trunk/lib/Lex/HeaderSearch.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> cfe/trunk/test/Modules/preprocess-module.cpp
>>> cfe/trunk/test/Modules/preprocess-nested.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Module.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/Module.h?rev=304346&r1=304345&r2=304346&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Module.h (original)
>>> +++ cfe/trunk/include/clang/Basic/Module.h Wed May 31 15:56:55 2017
>>> @@ -83,6 +83,10 @@ public:
>>>/// are found.
>>>const DirectoryEntry *Directory;
>>>
>>> +  /// \brief The presumed file name for the module map defining this
>>> module.
>>> +  /// Only non-empty when building from preprocessed source.
>>> +  std::string PresumedModuleMapFile;
>>> +
>>>/// \brief The umbrella header or directory.
>>>llvm::PointerUnion
>>> Umbrella;
>>>
>>>
>>> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Lex/HeaderSearch.h?rev=304346&r1=304345&r2=304346&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
>>> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 31 15:56:55 2017
>>> @@ -543,10 +543,13 @@ public:
>>>/// \param Offset [inout] An offset within ID to start parsing. On
>>> exit,
>>>///filled by the end of the parsed contents (either EOF or the
>>>///location of an end-of-module-map pragma).
>>> -  ///
>>> +  /// \param OriginalModuleMapFile The original path to the module map
>>> file,
>>> +  ///used to resolve paths within the module (this is required
>>> when
>>> +  ///building the module from preprocessed source).
>>>/// \returns true if an error occurred, false otherwise.
>>>bool loadModuleMapFile(const FileEntry *File, bool IsSystem,
>>> - FileID ID = FileID(), unsigned *Offset =
>>> nullptr);
>>> + FileID ID = FileID(), unsigned *Offset =
>>> nullptr,
>>> + StringRef OriginalModuleMapFile = StringRef());
>>>
>>>/// \brief Collect the set of all known, top-level modules.
>>>///
>>>
>>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/F
>>> rontendAction.cpp?rev=304346&r1=304345&r2=304346&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 31 15:56:55 2017
>>> @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOp
>>>return std::error_code();
>>>  }
>>>
>>> -static bool
>>> -loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename,
>>> -bool IsSystem, bool IsPreprocessed,
>>> -unsigned &Offset) {
>>> +static bool loadModuleMapForModuleBuild(CompilerInstance &CI,
>>> +St

[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

I guess this would need a cross-project test case (ie: it'd have to run LLVM 
optimizations to fail/pass/demonstrate the fix). I think it'd be OK to add one 
if there's a neat/clean/obvious optimization that can be reliably triggered to 
do the cloning that would assert/crash - please add one if you think that's 
practical/reasonable.


https://reviews.llvm.org/D33705



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


r304465 - Don't assume that a store source is a vector type just because the destination is (PR26099)

2017-06-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Jun  1 15:13:34 2017
New Revision: 304465

URL: http://llvm.org/viewvc/llvm-project?rev=304465&view=rev
Log:
Don't assume that a store source is a vector type just because the destination 
is (PR26099)

Added:
cfe/trunk/test/CodeGen/pr26099.c
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=304465&r1=304464&r2=304465&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jun  1 15:13:34 2017
@@ -1487,9 +1487,9 @@ void CodeGenFunction::EmitStoreOfScalar(
 // Handle vectors differently to get better performance.
 if (Ty->isVectorType()) {
   llvm::Type *SrcTy = Value->getType();
-  auto *VecTy = cast(SrcTy);
+  auto *VecTy = dyn_cast(SrcTy);
   // Handle vec3 special.
-  if (VecTy->getNumElements() == 3) {
+  if (VecTy && VecTy->getNumElements() == 3) {
 // Our source is a vec3, do a shuffle vector to make it a vec4.
 llvm::Constant *Mask[] = {Builder.getInt32(0), Builder.getInt32(1),
   Builder.getInt32(2),

Added: cfe/trunk/test/CodeGen/pr26099.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr26099.c?rev=304465&view=auto
==
--- cfe/trunk/test/CodeGen/pr26099.c (added)
+++ cfe/trunk/test/CodeGen/pr26099.c Thu Jun  1 15:13:34 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=i686-apple-darwin -target-feature 
+mmx -emit-llvm -o - -Wall -Werror
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +mmx -emit-llvm -o - -Wall -Werror
+// REQUIRES: asserts
+
+#include 
+
+int __attribute__ ((__vector_size__ (8))) b;
+
+void bar(int a)
+{
+  b = __builtin_ia32_vec_init_v2si (0, a);
+}
\ No newline at end of file


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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

There's already such a test case, but the cloning currently doesn't assert 
properly (but it can generate incorrect code). https://reviews.llvm.org/D33655 
fixes that up, so I think the testing is covered once that LLVM commit goes in. 
I'll hold off a little while to give @aprantl a chance to look at this as well, 
but I do want to get this in in short order, so I can recommit 
https://reviews.llvm.org/D33655.


https://reviews.llvm.org/D33705



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Looks good.. Are you also planning to change DIBuilder to not finalize 
subprograms automatically any more (and not insert them into AllSubprograms)? 
(That will be the more impactful change as it will force all non-clang 
frontends to make a similar change).


https://reviews.llvm.org/D33705



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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Keno Fischer via Phabricator via cfe-commits
loladiro added a comment.

I don't think that change is entirely necessary. I don't have any strong 
objections to it, but I also don't see a good reason to require it. In any 
case, let me get this in to be able to re-land https://reviews.llvm.org/D33655 
and we can revisit the more disruptive change later.


https://reviews.llvm.org/D33705



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


[PATCH] D33692: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-06-01 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 101106.
timshen added a comment.

Rebase the patch onto https://reviews.llvm.org/D33799.


https://reviews.llvm.org/D33692

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thin_link_bitcode.c


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  CodeGenOpts.EmitSummaryIndex,
-  CodeGenOpts.EmitSummaryIndex));
+if (CodeGenOpts.EmitSummaryIndex) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output)
+  << CodeGenOpts.ThinLinkBitcodeFile << EC.message();
+  return;
+}
+  }
+  MPM.addPass(
+  ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));
+} else {
+  MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
+}
 break;
 
   case Backend_EmitLL:
@@ -1029,6 +1046,7 @@
   Conf.CGOptLevel = getCGOptLevel(CGOpts);
   initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts);
   Conf.SampleProfile = std::move(SampleProfile);
+  Conf.UseNewPM = CGOpts.ExperimentalNewPassManager;
   switch (Action) {
   case Backend_EmitNothing:
 Conf.PreCodeGenModuleHook = [](size_t Task, const Module &Mod) {


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager -fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s --check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -897,16 +898,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addP

r304470 - [CGDebugInfo] Finalize SubPrograms when we're done with them

2017-06-01 Thread Keno Fischer via cfe-commits
Author: kfischer
Date: Thu Jun  1 16:14:03 2017
New Revision: 304470

URL: http://llvm.org/viewvc/llvm-project?rev=304470&view=rev
Log:
[CGDebugInfo] Finalize SubPrograms when we're done with them

`GenerateVarArgsThunk` in `CGVTables` clones a function before the frontend
is done emitting the compilation unit. Because of the way that DIBuilder
works, this means that the attached subprogram had incomplete (temporary)
metadata. Cloning such metadata is semantically disallowed, but happened
to work anyway due to bugs in the cloning logic. rL304226 attempted to fix
up that logic, but in the process exposed the incorrect API use here and
had to be reverted. To be able to fix this, I added a new method to
DIBuilder in rL304467, to allow finalizing a subprogram independently
of the entire compilation unit. Use that here, in preparation of re-applying
rL304226.

Reviewers: aprantl, dblaikie
Differential Revision: https://reviews.llvm.org/D33705

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=304470&r1=304469&r2=304470&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun  1 16:14:03 2017
@@ -3263,7 +3263,7 @@ void CGDebugInfo::EmitInlineFunctionStar
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@ void CGDebugInfo::EmitLexicalBlockEnd(CG
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@ void CGDebugInfo::EmitFunctionEnd(CGBuil
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=304470&r1=304469&r2=304470&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Jun  1 16:14:03 2017
@@ -367,7 +367,7 @@ public:
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy &Builder);
+  void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=304470&r1=304469&r2=304470&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Jun  1 16:14:03 2017
@@ -348,7 +348,7 @@ void CodeGenFunction::FinishFunction(Sou
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.


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


[PATCH] D33705: [CGVTables] Finalize SP before attempting to clone it

2017-06-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304470: [CGDebugInfo] Finalize SubPrograms when we're done 
with them (authored by kfischer).

Changed prior to commit:
  https://reviews.llvm.org/D33705?vs=101092&id=101107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33705

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy &Builder);
+  void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3263,7 +3263,7 @@
 
 void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) {
   assert(CurInlinedAt && "unbalanced inline scope stack");
-  EmitFunctionEnd(Builder);
+  EmitFunctionEnd(Builder, nullptr);
   setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt());
 }
 
@@ -3332,7 +3332,7 @@
   LexicalBlockStack.pop_back();
 }
 
-void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder) {
+void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) {
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   unsigned RCount = FnBeginRegionCount.back();
   assert(RCount <= LexicalBlockStack.size() && "Region stack mismatch");
@@ -3344,6 +3344,9 @@
 LexicalBlockStack.pop_back();
   }
   FnBeginRegionCount.pop_back();
+
+  if (Fn && Fn->getSubprogram())
+DBuilder.finalizeSubprogram(Fn->getSubprogram());
 }
 
 llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h
@@ -367,7 +367,7 @@
   void EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, QualType FnType);
 
   /// Constructs the debug code for exiting a function.
-  void EmitFunctionEnd(CGBuilderTy &Builder);
+  void EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn);
 
   /// Emit metadata to indicate the beginning of a new lexical block
   /// and push the block onto the stack.
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -348,7 +348,7 @@
 
   // Emit debug descriptor for function end.
   if (CGDebugInfo *DI = getDebugInfo())
-DI->EmitFunctionEnd(Builder);
+DI->EmitFunctionEnd(Builder, CurFn);
 
   // Reset the debug location to that of the simple 'return' expression, if any
   // rather than that of the end of the function's scope '}'.

r304472 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:15:34 2017
New Revision: 304472

URL: http://llvm.org/viewvc/llvm-project?rev=304472&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=304472&r1=304471&r2=304472&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Jun  1 16:15:34 2017
@@ -2552,6 +2552,7 @@ bool Parser::ParseImplicitInt(DeclSpec &
 }
   }
   // Fall through.
+  LLVM_FALLTHROUGH;
 }
 case tok::comma:
 case tok::equal:
@@ -3678,6 +3679,7 @@ void Parser::ParseDeclarationSpecifiers(
 isInvalid = true;
 break;
   };
+  LLVM_FALLTHROUGH;
 case tok::kw___private:
 case tok::kw___global:
 case tok::kw___local:
@@ -5045,6 +5047,7 @@ void Parser::ParseTypeQualifierListOpt(
 if (TryKeywordIdentFallback(false))
   continue;
   }
+  LLVM_FALLTHROUGH;
 case tok::kw___sptr:
 case tok::kw___w64:
 case tok::kw___ptr64:
@@ -5094,6 +5097,7 @@ void Parser::ParseTypeQualifierListOpt(
 continue; // do *not* consume the next token!
   }
   // otherwise, FALL THROUGH!
+  LLVM_FALLTHROUGH;
 default:
   DoneWithTypeQuals:
   // If this is not a type-qualifier token, we're done reading type


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


r304473 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:19:06 2017
New Revision: 304473

URL: http://llvm.org/viewvc/llvm-project?rev=304473&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=304473&r1=304472&r2=304473&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Jun  1 16:19:06 2017
@@ -4215,6 +4215,7 @@ void Parser::ParseMicrosoftIfExistsClass
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
   << Result.IsIfExists;
 // Fall through to skip.
+LLVM_FALLTHROUGH;
   
   case IEB_Skip:
 Braces.skipToEnd();


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


r304475 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:21:49 2017
New Revision: 304475

URL: http://llvm.org/viewvc/llvm-project?rev=304475&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=304475&r1=304474&r2=304475&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Jun  1 16:21:49 2017
@@ -1314,6 +1314,7 @@ ExprResult Parser::ParseCastExpression(b
 }
 
 // Fall through to treat the template-id as an id-expression.
+LLVM_FALLTHROUGH;
   }
 
   case tok::kw_operator: // [C++] id-expression: 
operator/conversion-function-id
@@ -1484,9 +1485,9 @@ Parser::ParsePostfixExpressionSuffix(Exp
  nullptr, LHS.get());
 break;
   }
-
   // Fall through; this isn't a message send.
-
+  LLVM_FALLTHROUGH;
+
 default:  // Not a postfix-expression suffix.
   return LHS;
 case tok::l_square: {  // postfix-expression: p-e '[' expression ']'


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


r304477 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:23:52 2017
New Revision: 304477

URL: http://llvm.org/viewvc/llvm-project?rev=304477&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseInit.cpp

Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=304477&r1=304476&r2=304477&view=diff
==
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Thu Jun  1 16:23:52 2017
@@ -501,7 +501,8 @@ bool Parser::ParseMicrosoftIfExistsBrace
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
   << Result.IsIfExists;
 // Fall through to skip.
-  
+LLVM_FALLTHROUGH;
+
   case IEB_Skip:
 Braces.skipToEnd();
 return false;


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


r304478 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:26:38 2017
New Revision: 304478

URL: http://llvm.org/viewvc/llvm-project?rev=304478&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=304478&r1=304477&r2=304478&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Jun  1 16:26:38 2017
@@ -192,6 +192,7 @@ static DeclarationName parseOpenMPReduct
   case tok::identifier: // identifier
 if (!WithOperator)
   break;
+LLVM_FALLTHROUGH;
   default:
 P.Diag(Tok.getLocation(), diag::err_omp_expected_reduction_identifier);
 P.SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
@@ -869,6 +870,7 @@ StmtResult Parser::ParseOpenMPDeclarativ
   // pseudo-clause OMPFlushClause.
   PP.EnterToken(Tok);
 }
+LLVM_FALLTHROUGH;
   case OMPD_taskyield:
   case OMPD_barrier:
   case OMPD_taskwait:
@@ -883,6 +885,7 @@ StmtResult Parser::ParseOpenMPDeclarativ
 }
 HasAssociatedStatement = false;
 // Fall through for further analysis.
+LLVM_FALLTHROUGH;
   case OMPD_parallel:
   case OMPD_simd:
   case OMPD_for:
@@ -1184,6 +1187,7 @@ OMPClause *Parser::ParseOpenMPClause(Ope
   << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind) << 0;
   ErrorFound = true;
 }
+LLVM_FALLTHROUGH;
 
   case OMPC_if:
 Clause = ParseOpenMPSingleExprWithArgClause(CKind);


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


r304479 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:28:26 2017
New Revision: 304479

URL: http://llvm.org/viewvc/llvm-project?rev=304479&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseStmt.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=304479&r1=304478&r2=304479&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu Jun  1 16:28:26 2017
@@ -203,6 +203,7 @@ Retry:
 }
 
 // Fall through
+LLVM_FALLTHROUGH;
   }
 
   default: {


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


r304481 - Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

2017-06-01 Thread Galina Kistanova via cfe-commits
Author: gkistanova
Date: Thu Jun  1 16:29:45 2017
New Revision: 304481

URL: http://llvm.org/viewvc/llvm-project?rev=304481&view=rev
Log:
Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.

Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=304481&r1=304480&r2=304481&view=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Thu Jun  1 16:29:45 2017
@@ -1450,6 +1450,7 @@ Parser::isCXXDeclarationSpecifier(Parser
   return TPResult::False;
 }
 // If that succeeded, fallthrough into the generic simple-type-id case.
+LLVM_FALLTHROUGH;
 
 // The ambiguity resides in a simple-type-specifier/typename-specifier
 // followed by a '('. The '(' could either be the start of:
@@ -1492,6 +1493,7 @@ Parser::isCXXDeclarationSpecifier(Parser
   
   return TPResult::True;
 }
+LLVM_FALLTHROUGH;
   
   case tok::kw_char:
   case tok::kw_wchar_t:


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


[PATCH] D33692: [ThinLTO] Wire up ThinLTO and new PM

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

This patch LGTM whenever the underlying LLVM change lands, thanks


https://reviews.llvm.org/D33692



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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-06-01 Thread Tim Northover via cfe-commits
On 26 May 2017 at 11:29, Richard Smith  wrote:
> If we generally think that distinction is a good thing, then (because this
> is a conforming extension) consistency weakly suggests that it should not be
> controlled by GNU mode. But I don't find that argument decisive; the
> important thing is that we don't enable non-conforming extensions by default
> in non-GNU (and non-MS-compat) modes, not that GNU mode consists of /only/
> non-conforming extensions.

I'm pretty convinced by the conforming/non-conforming distinction and
consistency argument. And think that the Microsoft way seems even
better for the future.

Making the libc++ test pass is pretty ugly, but I've managed to get it
working by building with "-Werror=gnu-imaginary-constant".

Marshall, I know this really isn't your preferred solution but can you
stomach it if I also make sure we do the extra diagnostics so it's
difficult to misuse?

> Looking at the
>
>   std::complex x = 1.0if;
>
> case again, I think there's another problem here: we support an implicit
> conversion from _Complex float to float in C++ (without even a warning).
> This conversion is valid in C, but at least GCC disallows it in its C++
> mode. We should probably at least warn on that.

Definitely. I think the error from G++ is probably the right choice.
I'll get cracking on that, it's a good idea regardless of what happens
here.

Cheers.

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


[PATCH] D33692: [ThinLTO] Wire up ThinLTO and new PM

2017-06-01 Thread Davide Italiano via Phabricator via cfe-commits
davide added a comment.

LGTM once the other patch lands.


https://reviews.llvm.org/D33692



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


[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").

2017-06-01 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/Basic/Targets.cpp:5439-5442
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto &Feature : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)

Won't work below in handleTargetFeatures?


https://reviews.llvm.org/D33721



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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-06-01 Thread Richard Smith via cfe-commits
On 1 June 2017 at 14:36, Tim Northover  wrote:

> On 26 May 2017 at 11:29, Richard Smith  wrote:
> > If we generally think that distinction is a good thing, then (because
> this
> > is a conforming extension) consistency weakly suggests that it should
> not be
> > controlled by GNU mode. But I don't find that argument decisive; the
> > important thing is that we don't enable non-conforming extensions by
> default
> > in non-GNU (and non-MS-compat) modes, not that GNU mode consists of
> /only/
> > non-conforming extensions.
>
> I'm pretty convinced by the conforming/non-conforming distinction and
> consistency argument. And think that the Microsoft way seems even
> better for the future.
>
> Making the libc++ test pass is pretty ugly, but I've managed to get it
> working by building with "-Werror=gnu-imaginary-constant".
>
> Marshall, I know this really isn't your preferred solution but can you
> stomach it if I also make sure we do the extra diagnostics so it's
> difficult to misuse?
>
> > Looking at the
> >
> >   std::complex x = 1.0if;
> >
> > case again, I think there's another problem here: we support an implicit
> > conversion from _Complex float to float in C++ (without even a warning).
> > This conversion is valid in C, but at least GCC disallows it in its C++
> > mode. We should probably at least warn on that.
>
> Definitely. I think the error from G++ is probably the right choice.
> I'll get cracking on that, it's a good idea regardless of what happens
> here.
>

Great, thanks, your intended direction makes sense to me.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Galina Kistanova via cfe-commits
Hello Vedant,

This commit broke tests on some of our builders:

Failing Tests (1):
Clang :: CodeGen/ubsan-pointer-overflow.m

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097
etc

Thanks

Galina

On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vedantk
> Date: Thu Jun  1 14:22:18 2017
> New Revision: 304459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304459&view=rev
> Log:
> [ubsan] Add a check for pointer overflow UB
>
> Check pointer arithmetic for overflow.
>
> For some more background on this check, see:
>
>   https://wdtz.org/catching-pointer-overflow-bugs.html
>   https://reviews.llvm.org/D20322
>
> Patch by Will Dietz and John Regehr!
>
> This version of the patch is different from the original in a few ways:
>
>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
> checks when the pointer overflow check is enabled.
>
>   - It does some constant-folding to reduce instrumentation overhead.
>
>   - It does not check some GEPs in CGExprCXX. I'm not sure that
> inserting checks here, or in CGClass, would catch many bugs.
>
> Possible future directions for this check:
>
>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
> accessing structures.
>
> Testing: Apart from the added lit test, I ran check-llvm and check-clang
> with a stage2, ubsan-instrumented clang. Will and John have also done
> extensive testing on numerous open source projects.
>
> Differential Revision: https://reviews.llvm.org/D33305
>
> Added:
> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Basic/Sanitizers.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/Driver/fsanitize.c
>
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/
> UndefinedBehaviorSanitizer.rst?rev=304459&r1=304458&r2=304459&view=diff
> 
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
> @@ -106,6 +106,8 @@ Available checks are:
>   invalid pointers. These checks are made in terms of
>   ``__builtin_object_size``, and consequently may be able to detect
> more
>   problems at higher optimization levels.
> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
> + overflows.
>-  ``-fsanitize=return``: In C++, reaching the end of a
>   value-returning function without returning a value.
>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>
> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/Sanitizers.def?rev=304459&r1=304458&r2=304459&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>  SANITIZER_GROUP("nullability", Nullability,
>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>  SANITIZER("object-size", ObjectSize)
> +SANITIZER("pointer-overflow", PointerOverflow)
>  SANITIZER("return", Return)
>  SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
>  SANITIZER("shift-base", ShiftBase)
> @@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
>  SANITIZER_GROUP("undefined", Undefined,
>  Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow
> |
>  FloatDivideByZero | IntegerDivideByZero |
> NonnullAttribute |
> -Null | ObjectSize | Return | ReturnsNonnullAttribute |
> -Shift | SignedIntegerOverflow | Unreachable |
> VLABound |
> -Function | Vptr)
> +Null | ObjectSize | PointerOverflow | Return |
> +ReturnsNonnullAttribute | Shift |
> SignedIntegerOverflow |
> +Unreachable | VLABound | Function | Vptr)
>
>  // -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
>  SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=304459&r1=304458&r2=304459&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (orig

Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
Taking a look.

vedant

> On Jun 1, 2017, at 2:45 PM, Galina Kistanova  wrote:
> 
> Hello Vedant,
> 
> This commit broke tests on some of our builders:
> 
> Failing Tests (1):
> Clang :: CodeGen/ubsan-pointer-overflow.m
> 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
>  
> 
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
>  
> 
> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097 
> 
> etc
> 
> Thanks
> 
> Galina
> 
> On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: vedantk
> Date: Thu Jun  1 14:22:18 2017
> New Revision: 304459
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=304459&view=rev 
> 
> Log:
> [ubsan] Add a check for pointer overflow UB
> 
> Check pointer arithmetic for overflow.
> 
> For some more background on this check, see:
> 
>   https://wdtz.org/catching-pointer-overflow-bugs.html 
> 
>   https://reviews.llvm.org/D20322 
> 
> Patch by Will Dietz and John Regehr!
> 
> This version of the patch is different from the original in a few ways:
> 
>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
> checks when the pointer overflow check is enabled.
> 
>   - It does some constant-folding to reduce instrumentation overhead.
> 
>   - It does not check some GEPs in CGExprCXX. I'm not sure that
> inserting checks here, or in CGClass, would catch many bugs.
> 
> Possible future directions for this check:
> 
>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
> accessing structures.
> 
> Testing: Apart from the added lit test, I ran check-llvm and check-clang
> with a stage2, ubsan-instrumented clang. Will and John have also done
> extensive testing on numerous open source projects.
> 
> Differential Revision: https://reviews.llvm.org/D33305 
> 
> 
> Added:
> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
> Modified:
> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> cfe/trunk/include/clang/Basic/Sanitizers.def
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/Driver/fsanitize.c
> 
> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459&r1=304458&r2=304459&view=diff
>  
> 
> ==
> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
> @@ -106,6 +106,8 @@ Available checks are:
>   invalid pointers. These checks are made in terms of
>   ``__builtin_object_size``, and consequently may be able to detect more
>   problems at higher optimization levels.
> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
> + overflows.
>-  ``-fsanitize=return``: In C++, reaching the end of a
>   value-returning function without returning a value.
>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
> 
> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459&r1=304458&r2=304459&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>  SANITIZER_GROUP("nullability", Nullability,
>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>  SANITIZER("object-size", ObjectSize)
> +SANITIZER("pointer-overflow", PointerOverflow)
>  SANITIZER("return", Return)
>  SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
>  SANITIZER("shift-base", ShiftBase)
> @@ -108,9 +109,9 @@ SANITIZER("safe-stack", SafeStack)
>  SANITIZER_GROUP("undefined", Undefined,
>  Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
>  FloatDivideByZero | IntegerD

r304486 - Relax test to try and appease builders. NFC.

2017-06-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Jun  1 17:27:39 2017
New Revision: 304486

URL: http://llvm.org/viewvc/llvm-project?rev=304486&view=rev
Log:
Relax test to try and appease builders. NFC.

I'm not sure why, but on some bots, the order of two instructions are
swapped (as compared to the output on my machine). Loosen up the
CHECK-NEXT directives to deal with this.

Failing bot: http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097

Modified:
cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m

Modified: cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m?rev=304486&r1=304485&r2=304486&view=diff
==
--- cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m (original)
+++ cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m Thu Jun  1 17:27:39 2017
@@ -37,9 +37,9 @@ void binary_arith(char *p, int i) {
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, 
!nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], 
!nosanitize
+  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], 
i64 [[COMPGEP]]){{.*}}, !nosanitize
   p + i;
@@ -62,9 +62,9 @@ void fixed_len_array(int k) {
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], 
!nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, 
!nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], 
!nosanitize
+  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], 
i1 [[NEGVALID]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], 
i64 [[COMPGEP]]){{.*}}, !nosanitize
 


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


Re: r304459 - [ubsan] Add a check for pointer overflow UB

2017-06-01 Thread Vedant Kumar via cfe-commits
I checked in r304486 to try and address the issue.

thanks,
vedant

> On Jun 1, 2017, at 3:21 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Taking a look.
> 
> vedant
> 
>> On Jun 1, 2017, at 2:45 PM, Galina Kistanova > > wrote:
>> 
>> Hello Vedant,
>> 
>> This commit broke tests on some of our builders:
>> 
>> Failing Tests (1):
>> Clang :: CodeGen/ubsan-pointer-overflow.m
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2865/steps/test-check-all/logs/stdio
>>  
>> 
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/10259
>>  
>> 
>> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/3097 
>> 
>> etc
>> 
>> Thanks
>> 
>> Galina
>> 
>> On Thu, Jun 1, 2017 at 12:22 PM, Vedant Kumar via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: vedantk
>> Date: Thu Jun  1 14:22:18 2017
>> New Revision: 304459
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=304459&view=rev 
>> 
>> Log:
>> [ubsan] Add a check for pointer overflow UB
>> 
>> Check pointer arithmetic for overflow.
>> 
>> For some more background on this check, see:
>> 
>>   https://wdtz.org/catching-pointer-overflow-bugs.html 
>> 
>>   https://reviews.llvm.org/D20322 
>> 
>> Patch by Will Dietz and John Regehr!
>> 
>> This version of the patch is different from the original in a few ways:
>> 
>>   - It introduces the EmitCheckedInBoundsGEP utility which inserts
>> checks when the pointer overflow check is enabled.
>> 
>>   - It does some constant-folding to reduce instrumentation overhead.
>> 
>>   - It does not check some GEPs in CGExprCXX. I'm not sure that
>> inserting checks here, or in CGClass, would catch many bugs.
>> 
>> Possible future directions for this check:
>> 
>>   - Introduce CGF.EmitCheckedStructGEP, to detect overflows when
>> accessing structures.
>> 
>> Testing: Apart from the added lit test, I ran check-llvm and check-clang
>> with a stage2, ubsan-instrumented clang. Will and John have also done
>> extensive testing on numerous open source projects.
>> 
>> Differential Revision: https://reviews.llvm.org/D33305 
>> 
>> 
>> Added:
>> cfe/trunk/test/CodeGen/ubsan-pointer-overflow.m
>> Modified:
>> cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> cfe/trunk/include/clang/Basic/Sanitizers.def
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>> cfe/trunk/test/Driver/fsanitize.c
>> 
>> Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=304459&r1=304458&r2=304459&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
>> +++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Thu Jun  1 14:22:18 2017
>> @@ -106,6 +106,8 @@ Available checks are:
>>   invalid pointers. These checks are made in terms of
>>   ``__builtin_object_size``, and consequently may be able to detect more
>>   problems at higher optimization levels.
>> +  -  ``-fsanitize=pointer-overflow``: Performing pointer arithmetic which
>> + overflows.
>>-  ``-fsanitize=return``: In C++, reaching the end of a
>>   value-returning function without returning a value.
>>-  ``-fsanitize=returns-nonnull-attribute``: Returning null pointer
>> 
>> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=304459&r1=304458&r2=304459&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
>> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Thu Jun  1 14:22:18 2017
>> @@ -73,6 +73,7 @@ SANITIZER("nullability-return", Nullabil
>>  SANITIZER_GROUP("nullability", Nullability,
>>  NullabilityArg | NullabilityAssign | NullabilityReturn)
>>  SANITIZER("object-size", ObjectSize)
>> +SANITIZER("pointer-overflow", PointerOverflow)
>>  SANITIZER("return", Return)
>>  SANITIZER("returns-nonnull-attribute", Ret

  1   2   >