[PATCH] D75561: Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

2020-03-25 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I added a comment to D75488 . It's in 
getOrCreateModule().


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75561/new/

https://reviews.llvm.org/D75561



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


[PATCH] D76772: [AMDGPU] Add __builtin_amdgcn_workgroup_size_x/y/z

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13428
+return Call;
+  return CGF.Builder.CreateAddrSpaceCast(Call, RetTy);
+}

arsenm wrote:
> Why is this necessary? The builtin always has the same return type?
due to 
https://github.com/llvm/llvm-project/commit/c65f966d76aa5412920b3f14d199e764135bd5ec

pointers returned by builtin functions are in default address space for HIP.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13435
+  auto *DP = EmitAMDGPUDispatchPtr(CGF);
+  auto *Offset = llvm::ConstantInt::get(CGF.Int32Ty, XOffset + Index * 2);
+  auto *GEP = CGF.Builder.CreateGEP(DP, Offset);

arsenm wrote:
> Comment that this is indexing the hsa_kernel_dispatch_packet sstruct?
done



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13442
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1), APInt(16, 1025));
+  LD->setMetadata(llvm::LLVMContext::MD_range, RNode);

arsenm wrote:
> I thought I had a patch to include the maximum group size in AMDGPUTargetInfo 
> to avoid hardcoding it, but I guess it was never committed
Added getMaxOpenCLWorkGroupSize() to TargetInfo



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13443
+  llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1), APInt(16, 1025));
+  LD->setMetadata(llvm::LLVMContext::MD_range, RNode);
+  return LD;

arsenm wrote:
> Also set it's invariant
done


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76772/new/

https://reviews.llvm.org/D76772



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


[PATCH] D74541: [Analyzer] Use note tags to track iterator increments and decrements

2020-03-25 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: clang/test/Analysis/iterator-modelling.cpp:434
+  //expected-note@-1 0-1{{Calling 'next}}
+  //expected-note@-2 0-1{{Passing the value 1 via 2nd parameter 'n'}}
+  //expected-note@Inputs/system-header-simulator-cxx.h:814 0-1{{Iterator 'it' 
incremented by 1}}

Strange, that we do not get this note for `prev`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74541/new/

https://reviews.llvm.org/D74541



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


[PATCH] D76772: [AMDGPU] Add __builtin_amdgcn_workgroup_size_x/y/z

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 252621.
yaxunl marked 9 inline comments as done.
yaxunl added a comment.

Revised by Matt's comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76772/new/

https://reviews.llvm.org/D76772

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -527,6 +527,24 @@
 	}
 }
 
+// CHECK-LABEL: @test_get_workgroup_size(
+// CHECK: call align 4 dereferenceable(64) i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 4
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 6
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 8
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+void test_get_workgroup_size(int d, global int *out)
+{
+	switch (d) {
+	case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+	case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
+	case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
+	default: *out = 0;
+	}
+}
+
 // CHECK-LABEL: @test_fmed3_f32
 // CHECK: call float @llvm.amdgcn.fmed3.f32(
 void test_fmed3_f32(global float* out, float a, float b, float c)
@@ -698,6 +716,7 @@
 }
 
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
+// CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
Index: clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
+// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-LABEL: test_get_workgroup_size
+// CHECK: call align 4 dereferenceable(64) i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i32 4
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i32 6
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i32 8
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]], !invariant.load
+__device__ void test_get_workgroup_size(int d, int *out)
+{
+  switch (d) {
+  case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+  case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
+  case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
+  default: *out = 0;
+  }
+}
+
+// CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13407,6 +13407,48 @@
   }
 }
 
+namespace {
+// If \p E is not null pointer, insert address space cast to match return
+// type of \p E if necessary.
+Value *EmitAMDGPUDispatchPtr(CodeGenFunction ,
+ const CallExpr *E = nullptr) {
+  auto *F = CGF.CGM.getIntrinsic(Intrinsic::amdgcn_dispatch_ptr);
+  auto *Call = CGF.Builder.CreateCall(F);
+  Call->addAttribute(
+  AttributeList::ReturnIndex,
+  Attribute::getWithDereferenceableBytes(Call->getContext(), 64));
+  Call->addAttribute(AttributeList::ReturnIndex,
+ Attribute::getWithAlignment(Call->getContext(), Align(4)));
+  if (!E)
+return Call;
+  QualType BuiltinRetType = E->getType();
+  auto *RetTy = cast(CGF.ConvertType(BuiltinRetType));
+  if (RetTy == Call->getType())
+return Call;
+  return CGF.Builder.CreateAddrSpaceCast(Call, RetTy);
+}
+
+// \p Index is 0, 1, and 2 for x, y, and z dimension, respectively.
+Value *EmitAMDGPUWorkGroupSize(CodeGenFunction , unsigned Index) {
+  const unsigned XOffset = 4;
+  auto *DP = EmitAMDGPUDispatchPtr(CGF);
+  // Indexing the HSA kernel_dispatch_packet struct.
+  auto *Offset = llvm::ConstantInt::get(CGF.Int32Ty, XOffset + Index * 2);
+  auto *GEP = CGF.Builder.CreateGEP(DP, Offset);
+  auto *DstTy =
+  CGF.Int16Ty->getPointerTo(GEP->getType()->getPointerAddressSpace());
+  auto *Cast = 

[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@jyknight yes, the current plan is to use it in libc++'s implementation. I can 
put that implementation (which uses this builtin) up for review before this 
lands. That way we can discuss the implementation before adding a (possibly 
unneeded) builtin. Sound good?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76525/new/

https://reviews.llvm.org/D76525



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb915aec6b591: Add method to TargetInfo to get CPU cache line 
size (authored by zoecarver).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h

Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -182,6 +182,8 @@
   StringRef Name,
   llvm::SmallVectorImpl ) const override;
 
+  Optional getCPUCacheLineSize() const override;
+
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override;
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,119 @@
   }
 }
 
+// Below is based on the following information:
+// ++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |Source|
+// ++-+--+
+// | i386   |  64 | https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf  |
+// | i486   |  16 | "four doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf and http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216=rep1=pdf (page 29) |
+// | i586/Pentium MMX   |  32 | https://www.7-cpu.com/cpu/P-MMX.html |
+// | i686/Pentium   |  32 | https://www.7-cpu.com/cpu/P6.html|
+// | Netburst/Pentium4  |  64 | https://www.7-cpu.com/cpu/P4-180.html|
+// | Atom   |  64 | https://www.7-cpu.com/cpu/Atom.html  |
+// | Westmere   |  64 | https://en.wikichip.org/wiki/intel/microarchitectures/sandy_bridge_(client) "Cache Architecture" |
+// | Sandy Bridge   |  64 | https://en.wikipedia.org/wiki/Sandy_Bridge and https://www.7-cpu.com/cpu/SandyBridge.html|
+// | Ivy Bridge |  64 | https://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ and https://www.7-cpu.com/cpu/IvyBridge.html  |
+// | Haswell|  64 | https://www.7-cpu.com/cpu/Haswell.html   |
+// | Boadwell   |  64 | https://www.7-cpu.com/cpu/Broadwell.html |
+// | Skylake (including skylake-avx512) |  64 | https://www.nas.nasa.gov/hecc/support/kb/skylake-processors_550.html "Cache Hierarchy"   |
+// | Cascade Lake   |  64 | https://www.nas.nasa.gov/hecc/support/kb/cascade-lake-processors_579.html "Cache Hierarchy"  |
+// | Skylake  

[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f237f9b09aa: [clangd] Support multiple cursors in 
selectionRange. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76741/new/

https://reviews.llvm.org/D76741

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h
  llvm/include/llvm/Testing/Support/Annotations.h

Index: llvm/include/llvm/Testing/Support/Annotations.h
===
--- llvm/include/llvm/Testing/Support/Annotations.h
+++ llvm/include/llvm/Testing/Support/Annotations.h
@@ -68,12 +68,14 @@
   /// Crashes if there isn't exactly one.
   size_t point(llvm::StringRef Name = "") const;
   /// Returns the position of all points marked by ^ (or $name^) in the text.
+  /// Order matches the order within the text.
   std::vector points(llvm::StringRef Name = "") const;
 
   /// Returns the location of the range marked by [[ ]] (or $name[[ ]]).
   /// Crashes if there isn't exactly one.
   Range range(llvm::StringRef Name = "") const;
   /// Returns the location of all ranges marked by [[ ]] (or $name[[ ]]).
+  /// They are ordered by start position within the text.
   std::vector ranges(llvm::StringRef Name = "") const;
 
 private:
Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -56,8 +56,9 @@
 SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
 RefSlab getRefs(const SymbolIndex , SymbolID ID);
 
-llvm::Expected>
-runSemanticRanges(ClangdServer , PathRef File, Position Pos);
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File,
+  const std::vector );
 
 llvm::Expected>
 runSwitchHeaderSource(ClangdServer , PathRef File);
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -146,9 +146,10 @@
   return std::move(Slab).build();
 }
 
-llvm::Expected>
-runSemanticRanges(ClangdServer , PathRef File, Position Pos) {
-  llvm::Optional>> Result;
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File,
+  const std::vector ) {
+  llvm::Optional>> Result;
   Server.semanticRanges(File, Pos, capture(Result));
   return std::move(*Result);
 }
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -24,8 +24,17 @@
 namespace clang {
 namespace clangd {
 namespace {
+using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 
+// front() is SR.range, back() is outermost range.
+std::vector gatherRanges(const SelectionRange ) {
+  std::vector Ranges;
+  for (const SelectionRange *S =  S; S = S->parent.get())
+Ranges.push_back(S->range);
+  return Ranges;
+}
+
 TEST(SemanticSelection, All) {
   const char *Tests[] = {
   R"cpp( // Single statement in a function body.
@@ -78,7 +87,7 @@
 }
)cpp",
   // Empty file.
-  "^",
+  "[[^]]",
   // FIXME: We should get the whole DeclStmt as a range.
   R"cpp( // Single statement in TU.
 [[int v = [[1^00;
@@ -89,7 +98,7 @@
   // FIXME: No node found associated to the position.
   R"cpp( // Cursor in between spaces.
 void func() {
-  int v = 100 + ^  100;
+  int v = 100 + [[^]]  100;
 }
   )cpp",
   // Structs.
@@ -133,13 +142,13 @@
   for (const char *Test : Tests) {
 auto T = Annotations(Test);
 auto AST = TestTU::withCode(T.code()).build();
-EXPECT_THAT(llvm::cantFail(getSemanticRanges(AST, T.point())),
+EXPECT_THAT(gatherRanges(llvm::cantFail(getSemanticRanges(AST, T.point(,
 ElementsAreArray(T.ranges()))
 << Test;
   }
 }
 
-TEST(SemanticSelection, RunViaClangDServer) {
+TEST(SemanticSelection, RunViaClangdServer) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;
   ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
@@ -157,15 +166,20 @@
 // inp = HASH(foo(inp));
 [[inp = [[HASH([[foo([[in^p]])]]);
   }
+  $empty[[^]]
   )cpp";
   Annotations SourceAnnotations(SourceContents);
   FS.Files[FooCpp] = std::string(SourceAnnotations.code());
   Server.addDocument(FooCpp, 

[PATCH] D76610: [ARM,CDE] Implement predicated Q-register CDE intrinsics

2020-03-25 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb4da94e5b5f: [ARM,CDE] Implement predicated Q-register CDE 
intrinsics (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76610/new/

https://reviews.llvm.org/D76610

Files:
  clang/include/clang/Basic/arm_cde.td
  clang/test/CodeGen/arm-cde-vec.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrCDE.td
  llvm/test/CodeGen/Thumb2/cde-vec.ll

Index: llvm/test/CodeGen/Thumb2/cde-vec.ll
===
--- llvm/test/CodeGen/Thumb2/cde-vec.ll
+++ llvm/test/CodeGen/Thumb2/cde-vec.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=thumbv8.1m.main -mattr=+cdecp0 -mattr=+cdecp1 -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+cdecp0 -mattr=+cdecp1 -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
 
 declare <16 x i8> @llvm.arm.cde.vcx1q(i32 immarg, i32 immarg)
 declare <16 x i8> @llvm.arm.cde.vcx1qa(i32 immarg, <16 x i8>, i32 immarg)
@@ -112,3 +112,103 @@
   %2 = call <16 x i8> @llvm.arm.cde.vcx3qa(i32 1, <16 x i8> %acc, <16 x i8> %0, <16 x i8> %1, i32 13)
   ret <16 x i8> %2
 }
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+declare <8 x i16> @llvm.arm.cde.vcx1q.predicated.v8i16.v8i1(i32 immarg, <8 x i16>, i32 immarg, <8 x i1>)
+declare <16 x i8> @llvm.arm.cde.vcx1qa.predicated.v16i8.v16i1(i32 immarg, <16 x i8>, i32 immarg, <16 x i1>)
+declare <4 x i32> @llvm.arm.cde.vcx2q.predicated.v4i32.v4i1(i32 immarg, <4 x i32>, <16 x i8>, i32 immarg, <4 x i1>)
+declare <4 x float> @llvm.arm.cde.vcx2qa.predicated.v4f32.v4i1(i32 immarg, <4 x float>, <16 x i8>, i32 immarg, <4 x i1>)
+declare <2 x i64> @llvm.arm.cde.vcx3q.predicated.v2i64.v4i1(i32 immarg, <2 x i64>, <16 x i8>, <16 x i8>, i32 immarg, <4 x i1>)
+declare <4 x float> @llvm.arm.cde.vcx3qa.predicated.v4f32.v4i1(i32 immarg, <4 x float>, <16 x i8>, <16 x i8>, i32 immarg, <4 x i1>)
+
+define arm_aapcs_vfpcc <8 x i16> @test_vcx1q_m(<8 x i16> %inactive, i16 zeroext %p) {
+; CHECK-LABEL: test_vcx1q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcx1t p0, q0, #
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x i16> @llvm.arm.cde.vcx1q.predicated.v8i16.v8i1(i32 0, <8 x i16> %inactive, i32 , <8 x i1> %1)
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vcx1qa_m(<16 x i8> %acc, i16 zeroext %p) {
+; CHECK-LABEL: test_vcx1qa_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcx1at p1, q0, #1112
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = call <16 x i8> @llvm.arm.cde.vcx1qa.predicated.v16i8.v16i1(i32 1, <16 x i8> %acc, i32 1112, <16 x i1> %1)
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vcx2q_m(<4 x i32> %inactive, <4 x float> %n, i16 zeroext %p) {
+; CHECK-LABEL: test_vcx2q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcx2t p0, q0, q1, #111
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %n to <16 x i8>
+  %1 = zext i16 %p to i32
+  %2 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %1)
+  %3 = call <4 x i32> @llvm.arm.cde.vcx2q.predicated.v4i32.v4i1(i32 0, <4 x i32> %inactive, <16 x i8> %0, i32 111, <4 x i1> %2)
+  ret <4 x i32> %3
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vcx2qa_m(<4 x float> %acc, <8 x half> %n, i16 zeroext %p) {
+; CHECK-LABEL: test_vcx2qa_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcx2at p0, q0, q1, #112
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <8 x half> %n to <16 x i8>
+  %1 = zext i16 %p to i32
+  %2 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %1)
+  %3 = call <4 x float> @llvm.arm.cde.vcx2qa.predicated.v4f32.v4i1(i32 0, <4 x float> %acc, <16 x i8> %0, i32 112, <4 x i1> %2)
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <2 x i64> @test_vcx3q_m(<2 x i64> %inactive, <4 x float> %n, <16 x i8> %m, i16 zeroext %p) {
+; CHECK-LABEL: test_vcx3q_m:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vcx3t p0, q0, q1, q2, #11
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %n to <16 x i8>
+  %1 = zext i16 %p to i32
+  %2 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %1)
+  %3 = call <2 x i64> @llvm.arm.cde.vcx3q.predicated.v2i64.v4i1(i32 0, <2 x i64> %inactive, <16 x i8> %0, <16 x i8> %m, i32 11, <4 x i1> %2)
+  ret <2 x i64> %3
+}
+
+define 

[PATCH] D76443: Use ConstantExpr cached APValues if present for code generation

2020-03-25 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders updated this revision to Diff 252610.
wchilders added a comment.

Updated to remove duplicated (and out dated) APValue generation logic, and 
fixed formatting issues. (Thanks for pointing out something was awry Tyker)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76443/new/

https://reviews.llvm.org/D76443

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp

Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1092,8 +1092,13 @@
   // statements following block literals with non-trivial cleanups.
   RunCleanupsScope cleanupScope(*this);
   if (const FullExpr *fe = dyn_cast_or_null(RV)) {
-enterFullExpression(fe);
-RV = fe->getSubExpr();
+// Constant expressions will emit their cached APValues, so
+// we don't want to handle this here, as it will unwrap them,
+// preventing the cached results from being used.
+if (!isa(fe)) {
+  enterFullExpression(fe);
+  RV = fe->getSubExpr();
+}
   }
 
   // FIXME: Clean this up by using an LValue for ReturnTemp,
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -433,7 +433,13 @@
   Value *VisitExpr(Expr *S);
 
   Value *VisitConstantExpr(ConstantExpr *E) {
-return Visit(E->getSubExpr());
+if (E->hasAPValueResult()) {
+  assert(!E->getType()->isVoidType());
+  return ConstantEmitter(CGF).emitAbstract(
+  E->getLocation(), E->getAPValueResult(), E->getType());
+} else {
+  return Visit(E->getSubExpr());
+}
   }
   Value *VisitParenExpr(ParenExpr *PE) {
 return Visit(PE->getSubExpr());
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -126,7 +126,17 @@
   }
 
   void VisitConstantExpr(ConstantExpr *E) {
-return Visit(E->getSubExpr());
+if (E->hasAPValueResult()) {
+  // Create a temporary for the value and store the constant.
+  llvm::Constant *Const = ConstantEmitter(CGF).emitAbstract(
+  E->getLocation(), E->getAPValueResult(), E->getType());
+  Address Addr = CGF.CreateMemTemp(E->getType());
+  CGF.InitTempAlloca(Addr, Const);
+  RValue RV = RValue::getAggregate(Addr);
+  EmitFinalDestCopy(E->getType(), RV);
+} else {
+  Visit(E->getSubExpr());
+}
   }
 
   // l-values.
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1292,8 +1292,20 @@
 return EmitVAArgExprLValue(cast(E));
   case Expr::DeclRefExprClass:
 return EmitDeclRefLValue(cast(E));
-  case Expr::ConstantExprClass:
-return EmitLValue(cast(E)->getSubExpr());
+  case Expr::ConstantExprClass: {
+const ConstantExpr *CE = cast(E);
+
+if (CE->hasAPValueResult()) {
+  QualType T = getContext().getPointerType(CE->getType());
+  llvm::Constant *C = ConstantEmitter(*this).emitAbstract(
+  CE->getLocation(), CE->getAPValueResult(), T);
+  ConstantAddress Addr(C, getContext().getTypeAlignInChars(T));
+  LValueBaseInfo BI;
+  return LValue::MakeAddr(Addr, T, getContext(), BI, TBAAAccessInfo());
+}
+
+return EmitLValue(CE->getSubExpr());
+  }
   case Expr::ParenExprClass:
 return EmitLValue(cast(E)->getSubExpr());
   case Expr::GenericSelectionExprClass:
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1031,6 +1031,7 @@
   static ResultStorageKind getStorageKind(const Type *T,
   const ASTContext );
 
+  SourceLocation getLocation() const { return getBeginLoc(); }
   SourceLocation getBeginLoc() const LLVM_READONLY {
 return SubExpr->getBeginLoc();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76782: [CodeGenObjC] Fix a crash when attempting to copy a zero-sized bit-field in a non-trivial C struct

2020-03-25 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: ahatanak.
Herald added subscribers: ributzka, dexonsmith, jkorous.

Zero sized bit-fields aren't included in the CGRecordLayout, so we shouldn't be 
calling EmitLValueForField for them.

rdar://60695105


https://reviews.llvm.org/D76782

Files:
  clang/include/clang/AST/NonTrivialTypeVisitor.h
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/test/CodeGenObjC/strong-in-c-struct.m


Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -887,4 +887,14 @@
   func(0);
 }
 
+struct ZeroBitfield {
+  int : 0;
+  id strong;
+};
+
+void test_zero_bitfield() {
+  struct ZeroBitfield volatile a, b;
+  a = b;
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -543,6 +543,10 @@
 std::array Addrs) {
 LValue DstLV, SrcLV;
 if (FD) {
+  // No need to copy zero-length bit-fields.
+  if (FD->isZeroLengthBitField(this->CGF->getContext()))
+return;
+
   QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
   llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo();
   Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);
Index: clang/include/clang/AST/NonTrivialTypeVisitor.h
===
--- clang/include/clang/AST/NonTrivialTypeVisitor.h
+++ clang/include/clang/AST/NonTrivialTypeVisitor.h
@@ -1,4 +1,4 @@
-//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ 
--*-===//
+//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.


Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -887,4 +887,14 @@
   func(0);
 }
 
+struct ZeroBitfield {
+  int : 0;
+  id strong;
+};
+
+void test_zero_bitfield() {
+  struct ZeroBitfield volatile a, b;
+  a = b;
+}
+
 #endif /* USESTRUCT */
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -543,6 +543,10 @@
 std::array Addrs) {
 LValue DstLV, SrcLV;
 if (FD) {
+  // No need to copy zero-length bit-fields.
+  if (FD->isZeroLengthBitField(this->CGF->getContext()))
+return;
+
   QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
   llvm::PointerType *PtrTy = this->CGF->ConvertType(RT)->getPointerTo();
   Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);
Index: clang/include/clang/AST/NonTrivialTypeVisitor.h
===
--- clang/include/clang/AST/NonTrivialTypeVisitor.h
+++ clang/include/clang/AST/NonTrivialTypeVisitor.h
@@ -1,4 +1,4 @@
-//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ --*-===//
+//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Sorry for the delayed comments. It would be good to address those in a separate 
commit if possible.




Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:12
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}

erichkeane wrote:
> Anastasia wrote:
> > Any reason to test unmangled?
> Because you asked to validate the OpenCL cases as well.
Ok, I guess we should add overloadable attribute otherwise it doesn't go 
through mangling? Then I guess you only need a check for Linux or Windows cases.



Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:25
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type

erichkeane wrote:
> Anastasia wrote:
> > I am still unclear why is this special case?
> It isn't possible to overload on these types in Linux mode, because the 
> OpenCL spec on ItaniumABI has a specific mangling that doesn't take element 
> type and read/write into effect.  The probelm is that on Linux BOTH versions 
> of 'test2' end up with the mangling '@_Z5test28ocl_pipe' (and we get an error 
> in codegen).
> 
> 
Oh I see. I think it would be good to explain this better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75685/new/

https://reviews.llvm.org/D75685



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


[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-25 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:82-94
 #undef __CUDACC__
 #if CUDA_VERSION < 9000
 #define __CUDABE__
 #else
+#define __CUDACC__
 #define __CUDA_LIBDEVICE__
 #endif

hliao wrote:
> hliao wrote:
> > tra wrote:
> > > hliao wrote:
> > > > tra wrote:
> > > > > Please add comments on why __CUDACC__ is needed for driver_types.h 
> > > > > here? AFAICT, driver_types.h does not have any conditionals that 
> > > > > depend on __CUDACC__. What happens if it's not defined.
> > > > > 
> > > > > 
> > > > `driver_types.h` includes `host_defines.h`, where macros 
> > > > `__device_builtin_surface_type__` and `__device_builtin_texture_type__` 
> > > > are conditional defined if `__CUDACC__`.
> > > > 
> > > > The following is extracted from `cuda/crt/host_defines.h`
> > > > 
> > > > ```
> > > > #if !defined(__CUDACC__)
> > > > #define __device_builtin__
> > > > #define __device_builtin_texture_type__
> > > > #define __device_builtin_surface_type__
> > > > #define __cudart_builtin__
> > > > #else /* defined(__CUDACC__) */
> > > > #define __device_builtin__ \
> > > > __location__(device_builtin)
> > > > #define __device_builtin_texture_type__ \
> > > > __location__(device_builtin_texture_type)
> > > > #define __device_builtin_surface_type__ \
> > > > __location__(device_builtin_surface_type)
> > > > #define __cudart_builtin__ \
> > > > __location__(cudart_builtin)
> > > > #endif /* !defined(__CUDACC__) */
> > > > ```
> > > My concern is -- what else is going to get defined? There are ~60 
> > > references to __CUDACC__ in CUDA-10.1 headers. The wrappers are fragile 
> > > enough that there's a good chance something may break. It does not help 
> > > that my CUDA build bot decided to die just after we switched to 
> > > work-from-home, so there will be no early warning if something goes wrong.
> > > 
> > > If all we need are the macros above, we may just define them. 
> > Let me check all CUDA SDK through their dockers. Redefining sounds good me 
> > as wll.
> I checked headers from 7.0 to 10.0, `__device_builtin_texture_type__` and 
> `__builtin_builtin_surface_type__` are only defined with that attributes if 
> `__CUDACC__` is defined. As we only pre-define `__CUDA_ARCH__` in clang but 
> flip `__CUDACC__` on and off in the wrapper headers to selectively reuse 
> CUDA's headers. I would hear your suggestion on that.
> BTW, macros like `__device__` are defined regardless of `__CUDACC__` from 7.0 
> to 10.0 as `__location(device)`. `__location__` is defined if `__CUDACC__` is 
> present. But, different from `__device__`, `__device_builtin_texture_type__` 
> is defined only `__CUDACC__` is defined.
`__device_builtin_texture_type__` is defined in `host_defines.h`, which does 
not seem to include any other files or does anything suspicious with 
`__CUDACC__`

It may be OK to move inclusion of `host_defines.h` to the point before 
`driver_types.h`, which happens to include the host_defines.h first, and define 
__CUDACC__ only around `host_defines.h`.

An alternative is to add the macros just after inclusion of `host_defines.h`

In either case please verify that these attributes are the only things that's 
changed by diffing output of `clang++ -x cuda /dev/null --cuda-host-only -dD -E 
-o -` before and after the change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76365/new/

https://reviews.llvm.org/D76365



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


[PATCH] D76770: [CodeComplete] Don't replace the rest of line in #include completion.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Does this regress the case where you complete a file rather than a directory?
e.g. `#include "foo/^one.h"`
If you select "two.h", then we definitely want to replace "one.h", right?

The root here is that we have to decide what to replace independently of the 
completion item.
One compromise might be to replace up to the quote, but if you're completing 
`"foo/^one.h"` and `bar` is a directory, check if `foo/bar/one.h` exists and 
offer it as a completion. Seems complicated though.

Or we can take the tradeoff here if it's better but it'd be good to understand 
why.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76770/new/

https://reviews.llvm.org/D76770



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/Expr.h:3465
+SubExprs[RHS] = rhs;
+hasFPFeatures = true;
+isCompoundAssign = 1;

mibintc wrote:
> rjmccall wrote:
> > Okay, so this is *always* adding trailing storage.  Is there a common value 
> > for `FPOptions` — something that corresponds to default settings, for 
> > example — that we could use to avoid needing storage in the common case?
> > 
> > Also, it would be useful to extract a function somewhere that you can use 
> > in all of these places for consistency, maybe something like this on 
> > `FPOptions`:
> > 
> > ```
> >   /// Does this FPOptions require trailing storage when stored in various 
> > AST nodes,
> >   /// or can it be recreated using `defaultWithoutTrailingStorage`?
> >   bool requiresTrailingStorage() const { return *this == 
> > defaultWithoutTrailingStorage(); }
> > 
> >   /// Return the default value of FPOptions that's used when trailing 
> > storage isn't required.
> >   static FPOptions defaultWithoutTrailingStorage() { ... }
> > ```
> The reason I set hasFPFeatures to True in this revision is because in the 
> previous review you asked me to make it purely a representational change and 
> "add stuff about whether there is a pragma in a separate patch".  The stuff I 
> had in the previous version was smarter about creating trailing storage, it 
> only created trailing storage when the pragma was in effect. I envirsioned 
> that the evolution would accept something that always created the FPOptions 
> in trailing storage, and in the 2nd generation would adopt the more thrifty 
> way of creating trailing storage. 
Well, let's at least set up the infrastructure and APIs correctly, even if we 
always allocate trailing storage.

For example, should `getFPOptions` take an `ASTContext &` so that it can always 
return the right options instead of making clients do `hasFPOptions() ? 
getFPOptions() : ctx.getFPOptions()`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76384/new/

https://reviews.llvm.org/D76384



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


[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

I don't think there's a particularly good reason to expose this as a builtin, 
unless it's to be used by the standard library implementation. (Which again I 
do not think we should implement.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76525/new/

https://reviews.llvm.org/D76525



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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-03-25 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

edit: actually you've already done the clang-format on trunk as I hoped, 
phabricator mislead me. Apologies for the noise


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76342/new/

https://reviews.llvm.org/D76342



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@lebedev.ri my misunderstanding. I'll commit :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918



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


[clang] bb4da94 - [ARM, CDE] Implement predicated Q-register CDE intrinsics

2020-03-25 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-03-25T17:08:19Z
New Revision: bb4da94e5b5f64ea68197de9be44c7c5a4c91ce7

URL: 
https://github.com/llvm/llvm-project/commit/bb4da94e5b5f64ea68197de9be44c7c5a4c91ce7
DIFF: 
https://github.com/llvm/llvm-project/commit/bb4da94e5b5f64ea68197de9be44c7c5a4c91ce7.diff

LOG: [ARM,CDE] Implement predicated Q-register CDE intrinsics

Summary:
This patch implements the following CDE intrinsics:

  T __arm_vcx1q_m(int coproc, T inactive, uint32_t imm, mve_pred_t p);
  T __arm_vcx2q_m(int coproc, T inactive, U n, uint32_t imm, mve_pred_t p);
  T __arm_vcx3q_m(int coproc, T inactive, U n, V m, uint32_t imm, mve_pred_t p);

  T __arm_vcx1qa_m(int coproc, T acc, uint32_t imm, mve_pred_t p);
  T __arm_vcx2qa_m(int coproc, T acc, U n, uint32_t imm, mve_pred_t p);
  T __arm_vcx3qa_m(int coproc, T acc, U n, V m, uint32_t imm, mve_pred_t p);

The intrinsics are not part of the released ACLE spec, but internally at
Arm we have reached consensus to add them to the next ACLE release.

Reviewers: simon_tatham, MarkMurrayARM, ostannard, dmgreen

Reviewed By: simon_tatham

Subscribers: kristof.beyls, hiraditya, danielkiss, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/arm_cde.td
clang/test/CodeGen/arm-cde-vec.c
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrCDE.td
llvm/test/CodeGen/Thumb2/cde-vec.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_cde.td 
b/clang/include/clang/Basic/arm_cde.td
index e258bf5ee83e..6a00e669864c 100644
--- a/clang/include/clang/Basic/arm_cde.td
+++ b/clang/include/clang/Basic/arm_cde.td
@@ -189,6 +189,40 @@ def vcx3qa : FunctionMacro<
   "__arm_vcx3qa_impl((cp), (acc), __arm_vreinterpretq_u8(n), "
  "__arm_vreinterpretq_u8(m), (imm))">;
 
+class CDEIntrinsicMasked
+  : CDEIntrinsic
+$cp, $inactive_or_acc), cgArgs, (? $imm, $pred))> {
+  let params = T.All;
+  let polymorphicOnly = 1;
+}
+
+def vcx1q_m : CDEIntrinsicMasked<"vcx1q", (args), (args imm_12b:$imm), (?)>;
+def vcx1qa_m : CDEIntrinsicMasked<"vcx1qa", (args), (args imm_12b:$imm), (?)>;
+
+multiclass VCXPredicated macroArgs, string macro> {
+  def _m_impl : CDEIntrinsicMasked;
+  def a_m_impl : CDEIntrinsicMasked;
+
+  def _m: FunctionMacro<
+!listconcat(["cp", "inactive"], macroArgs, ["imm", "pred"]),
+"__arm_"#NAME#"_m_impl((cp), (inactive), "#macro#" (imm), (pred))">;
+  def a_m: FunctionMacro<
+!listconcat(["cp", "acc"], macroArgs, ["imm", "pred"]),
+"__arm_"#NAME#"a_m_impl((cp), (acc), "#macro#" (imm), (pred))">;
+}
+
+defm vcx2q :
+  VCXPredicated<(args v16u8:$n), (args imm_7b:$imm), (? $n), ["n"],
+"__arm_vreinterpretq_u8(n),">;
+defm vcx3q :
+  VCXPredicated<(args v16u8:$n, v16u8:$m), (args imm_4b:$imm), (? $n, $m),
+["n", "m"], "__arm_vreinterpretq_u8(n), "
+"__arm_vreinterpretq_u8(m),">;
+
 // vreinterpretq intrinsics required by the ACLE CDE specification
 
 foreach desttype = [/* no u8 */ s8, u16, s16, u32, s32, u64, s64, f16, f32] in 
{

diff  --git a/clang/test/CodeGen/arm-cde-vec.c 
b/clang/test/CodeGen/arm-cde-vec.c
index fcf9270d87f0..ea186a46be00 100644
--- a/clang/test/CodeGen/arm-cde-vec.c
+++ b/clang/test/CodeGen/arm-cde-vec.c
@@ -102,3 +102,75 @@ uint64x2_t test_vcx3q(uint64x2_t n, float32x4_t m) {
 int8x16_t test_vcx3qa(int8x16_t acc, uint16x8_t n, float32x4_t m) {
   return __arm_vcx3qa(1, acc, n, m, 13);
 }
+
+// CHECK-LABEL: @test_vcx1q_m(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i16> 
@llvm.arm.cde.vcx1q.predicated.v8i16.v8i1(i32 0, <8 x i16> [[INACTIVE:%.*]], 
i32 , <8 x i1> [[TMP1]])
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+uint16x8_t test_vcx1q_m(uint16x8_t inactive, mve_pred16_t p) {
+  return __arm_vcx1q_m(0, inactive, , p);
+}
+
+// CHECK-LABEL: @test_vcx1qa_m(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <16 x i8> 
@llvm.arm.cde.vcx1qa.predicated.v16i8.v16i1(i32 1, <16 x i8> [[ACC:%.*]], i32 
1112, <16 x i1> [[TMP1]])
+// CHECK-NEXT:ret <16 x i8> [[TMP2]]
+//
+uint8x16_t test_vcx1qa_m(uint8x16_t acc, mve_pred16_t p) {
+  return __arm_vcx1qa_m(1, acc, 1112, p);
+}
+
+// CHECK-LABEL: @test_vcx2q_m(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x float> [[N:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP2:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP1]])
+// CHECK-NEXT:[[TMP3:%.*]] = call <4 x i32> 

[clang-tools-extra] 8f237f9 - [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-25T17:59:09+01:00
New Revision: 8f237f9b09aa10fcb684a2ceddc3128e1cafadc7

URL: 
https://github.com/llvm/llvm-project/commit/8f237f9b09aa10fcb684a2ceddc3128e1cafadc7
DIFF: 
https://github.com/llvm/llvm-project/commit/8f237f9b09aa10fcb684a2ceddc3128e1cafadc7.diff

LOG: [clangd] Support multiple cursors in selectionRange.

Summary:
One change: because there's no way to signal failure individually for
each cursor, we now "succeed" with an empty range with no parent if a
cursor doesn't point at anything.

Reviewers: usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/SemanticSelection.h
clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h
llvm/include/llvm/Testing/Support/Annotations.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index d0e8d139a40e..9be449660eb0 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -150,21 +150,6 @@ llvm::Error validateEdits(const DraftStore , 
const FileEdits ) {
   llvm::to_string(InvalidFileCount - 1) + " others)");
 }
 
-// Converts a list of Ranges to a LinkedList of SelectionRange.
-SelectionRange render(const std::vector ) {
-  if (Ranges.empty())
-return {};
-  SelectionRange Result;
-  Result.range = Ranges[0];
-  auto *Next = 
-  for (const auto  : llvm::make_range(Ranges.begin() + 1, Ranges.end())) {
-*Next = std::make_unique();
-Next->get()->range = R;
-Next = >get()->parent;
-  }
-  return Result;
-}
-
 } // namespace
 
 // MessageHandler dispatches incoming LSP messages.
@@ -1206,24 +1191,13 @@ void ClangdLSPServer::onSymbolInfo(const 
TextDocumentPositionParams ,
 void ClangdLSPServer::onSelectionRange(
 const SelectionRangeParams ,
 Callback> Reply) {
-  if (Params.positions.size() != 1) {
-elog("{0} positions provided to SelectionRange. Supports exactly one "
- "position.",
- Params.positions.size());
-return Reply(llvm::make_error(
-"SelectionRange supports exactly one position",
-ErrorCode::InvalidRequest));
-  }
   Server->semanticRanges(
-  Params.textDocument.uri.file(), Params.positions[0],
+  Params.textDocument.uri.file(), Params.positions,
   [Reply = std::move(Reply)](
-  llvm::Expected> Ranges) mutable {
-if (!Ranges) {
+  llvm::Expected> Ranges) mutable {
+if (!Ranges)
   return Reply(Ranges.takeError());
-}
-std::vector Result;
-Result.emplace_back(render(std::move(*Ranges)));
-return Reply(std::move(Result));
+return Reply(std::move(*Ranges));
   });
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 3d68f85b6487..acfaa81dbf29 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -654,14 +654,22 @@ void ClangdServer::symbolInfo(PathRef File, Position Pos,
   WorkScheduler.runWithAST("SymbolInfo", File, std::move(Action));
 }
 
-void ClangdServer::semanticRanges(PathRef File, Position Pos,
-  Callback> CB) {
-  auto Action =
-  [Pos, CB = std::move(CB)](llvm::Expected InpAST) mutable {
-if (!InpAST)
-  return CB(InpAST.takeError());
-CB(clangd::getSemanticRanges(InpAST->AST, Pos));
-  };
+void ClangdServer::semanticRanges(PathRef File,
+  const std::vector ,
+  Callback> CB) {
+  auto Action = [Positions, CB = std::move(CB)](
+llvm::Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+std::vector Result;
+for (const auto  : Positions) {
+  if (auto Range = clangd::getSemanticRanges(InpAST->AST, Pos))
+Result.push_back(std::move(*Range));
+  else
+return CB(Range.takeError());
+}
+CB(std::move(Result));
+  };
   WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index ae3dd8a065d8..8d9193366d95 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -292,8 +292,8 @@ class ClangdServer {
   Callback> CB);
 
   /// Get semantic ranges around a specified position in a 

[clang] eaa7d00 - [analyzer][NFC] Add missing LLVM header blurb (and license)

2020-03-25 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-03-25T17:57:29+01:00
New Revision: eaa7d00f366ba53e9cf4391163b93253065c2e6c

URL: 
https://github.com/llvm/llvm-project/commit/eaa7d00f366ba53e9cf4391163b93253065c2e6c
DIFF: 
https://github.com/llvm/llvm-project/commit/eaa7d00f366ba53e9cf4391163b93253065c2e6c.diff

LOG: [analyzer][NFC] Add missing LLVM header blurb (and license)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index be1a65c474d8..b7d615bec9ac 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -1,3 +1,15 @@
+//==- CheckPlacementNew.cpp - Check for placement new operation --*- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines a check for misuse of the default placement new operator.
+//
+//===--===//
+
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"



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


[clang] b915aec - Add method to TargetInfo to get CPU cache line size

2020-03-25 Thread via cfe-commits

Author: zoecarver
Date: 2020-03-25T09:50:38-07:00
New Revision: b915aec6b591bdd9a9ffef73db241353b5ba2e2c

URL: 
https://github.com/llvm/llvm-project/commit/b915aec6b591bdd9a9ffef73db241353b5ba2e2c
DIFF: 
https://github.com/llvm/llvm-project/commit/b915aec6b591bdd9a9ffef73db241353b5ba2e2c.diff

LOG: Add method to TargetInfo to get CPU cache line size

Summary:
This patch adds a virtual method `getCPUCacheLineSize()` to `TargetInfo`. 
Currently, I've only implemented the method in `X86TargetInfo`. It's extremely 
important that each CPU's cache line size correct (e.g., we can't just define 
it as `64` across the board) so, it has been a little slow getting to this 
point.

I'll work on the ARM CPUs next, but that will probably come later in a 
different patch.

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index cbfcece1b666..615f09985132 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1206,6 +1206,10 @@ class TargetInfo : public virtual 
TransferrableTargetInfo,
 "cpu_specific Multiversioning not implemented on this target");
   }
 
+  // Get the cache line size of a given cpu. This method switches over
+  // the given cpu and returns "None" if the CPU is not found.
+  virtual Optional getCPUCacheLineSize() const { return None; }
+
   // Returns maximal number of args passed in registers.
   unsigned getRegParmMax() const {
 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 7b575f52bb22..f35b520de657 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1731,6 +1731,119 @@ bool X86TargetInfo::validateAsmConstraint(
   }
 }
 
+// Below is based on the following information:
+// 
++-+--+
+// |   Processor Name   | Cache Line Size (Bytes) |
Source  
  |
+// 
++-+--+
+// | i386   |  64 | 
https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf
  |
+// | i486   |  16 | "four 
doublewords" (doubleword = 32 bits, 4 bits * 32 bits = 16 bytes) 
https://en.wikichip.org/w/images/d/d3/i486_MICROPROCESSOR_HARDWARE_REFERENCE_MANUAL_%281990%29.pdf
 and 
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.126.4216=rep1=pdf
 (page 29) |
+// | i586/Pentium MMX   |  32 | 
https://www.7-cpu.com/cpu/P-MMX.html
 |
+// | i686/Pentium   |  32 | 
https://www.7-cpu.com/cpu/P6.html   
 |
+// | Netburst/Pentium4  |  64 | 
https://www.7-cpu.com/cpu/P4-180.html   
 |
+// | Atom   |  64 | 
https://www.7-cpu.com/cpu/Atom.html 
 |
+// | Westmere   |  64 | 
https://en.wikichip.org/wiki/intel/microarchitectures/sandy_bridge_(client) 
"Cache Architecture"
 |
+// | Sandy Bridge   |  64 | 
https://en.wikipedia.org/wiki/Sandy_Bridge and 
https://www.7-cpu.com/cpu/SandyBridge.html  
  |
+// | Ivy Bridge |  64 | 
https://blog.stuffedcow.net/2013/01/ivb-cache-replacement/ and 
https://www.7-cpu.com/cpu/IvyBridge.html   

[PATCH] D75661: Remove SequentialType from the type heirarchy.

2020-03-25 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added a comment.

I'd like the see the clang-format complaints actually addressed, but don't 
bother unless you need to upload another patch for some other reason anyways.

That aside, LGTM. This has been looked at by 3 people (plus yourself). So far, 
nobody has had any serious objections. Perhaps enough has been enough?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75661/new/

https://reviews.llvm.org/D75661



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:409
 
-  Optional FoundSummary = findFunctionSummary(FD, CE, C);
+  for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
+ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > martong wrote:
> > > > NoQ wrote:
> > > > > Maybe we should add an assertion that the same argument isn't 
> > > > > specified multiple times.
> > > > I think there could be cases when we want to have e.g. a not-null 
> > > > constraint on the 1st argument, but also we want to express that the 
> > > > 1st argument's size is described by the 2nd argument. I am planning to 
> > > > implement such a constraints in the future. In that case we would have 
> > > > two constraints on the 1st argument and the assert would fire.
> > > Wait, i misunderstood the code. It's even worse than that: you're adding 
> > > transitions in a loop, so it'll cause state splits for every constraint. 
> > > Because you do not intend to create multiple branches here, there needs 
> > > to be exactly one `addTransition` performed every time `checkPreCall` is 
> > > called. I.e., for now this code is breaking everything whenever there's 
> > > more than one constraint, regardless of whether it's on the same argument.
> > Yeah, that's a very good catch, thanks! I am going to prepare a patch to 
> > fix this soon. My idea is to store the `SuccessSt` and apply the next 
> > argument constraint on that. And once the loop is finished I'll have call 
> > the `addTransition()`.
> Yup, that's the common thing to do in such cases.
While we're at it, could you try to come up with a runtime assertion that'll 
help us prevent these mistakes?

Like, dunno, make `CheckerContext` crash whenever there's more than one branch 
being added, and then add a method to opt out when it's actually necessary to 
add more transitions (i.e., the user would say `C.setMaxTransitions(2)` at the 
beginning of their checker callback whenever they need to make a state split, 
defaulting to 1). It's a bit tricky because i still want to allow multiple 
transitions when they allow one branch (i.e., transitions chained together) but 
i think it'll take a lot of review anxiety from me because it's a very 
dangerous mistake to make and for now code review is the only way to catch it. 
So, yay, faster code reviews.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73898/new/

https://reviews.llvm.org/D73898



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-25 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/include/clang/AST/Expr.h:3465
+SubExprs[RHS] = rhs;
+hasFPFeatures = true;
+isCompoundAssign = 1;

rjmccall wrote:
> Okay, so this is *always* adding trailing storage.  Is there a common value 
> for `FPOptions` — something that corresponds to default settings, for example 
> — that we could use to avoid needing storage in the common case?
> 
> Also, it would be useful to extract a function somewhere that you can use in 
> all of these places for consistency, maybe something like this on `FPOptions`:
> 
> ```
>   /// Does this FPOptions require trailing storage when stored in various AST 
> nodes,
>   /// or can it be recreated using `defaultWithoutTrailingStorage`?
>   bool requiresTrailingStorage() const { return *this == 
> defaultWithoutTrailingStorage(); }
> 
>   /// Return the default value of FPOptions that's used when trailing storage 
> isn't required.
>   static FPOptions defaultWithoutTrailingStorage() { ... }
> ```
The reason I set hasFPFeatures to True in this revision is because in the 
previous review you asked me to make it purely a representational change and 
"add stuff about whether there is a pragma in a separate patch".  The stuff I 
had in the previous version was smarter about creating trailing storage, it 
only created trailing storage when the pragma was in effect. I envirsioned that 
the evolution would accept something that always created the FPOptions in 
trailing storage, and in the 2nd generation would adopt the more thrifty way of 
creating trailing storage. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76384/new/

https://reviews.llvm.org/D76384



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Like i said in previous comments, this can be moved later, that is not a 
blocker.
Ship it first :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-25 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I don't see those Harbormaster fails, using trunk and RHEL8 on architecture 
x86_64, Debug build of clang;clang-tools-extra and check-all. I ran all the 
failed lit tests separately and each passed


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76384/new/

https://reviews.llvm.org/D76384



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


[PATCH] D74918: Add method to TargetInfo to get CPU cache line size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

I don't know enough about clang and llvm to know what is both possible and 
preferable. @craig.topper @lebedev.ri what is the best course of action here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74918/new/

https://reviews.llvm.org/D74918



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


[PATCH] D76525: Expose cache line size in __builtin_get_cpu_cache_line_size

2020-03-25 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@craig.topper thanks for the comments! I'm going to hold off on updating this 
until we figure out what's happening with D74918 
, though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76525/new/

https://reviews.llvm.org/D76525



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/Expr.h:2573
 
+  FPOptions FPFeatures;
+

Let's split the CallExpr changes out into a separate patch, so that we have one 
patch that's *purely* about unifying BinaryOperator and CompoundAssignOperator 
and putting FPOptions in trailing storage, and then another that's about adding 
FPOptions to CallExpr.

For that latter patch, CallExpr already has its own, hand-rolled concept of 
trailing storage which you should be able to emulate instead of unifying the 
hierarchy.



Comment at: clang/include/clang/AST/Expr.h:3417
+: public Expr,
+  private llvm::TrailingObjects {
   enum { LHS, RHS, END_EXPR };

Why does this use `unsigned` for the trailing storage of the `FPOptions`?



Comment at: clang/include/clang/AST/Expr.h:3421
+  bool hasFPFeatures;
+  bool isCompoundAssign;
+

Can these bits go in the bitfields?



Comment at: clang/include/clang/AST/Expr.h:3465
+SubExprs[RHS] = rhs;
+hasFPFeatures = true;
+isCompoundAssign = 1;

Okay, so this is *always* adding trailing storage.  Is there a common value for 
`FPOptions` — something that corresponds to default settings, for example — 
that we could use to avoid needing storage in the common case?

Also, it would be useful to extract a function somewhere that you can use in 
all of these places for consistency, maybe something like this on `FPOptions`:

```
  /// Does this FPOptions require trailing storage when stored in various AST 
nodes,
  /// or can it be recreated using `defaultWithoutTrailingStorage`?
  bool requiresTrailingStorage() const { return *this == 
defaultWithoutTrailingStorage(); }

  /// Return the default value of FPOptions that's used when trailing storage 
isn't required.
  static FPOptions defaultWithoutTrailingStorage() { ... }
```



Comment at: clang/include/clang/AST/Expr.h:3471
+assert(isCompoundAssignmentOp() &&
+   "Expected CompoundAssignOperator for compound assignments");
+setComputationLHSType(CompLHSType);

Please change the text in this assertion and the one in the constructor above.  
The requirement is now that you use the appropriate constructor for the case.  
Or maybe we should just have one constructor that takes optional 
CompLHS/CompResult types and then assert that they're given if we're building a 
compound assignment?  If you do the same for `Create`, the whole thing might 
end up being much more convenient for callers, too.



Comment at: clang/include/clang/AST/Expr.h:3643
+return *getTrailingObjects();
+  }
+

Are these necessary?



Comment at: clang/include/clang/AST/Expr.h:3676
+getTrailingObjects()[1] = T;
+  }
+

These should all assert that they're being used on a compound-assignment 
operator.

Please preserve the comments from CompoundAssignOperator on these.



Comment at: clang/include/clang/AST/Expr.h:6029
   friend class ASTStmtWriter;
 };
 

Why is this in this patch?



Comment at: clang/lib/AST/Expr.cpp:4285
+   FPOptions FPFeatures) {
+  bool hasFPFeatures = true;
+  unsigned SizeOfTrailingObjects =

These places should use that same unified predicate.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76384/new/

https://reviews.llvm.org/D76384



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


[PATCH] D76772: [AMDGPU] Add __builtin_amdgcn_workgroup_size_x/y/z

2020-03-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13428
+return Call;
+  return CGF.Builder.CreateAddrSpaceCast(Call, RetTy);
+}

Why is this necessary? The builtin always has the same return type?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13435
+  auto *DP = EmitAMDGPUDispatchPtr(CGF);
+  auto *Offset = llvm::ConstantInt::get(CGF.Int32Ty, XOffset + Index * 2);
+  auto *GEP = CGF.Builder.CreateGEP(DP, Offset);

Comment that this is indexing the hsa_kernel_dispatch_packet sstruct?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13442
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1), APInt(16, 1025));
+  LD->setMetadata(llvm::LLVMContext::MD_range, RNode);

I thought I had a patch to include the maximum group size in AMDGPUTargetInfo 
to avoid hardcoding it, but I guess it was never committed



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13443
+  llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1), APInt(16, 1025));
+  LD->setMetadata(llvm::LLVMContext::MD_range, RNode);
+  return LD;

Also set it's invariant



Comment at: clang/test/CodeGenOpenCL/builtins-amdgcn.cl:539
+void test_get_workgroup_size(int d, global int *out)
+{
+   switch (d) {

Also run in a hip test, or some case where the addrspacecast is needed?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76772/new/

https://reviews.llvm.org/D76772



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


[PATCH] D43159: Modernize: Use nullptr more.

2020-03-25 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Ping -- is there still interest in moving forward with this? If so, please 
address the comments and update the patch, otherwise you can abandon the 
revision to clean up the libc++ review queue.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43159/new/

https://reviews.llvm.org/D43159



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


[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D76761#1941380 , @njames93 wrote:

> In D76761#1941070 , @gribozavr2 
> wrote:
>
> > Could you provide more information about why these null checks are needed 
> > in this case?
>
>
> Well the fact it was crashing without those null checks was the reason they 
> were added. I'm not 100% sure of the root cause and this could just be a case 
> of applying a plaster to a broken arm. I'm guessing the root cause of the 
> crash is the fact the callee is a `CXXMethodDecl` which is not being handled 
> but I honestly don't know.


Right -- what I meant is a more detailed description of why, for example, 
`tryGetCallExprAncestorForCxxConstructExpr` can't find the `CallExpr` in this 
case -- is it not there, or does it not have the expected shape, or something 
else? What does the AST look like?

I'm worried about adding defensive checks because they can make code more 
difficult to fix in future.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76761/new/

https://reviews.llvm.org/D76761



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:1
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"

Szelethus wrote:
> Header blurb is missing :) Could you sneak it in there?
Sure, I am getting right on it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71612/new/

https://reviews.llvm.org/D71612



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


[PATCH] D70366: Add new 'flatten' LLVM attribute to fix clang's 'flatten' function attribute

2020-03-25 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.
Herald added a subscriber: kerbowa.

[reverse ping] Is this still active?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70366/new/

https://reviews.llvm.org/D70366



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:409
 
-  Optional FoundSummary = findFunctionSummary(FD, CE, C);
+  for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
+ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);

martong wrote:
> NoQ wrote:
> > martong wrote:
> > > NoQ wrote:
> > > > Maybe we should add an assertion that the same argument isn't specified 
> > > > multiple times.
> > > I think there could be cases when we want to have e.g. a not-null 
> > > constraint on the 1st argument, but also we want to express that the 1st 
> > > argument's size is described by the 2nd argument. I am planning to 
> > > implement such a constraints in the future. In that case we would have 
> > > two constraints on the 1st argument and the assert would fire.
> > Wait, i misunderstood the code. It's even worse than that: you're adding 
> > transitions in a loop, so it'll cause state splits for every constraint. 
> > Because you do not intend to create multiple branches here, there needs to 
> > be exactly one `addTransition` performed every time `checkPreCall` is 
> > called. I.e., for now this code is breaking everything whenever there's 
> > more than one constraint, regardless of whether it's on the same argument.
> Yeah, that's a very good catch, thanks! I am going to prepare a patch to fix 
> this soon. My idea is to store the `SuccessSt` and apply the next argument 
> constraint on that. And once the loop is finished I'll have call the 
> `addTransition()`.
Yup, that's the common thing to do in such cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73898/new/

https://reviews.llvm.org/D73898



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


[PATCH] D31343: Add an attribute plugin example

2020-03-25 Thread John Brawn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f03c12a51be: Add an attribute plugin example (authored by 
john.brawn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D31343/new/

https://reviews.llvm.org/D31343

Files:
  clang/docs/ClangPlugins.rst
  clang/examples/Attribute/Attribute.cpp
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugin-attribute.cpp

Index: clang/test/Frontend/plugin-attribute.cpp
===
--- /dev/null
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
+// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// REQUIRES: plugins, examples
+
+void fn1a() __attribute__((example)) { }
+[[example]] void fn1b() { }
+[[plugin::example]] void fn1c() { }
+void fn2() __attribute__((example("somestring"))) { }
+// ATTRIBUTE: warning: 'example' attribute only applies to functions
+int var1 __attribute__((example("otherstring"))) = 1;
+
+// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
+// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
+// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
+
+#ifdef BAD_ATTRIBUTE
+class Example {
+  // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
+  void __attribute__((example)) fn3();
+};
+// BADATTRIBUTE: error: 'example' attribute requires a string
+void fn4() __attribute__((example(123))) { }
+// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
+void fn5() __attribute__((example("a","b"))) { }
+#endif
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -81,6 +81,7 @@
 
 if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
+Attribute
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -6,3 +6,4 @@
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
+add_subdirectory(Attribute)
Index: clang/examples/Attribute/CMakeLists.txt
===
--- /dev/null
+++ clang/examples/Attribute/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+clangAST
+clangBasic
+clangFrontend
+clangLex
+LLVMSupport
+)
+endif()
Index: clang/examples/Attribute/Attribute.cpp
===
--- /dev/null
+++ clang/examples/Attribute/Attribute.cpp
@@ -0,0 +1,80 @@
+//===- Attribute.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Example clang plugin which adds an an annotation to file-scope declarations
+// with the 'example' attribute.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/IR/Attributes.h"
+using namespace clang;
+
+namespace {
+
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Can take an optional string argument (the check that the argument
+// actually is a string happens in handleDeclAttribute).
+OptArgs = 1;
+// GNU-style __attribute__(("example")) and C++-style [[example]] and
+// [[plugin::example]] supported.
+Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "plugin::example"});
+  }
+
+  bool diagAppertainsToDecl(Sema , const ParsedAttr ,
+const Decl *D) const override {
+// This attribute appertains to functions only.
+if (!isa(D)) {
+  S.Diag(Attr.getLoc(), 

[PATCH] D76704: Don't normalise CXX11/C2X attribute names to start with ::

2020-03-25 Thread John Brawn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc3f171090f6: Dont normalise CXX11/C2X attribute names 
to start with :: (authored by john.brawn).

Changed prior to commit:
  https://reviews.llvm.org/D76704?vs=252308=252578#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76704/new/

https://reviews.llvm.org/D76704

Files:
  clang/lib/Basic/Attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3739,10 +3739,8 @@
 for (const auto  : GetFlattenedSpellings(Attr)) {
   const std::string  = S.name();
   std::string Spelling;
-  if (S.variety() == "CXX11" || S.variety() == "C2x") {
-Spelling += S.nameSpace();
-Spelling += "::";
-  }
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
   if (S.variety() == "GNU")
 Spelling += NormalizeGNUAttrSpelling(RawSpelling);
   else
@@ -3815,12 +3813,12 @@
 const std::string  = S.variety();
 if (Variety == "CXX11") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "C2x") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "GNU")
   Matches = 
 else if (Variety == "Declspec")
Index: clang/lib/Basic/Attributes.cpp
===
--- clang/lib/Basic/Attributes.cpp
+++ clang/lib/Basic/Attributes.cpp
@@ -85,12 +85,12 @@
   StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
   StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
 
-  // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
-  // unscoped.
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty()) {
+assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+   SyntaxUsed == AttributeCommonInfo::AS_C2X);
 FullName += "::";
+  }
   FullName += AttrName;
 
   return FullName;


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3739,10 +3739,8 @@
 for (const auto  : GetFlattenedSpellings(Attr)) {
   const std::string  = S.name();
   std::string Spelling;
-  if (S.variety() == "CXX11" || S.variety() == "C2x") {
-Spelling += S.nameSpace();
-Spelling += "::";
-  }
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
   if (S.variety() == "GNU")
 Spelling += NormalizeGNUAttrSpelling(RawSpelling);
   else
@@ -3815,12 +3813,12 @@
 const std::string  = S.variety();
 if (Variety == "CXX11") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "C2x") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "GNU")
   Matches = 
 else if (Variety == "Declspec")
Index: clang/lib/Basic/Attributes.cpp
===
--- clang/lib/Basic/Attributes.cpp
+++ clang/lib/Basic/Attributes.cpp
@@ -85,12 +85,12 @@
   StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
   StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
 
-  // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
-  // unscoped.
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty()) {
+assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+   SyntaxUsed == AttributeCommonInfo::AS_C2X);
 FullName += "::";
+  }
   FullName += AttrName;
 
   return FullName;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76078: [AArch64][SVE] Add a pass for SVE intrinsic optimisations

2020-03-25 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 252575.
kmclaughlin marked an inline comment as done.
kmclaughlin added a comment.

Use SmallSetVector for the list of functions gathered by runOnModule to 
preserve the order of iteration


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76078/new/

https://reviews.llvm.org/D76078

Files:
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
@@ -0,0 +1,203 @@
+; RUN: opt -S -sve-intrinsic-opts -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck --check-prefix OPT %s
+
+define  @reinterpret_test_h( %a) {
+; OPT-LABEL: @reinterpret_test_h(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_h_rev( %a) {
+; OPT-LABEL: @reinterpret_test_h_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_w( %a) {
+; OPT-LABEL: @reinterpret_test_w(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_w_rev( %a) {
+; OPT-LABEL: @reinterpret_test_w_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_d( %a) {
+; OPT-LABEL: @reinterpret_test_d(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_d_rev( %a) {
+; OPT-LABEL: @reinterpret_test_d_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_reductions(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions
+; OPT-NOT: convert
+; OPT-NOT: phi 
+; OPT: phi  [ %a, %br_phi_a ], [ %b, %br_phi_b ], [ %c, %br_phi_c ]
+; OPT-NOT: convert
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c [
+ i32 43, label %br_phi_a
+ i32 45, label %br_phi_b
+  ]
+
+br_phi_a:
+  %a1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  br label %join
+
+br_phi_b:
+  %b1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %b)
+  br label %join
+
+br_phi_c:
+  %c1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %c)
+  br label %join
+
+join:
+  %pg = phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+  %pg1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  ret  %pg1
+}
+
+; No transform as the reinterprets are converting from different types (nxv2i1 & nxv4i1)
+; As the incoming values to the phi must all be the same type, we cannot remove the reinterprets.
+define  @reinterpret_reductions_1(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions_1
+; OPT: convert
+; OPT: phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+; OPT-NOT: phi 
+; OPT: tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c [
+ i32 43, label %br_phi_a
+ i32 45, label %br_phi_b
+  ]
+
+br_phi_a:
+  %a1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  br label %join
+
+br_phi_b:
+  %b1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %b)
+  br label %join
+

[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-25 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86e0a6c60627: Add MS Mangling for OpenCL Pipe types, add 
mangling test. (authored by erichkeane).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D75685?vs=249367=252579#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75685/new/

https://reviews.llvm.org/D75685

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl

Index: clang/test/CodeGenOpenCL/pipe_types_mangling.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/pipe_types_mangling.cl
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++ -o - %s | FileCheck %s --check-prefixes=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=clc++ -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=UNMANGLED,OCLLINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=UNMANGLED,OCLWINDOWS
+
+typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
+typedef int __attribute__((ext_vector_type(4))) int4;
+
+void test1(read_only pipe int p) {
+// LINUX: define void @_Z5test18ocl_pipe
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}
+
+__attribute__((overloadable))
+void test2(write_only pipe float p) {
+// LINUX: define void @_Z5test28ocl_pipe
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+// Note: overloadable attribute makes OpenCL Linux still mangle this,
+// but we cannot overload on pipe still.
+// OCLLINUX: define void @_Z5test28ocl_pipe
+// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+}
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type
+//  or write/read. Our Windows mangling does, so make sure this still works.
+__attribute__((overloadable))
+void test2(read_only pipe int p) {
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
+}
+#endif
+
+
+void test3(read_only pipe const int p) {
+// LINUX: define void @_Z5test38ocl_pipe
+// WINDOWS: define dso_local void @"?test3@@YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test3(
+}
+
+void test4(read_only pipe uchar3 p) {
+// LINUX: define void @_Z5test48ocl_pipe
+// WINDOWS: define dso_local void @"?test4@@YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test4(
+}
+
+void test5(read_only pipe int4 p) {
+// LINUX: define void @_Z5test58ocl_pipe
+// WINDOWS: define dso_local void @"?test5@@YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test5(
+}
+
+typedef read_only pipe int MyPipe;
+kernel void test6(MyPipe p) {
+// LINUX: define spir_kernel void @test6
+// WINDOWS: define dso_local spir_kernel void @test6
+// UNMANGLED: define {{.*}}void @test6(
+}
+
+struct Person {
+  const char *Name;
+  bool isFemale;
+  int ID;
+};
+
+void test_reserved_read_pipe(global struct Person *SDst,
+ read_only pipe struct Person SPipe) {
+// LINUX: define void @_Z23test_reserved_read_pipePU8CLglobal6Person8ocl_pipe
+// WINDOWS: define dso_local void @"?test_reserved_read_pipe@@YAXPEAU?$_ASCLglobal@$$CAUPerson@@@__clang@@U?$ocl_pipe@UPerson@@$00@2@@Z"
+// UNMANGLED: define {{.*}}void @test_reserved_read_pipe(
+}
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -2940,11 +2940,17 @@
 
 void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
  SourceRange Range) {
-  DiagnosticsEngine  = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this OpenCL pipe type yet");
-  Diags.Report(Range.getBegin(), DiagID)
-<< Range;
+  QualType ElementType = T->getElementType();
+
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+  Stream << "?$";
+  Extra.mangleSourceName("ocl_pipe");
+  Extra.mangleType(ElementType, Range, QMM_Escape);
+  Extra.mangleIntegerLiteral(llvm::APSInt::get(T->isReadOnly()), true);
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }
 
 void MicrosoftMangleContextImpl::mangleCXXName(GlobalDecl GD,
___
cfe-commits mailing list

[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D76761#1941070 , @gribozavr2 wrote:

> Could you provide more information about why these null checks are needed in 
> this case?


Well the fact it was crashing without those null checks was the reason they 
were added. I'm not 100% sure of the root cause and this could just be a case 
of applying a plaster to a broken arm. I'm guessing the root cause of the crash 
is the fact the callee is a `CXXMethodDecl` which is not being handled but I 
honestly don't know.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76761/new/

https://reviews.llvm.org/D76761



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


[PATCH] D76365: [cuda][hip] Add CUDA builtin surface/texture reference support.

2020-03-25 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 3 inline comments as done.
hliao added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:82-94
 #undef __CUDACC__
 #if CUDA_VERSION < 9000
 #define __CUDABE__
 #else
+#define __CUDACC__
 #define __CUDA_LIBDEVICE__
 #endif

hliao wrote:
> tra wrote:
> > hliao wrote:
> > > tra wrote:
> > > > Please add comments on why __CUDACC__ is needed for driver_types.h 
> > > > here? AFAICT, driver_types.h does not have any conditionals that depend 
> > > > on __CUDACC__. What happens if it's not defined.
> > > > 
> > > > 
> > > `driver_types.h` includes `host_defines.h`, where macros 
> > > `__device_builtin_surface_type__` and `__device_builtin_texture_type__` 
> > > are conditional defined if `__CUDACC__`.
> > > 
> > > The following is extracted from `cuda/crt/host_defines.h`
> > > 
> > > ```
> > > #if !defined(__CUDACC__)
> > > #define __device_builtin__
> > > #define __device_builtin_texture_type__
> > > #define __device_builtin_surface_type__
> > > #define __cudart_builtin__
> > > #else /* defined(__CUDACC__) */
> > > #define __device_builtin__ \
> > > __location__(device_builtin)
> > > #define __device_builtin_texture_type__ \
> > > __location__(device_builtin_texture_type)
> > > #define __device_builtin_surface_type__ \
> > > __location__(device_builtin_surface_type)
> > > #define __cudart_builtin__ \
> > > __location__(cudart_builtin)
> > > #endif /* !defined(__CUDACC__) */
> > > ```
> > My concern is -- what else is going to get defined? There are ~60 
> > references to __CUDACC__ in CUDA-10.1 headers. The wrappers are fragile 
> > enough that there's a good chance something may break. It does not help 
> > that my CUDA build bot decided to die just after we switched to 
> > work-from-home, so there will be no early warning if something goes wrong.
> > 
> > If all we need are the macros above, we may just define them. 
> Let me check all CUDA SDK through their dockers. Redefining sounds good me as 
> wll.
I checked headers from 7.0 to 10.0, `__device_builtin_texture_type__` and 
`__builtin_builtin_surface_type__` are only defined with that attributes if 
`__CUDACC__` is defined. As we only pre-define `__CUDA_ARCH__` in clang but 
flip `__CUDACC__` on and off in the wrapper headers to selectively reuse CUDA's 
headers. I would hear your suggestion on that.
BTW, macros like `__device__` are defined regardless of `__CUDACC__` from 7.0 
to 10.0 as `__location(device)`. `__location__` is defined if `__CUDACC__` is 
present. But, different from `__device__`, `__device_builtin_texture_type__` is 
defined only `__CUDACC__` is defined.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76365/new/

https://reviews.llvm.org/D76365



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


[PATCH] D75779: [OpenMP] `omp begin/end declare variant` - part 2, sema (+"CG")

2020-03-25 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5396
+  IdentifierInfo  = Context.Idents.get(
+  (D.getIdentifier()->getName() + "." + DVScope.NameSuffix).str());
+  D.SetIdentifier(, D.getBeginLoc());

jdoerfert wrote:
> hfinkel wrote:
> > Is there any way in which this name might become visible to users (e.g., in 
> > error messages)?
> Yes, I think so. One way to trigger it would be to define the same function 
> in the same `omp begin declare variant scope` (or two with the same context). 
> I haven't verified this though.
> TBH, I'm unsure how bad this actually is in the short term. The original name 
> is still a at the beginning. We should obviously make sure the error message 
> is appropriate eventually, e.g., it de-mangles the name.
I think that we have to consider diagnostic quality as a first-class citizen. 
There are a few different ways that we might approach this. A minimal diff from 
what you have might be:

  1. Replace the "." above with ".ompvariant."
  2. Add logic to FunctionDecl::getNameForDiagnostic (or 
NamedDecl::getNameForDiagnostic) that recognizes that magic string in the name 
and alters the printing to do something intelligible for the user with the name.

(I think that (1) is a good idea anyway).

Another way would be to add some first-class property to the function and then 
leave the mangling to CodeGen. Are we mangling these in Sema in other places 
too?




Also, these can have external linkage, right?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:5487
+
+VMIs.erase(VMIs.begin() + BestIdx);
+Exprs.erase(Exprs.begin() + BestIdx);

jdoerfert wrote:
> hfinkel wrote:
> > Why is the ordering here useful? Don't you collect all of the variant 
> > clauses from all of the declarations? Can't there be duplicates? (and does 
> > the relative order need always be the same?) Are we effectively supporting 
> > here, as an extension, cases where not all of the declarations have the 
> > same set of variants declared (it loos like we are because there's no break 
> > in the `while (CalleeFnDecl)` loop, but this makes me wonder if that would 
> > still have an odd behavior.
> > Why is the ordering here useful?
> 
> I don't think it is ordered. We have a conceptual set and BestIdx determines 
> the which of the set is the best. All others are equal.
> 
> > Don't you collect all of the variant clauses from all of the declarations? 
> 
> Yes.
> 
> > Can't there be duplicates? (and does the relative order need always be the 
> > same?)
> 
> Yes (and no).  `getBestVariantMatchForContext` should determine the best 
> regardless of duplicates, we might just try it multiple times if we didn't 
> manage to create a call.
> 
> > Are we effectively supporting here, as an extension, cases where not all of 
> > the declarations have the same set of variants declared (it loos like we 
> > are because there's no break in the while (CalleeFnDecl) loop, but this 
> > makes me wonder if that would still have an odd behavior.
> 
> We are supporting that. All declarations are scanned and all variants are 
> collected. What odd behavior do you refer to?
> 
Makes sense, thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75779/new/

https://reviews.llvm.org/D75779



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:409
 
-  Optional FoundSummary = findFunctionSummary(FD, CE, C);
+  for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
+ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > Maybe we should add an assertion that the same argument isn't specified 
> > > multiple times.
> > I think there could be cases when we want to have e.g. a not-null 
> > constraint on the 1st argument, but also we want to express that the 1st 
> > argument's size is described by the 2nd argument. I am planning to 
> > implement such a constraints in the future. In that case we would have two 
> > constraints on the 1st argument and the assert would fire.
> Wait, i misunderstood the code. It's even worse than that: you're adding 
> transitions in a loop, so it'll cause state splits for every constraint. 
> Because you do not intend to create multiple branches here, there needs to be 
> exactly one `addTransition` performed every time `checkPreCall` is called. 
> I.e., for now this code is breaking everything whenever there's more than one 
> constraint, regardless of whether it's on the same argument.
Yeah, that's a very good catch, thanks! I am going to prepare a patch to fix 
this soon. My idea is to store the `SuccessSt` and apply the next argument 
constraint on that. And once the loop is finished I'll have call the 
`addTransition()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73898/new/

https://reviews.llvm.org/D73898



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


[PATCH] D31343: Add an attribute plugin example

2020-03-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think this was the last remaining review for the feature to support 
attributes as plugins, yes? If so, can you please add a release note about the 
feature to the release notes?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D31343/new/

https://reviews.llvm.org/D31343



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


[clang] 86e0a6c - Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-25 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-25T07:59:22-07:00
New Revision: 86e0a6c6062705ec8f6f7333872d566e74d66424

URL: 
https://github.com/llvm/llvm-project/commit/86e0a6c6062705ec8f6f7333872d566e74d66424
DIFF: 
https://github.com/llvm/llvm-project/commit/86e0a6c6062705ec8f6f7333872d566e74d66424.diff

LOG: Add MS Mangling for OpenCL Pipe types, add mangling test.

SPIRV2.0 Spec only specifies Linux mangling, however our downstream has
use for a Windows mangling for these types.

Unfortunately, the SPIRV
spec specifies a single mangling for all pipe types, despite clang
allowing overloading on these types.  Because of this, this patch
chooses to mangle the read/writability and element type for the windows
mangling.

The windows manglings in the test all demangle according to demangler:
"void __cdecl test1(struct __clang::ocl_pipe)
"void __cdecl test2(struct __clang::ocl_pipe)
"void __cdecl test2(struct __clang::ocl_pipe)
"void __cdecl test3(struct __clang::ocl_pipe)
"void __cdecl test4(struct __clang::ocl_pipe,1>)
"void __cdecl test5(struct __clang::ocl_pipe,1>)
"void __cdecl test_reserved_read_pipe(struct __clang::_ASCLglobal * __ptr64,struct __clang::ocl_pipe)

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

Added: 
clang/test/CodeGenOpenCL/pipe_types_mangling.cl

Modified: 
clang/lib/AST/MicrosoftMangle.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 4c32093bc9dc..0b3c9b738f9c 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2940,11 +2940,17 @@ void MicrosoftCXXNameMangler::mangleType(const 
AtomicType *T, Qualifiers,
 
 void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
  SourceRange Range) {
-  DiagnosticsEngine  = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this OpenCL pipe type yet");
-  Diags.Report(Range.getBegin(), DiagID)
-<< Range;
+  QualType ElementType = T->getElementType();
+
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+  Stream << "?$";
+  Extra.mangleSourceName("ocl_pipe");
+  Extra.mangleType(ElementType, Range, QMM_Escape);
+  Extra.mangleIntegerLiteral(llvm::APSInt::get(T->isReadOnly()), true);
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }
 
 void MicrosoftMangleContextImpl::mangleCXXName(GlobalDecl GD,

diff  --git a/clang/test/CodeGenOpenCL/pipe_types_mangling.cl 
b/clang/test/CodeGenOpenCL/pipe_types_mangling.cl
new file mode 100644
index ..32b3b30759b8
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/pipe_types_mangling.cl
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=clc++ -o - %s | FileCheck %s --check-prefixes=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=clc++ -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=UNMANGLED,OCLLINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=UNMANGLED,OCLWINDOWS
+
+typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
+typedef int __attribute__((ext_vector_type(4))) int4;
+
+void test1(read_only pipe int p) {
+// LINUX: define void @_Z5test18ocl_pipe
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}
+
+__attribute__((overloadable))
+void test2(write_only pipe float p) {
+// LINUX: define void @_Z5test28ocl_pipe
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+// Note: overloadable attribute makes OpenCL Linux still mangle this,
+// but we cannot overload on pipe still.
+// OCLLINUX: define void @_Z5test28ocl_pipe
+// OCLWINDOWS: define dso_local void 
@"?test2@@$$J0YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+}
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type
+//  or write/read. Our Windows mangling does, so make sure this still works.
+__attribute__((overloadable))
+void test2(read_only pipe int p) {
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// OCLWINDOWS: define dso_local void 
@"?test2@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
+}
+#endif
+
+
+void test3(read_only pipe const int p) {
+// LINUX: define void @_Z5test38ocl_pipe
+// WINDOWS: define dso_local void 
@"?test3@@YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test3(
+}
+
+void test4(read_only pipe uchar3 p) {
+// LINUX: define void @_Z5test48ocl_pipe
+// WINDOWS: define dso_local void 

Re: [clang] c278e8f - Build fix: AttributeCommonInfo::AS_C2x

2020-03-25 Thread John Brawn via cfe-commits
Thanks, I was about to fix that myself (I was sure I'd built and tested 
everything before committing,
but it appears I failed somehow).

John


From: cfe-commits  on behalf of Hans 
Wennborg via cfe-commits 
Sent: 25 March 2020 14:43
To: cfe-commits@lists.llvm.org 
Subject: [clang] c278e8f - Build fix: AttributeCommonInfo::AS_C2x


Author: Hans Wennborg
Date: 2020-03-25T15:42:21+01:00
New Revision: c278e8f8f916fd8781f24e41a8685514cc448670

URL: 
https://github.com/llvm/llvm-project/commit/c278e8f8f916fd8781f24e41a8685514cc448670
DIFF: 
https://github.com/llvm/llvm-project/commit/c278e8f8f916fd8781f24e41a8685514cc448670.diff

LOG: Build fix: AttributeCommonInfo::AS_C2x

Added:


Modified:
clang/lib/Basic/Attributes.cpp

Removed:




diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index d479b39e149e..ff6dbf870fcf 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -88,7 +88,7 @@ static SmallString<64> normalizeName(const IdentifierInfo 
*Name,
   SmallString<64> FullName = ScopeName;
   if (!ScopeName.empty()) {
 assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-   SyntaxUsed == AttributeCommonInfo::AS_C2X);
+   SyntaxUsed == AttributeCommonInfo::AS_C2x);
 FullName += "::";
   }
   FullName += AttrName;



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


[clang] c278e8f - Build fix: AttributeCommonInfo::AS_C2x

2020-03-25 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-03-25T15:42:21+01:00
New Revision: c278e8f8f916fd8781f24e41a8685514cc448670

URL: 
https://github.com/llvm/llvm-project/commit/c278e8f8f916fd8781f24e41a8685514cc448670
DIFF: 
https://github.com/llvm/llvm-project/commit/c278e8f8f916fd8781f24e41a8685514cc448670.diff

LOG: Build fix: AttributeCommonInfo::AS_C2x

Added: 


Modified: 
clang/lib/Basic/Attributes.cpp

Removed: 




diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index d479b39e149e..ff6dbf870fcf 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -88,7 +88,7 @@ static SmallString<64> normalizeName(const IdentifierInfo 
*Name,
   SmallString<64> FullName = ScopeName;
   if (!ScopeName.empty()) {
 assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-   SyntaxUsed == AttributeCommonInfo::AS_C2X);
+   SyntaxUsed == AttributeCommonInfo::AS_C2x);
 FullName += "::";
   }
   FullName += AttrName;



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


[clang] 3f03c12 - Add an attribute plugin example

2020-03-25 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2020-03-25T14:33:44Z
New Revision: 3f03c12a51be656c595301ace832c24a68601ee2

URL: 
https://github.com/llvm/llvm-project/commit/3f03c12a51be656c595301ace832c24a68601ee2
DIFF: 
https://github.com/llvm/llvm-project/commit/3f03c12a51be656c595301ace832c24a68601ee2.diff

LOG: Add an attribute plugin example

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

Added: 
clang/examples/Attribute/Attribute.cpp
clang/examples/Attribute/CMakeLists.txt
clang/test/Frontend/plugin-attribute.cpp

Modified: 
clang/docs/ClangPlugins.rst
clang/examples/CMakeLists.txt
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/ClangPlugins.rst b/clang/docs/ClangPlugins.rst
index 7e33ea33c0df..4194491d396a 100644
--- a/clang/docs/ClangPlugins.rst
+++ b/clang/docs/ClangPlugins.rst
@@ -110,6 +110,9 @@ attribute, are:
  * ``existsInTarget``, which checks if the attribute is permitted for the given
target.
 
+To see a working example of an attribute plugin, see `the Attribute.cpp example
+`_.
+
 Putting it all together
 ===
 

diff  --git a/clang/examples/Attribute/Attribute.cpp 
b/clang/examples/Attribute/Attribute.cpp
new file mode 100644
index ..04e30e1bd21b
--- /dev/null
+++ b/clang/examples/Attribute/Attribute.cpp
@@ -0,0 +1,80 @@
+//===- Attribute.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Example clang plugin which adds an an annotation to file-scope declarations
+// with the 'example' attribute.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/IR/Attributes.h"
+using namespace clang;
+
+namespace {
+
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Can take an optional string argument (the check that the argument
+// actually is a string happens in handleDeclAttribute).
+OptArgs = 1;
+// GNU-style __attribute__(("example")) and C++-style [[example]] and
+// [[plugin::example]] supported.
+Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "plugin::example"});
+  }
+
+  bool diagAppertainsToDecl(Sema , const ParsedAttr ,
+const Decl *D) const override {
+// This attribute appertains to functions only.
+if (!isa(D)) {
+  S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
+<< Attr << "functions";
+  return false;
+}
+return true;
+  }
+
+  AttrHandling handleDeclAttribute(Sema , Decl *D,
+   const ParsedAttr ) const override {
+// Check if the decl is at file scope.
+if (!D->getDeclContext()->isFileContext()) {
+  unsigned ID = S.getDiagnostics().getCustomDiagID(
+  DiagnosticsEngine::Error,
+  "'example' attribute only allowed at file scope");
+  S.Diag(Attr.getLoc(), ID);
+  return AttributeNotApplied;
+}
+// Check if we have an optional string argument.
+StringRef Str = "";
+if (Attr.getNumArgs() > 0) {
+  Expr *ArgExpr = Attr.getArgAsExpr(0);
+  StringLiteral *Literal =
+  dyn_cast(ArgExpr->IgnoreParenCasts());
+  if (Literal) {
+Str = Literal->getString();
+  } else {
+S.Diag(ArgExpr->getExprLoc(), diag::err_attribute_argument_type)
+<< Attr.getAttrName() << AANT_ArgumentString;
+return AttributeNotApplied;
+  }
+}
+// Attach an annotate attribute to the Decl.
+D->addAttr(AnnotateAttr::Create(S.Context, "example(" + Str.str() + ")",
+Attr.getRange()));
+return AttributeApplied;
+  }
+};
+
+} // namespace
+
+static ParsedAttrInfoRegistry::Add X("example", "");

diff  --git a/clang/examples/Attribute/CMakeLists.txt 
b/clang/examples/Attribute/CMakeLists.txt
new file mode 100644
index ..19323bb0962b
--- /dev/null
+++ b/clang/examples/Attribute/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+clangAST
+clangBasic
+clangFrontend
+clangLex
+LLVMSupport
+)
+endif()

diff  --git 

[PATCH] D75010: [OpenMP] Adding InaccessibleMemOnly and InaccessibleMemOrArgMemOnly for runtime calls.

2020-03-25 Thread Stefan Stipanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72b51d6f93b5: OpenMP] Adding InaccessibleMemOnly and 
InaccessibleMemOrArgMemOnly for runtime… (authored by sstefan1).

Changed prior to commit:
  https://reviews.llvm.org/D75010?vs=250599=252572#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75010/new/

https://reviews.llvm.org/D75010

Files:
  clang/test/OpenMP/barrier_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/test/Transforms/OpenMP/add_attributes.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll

Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
 ; RUN: opt -S -attributor -openmpopt -attributor-disable=false < %s | FileCheck %s
 ; RUN: opt -S -passes='attributor,cgscc(openmpopt)' -attributor-disable=false < %s | FileCheck %s
 ;
@@ -142,7 +142,7 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A:%.*]] = alloca i32, align 4
 ; CHECK-NEXT:[[TMP:%.*]] = bitcast i32* [[A]] to i8*
-; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull align 4 dereferenceable(4) [[TMP]])
+; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull align 4 dereferenceable(4) [[TMP]]) #0
 ; CHECK-NEXT:store i32 0, i32* [[A]], align 4
 ; CHECK-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @0, i32 1, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*)* @.omp_outlined..3 to void (i32*, i32*, ...)*), i32* nocapture nofree nonnull align 4 dereferenceable(4) [[A]])
 ; CHECK-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull align 8 dereferenceable(24) @0, i32 1, void (i32*, i32*, ...)* nonnull bitcast (void (i32*, i32*, i32*)* @.omp_outlined..4 to void (i32*, i32*, ...)*), i32* nocapture nonnull align 4 dereferenceable(4) [[A]])
Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -9,6 +9,7 @@
 
 %struct.omp_lock_t = type { i8* }
 %struct.omp_nest_lock_t = type { i8* }
+%struct.ident_t = type { i32, i32, i32, i32, i8* }
 
 define void @call_all(i32 %schedule, %struct.omp_lock_t* %lock, i32 %lock_hint, %struct.omp_nest_lock_t* %nest_lock, i32 %i, i8* %s, i64 %st, i8* %vp, double %d, i32 %proc_bind, i64 %allocator_handle, i8* %cp, i64 %event_handle, i32 %pause_resource) {
 entry:
@@ -460,6 +461,40 @@
 
 declare dso_local i32 @omp_get_supported_active_levels()
 
+declare void @__kmpc_barrier(%struct.ident_t*, i32)
+
+declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
+
+declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+
+declare void @__kmpc_flush(%struct.ident_t*)
+
+declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+
+declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
+
+declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
+
+declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
+
+declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
+
+declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
+
+declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
+
+declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
+
+declare i32 @__kmpc_master(%struct.ident_t*, i32)
+
+declare void @__kmpc_end_master(%struct.ident_t*, i32)
+
+declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
+
+declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
+
+declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*)
+
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local void @omp_set_num_threads(i32)
 
@@ -685,67 +720,118 @@
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
 
-; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind writeonly
+; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
+
+; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
+
+; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+
+; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK-NEXT: declare void @__kmpc_flush(%struct.ident_t*)
+
+; CHECK: Function Attrs: nounwind
+; 

[PATCH] D76620: [SYCL] Implement __builtin_unique_stable_name.

2020-03-25 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5a034e771d0: [SYCL] Implement __builtin_unique_stable_name. 
(authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76620/new/

https://reviews.llvm.org/D76620

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CodeGenSYCL/unique-stable-name.cpp
  clang/test/ParserSYCL/unique-stable-name.cpp

Index: clang/test/ParserSYCL/unique-stable-name.cpp
===
--- /dev/null
+++ clang/test/ParserSYCL/unique-stable-name.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
+
+namespace NS{};
+
+void f(int var) {
+  // expected-error@+1{{expected '(' after '__builtin_unique_stable_name'}}
+  __builtin_unique_stable_name int;
+  // expected-error@+1{{expected '(' after '__builtin_unique_stable_name'}}
+  __builtin_unique_stable_name {int};
+
+  __builtin_unique_stable_name(var);
+  // expected-error@+1{{use of undeclared identifier 'bad_var'}}
+  __builtin_unique_stable_name(bad_var);
+  // expected-error@+1{{use of undeclared identifier 'bad'}}
+  __builtin_unique_stable_name(bad::type);
+  // expected-error@+1{{no member named 'still_bad' in namespace 'NS'}}
+  __builtin_unique_stable_name(NS::still_bad);
+}
+
+template 
+void f2() {
+  // expected-error@+1{{no member named 'bad_val' in 'S'}}
+  __builtin_unique_stable_name(T::bad_val);
+  // expected-error@+1{{no type named 'bad_type' in 'S'}}
+  __builtin_unique_stable_name(typename T::bad_type);
+}
+
+struct S{};
+
+void use() {
+  // expected-note@+1{{in instantiation of}}
+  f2();
+}
Index: clang/test/CodeGenSYCL/unique-stable-name.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/unique-stable-name.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -fsycl -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+// CHECK: @[[INT:[^\w]+]] = private unnamed_addr constant [[INT_SIZE:\[[0-9]+ x i8\]]] c"_ZTSi\00"
+// CHECK: @[[LAMBDA_X:[^\w]+]] = private unnamed_addr constant [[LAMBDA_X_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE42->5clEvEUlvE46->16\00"
+// CHECK: @[[MACRO_X:[^\w]+]] = private unnamed_addr constant [[MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE42->5clEvEUlvE52->7~28->18\00"
+// CHECK: @[[MACRO_Y:[^\w]+]] =  private unnamed_addr constant [[MACRO_SIZE]] c"_ZTSZZ4mainENKUlvE42->5clEvEUlvE52->7~28->41\00"
+// CHECK: @[[MACRO_MACRO_X:[^\w]+]] = private unnamed_addr constant [[MACRO_MACRO_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZZ4mainENKUlvE42->5clEvEUlvE55->7~28->18~33->4\00"
+// CHECK: @[[MACRO_MACRO_Y:[^\w]+]] = private unnamed_addr constant [[MACRO_MACRO_SIZE]] c"_ZTSZZ4mainENKUlvE42->5clEvEUlvE55->7~28->41~33->4\00"
+// CHECK: @[[LAMBDA_IN_DEP_INT:[^\w]+]] = private unnamed_addr constant [[DEP_INT_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ28lambda_in_dependent_functionIiEvvEUlvE23->12\00",
+// CHECK: @[[LAMBDA_IN_DEP_X:[^\w]+]] = private unnamed_addr constant [[DEP_LAMBDA_SIZE:\[[0-9]+ x i8\]]] c"_ZTSZ28lambda_in_dependent_functionIZZ4mainENKUlvE42->5clEvEUlvE46->16EvvEUlvE23->12\00",
+
+extern "C" void printf(const char *) {}
+
+template 
+void template_param() {
+  printf(__builtin_unique_stable_name(T));
+}
+
+template 
+T getT() { return T{}; }
+
+template 
+void lambda_in_dependent_function() {
+  auto y = [] {};
+  printf(__builtin_unique_stable_name(y));
+}
+
+#define DEF_IN_MACRO()  \
+  auto MACRO_X = []() {};auto MACRO_Y = []() {};\
+  printf(__builtin_unique_stable_name(MACRO_X));\
+  printf(__builtin_unique_stable_name(MACRO_Y));
+
+#define MACRO_CALLS_MACRO() \
+  {DEF_IN_MACRO();}{DEF_IN_MACRO();}
+
+template 
+[[clang::sycl_kernel]] void kernel_single_task(KernelType kernelFunc) {
+  kernelFunc();
+}
+
+int main() {
+  kernel_single_task(
+[]() {
+  printf(__builtin_unique_stable_name(int));
+  // CHECK: call spir_func void @printf(i8* getelementptr inbounds ([[INT_SIZE]], [[INT_SIZE]]* @[[INT]]
+
+  auto x = [](){};
+  printf(__builtin_unique_stable_name(x));
+  printf(__builtin_unique_stable_name(decltype(x)));
+  // CHECK: call spir_func void @printf(i8* getelementptr inbounds ([[LAMBDA_X_SIZE]], [[LAMBDA_X_SIZE]]* @[[LAMBDA_X]]
+  // CHECK: call spir_func void @printf(i8* getelementptr inbounds ([[LAMBDA_X_SIZE]], [[LAMBDA_X_SIZE]]* @[[LAMBDA_X]]
+
+  DEF_IN_MACRO();
+  // 

[clang] bc3f171 - Don't normalise CXX11/C2X attribute names to start with ::

2020-03-25 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2020-03-25T14:33:44Z
New Revision: bc3f171090f6d9f84a5d7b333bc70a1e14afffd4

URL: 
https://github.com/llvm/llvm-project/commit/bc3f171090f6d9f84a5d7b333bc70a1e14afffd4
DIFF: 
https://github.com/llvm/llvm-project/commit/bc3f171090f6d9f84a5d7b333bc70a1e14afffd4.diff

LOG: Don't normalise CXX11/C2X attribute names to start with ::

Currently square-bracket-style (CXX11/C2X) attribute names are normalised to
start with :: if they don't have a namespace. This is a bit odd, as such
names are rejected when parsing, so don't do this.

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

Added: 


Modified: 
clang/lib/Basic/Attributes.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index a860c9dba2ef..d479b39e149e 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -85,12 +85,12 @@ static SmallString<64> normalizeName(const IdentifierInfo 
*Name,
   StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
   StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
 
-  // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
-  // unscoped.
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty()) {
+assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+   SyntaxUsed == AttributeCommonInfo::AS_C2X);
 FullName += "::";
+  }
   FullName += AttrName;
 
   return FullName;

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index dcb2f323122c..32744f7579fb 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3739,10 +3739,8 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper , 
raw_ostream ) {
 for (const auto  : GetFlattenedSpellings(Attr)) {
   const std::string  = S.name();
   std::string Spelling;
-  if (S.variety() == "CXX11" || S.variety() == "C2x") {
-Spelling += S.nameSpace();
-Spelling += "::";
-  }
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
   if (S.variety() == "GNU")
 Spelling += NormalizeGNUAttrSpelling(RawSpelling);
   else
@@ -3815,12 +3813,12 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper 
, raw_ostream ) {
 const std::string  = S.variety();
 if (Variety == "CXX11") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "C2x") {
   Matches = 
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "GNU")
   Matches = 
 else if (Variety == "Declspec")



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


[PATCH] D76774: [cmake] Link libc++ tests against static libc++/libc++abi in CrossWinToARMLinux.cmake

2020-03-25 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb created this revision.
broadwaylamb added a reviewer: vvereschaka.
Herald added subscribers: cfe-commits, kristof.beyls, mgorny.
Herald added a project: clang.

Now that D72687  has landed, we can enable 
this setting in our cache file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76774

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -86,6 +86,8 @@
 set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -86,6 +86,8 @@
 set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
 set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
+set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
 
 set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-03-25 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76384/new/

https://reviews.llvm.org/D76384



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75685/new/

https://reviews.llvm.org/D75685



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


[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-03-25 Thread Yvan Roux via Phabricator via cfe-commits
yroux marked 5 inline comments as done.
yroux added a comment.

Thanks for the review Sam,

I'll update the patch with more tests (for CPSR/LR it was part of D76068 
 but you are right it should be done here) and 
take your comments into account.

In D76066#1921331 , @samparker wrote:

> Hi,
>
> I like reading your code! But I'm concerned around the lack of tests here, 
> specifically:
>
> - CPSR liveness.
> - LR liveness.
> - All things PIC related.
> - Linkage legality.
> - A negative test for Thumb-1.
> - Inline asm generally concerns me too.







Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5653
+
+  // Check if each of the unsafe registers are available...
+  bool R12AvailableInBlock = LRU.available(ARM::R12);

samparker wrote:
> When you say 'available', do you mean 'dead'? I'm struggling to follow the 
> logic here...
Yes that's it,  'available' in llvm::LiveRegUnit means no part of the register 
is live so it's 'dead'.

The logic is to identify the unsafe cases where R12 or CPSR are live across the 
MBB without being defined in that MBB




Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5663
+  // Now, add the live outs to the set.
+  LRU.addLiveOuts(MBB);
+

samparker wrote:
> Do you need to clear LRU first?
hmm, I don't think it is necessary to clear it, given that if the register was 
in the set the XXavailableInBlock is false so it doesn't matter if it is among 
liveouts or not the candidate will not have the flag UnsafeRegsDead and thus 
will not be outlined, if it wasn't and is part of the liveouts, we will reture 
false and the generic part of the MachineOutliner will not map the MBB and we 
will not outliune it.



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5705
+  unsigned Opc = MI.getOpcode();
+  if (Opc == ARM::t2IT || Opc == ARM::tPICADD || Opc == ARM::PICADD ||
+  Opc == ARM::PICSTR || Opc == ARM::PICSTRB || Opc == ARM::PICSTRH ||

samparker wrote:
> I'm surprised to see IT here?
Yes, sorry I need to update the comment, this is a conservative way of handling 
IT blocks, to avoid having it splitted between an outlined region and the call 
sites



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5761
+
+  // Don't touch the link register
+  if (MI.readsRegister(ARM::LR, ()) ||

samparker wrote:
> Isn't this already handled in the loop above? I prefer this notation though.
Yes you are right, I'm cleaning this part



Comment at: llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp:5781
+if (Subtarget.isThumb())
+  if (Call->getOperand(2).isReg())
+BuildMI(MBB, MBB.end(), DebugLoc(), get(ARM::tTAILJMPr))

samparker wrote:
> Looks like this MI building could be refactored.
yes, I'm refactoring it


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76066/new/

https://reviews.llvm.org/D76066



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


[clang] 72b51d6 - OpenMP] Adding InaccessibleMemOnly and InaccessibleMemOrArgMemOnly for runtime calls.

2020-03-25 Thread via cfe-commits

Author: sstefan1
Date: 2020-03-25T14:08:50Z
New Revision: 72b51d6f93b503be23ead4dce850b5240834bbb7

URL: 
https://github.com/llvm/llvm-project/commit/72b51d6f93b503be23ead4dce850b5240834bbb7
DIFF: 
https://github.com/llvm/llvm-project/commit/72b51d6f93b503be23ead4dce850b5240834bbb7.diff

LOG: OpenMP] Adding InaccessibleMemOnly and InaccessibleMemOrArgMemOnly for 
runtime calls.

Summary: Attempt to add more attributes for runtime calls.

Reviewers: jdoerfert

Subscribers: guansong, llvm-commits

Tags: #llvm

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

Added: 


Modified: 
clang/test/OpenMP/barrier_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/test/Transforms/OpenMP/add_attributes.ll
llvm/test/Transforms/OpenMP/parallel_deletion.ll

Removed: 




diff  --git a/clang/test/OpenMP/barrier_codegen.cpp 
b/clang/test/OpenMP/barrier_codegen.cpp
index 3f2e7e346aed..e61ca186a697 100644
--- a/clang/test/OpenMP/barrier_codegen.cpp
+++ b/clang/test/OpenMP/barrier_codegen.cpp
@@ -46,7 +46,7 @@ int main(int argc, char **argv) {
 // CLANGCG-NOT:#
 // IRBUILDER:  ; Function Attrs: nounwind
 // IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) 
#
-// IRBUILDER_OPT:  ; Function Attrs: nofree nosync nounwind readonly
+// IRBUILDER_OPT:  ; Function Attrs: inaccessiblememonly nofree nosync 
nounwind readonly
 // IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) 
#
 
 // CHECK: define {{.+}} [[TMAIN_INT]](

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 5d26f07a7f5a..5ed472b9d546 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -251,17 +251,17 @@ __OMP_RTL(__last, false, Void, )
 __OMP_ATTRS_SET(GetterAttrs,
 OptimisticAttributes
 ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(ReadOnly),
-   EnumAttr(NoSync), EnumAttr(NoFree))
+   EnumAttr(NoSync), EnumAttr(NoFree), 
EnumAttr(InaccessibleMemOnly))
 : AttributeSet(EnumAttr(NoUnwind)))
 __OMP_ATTRS_SET(GetterArgWriteAttrs,
 OptimisticAttributes
 ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(NoSync),
-   EnumAttr(NoFree))
+   EnumAttr(NoFree), 
EnumAttr(InaccessibleMemOrArgMemOnly))
 : AttributeSet(EnumAttr(NoUnwind)))
 __OMP_ATTRS_SET(SetterAttrs,
 OptimisticAttributes
 ? AttributeSet(EnumAttr(NoUnwind), EnumAttr(WriteOnly),
-   EnumAttr(NoSync), EnumAttr(NoFree))
+   EnumAttr(NoSync), EnumAttr(NoFree), 
EnumAttr(InaccessibleMemOnly))
 : AttributeSet(EnumAttr(NoUnwind)))
 
 #undef __OMP_ATTRS_SET
@@ -274,10 +274,40 @@ __OMP_ATTRS_SET(SetterAttrs,
 #define __OMP_RTL_ATTRS(Name, FnAttrSet, RetAttrSet, ArgAttrSets)  
\
   OMP_RTL_ATTRS(OMPRTL_##Name, FnAttrSet, RetAttrSet, ArgAttrSets)
 
+__OMP_RTL_ATTRS(__kmpc_barrier,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_cancel,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_cancel_barrier,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_flush,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_global_thread_num, GetterAttrs, AttributeSet(), {})
 __OMP_RTL_ATTRS(__kmpc_fork_call, AttributeSet(EnumAttr(NoUnwind)),
 AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_omp_taskwait,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_omp_taskyield,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_push_num_threads,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_push_proc_bind,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_serialized_parallel,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
+__OMP_RTL_ATTRS(__kmpc_end_serialized_parallel,
+AttributeSet(EnumAttr(InaccessibleMemOrArgMemOnly)),
+AttributeSet(), {})
 
-__OMP_RTL_ATTRS(__kmpc_global_thread_num, GetterAttrs, AttributeSet(), {})
 

[clang] b5a034e - [SYCL] Implement __builtin_unique_stable_name.

2020-03-25 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-25T07:01:50-07:00
New Revision: b5a034e771d0e4d7d8e71fc545b230d98e5a1f42

URL: 
https://github.com/llvm/llvm-project/commit/b5a034e771d0e4d7d8e71fc545b230d98e5a1f42
DIFF: 
https://github.com/llvm/llvm-project/commit/b5a034e771d0e4d7d8e71fc545b230d98e5a1f42.diff

LOG: [SYCL] Implement __builtin_unique_stable_name.

In order to support non-user-named kernels, SYCL needs some way in the
integration headers to name the kernel object themselves. Initially, the
design considered just RTTI naming of the lambdas, this results in a
quite unstable situation in light of some device/host macros.
Additionally, this ends up needing to use RTTI, which is a burden on the
implementation and typically unsupported.

Instead, we've introduced a builtin, __builtin_unique_stable_name, which
takes a type or expression, and results in a constexpr constant
character array that uniquely represents the type (or type of the
expression) being passed to it.

The implementation accomplishes that simply by using a slightly modified
version of the Itanium Mangling. The one exception is when mangling
lambdas, instead of appending the index of the lambda in the function,
it appends the macro-expansion back-trace of the lambda itself in the
form LINE->COL[~LINE->COL...].

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

Added: 
clang/test/CodeGenSYCL/unique-stable-name.cpp
clang/test/ParserSYCL/unique-stable-name.cpp

Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Mangle.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f9511dc1a02f..558ce7dee653 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2187,6 +2187,30 @@ argument.
   int *pb =__builtin_preserve_access_index(>c[3].b);
   __builtin_preserve_access_index(v->j);
 
+``__builtin_unique_stable_name``
+
+
+``__builtin_unique_stable_name()`` is a builtin that takes a type or 
expression and
+produces a string literal containing a unique name for the type (or type of the
+expression) that is stable across split compilations.
+
+In cases where the split compilation needs to share a unique token for a type
+across the boundary (such as in an offloading situation), this name can be used
+for lookup purposes.
+
+This builtin is superior to RTTI for this purpose for two reasons.  First, this
+value is computed entirely at compile time, so it can be used in constant
+expressions. Second, this value encodes lambda functions based on line-number
+rather than the order in which it appears in a function. This is valuable
+because it is stable in cases where an unrelated lambda is introduced
+conditionally in the same function.
+
+The current implementation of this builtin uses a slightly modified Itanium
+Mangler to produce the unique name. The lambda ordinal is replaced with one or
+more line/column pairs in the format ``LINE->COL``, separated with a ``~``
+character. Typically, only one pair will be included, however in the case of
+macro expansions the entire macro expansion stack is expressed.
+
 Multiprecision Arithmetic Builtins
 --
 

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index e27d7f04093b..fa4918272819 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1896,13 +1896,17 @@ class StringLiteral final
 /// [C99 6.4.2.2] - A predefined identifier such as __func__.
 class PredefinedExpr final
 : public Expr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects {
   friend class ASTStmtReader;
   friend TrailingObjects;
 
   // PredefinedExpr is optionally followed by a single trailing
   // "Stmt *" for the predefined identifier. It is present if and only if
   // hasFunctionName() is true and is always a "StringLiteral *".
+  // It can also be followed by a Expr* in the case of a
+  // __builtin_unique_stable_name with an expression, or TypeSourceInfo * if
+  // __builtin_unique_stable_name with a type.
 
 public:
   enum IdentKind {
@@ -1915,12 +1919,18 @@ class PredefinedExpr final
 PrettyFunction,
 /// The same as PrettyFunction, except that the
 /// 'virtual' keyword is omitted for virtual member functions.
-PrettyFunctionNoVirtual
+PrettyFunctionNoVirtual,
+UniqueStableNameType,
+UniqueStableNameExpr,
   };
 
 private:
   PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
   

[PATCH] D76764: [AST] Build recovery expressions for nonexistent member exprs.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252559.
hokein marked an inline comment as done.
hokein added a comment.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous.

address comment and fix a failing testcase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76764/new/

https://reviews.llvm.org/D76764

Files:
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/constructor-initializer.cpp


Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -250,7 +250,7 @@
 B(const String& s, int e=0) // expected-error {{unknown type name}} 
   : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no 
matching constructor}} expected-error {{does not name}}
 B(const B& e)
-  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 
{{does not name}} \
+  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 
2{{does not name}} \
   // expected-error {{no member named 'm_String' in 'test3::B'}}
 }
   };
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -83,3 +83,18 @@
 // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a'
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int ternary = a ? nullptr : a;
+
+// CHECK: FunctionDecl
+// CHECK-NEXT:|-ParmVarDecl {{.*}} x
+// CHECK-NEXT:`-CompoundStmt
+// CHECK-NEXT: |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT: `-CallExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT:  `-DeclRefExpr {{.*}} 'x'
+struct Foo {} foo;
+void test(int x) {
+  foo.abc;
+  foo->func(x);
+}
\ No newline at end of file
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2100,8 +2100,14 @@
 OpKind, SS, TemplateKWLoc, Name,
  CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
: nullptr);
-  if (!LHS.isInvalid() && Tok.is(tok::less))
-checkPotentialAngleBracket(LHS);
+  if (!LHS.isInvalid()) {
+if (Tok.is(tok::less))
+  checkPotentialAngleBracket(LHS);
+  } else if (OrigLHS && Name.isValid()) {
+// Preserve the LHS if the RHS is an invalid member.
+LHS = Actions.CreateRecoveryExpr(OrigLHS->getBeginLoc(),
+ Name.getEndLoc(), {OrigLHS});
+  }
   break;
 }
 case tok::plusplus:// postfix-expression: postfix-expression '++'
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -678,7 +678,7 @@
 TEST(IncludeFixerTest, NoCrashMemebrAccess) {
   Annotations Test(R"cpp(// error-ok
 struct X { int  xyz; };
-void g() { X x; x.$[[xy]] }
+void g() { X x; x.$[[xy]]; }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   auto Index = buildIndexWithSymbol(


Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -250,7 +250,7 @@
 B(const String& s, int e=0) // expected-error {{unknown type name}} 
   : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}}
 B(const B& e)
-  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{does not name}} \
+  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 2{{does not name}} \
   // expected-error {{no member named 'm_String' in 'test3::B'}}
 }
   };
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -83,3 +83,18 @@
 // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a'
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int ternary = a ? nullptr : a;
+
+// CHECK: FunctionDecl
+// CHECK-NEXT:|-ParmVarDecl {{.*}} x
+// CHECK-NEXT:`-CompoundStmt
+// CHECK-NEXT: |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT: `-CallExpr {{.*}} contains-errors
+// CHECK-NEXT:  

[PATCH] D76772: [AMDGPU] Add __builtin_amdgcn_workgroup_size_x/y/z

2020-03-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: arsenm, b-sumner, cfang.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

The main purpose of introducing these builtins is to add a range metadata [1, 
1025) on the work group size loaded from dispatch ptr, which cannot be done by 
source code.


https://reviews.llvm.org/D76772

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -527,6 +527,24 @@
 	}
 }
 
+// CHECK-LABEL: @test_get_workgroup_size(
+// CHECK: call align 4 dereferenceable(64) i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 4
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]]
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 6
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 2, !range [[$WS_RANGE:![0-9]*]]
+// CHECK: getelementptr i8, i8 addrspace(4)* %{{.*}}, i64 8
+// CHECK: load i16, i16 addrspace(4)* %{{.*}}, align 4, !range [[$WS_RANGE:![0-9]*]]
+void test_get_workgroup_size(int d, global int *out)
+{
+	switch (d) {
+	case 0: *out = __builtin_amdgcn_workgroup_size_x(); break;
+	case 1: *out = __builtin_amdgcn_workgroup_size_y(); break;
+	case 2: *out = __builtin_amdgcn_workgroup_size_z(); break;
+	default: *out = 0;
+	}
+}
+
 // CHECK-LABEL: @test_fmed3_f32
 // CHECK: call float @llvm.amdgcn.fmed3.f32(
 void test_fmed3_f32(global float* out, float a, float b, float c)
@@ -698,6 +716,7 @@
 }
 
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
+// CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13407,6 +13407,44 @@
   }
 }
 
+namespace {
+// If \p E is not null pointer, insert address space cast to match return
+// type of \p E if necessary.
+Value *EmitAMDGPUDispatchPtr(CodeGenFunction ,
+ const CallExpr *E = nullptr) {
+  auto *F = CGF.CGM.getIntrinsic(Intrinsic::amdgcn_dispatch_ptr);
+  auto *Call = CGF.Builder.CreateCall(F);
+  Call->addAttribute(
+  AttributeList::ReturnIndex,
+  Attribute::getWithDereferenceableBytes(Call->getContext(), 64));
+  Call->addAttribute(AttributeList::ReturnIndex,
+ Attribute::getWithAlignment(Call->getContext(), Align(4)));
+  if (!E)
+return Call;
+  QualType BuiltinRetType = E->getType();
+  auto *RetTy = cast(CGF.ConvertType(BuiltinRetType));
+  if (RetTy == Call->getType())
+return Call;
+  return CGF.Builder.CreateAddrSpaceCast(Call, RetTy);
+}
+
+// \p Index is 0, 1, and 2 for x, y, and z dimension, respectively.
+Value *EmitAMDGPUWorkGroupSize(CodeGenFunction , unsigned Index) {
+  const unsigned XOffset = 4;
+  auto *DP = EmitAMDGPUDispatchPtr(CGF);
+  auto *Offset = llvm::ConstantInt::get(CGF.Int32Ty, XOffset + Index * 2);
+  auto *GEP = CGF.Builder.CreateGEP(DP, Offset);
+  auto *DstTy =
+  CGF.Int16Ty->getPointerTo(GEP->getType()->getPointerAddressSpace());
+  auto *Cast = CGF.Builder.CreateBitCast(GEP, DstTy);
+  auto *LD = CGF.Builder.CreateLoad(Address(Cast, CharUnits::fromQuantity(2)));
+  llvm::MDBuilder MDHelper(CGF.getLLVMContext());
+  llvm::MDNode *RNode = MDHelper.createRange(APInt(16, 1), APInt(16, 1025));
+  LD->setMetadata(llvm::LLVMContext::MD_range, RNode);
+  return LD;
+}
+} // namespace
+
 Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E) {
   switch (BuiltinID) {
@@ -13489,21 +13527,8 @@
   case AMDGPU::BI__builtin_amdgcn_cosf:
   case AMDGPU::BI__builtin_amdgcn_cosh:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_cos);
-  case AMDGPU::BI__builtin_amdgcn_dispatch_ptr: {
-auto *F = CGM.getIntrinsic(Intrinsic::amdgcn_dispatch_ptr);
-auto *Call = Builder.CreateCall(F);
-Call->addAttribute(
-AttributeList::ReturnIndex,
-Attribute::getWithDereferenceableBytes(Call->getContext(), 64));
-Call->addAttribute(
-AttributeList::ReturnIndex,
-Attribute::getWithAlignment(Call->getContext(), Align(4)));
-QualType BuiltinRetType = E->getType();
-auto *RetTy = cast(ConvertType(BuiltinRetType));
-if (RetTy == Call->getType())
-  return Call;
-return Builder.CreateAddrSpaceCast(Call, RetTy);
-  }
+  case AMDGPU::BI__builtin_amdgcn_dispatch_ptr:
+return EmitAMDGPUDispatchPtr(*this, E);
   case 

[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

Thanks. LG.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76741/new/

https://reviews.llvm.org/D76741



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


[PATCH] D76770: [CodeComplete] Don't replace the rest of line in #include completion.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.

The previous behavior was aggressive,

  #include "abc/f^/abc.h"
foo/  -> candidate

"f/abc.h" is replaced with "foo/", this patch will preserve the "abc.h".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76770

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/StringRef.h"
@@ -2092,7 +2093,8 @@
  bool IsAngled) {
   // Completion only applies to the filename, after the last slash.
   StringRef PartialPath(PathStart, CompletionPoint - PathStart);
-  auto Slash = PartialPath.find_last_of(LangOpts.MSVCCompat ? "/\\" : "/");
+  llvm::StringRef SlashChars = LangOpts.MSVCCompat ? "/\\" : "/";
+  auto Slash = PartialPath.find_last_of(SlashChars);
   StringRef Dir =
   (Slash == StringRef::npos) ? "" : PartialPath.take_front(Slash);
   const char *StartOfFilename =
@@ -2100,7 +2102,8 @@
   // Code completion filter range is the filename only, up to completion point.
   PP->setCodeCompletionIdentifierInfo(>getIdentifierTable().get(
   StringRef(StartOfFilename, CompletionPoint - StartOfFilename)));
-  // We should replace the characters up to the closing quote, if any.
+  // We should replace the characters up to the closing quote or closest slash,
+  // if any.
   while (CompletionPoint < BufferEnd) {
 char Next = *(CompletionPoint + 1);
 if (Next == 0 || Next == '\r' || Next == '\n')
@@ -2108,7 +2111,10 @@
 ++CompletionPoint;
 if (Next == (IsAngled ? '>' : '"'))
   break;
+if (llvm::is_contained(SlashChars, Next))
+  break;
   }
+
   PP->setCodeCompletionTokenRange(
   FileLoc.getLocWithOffset(StartOfFilename - BufferStart),
   FileLoc.getLocWithOffset(CompletionPoint - BufferStart));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1860,6 +1860,7 @@
 TEST(CompletionTest, CompletionTokenRange) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;
+  FS.Files["foo/abc/foo.h"] = "";
   ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
 
   constexpr const char *TestCodes[] = {
@@ -1882,7 +1883,14 @@
   Auxilary x;
   x.[[]]^;
 }
-  )cpp"};
+  )cpp",
+  R"cpp(
+#include "foo/[[a^/]]foo.h"
+  )cpp",
+  R"cpp(
+#include "foo/abc/[[fo^o.h"]]
+  )cpp",
+  };
   for (const auto  : TestCodes) {
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/StringRef.h"
@@ -2092,7 +2093,8 @@
  bool IsAngled) {
   // Completion only applies to the filename, after the last slash.
   StringRef PartialPath(PathStart, CompletionPoint - PathStart);
-  auto Slash = PartialPath.find_last_of(LangOpts.MSVCCompat ? "/\\" : "/");
+  llvm::StringRef SlashChars = LangOpts.MSVCCompat ? "/\\" : "/";
+  auto Slash = PartialPath.find_last_of(SlashChars);
   StringRef Dir =
   (Slash == StringRef::npos) ? "" : PartialPath.take_front(Slash);
   const char *StartOfFilename =
@@ -2100,7 +2102,8 @@
   // Code completion filter range is the filename only, up to completion point.
   PP->setCodeCompletionIdentifierInfo(>getIdentifierTable().get(
   StringRef(StartOfFilename, CompletionPoint - StartOfFilename)));
-  // We should replace the characters up to the closing quote, if any.
+  // We should replace the characters up to the closing quote or closest slash,
+  // if any.
   while (CompletionPoint < BufferEnd) {
 char Next = *(CompletionPoint + 1);
 if (Next == 0 || Next == '\r' || Next == '\n')
@@ -2108,7 +2111,10 @@
 ++CompletionPoint;
 if (Next == (IsAngled ? '>' : '"'))
   break;
+if (llvm::is_contained(SlashChars, Next))
+  break;
   }
+
   PP->setCodeCompletionTokenRange(
   FileLoc.getLocWithOffset(StartOfFilename - BufferStart),
   

[PATCH] D71612: [analyzer] Add PlacementNewChecker

2020-03-25 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.
Herald added subscribers: ASDenysPetrov, steakhal.



Comment at: clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp:1
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"

Header blurb is missing :) Could you sneak it in there?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71612/new/

https://reviews.llvm.org/D71612



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-03-25 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76140/new/

https://reviews.llvm.org/D76140



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


[PATCH] D76764: [AST] Build recovery expressions for nonexistent member exprs.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice!




Comment at: clang/lib/Parse/ParseExpr.cpp:2107
+  } else if (OrigLHS && Name.isValid()) {
+// Preserve the member expr if the LHS is an invalid members.
+LHS = Actions.CreateRecoveryExpr(OrigLHS->getBeginLoc(),

preserve the LHS if the RHS is an invalid member?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76764/new/

https://reviews.llvm.org/D76764



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


[PATCH] D76688: [AArch64][SVE] Add SVE intrinsics for masked loads & stores

2020-03-25 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05606329e235: [AArch64][SVE] Add SVE intrinsics for masked 
loads  stores (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76688/new/

https://reviews.llvm.org/D76688

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; LD1B
+;
+
+define  @ld1b_i8( %pred, i8* %addr) {
+; CHECK-LABEL: ld1b_i8:
+; CHECK: ld1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv16i8( %pred,
+   i8* %addr)
+  ret  %res
+}
+
+;
+; LD1H
+;
+
+define  @ld1h_i16( %pred, i16* %addr) {
+; CHECK-LABEL: ld1h_i16:
+; CHECK: ld1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv8i16( %pred,
+   i16* %addr)
+  ret  %res
+}
+
+define  @ld1h_f16( %pred, half* %addr) {
+; CHECK-LABEL: ld1h_f16:
+; CHECK: ld1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv8f16( %pred,
+half* %addr)
+  ret  %res
+}
+
+;
+; LD1W
+;
+
+define  @ld1w_i32( %pred, i32* %addr) {
+; CHECK-LABEL: ld1w_i32:
+; CHECK: ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv4i32( %pred,
+   i32* %addr)
+  ret  %res
+}
+
+define  @ld1w_f32( %pred, float* %addr) {
+; CHECK-LABEL: ld1w_f32:
+; CHECK: ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv4f32( %pred,
+ float* %addr)
+  ret  %res
+}
+
+;
+; LD1D
+;
+
+define  @ld1d_i64( %pred, i64* %addr) {
+; CHECK-LABEL: ld1d_i64:
+; CHECK: ld1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv2i64( %pred,
+   i64* %addr)
+  ret  %res
+}
+
+define  @ld1d_f64( %pred, double* %addr) {
+; CHECK-LABEL: ld1d_f64:
+; CHECK: ld1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv2f64( %pred,
+  double* %addr)
+  ret  %res
+}
+
+;
+; ST1B
+;
+
+define void @st1b_i8( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_i8:
+; CHECK: st1b { z0.b }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,
+   %pred,
+  i8* %addr)
+  ret void
+}
+
+;
+; ST1H
+;
+
+define void @st1h_i16( %data,  %pred, i16* %addr) {
+; CHECK-LABEL: st1h_i16:
+; CHECK: st1h { z0.h }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv8i16( %data,
+   %pred,
+  i16* %addr)
+  ret void
+}
+
+define void @st1h_f16( %data,  %pred, half* %addr) {
+; CHECK-LABEL: st1h_f16:
+; CHECK: st1h { z0.h }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv8f16( %data,
+   %pred,
+  half* %addr)
+  ret void
+}
+
+;
+; ST1W
+;
+
+define void @st1w_i32( %data,  %pred, i32* %addr) {
+; CHECK-LABEL: st1w_i32:
+; CHECK: st1w { z0.s }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv4i32( %data,
+   %pred,
+  i32* %addr)
+  ret void
+}
+
+define void @st1w_f32( %data,  %pred, float* %addr) {
+; CHECK-LABEL: st1w_f32:
+; CHECK: st1w { z0.s }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv4f32( %data,
+   %pred,
+  float* %addr)
+  ret void
+}
+
+;
+; ST1D
+;
+
+define void @st1d_i64( %data,  %pred, i64* %addr) {
+; CHECK-LABEL: st1d_i64:
+; CHECK: st1d { z0.d }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv2i64( %data,
+   %pred,
+  i64* %addr)
+  ret void
+}
+
+define void @st1d_f64( %data,  %pred, double* %addr) {
+; CHECK-LABEL: st1d_f64:
+; CHECK: st1d { z0.d }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv2f64( %data,
+   %pred,
+  double* %addr)
+  ret void
+}
+
+declare  @llvm.aarch64.sve.ld1.nxv16i8(, 

[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1194-1201
   if (Params.positions.size() != 1) {
 elog("{0} positions provided to SelectionRange. Supports exactly one "
  "position.",
  Params.positions.size());
 return Reply(llvm::make_error(
 "SelectionRange supports exactly one position",
 ErrorCode::InvalidRequest));

usaxena95 wrote:
> You can remove this check now.
Oops!



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:74
+  SelectionRange *Tail = 
+  for (auto  : llvm::makeArrayRef(Ranges).drop_front()) {
+Tail->parent = std::make_unique();

usaxena95 wrote:
> nit:`Range` can be made a `const` ref.
Oops, fixed to actually move.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:175
 
-  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
+  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.points());
   ASSERT_TRUE(bool(Ranges))

usaxena95 wrote:
> I think it would be better to name the two points in the test and explicitly 
> specify their order in the request (instead of relying on 
> `SourceAnnotations.points()`). 
> Annotations::points doesn't guarantee order in its contract. Even if the 
> current implementation does, it would be better to be explicit and not rely 
> on it.
Good point. I updated the documentation on Annotations instead to make this 
guarantee, this was always the intent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76741/new/

https://reviews.llvm.org/D76741



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


[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Could you provide more information about why these null checks are needed in 
this case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76761/new/

https://reviews.llvm.org/D76761



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


[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 252545.
sammccall marked 8 inline comments as done.
sammccall added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76741/new/

https://reviews.llvm.org/D76741

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h
  llvm/include/llvm/Testing/Support/Annotations.h

Index: llvm/include/llvm/Testing/Support/Annotations.h
===
--- llvm/include/llvm/Testing/Support/Annotations.h
+++ llvm/include/llvm/Testing/Support/Annotations.h
@@ -68,12 +68,14 @@
   /// Crashes if there isn't exactly one.
   size_t point(llvm::StringRef Name = "") const;
   /// Returns the position of all points marked by ^ (or $name^) in the text.
+  /// Order matches the order within the text.
   std::vector points(llvm::StringRef Name = "") const;
 
   /// Returns the location of the range marked by [[ ]] (or $name[[ ]]).
   /// Crashes if there isn't exactly one.
   Range range(llvm::StringRef Name = "") const;
   /// Returns the location of all ranges marked by [[ ]] (or $name[[ ]]).
+  /// They are ordered by start position within the text.
   std::vector ranges(llvm::StringRef Name = "") const;
 
 private:
Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -56,8 +56,9 @@
 SymbolSlab runFuzzyFind(const SymbolIndex , const FuzzyFindRequest );
 RefSlab getRefs(const SymbolIndex , SymbolID ID);
 
-llvm::Expected>
-runSemanticRanges(ClangdServer , PathRef File, Position Pos);
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File,
+  const std::vector );
 
 llvm::Expected>
 runSwitchHeaderSource(ClangdServer , PathRef File);
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -146,9 +146,10 @@
   return std::move(Slab).build();
 }
 
-llvm::Expected>
-runSemanticRanges(ClangdServer , PathRef File, Position Pos) {
-  llvm::Optional>> Result;
+llvm::Expected>
+runSemanticRanges(ClangdServer , PathRef File,
+  const std::vector ) {
+  llvm::Optional>> Result;
   Server.semanticRanges(File, Pos, capture(Result));
   return std::move(*Result);
 }
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -24,8 +24,17 @@
 namespace clang {
 namespace clangd {
 namespace {
+using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
 
+// front() is SR.range, back() is outermost range.
+std::vector gatherRanges(const SelectionRange ) {
+  std::vector Ranges;
+  for (const SelectionRange *S =  S; S = S->parent.get())
+Ranges.push_back(S->range);
+  return Ranges;
+}
+
 TEST(SemanticSelection, All) {
   const char *Tests[] = {
   R"cpp( // Single statement in a function body.
@@ -78,7 +87,7 @@
 }
)cpp",
   // Empty file.
-  "^",
+  "[[^]]",
   // FIXME: We should get the whole DeclStmt as a range.
   R"cpp( // Single statement in TU.
 [[int v = [[1^00;
@@ -89,7 +98,7 @@
   // FIXME: No node found associated to the position.
   R"cpp( // Cursor in between spaces.
 void func() {
-  int v = 100 + ^  100;
+  int v = 100 + [[^]]  100;
 }
   )cpp",
   // Structs.
@@ -133,13 +142,13 @@
   for (const char *Test : Tests) {
 auto T = Annotations(Test);
 auto AST = TestTU::withCode(T.code()).build();
-EXPECT_THAT(llvm::cantFail(getSemanticRanges(AST, T.point())),
+EXPECT_THAT(gatherRanges(llvm::cantFail(getSemanticRanges(AST, T.point(,
 ElementsAreArray(T.ranges()))
 << Test;
   }
 }
 
-TEST(SemanticSelection, RunViaClangDServer) {
+TEST(SemanticSelection, RunViaClangdServer) {
   MockFSProvider FS;
   MockCompilationDatabase CDB;
   ClangdServer Server(CDB, FS, ClangdServer::optsForTest());
@@ -157,15 +166,20 @@
 // inp = HASH(foo(inp));
 [[inp = [[HASH([[foo([[in^p]])]]);
   }
+  $empty[[^]]
   )cpp";
   Annotations SourceAnnotations(SourceContents);
   FS.Files[FooCpp] = std::string(SourceAnnotations.code());
   Server.addDocument(FooCpp, SourceAnnotations.code());
 
-  auto Ranges = 

[PATCH] D76764: [AST] Build recovery expressions for nonexistent member exprs.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

Previously, we dropped the AST node for nonexistent member exprs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76764

Files:
  clang/lib/Parse/ParseExpr.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/constructor-initializer.cpp


Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -250,7 +250,7 @@
 B(const String& s, int e=0) // expected-error {{unknown type name}} 
   : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no 
matching constructor}} expected-error {{does not name}}
 B(const B& e)
-  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 
{{does not name}} \
+  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 
2{{does not name}} \
   // expected-error {{no member named 'm_String' in 'test3::B'}}
 }
   };
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -83,3 +83,18 @@
 // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a'
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int ternary = a ? nullptr : a;
+
+// CHECK: FunctionDecl
+// CHECK-NEXT:|-ParmVarDecl {{.*}} x
+// CHECK-NEXT:`-CompoundStmt
+// CHECK-NEXT: |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT: `-CallExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT:  `-DeclRefExpr {{.*}} 'x'
+struct Foo {} foo;
+void test(int x) {
+  foo.abc;
+  foo->func(x);
+}
\ No newline at end of file
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2100,8 +2100,14 @@
 OpKind, SS, TemplateKWLoc, Name,
  CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
: nullptr);
-  if (!LHS.isInvalid() && Tok.is(tok::less))
-checkPotentialAngleBracket(LHS);
+  if (!LHS.isInvalid()) {
+if (Tok.is(tok::less))
+  checkPotentialAngleBracket(LHS);
+  } else if (OrigLHS && Name.isValid()) {
+// Preserve the member expr if the LHS is an invalid members.
+LHS = Actions.CreateRecoveryExpr(OrigLHS->getBeginLoc(),
+ Name.getEndLoc(), {OrigLHS});
+  }
   break;
 }
 case tok::plusplus:// postfix-expression: postfix-expression '++'


Index: clang/test/SemaCXX/constructor-initializer.cpp
===
--- clang/test/SemaCXX/constructor-initializer.cpp
+++ clang/test/SemaCXX/constructor-initializer.cpp
@@ -250,7 +250,7 @@
 B(const String& s, int e=0) // expected-error {{unknown type name}} 
   : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}}
 B(const B& e)
-  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{does not name}} \
+  : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error 2{{does not name}} \
   // expected-error {{no member named 'm_String' in 'test3::B'}}
 }
   };
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -83,3 +83,18 @@
 // CHECK-NEXT:  `-DeclRefExpr {{.*}} 'a'
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int ternary = a ? nullptr : a;
+
+// CHECK: FunctionDecl
+// CHECK-NEXT:|-ParmVarDecl {{.*}} x
+// CHECK-NEXT:`-CompoundStmt
+// CHECK-NEXT: |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT: `-CallExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  | `-DeclRefExpr {{.*}} 'foo'
+// CHECK-NEXT:  `-DeclRefExpr {{.*}} 'x'
+struct Foo {} foo;
+void test(int x) {
+  foo.abc;
+  foo->func(x);
+}
\ No newline at end of file
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -2100,8 +2100,14 @@
 OpKind, SS, TemplateKWLoc, Name,
  CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
: nullptr);
-  if (!LHS.isInvalid() && Tok.is(tok::less))
-

[PATCH] D76694: [Sema][SVE] Allow casting SVE types to themselves in C

2020-03-25 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG856bdd01fd65: [Sema][SVE] Allow casting SVE types to 
themselves in C (authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76694/new/

https://reviews.llvm.org/D76694

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/sizeless-1.c


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -108,6 +108,8 @@
 
   sel = local_int8; // expected-error {{assigning to 'int' from incompatible 
type 'svint8_t'}}
 
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
   local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   local_int8 = (svint8_t)0;   // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   sel = (int)local_int8;  // expected-error {{operand of type 
'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2652,6 +2652,13 @@
 return;
   }
 
+  // Allow casting a sizeless built-in type to itself.
+  if (DestType->isSizelessBuiltinType() &&
+  Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
+Kind = CK_NoOp;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -108,6 +108,8 @@
 
   sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}}
 
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
   local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
   local_int8 = (svint8_t)0;   // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
   sel = (int)local_int8;  // expected-error {{operand of type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2652,6 +2652,13 @@
 return;
   }
 
+  // Allow casting a sizeless built-in type to itself.
+  if (DestType->isSizelessBuiltinType() &&
+  Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
+Kind = CK_NoOp;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76693: [Sema][SVE] Allow ?: to select between SVE types in C

2020-03-25 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG578fb2501a66: [Sema][SVE] Allow ?: to select between SVE 
types in C (authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76693/new/

https://reviews.llvm.org/D76693

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/sizeless-1.c


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -126,6 +126,11 @@
 
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to 
variable 'const_volatile_int8' with const-qualified type 'const volatile 
svint8_t'}}
 
+  init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_volatile_int8;
+
   pass_int8(local_int8);
   pass_int8(local_int16); // expected-error {{passing 'svint16_t' (aka 
'__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7586,6 +7586,11 @@
   /*IsIntFirstExpr=*/false))
 return LHSTy;
 
+  // Allow ?: operations in which both operands have the same
+  // built-in sizeless type.
+  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+return LHSTy;
+
   // Emit a better diagnostic if one of the expressions is a null pointer
   // constant and the other is not a pointer type. In this case, the user most
   // likely forgot to take the address of the other expression.


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -126,6 +126,11 @@
 
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to variable 'const_volatile_int8' with const-qualified type 'const volatile svint8_t'}}
 
+  init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_volatile_int8;
+
   pass_int8(local_int8);
   pass_int8(local_int16); // expected-error {{passing 'svint16_t' (aka '__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7586,6 +7586,11 @@
   /*IsIntFirstExpr=*/false))
 return LHSTy;
 
+  // Allow ?: operations in which both operands have the same
+  // built-in sizeless type.
+  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+return LHSTy;
+
   // Emit a better diagnostic if one of the expressions is a null pointer
   // constant and the other is not a pointer type. In this case, the user most
   // likely forgot to take the address of the other expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 856bdd0 - [Sema][SVE] Allow casting SVE types to themselves in C

2020-03-25 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-25T10:52:43Z
New Revision: 856bdd01fd65002d8d88b491bbff53648b6002c1

URL: 
https://github.com/llvm/llvm-project/commit/856bdd01fd65002d8d88b491bbff53648b6002c1
DIFF: 
https://github.com/llvm/llvm-project/commit/856bdd01fd65002d8d88b491bbff53648b6002c1.diff

LOG: [Sema][SVE] Allow casting SVE types to themselves in C

Casts from an SVE type to itself aren't very useful, but they are
supposed to be valid, and could occur in things like macro expansions.

Such casts already work for C++ and are tested by sizeless-1.cpp.
This patch makes them work for C too.

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

Added: 


Modified: 
clang/lib/Sema/SemaCast.cpp
clang/test/Sema/sizeless-1.c

Removed: 




diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 2d0a2298329e..73f9a86c12e3 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2652,6 +2652,13 @@ void CastOperation::CheckCStyleCast() {
 return;
   }
 
+  // Allow casting a sizeless built-in type to itself.
+  if (DestType->isSizelessBuiltinType() &&
+  Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
+Kind = CK_NoOp;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 

diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
index a2ac9075347d..8fe8e7b30cf6 100644
--- a/clang/test/Sema/sizeless-1.c
+++ b/clang/test/Sema/sizeless-1.c
@@ -108,6 +108,8 @@ void func(int sel) {
 
   sel = local_int8; // expected-error {{assigning to 'int' from incompatible 
type 'svint8_t'}}
 
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
   local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   local_int8 = (svint8_t)0;   // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   sel = (int)local_int8;  // expected-error {{operand of type 
'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}



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


[clang] 578fb25 - [Sema][SVE] Allow ?: to select between SVE types in C

2020-03-25 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-25T10:31:09Z
New Revision: 578fb2501a66e407187ec0ac4da20995265f91c8

URL: 
https://github.com/llvm/llvm-project/commit/578fb2501a66e407187ec0ac4da20995265f91c8
DIFF: 
https://github.com/llvm/llvm-project/commit/578fb2501a66e407187ec0ac4da20995265f91c8.diff

LOG: [Sema][SVE] Allow ?: to select between SVE types in C

When compiling C, a ?: between two values of the same SVE type
currently gives an error such as:

  incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'svint8_t')

It's supposed to be valid to select between (cv-qualified versions of)
the same SVE type, so this patch adds that case.

These expressions already work for C++ and are tested by
SemaCXX/sizeless-1.cpp.

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

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/sizeless-1.c

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 152d177f147b..373ae9752d41 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7586,6 +7586,11 @@ QualType Sema::CheckConditionalOperands(ExprResult 
, ExprResult ,
   /*IsIntFirstExpr=*/false))
 return LHSTy;
 
+  // Allow ?: operations in which both operands have the same
+  // built-in sizeless type.
+  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+return LHSTy;
+
   // Emit a better diagnostic if one of the expressions is a null pointer
   // constant and the other is not a pointer type. In this case, the user most
   // likely forgot to take the address of the other expression.

diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
index c823823fa00c..a2ac9075347d 100644
--- a/clang/test/Sema/sizeless-1.c
+++ b/clang/test/Sema/sizeless-1.c
@@ -126,6 +126,11 @@ void func(int sel) {
 
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to 
variable 'const_volatile_int8' with const-qualified type 'const volatile 
svint8_t'}}
 
+  init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_volatile_int8;
+
   pass_int8(local_int8);
   pass_int8(local_int16); // expected-error {{passing 'svint16_t' (aka 
'__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
 



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


[PATCH] D76761: [clang-tidy] Fix crash in readability-redundant-string-cstr

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76761

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -220,3 +220,16 @@
   m1tp m1p2 = m1;
   m1p2(s.c_str());  
 }
+
+namespace PR45286 {
+struct Foo {
+  void func(const std::string &) {}
+};
+
+void bar() {
+  std::string Str{"aaa"};
+  Foo Foo;
+  Foo.func(Str.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant call to 'c_str' 
[readability-redundant-string-cstr]
+}
+} // namespace PR45286
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -83,24 +83,25 @@
 // Check that ParamDecl of CallExprDecl has rvalue type.
 static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
 const Expr *TheCxxConstructExpr, ASTContext ) {
-  if (const clang::CallExpr *TheCallExpr =
-  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
-Context)) {
-for (unsigned i = 0; i < TheCallExpr->getNumArgs(); ++i) {
-  const Expr *Arg = TheCallExpr->getArg(i);
-  if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
-if (const auto *TheCallExprFuncProto =
-TheCallExpr->getCallee()
-->getType()
-->getPointeeType()
-->getAs()) {
-  if (TheCallExprFuncProto->getParamType(i)->isRValueReferenceType())
-return true;
-}
-  }
+  const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr, Context);
+  if (!TheCallExpr)
+return false;
+  for (unsigned I = 0; I < TheCallExpr->getNumArgs(); ++I) {
+const Expr *Arg = TheCallExpr->getArg(I);
+if (Arg->getSourceRange() != TheCxxConstructExpr->getSourceRange())
+  continue;
+QualType CalleePointerType =
+TheCallExpr->getCallee()->getType()->getPointeeType();
+if (CalleePointerType.isNull())
+  // Not a pointer type, should probably avoid this
+  continue;
+if (const auto *TheCallExprFuncProto =
+CalleePointerType->getAs()) {
+  if (TheCallExprFuncProto->getParamType(I)->isRValueReferenceType())
+return true;
 }
   }
-
   return false;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -220,3 +220,16 @@
   m1tp m1p2 = m1;
   m1p2(s.c_str());  
 }
+
+namespace PR45286 {
+struct Foo {
+  void func(const std::string &) {}
+};
+
+void bar() {
+  std::string Str{"aaa"};
+  Foo Foo;
+  Foo.func(Str.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+}
+} // namespace PR45286
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -83,24 +83,25 @@
 // Check that ParamDecl of CallExprDecl has rvalue type.
 static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
 const Expr *TheCxxConstructExpr, ASTContext ) {
-  if (const clang::CallExpr *TheCallExpr =
-  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
-Context)) {
-for (unsigned i = 0; i < TheCallExpr->getNumArgs(); ++i) {
-  const Expr *Arg = TheCallExpr->getArg(i);
-  if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
-if (const auto *TheCallExprFuncProto =
-TheCallExpr->getCallee()
-->getType()
-->getPointeeType()
-->getAs()) {
-  if (TheCallExprFuncProto->getParamType(i)->isRValueReferenceType())
-return true;
-}
-  }
+  const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr, 

[PATCH] D76714: [ARM,MVE] Add missing tests for vqdmlash intrinsics.

2020-03-25 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f1651ccead1: [ARM,MVE] Add missing tests for vqdmlash 
intrinsics. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76714/new/

https://reviews.llvm.org/D76714

Files:
  clang/test/CodeGen/arm-mve-intrinsics/ternary.c
  llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
@@ -295,6 +295,38 @@
   ret <4 x i32> %0
 }
 
+define arm_aapcs_vfpcc <16 x i8> @test_vqdmlashq_n_s8(<16 x i8> %m1, <16 x i8> %m2, i8 signext %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i8 %add to i32
+  %1 = tail call <16 x i8> @llvm.arm.mve.vqdmlash.v16i8(<16 x i8> %m1, <16 x i8> %m2, i32 %0)
+  ret <16 x i8> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqdmlashq_n_s16(<8 x i16> %m1, <8 x i16> %m2, i16 signext %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %add to i32
+  %1 = tail call <8 x i16> @llvm.arm.mve.vqdmlash.v8i16(<8 x i16> %m1, <8 x i16> %m2, i32 %0)
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmlashq_n_s32(<4 x i32> %m1, <4 x i32> %m2, i32 %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vqdmlash.v4i32(<4 x i32> %m1, <4 x i32> %m2, i32 %add)
+  ret <4 x i32> %0
+}
+
 define arm_aapcs_vfpcc <16 x i8> @test_vqrdmlahq_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c) {
 ; CHECK-LABEL: test_vqrdmlahq_n_s8:
 ; CHECK:   @ %bb.0: @ %entry
@@ -711,6 +743,50 @@
   ret <4 x i32> %2
 }
 
+define arm_aapcs_vfpcc <16 x i8> @test_vqdmlashq_m_n_s8(<16 x i8> %m1, <16 x i8> %m2, i8 signext %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i8 %add to i32
+  %1 = zext i16 %p to i32
+  %2 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %1)
+  %3 = tail call <16 x i8> @llvm.arm.mve.vqdmlash.predicated.v16i8.v16i1(<16 x i8> %m1, <16 x i8> %m2, i32 %0, <16 x i1> %2)
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqdmlashq_m_n_s16(<8 x i16> %m1, <8 x i16> %m2, i16 signext %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %add to i32
+  %1 = zext i16 %p to i32
+  %2 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %1)
+  %3 = tail call <8 x i16> @llvm.arm.mve.vqdmlash.predicated.v8i16.v8i1(<8 x i16> %m1, <8 x i16> %m2, i32 %0, <8 x i1> %2)
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmlashq_m_n_s32(<4 x i32> %m1, <4 x i32> %m2, i32 %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.vqdmlash.predicated.v4i32.v4i1(<4 x i32> %m1, <4 x i32> %m2, i32 %add, <4 x i1> %1)
+  ret <4 x i32> %2
+}
+
 define arm_aapcs_vfpcc <16 x i8> @test_vqrdmlahq_m_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c, i16 zeroext %p) {
 ; CHECK-LABEL: test_vqrdmlahq_m_n_s8:
 ; CHECK:   @ %bb.0: @ %entry
@@ -816,6 +892,9 @@
 declare <16 x i8> @llvm.arm.mve.vqdmlah.v16i8(<16 x i8>, <16 x i8>, i32)
 declare <8 x i16> @llvm.arm.mve.vqdmlah.v8i16(<8 x i16>, <8 x i16>, i32)
 declare <4 x i32> @llvm.arm.mve.vqdmlah.v4i32(<4 x i32>, <4 x i32>, i32)
+declare <16 x i8> @llvm.arm.mve.vqdmlash.v16i8(<16 x i8>, <16 x i8>, i32)
+declare <8 x i16> @llvm.arm.mve.vqdmlash.v8i16(<8 x i16>, <8 x i16>, i32)
+declare <4 x i32> @llvm.arm.mve.vqdmlash.v4i32(<4 x i32>, <4 x i32>, i32)
 declare <16 x i8> @llvm.arm.mve.vqrdmlah.v16i8(<16 x i8>, <16 x i8>, i32)
 declare <8 x i16> @llvm.arm.mve.vqrdmlah.v8i16(<8 x i16>, <8 x i16>, i32)
 declare <4 x i32> @llvm.arm.mve.vqrdmlah.v4i32(<4 x i32>, <4 x i32>, i32)
@@ -825,6 +904,9 @@
 declare <16 x i8> @llvm.arm.mve.vqdmlah.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>)
 declare <8 x i16> @llvm.arm.mve.vqdmlah.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, i32, <8 x i1>)
 declare <4 x i32> 

[PATCH] D76741: [clangd] Support multiple cursors in selectionRange.

2020-03-25 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added a comment.

Mostly looks good. Few nits. Thanks.




Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1194-1201
   if (Params.positions.size() != 1) {
 elog("{0} positions provided to SelectionRange. Supports exactly one "
  "position.",
  Params.positions.size());
 return Reply(llvm::make_error(
 "SelectionRange supports exactly one position",
 ErrorCode::InvalidRequest));

You can remove this check now.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:671
+}
+return CB(std::move(Result));
+  };

nit: return statement can be omitted.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:65
+// Return an empty range at the point.
+SelectionRange Dummy;
+Dummy.range.start = Dummy.range.end = Pos;

nit: s/Dummy/Empty ?



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:74
+  SelectionRange *Tail = 
+  for (auto  : llvm::makeArrayRef(Ranges).drop_front()) {
+Tail->parent = std::make_unique();

nit:`Range` can be made a `const` ref.



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:175
 
-  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.point());
+  auto Ranges = runSemanticRanges(Server, FooCpp, SourceAnnotations.points());
   ASSERT_TRUE(bool(Ranges))

I think it would be better to name the two points in the test and explicitly 
specify their order in the request (instead of relying on 
`SourceAnnotations.points()`). 
Annotations::points doesn't guarantee order in its contract. Even if the 
current implementation does, it would be better to be explicit and not rely on 
it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76741/new/

https://reviews.llvm.org/D76741



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


[clang] 8f1651c - [ARM, MVE] Add missing tests for vqdmlash intrinsics.

2020-03-25 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-03-25T09:46:16Z
New Revision: 8f1651ccead149fbd2e6fe692fb8a7f787a222bd

URL: 
https://github.com/llvm/llvm-project/commit/8f1651ccead149fbd2e6fe692fb8a7f787a222bd
DIFF: 
https://github.com/llvm/llvm-project/commit/8f1651ccead149fbd2e6fe692fb8a7f787a222bd.diff

LOG: [ARM,MVE] Add missing tests for vqdmlash intrinsics.

Summary:
These were accidentally left out of D76123. I added tests for the
other three instructions in this small cross-product family (vqdmlah,
vqrdmlah, vqrdmlash) but missed this one.

Reviewers: miyuki

Reviewed By: miyuki

Subscribers: kristof.beyls, dmgreen, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/CodeGen/arm-mve-intrinsics/ternary.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Removed: 




diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/ternary.c 
b/clang/test/CodeGen/arm-mve-intrinsics/ternary.c
index 90e258715d26..77eb8d41fe58 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/ternary.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/ternary.c
@@ -357,6 +357,47 @@ int32x4_t test_vqdmlahq_n_s32(int32x4_t a, int32x4_t b, 
int32_t c) {
 #endif /* POLYMORPHIC */
 }
 
+// CHECK-LABEL: @test_vqdmlashq_n_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i8 [[ADD:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <16 x i8> 
@llvm.arm.mve.vqdmlash.v16i8(<16 x i8> [[M1:%.*]], <16 x i8> [[M2:%.*]], i32 
[[TMP0]])
+// CHECK-NEXT:ret <16 x i8> [[TMP1]]
+//
+int8x16_t test_vqdmlashq_n_s8(int8x16_t m1, int8x16_t m2, int8_t add) {
+#ifdef POLYMORPHIC
+  return vqdmlashq(m1, m2, add);
+#else  /* POLYMORPHIC */
+  return vqdmlashq_n_s8(m1, m2, add);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vqdmlashq_n_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[ADD:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i16> 
@llvm.arm.mve.vqdmlash.v8i16(<8 x i16> [[M1:%.*]], <8 x i16> [[M2:%.*]], i32 
[[TMP0]])
+// CHECK-NEXT:ret <8 x i16> [[TMP1]]
+//
+int16x8_t test_vqdmlashq_n_s16(int16x8_t m1, int16x8_t m2, int16_t add) {
+#ifdef POLYMORPHIC
+  return vqdmlashq(m1, m2, add);
+#else  /* POLYMORPHIC */
+  return vqdmlashq_n_s16(m1, m2, add);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vqdmlashq_n_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> 
@llvm.arm.mve.vqdmlash.v4i32(<4 x i32> [[M1:%.*]], <4 x i32> [[M2:%.*]], i32 
[[ADD:%.*]])
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+int32x4_t test_vqdmlashq_n_s32(int32x4_t m1, int32x4_t m2, int32_t add) {
+#ifdef POLYMORPHIC
+  return vqdmlashq(m1, m2, add);
+#else  /* POLYMORPHIC */
+  return vqdmlashq_n_s32(m1, m2, add);
+#endif /* POLYMORPHIC */
+}
+
 // CHECK-LABEL: @test_vqrdmlahq_n_s8(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = zext i8 [[C:%.*]] to i32
@@ -810,6 +851,53 @@ int32x4_t test_vqdmlahq_m_n_s32(int32x4_t a, int32x4_t b, 
int32_t c, mve_pred16_
 #endif /* POLYMORPHIC */
 }
 
+// CHECK-LABEL: @test_vqdmlashq_m_n_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i8 [[ADD:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP2:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP1]])
+// CHECK-NEXT:[[TMP3:%.*]] = call <16 x i8> 
@llvm.arm.mve.vqdmlash.predicated.v16i8.v16i1(<16 x i8> [[M1:%.*]], <16 x i8> 
[[M2:%.*]], i32 [[TMP0]], <16 x i1> [[TMP2]])
+// CHECK-NEXT:ret <16 x i8> [[TMP3]]
+//
+int8x16_t test_vqdmlashq_m_n_s8(int8x16_t m1, int8x16_t m2, int8_t add, 
mve_pred16_t p) {
+#ifdef POLYMORPHIC
+  return vqdmlashq_m(m1, m2, add, p);
+#else  /* POLYMORPHIC */
+  return vqdmlashq_m_n_s8(m1, m2, add, p);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vqdmlashq_m_n_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[ADD:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP1]])
+// CHECK-NEXT:[[TMP3:%.*]] = call <8 x i16> 
@llvm.arm.mve.vqdmlash.predicated.v8i16.v8i1(<8 x i16> [[M1:%.*]], <8 x i16> 
[[M2:%.*]], i32 [[TMP0]], <8 x i1> [[TMP2]])
+// CHECK-NEXT:ret <8 x i16> [[TMP3]]
+//
+int16x8_t test_vqdmlashq_m_n_s16(int16x8_t m1, int16x8_t m2, int16_t add, 
mve_pred16_t p) {
+#ifdef POLYMORPHIC
+  return vqdmlashq_m(m1, m2, add, p);
+#else  /* POLYMORPHIC */
+  return vqdmlashq_m_n_s16(m1, m2, add, p);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vqdmlashq_m_n_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 
[[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <4 x i32> 
@llvm.arm.mve.vqdmlash.predicated.v4i32.v4i1(<4 x i32> [[M1:%.*]], <4 x i32> 
[[M2:%.*]], i32 [[ADD:%.*]], <4 x 

[PATCH] D76054: [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6538b4393dc3: [clang-apply-replacements] No longer 
deduplucates replacements from the same TU (authored by njames93).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76054/new/

https://reviews.llvm.org/D76054

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  
clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file1.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file2.yaml
  
clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/identical-in-TU.cpp
  clang-tools-extra/test/clang-apply-replacements/identical-in-TU.cpp

Index: clang-tools-extra/test/clang-apply-replacements/identical-in-TU.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/identical-in-TU.cpp
@@ -0,0 +1,11 @@
+// RUN: mkdir -p %T/Inputs/identical-in-TU
+
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/identical-in-TU/identical-in-TU.cpp > %T/Inputs/identical-in-TU/identical-in-TU.cpp
+// RUN: sed "s#\$(path)#%/T/Inputs/identical-in-TU#" %S/Inputs/identical-in-TU/file1.yaml > %T/Inputs/identical-in-TU/file1.yaml
+// RUN: sed "s#\$(path)#%/T/Inputs/identical-in-TU#" %S/Inputs/identical-in-TU/file2.yaml > %T/Inputs/identical-in-TU/file2.yaml
+// RUN: clang-apply-replacements %T/Inputs/identical-in-TU
+// RUN: FileCheck -input-file=%T/Inputs/identical-in-TU/identical-in-TU.cpp %S/Inputs/identical-in-TU/identical-in-TU.cpp
+
+// Similar to identical test but each yaml file contains the same fix twice. 
+// This check ensures that only the duplicated replacements in a single yaml 
+// file are applied twice. Addresses PR45150.
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/identical-in-TU.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/identical-in-TU.cpp
@@ -0,0 +1,2 @@
+class MyType {};
+// CHECK: class MyType00 {};
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file2.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file2.yaml
@@ -0,0 +1,19 @@
+---
+MainSourceFile: identical-in-TU.cpp
+Diagnostics:
+  - DiagnosticName: test-identical-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/identical-in-TU.cpp
+  FileOffset: 12
+  Replacements:
+- FilePath:$(path)/identical-in-TU.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+- FilePath:$(path)/identical-in-TU.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+...
+
Index: clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file1.yaml
===
--- /dev/null
+++ clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file1.yaml
@@ -0,0 +1,19 @@
+---
+MainSourceFile: identical_in_TU.cpp
+Diagnostics:
+  - DiagnosticName: test-identical-insertion
+DiagnosticMessage:
+  Message: Fix
+  FilePath: $(path)/identical_in_TU.cpp
+  FileOffset: 12
+  Replacements:
+- FilePath:$(path)/identical_in_TU.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+- FilePath:$(path)/identical_in_TU.cpp
+  Offset:  12
+  Length:  0
+  ReplacementText: '0'
+...
+
Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -143,18 +143,26 @@
   llvm::DenseMap>
   GroupedReplacements;
 
-  // Deduplicate identical replacements in diagnostics.
+  // Deduplicate identical replacements in diagnostics unless they are from the
+  // same TU.
   // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap>
+  llvm::DenseMap>
   DiagReplacements;
 
-  auto AddToGroup = [&](const tooling::Replacement , bool FromDiag) {
+  auto AddToGroup = [&](const tooling::Replacement ,
+const tooling::TranslationUnitDiagnostics *SourceTU) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
-  if (FromDiag) {
+  if (SourceTU) {
 auto  = DiagReplacements[*Entry];
-if (!Replaces.insert(R).second)

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-03-25 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 252519.
baloghadamsoftware added a comment.

Test added.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73720/new/

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector ) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector ) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector ) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector ) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector ) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector ) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector ) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector ) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector ) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector ) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector ) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector ) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector ) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin_by_2(const std::vector ) {
@@ -246,11 +257,13 @@
 void decr_by_2_copy_begin(const std::vector ) {
   auto i = V.begin();
   auto j = i - 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator 

[PATCH] D76714: [ARM,MVE] Add missing tests for vqdmlash intrinsics.

2020-03-25 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76714/new/

https://reviews.llvm.org/D76714



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


[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-25 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

So what is missing or wrong in this change to be accepted?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75682/new/

https://reviews.llvm.org/D75682



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


[clang-tools-extra] 6538b43 - [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-25 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-25T09:36:36Z
New Revision: 6538b4393dc3e7df9fee2b07eba148d4cf603a24

URL: 
https://github.com/llvm/llvm-project/commit/6538b4393dc3e7df9fee2b07eba148d4cf603a24
DIFF: 
https://github.com/llvm/llvm-project/commit/6538b4393dc3e7df9fee2b07eba148d4cf603a24.diff

LOG: [clang-apply-replacements] No longer deduplucates replacements from the 
same TU

Summary:
clang-apply-replacements currently deduplicates all diagnostic replacements. 
However if you get a duplicated replacement from one TU then its expected that 
it should not be deduplicated. This goes some way to solving [[ 
https://bugs.llvm.org/show_bug.cgi?id=45150 | export-fixes to yaml adds extra 
newlines and breaks offsets. ]]

Take this example yaml.
```
---
MainSourceFile:  '/home/nathan/test/test.cpp'
Diagnostics:
  - DiagnosticName:  readability-braces-around-statements
DiagnosticMessage:
  Message: statement should be inside braces
  FilePath:'/home/nathan/test/test.cpp'
  FileOffset:  14
  Replacements:
- FilePath:'/home/nathan/test/test.cpp'
  Offset:  14
  Length:  0
  ReplacementText: ' {'
- FilePath:'/home/nathan/test/test.cpp'
  Offset:  28
  Length:  0
  ReplacementText: '

}'
  - DiagnosticName:  readability-braces-around-statements
DiagnosticMessage:
  Message: statement should be inside braces
  FilePath:'/home/nathan/test/test.cpp'
  FileOffset:  20
  Replacements:
- FilePath:'/home/nathan/test/test.cpp'
  Offset:  20
  Length:  0
  ReplacementText: ' {'
- FilePath:'/home/nathan/test/test.cpp'
  Offset:  28
  Length:  0
  ReplacementText: '

}'
...```

The current behaviour is to deduplicate the text insertions at Offset 28 and 
only apply one of the replacements.
However as both of these replacements came from the same translation unit we 
can be confident they were both meant to be applied together
The new behaviour won't deduplicate the text insertion and instead insert both 
of the replacements.
If the duplicate replacement is found inside different translation units (from 
a header file change perhaps) then they will still be deduplicated as before.

Reviewers: aaron.ballman, gribozavr2, klimek, ymandel

Reviewed By: ymandel

Subscribers: ymandel, cfe-commits

Tags: #clang

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

Added: 

clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file1.yaml

clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/file2.yaml

clang-tools-extra/test/clang-apply-replacements/Inputs/identical-in-TU/identical-in-TU.cpp
clang-tools-extra/test/clang-apply-replacements/identical-in-TU.cpp

Modified: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 33ece7f1b4e0..1e5012b9891b 100644
--- 
a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ 
b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -143,18 +143,26 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
   llvm::DenseMap>
   GroupedReplacements;
 
-  // Deduplicate identical replacements in diagnostics.
+  // Deduplicate identical replacements in diagnostics unless they are from the
+  // same TU.
   // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap>
+  llvm::DenseMap>
   DiagReplacements;
 
-  auto AddToGroup = [&](const tooling::Replacement , bool FromDiag) {
+  auto AddToGroup = [&](const tooling::Replacement ,
+const tooling::TranslationUnitDiagnostics *SourceTU) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
-  if (FromDiag) {
+  if (SourceTU) {
 auto  = DiagReplacements[*Entry];
-if (!Replaces.insert(R).second)
+auto It = Replaces.find(R);
+if (It == Replaces.end())
+  Replaces.emplace(R, SourceTU);
+else if (It->second != SourceTU)
+  // This replacement is a duplicate of one suggested by another TU.
   return;
   }
   GroupedReplacements[*Entry].push_back(R);
@@ -166,14 +174,14 @@ groupReplacements(const TUReplacements , const 
TUDiagnostics ,
 
   for (const auto  : TUs)
 for (const tooling::Replacement  : TU.Replacements)
-  AddToGroup(R, false);
+  AddToGroup(R, nullptr);
 
   for (const 

[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-25 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:1935
+
+alpha.security.cert.str.31c
+"""

Charusso wrote:
> Szelethus wrote:
> > balazske wrote:
> > > There are already more checkers that can check for CERT related problems 
> > > but not specially made for these. These checkers do not reside in this 
> > > new `cert` group. And generally a checker does not check for specifically 
> > > a CERT rule, instead for more of them or other things too, or more 
> > > checkers can detect a single rule. (And the user can think that only 
> > > these CERT rules are checkable that exist in this package, that is not 
> > > true.) So I do not like the introduction of this new `cert` package. (The 
> > > documentation of existing checkers lists if the checker is designed for a 
> > > CERT rule.)
> > I disagree to some extent. I think it would be great to have a `cert` 
> > package that houses all checkers for each of the rules with the addition of 
> > checker aliases. Clang-tidy has something similar as well!
> I designed the checker only for the rule STR31-C that is why I have picked 
> package `cert`. Clang-Tidy could aliasing checks. For example the check could 
> be in the `bugprone` category aliased to `cert` and both could trigger the 
> analysis.
> 
> > the user can think that only these CERT rules are checkable
> We only need to move `security.FloatLoopCounter` under the `cert` package. 
> What else SEI CERT rules are finished off other than package `cert`? It is 
> not my fault if someone could not package well or could not catch most of the 
> issues of a SEI CERT rule or could not reach the SEI CERT group to note the 
> fact the Analyzer catch a very tiny part of a rule. However, this patch 
> package well and could catch most of the STR31-C rule.
So I can move this checker: D71510 into `alpha.security.cert.err.33c`?



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:803
+
+} // end "cert.str"
+

Charusso wrote:
> balazske wrote:
> > NoQ wrote:
> > > `alpha.cert.str`.
> > This text may be hard to understand. The option means "if it is off, the 
> > problem report happens only if there is no hand-written null termination of 
> > the string"? I looked at the CERT rule but did not find out why is null 
> > termination by hand important here. (I did not look at the code to find out 
> > what it does.) And "WarnOnCall" suggests that there is warning made on 
> > calls if on, or not at all or at other location if off, is this correct?
> You let the buffer overflow by a bugprone function call, then you adjust the 
> null-terminator by simply `buf[size] = '\0'`, then you made sure the buffer 
> cannot overflow, since you have terminated it. It is a very common idiom 
> therefore I do not think a hand-written null-termination is a security issue. 
> The SEI CERT rules are all theoretical so you will not find anything useful 
> in practice. My solution is practical.
> 
> > This text may be hard to understand.
> Please note that this text only made for Static Analyzer developers. Let us 
> rephrase it then:
> 
> > Whether the checker needs to warn on the bugprone function calls 
> > immediately or look for bugprone hand-written null-termination of bugprone 
> > function call made strings. It is a common idiom to null-terminate the 
> > string by hand after the insecure function call produce the string which 
> > could be misused so that it is on by default. It is useful to turn it off 
> > to reduce the noise of the checker, because people usually null-terminate 
> > the string by hand immediately after the bugprone function call produce the 
> > string.
> 
> Do you buy that?
First sentence is OK, the later part relatively better. Probably the 
explanations about why it is good to turn it on or off can be left out, these 
are misunderstandable. (If the manual null-termination is done, in one case it 
is a "common idiom but can be misused so make warning" on other case "these 
warnings generates only extra noise".)
It can be something like this (if correct):
```
Whether the checker wars on the function calls immediately or warns on bugprone 
hand-written null-termination of function call made strings. Default value is 
on because null-terminating the string by hand after the insecure function call 
could be misused. But it is a common idiom to manually null-terminate the 
strings immediately after the function calls so it could be turned off to 
reduce noise of the checker.
```
I do not like the word "bugprone", is it correct english? ("Problematic" or 
"insecure" could be used instead.)



Comment at: clang/test/Analysis/cert/str31-c-notes-warn-on-call-off.cpp:68
+
+  do_something(dest);
+  // expected-warning@-1 {{'dest' is not null-terminated}}

Charusso wrote:
> balazske wrote:
> > Maybe I have wrong expectations about what this checker does but 

[PATCH] D76062: [PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support

2020-03-25 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76062/new/

https://reviews.llvm.org/D76062



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


[PATCH] D76744: [clang-tidy] Add check to ensure llvm-libc implementations are defined in correct namespace.

2020-03-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

This check should only worry about the first declaration of the function, any 
redecls or the definition could appear outside the namespace like this:

  namespace blah{
  void foo();
  }
  void blah::foo();
  void blah::foo(){}

There are some missing test cases I'd like to see like
wrapping in an enclosing namespace (including anonymous)

  namespace __llvm_libc {
  namespace  {
  // impl
  }
  }
  
  namespace  {
  namesapce __llvm_libc {
  // impl
  }
  }

As I don't work on libc I'm not sure how these should be handled, maybe its 
fine if there is a corresponding `inline namespace`.




Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/EntrypointNamespaceCheck.cpp:67
+  if (Result.SourceManager->getFilename(MatchedDecl->getLocation())
+  .endswith(".h"))
+return;

Is there a rule that all libc implementation headers must have the extension 
`.h`. If not there is `utils::FileExtensionSet` that could be used.
Alternatively you could just check to see if the SourceLocation is in the main 
file
`if (!Result.SourceManager->isInMainFile(MatchedDecl->getLocation())`



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/EntrypointNamespaceCheck.cpp:71
+  std::string RequiredNamespace =
+  Options.get("RequiredNamespace", "__llvm_libc");
+  const DeclContext *EnclosingDecl =

To save fetching the option each time, why not just store the required 
namespace in the class and initialize it in the constructor


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76744/new/

https://reviews.llvm.org/D76744



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


[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0788acbccbec: [AST] Build recovery expressions by default 
for C++. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D76696?vs=252513=252515#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76696/new/

https://reviews.llvm.org/D76696

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -487,6 +487,7 @@
 auto x = decltype(&1)(^);
 auto y = new decltype(&1)(^);
   )cpp";
-  EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
+  EXPECT_THAT(collectPreferredTypes(Code),
+  Each("decltype((1))"));
 }
 } // namespace
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int );
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   Noncopyable();
@@ -107,8 +107,10 @@
   sizeof(make_indestructible()); // expected-error {{deleted}}
   sizeof(make_incomplete()); // expected-error {{incomplete}}
   typeid(Indestructible{}); // expected-error {{deleted}}
-  typeid(make_indestructible()); // expected-error {{deleted}}
-  typeid(make_incomplete()); // expected-error {{incomplete}}
+  typeid(make_indestructible()); // expected-error {{deleted}} \
+  

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:2440
 TEST_F(FormatTest, FormatsExternC) {
-  verifyFormat("extern \"C\" {\nint a;");
-  verifyFormat("extern \"C\" {}");
+  verifyFormat("extern \"C\" {\nint a; /*2.1*/");
+  verifyFormat("extern \"C\" { /*2.2*/\n}");

MarcusJohnson91 wrote:
> MyDeveloperDay wrote:
> > why are you changing tests? where is the test that shows this works when a 
> > comment isn't present?
> These test comments were adds solely so I could see which part of the tests 
> we're failing, because there's some repeats and it got confusing. Clang's 
> tests would print the line which included the text, it was basically printf 
> debugging without printf.
> 
> There is now just one minor change to the existing tests.
actually I have a change in https://reviews.llvm.org/D69764#change-XlRuRVhsnCkV 
which helps address this, but it feels too much to roll out.

Instead of using verifyFormat we use a macro VERIFYFORMAT(), this passes the 
__LINE__ and __FILE__ across into the gtest code which then means when these 
verifyFormat() fail it actually tells you which line its failing on!



Comment at: clang/unittests/Format/FormatTest.cpp:2497
Style);
 }
 

my assumption is this test is using `Style.IndentExternBlock =false` correct?

This suggests the default was previously true not false

```
if (Style.BraceWrapping.AfterExternBlock) {
if (Style.BraceWrapping.AfterExternBlock) {
  addUnwrappedLine();
  parseBlock(/*MustBeDeclaration=*/true);
} else {
  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
   }
```

This one test change alone, makes me see that it might be incorrect to set the 
default Indent to false when AfterExternBlock is true.  (parseBlock default 
parameter for AddLevel is true)

shouldn't the default value of `Style.IndentExternBlock = 
Style.BraceWrapping.AfterExternBlock`?

(which is 100% why I don't like seeing tests changed).. this was buried in your 
last changes to the tests and I didn't see it.)

So now we need to go back and take a look through the clang sources and see 
what its doing by default, and tests what other default styles are doing prior 
to this change and if they indent then I think by default we need to indent.

If we run clang-format on the following code, we see an issues

https://github.com/llvm/llvm-project/blob/a974b33a10745b528c34f0accbd230b0a4e1fb87/clang/test/SemaCXX/linkage-spec.cpp

Whats great about this Fix (which is why it needs to go in) this test file 
despite being part of LLVM its not actually formatted with the LLVM style ;-) 
i.e. it will come out as

```
extern "C" {
extern "C" void f(int);
}

extern "C++" {
extern "C++" int (int);
float ();
}
```

instead of 

```
extern "C" {
  extern "C" void f(int);
}

extern "C++" {
  extern "C++" int& g(int);
  float& g();
}
```

Thats because they don't want a break after the "C" and before the { but they 
do what the indent.

Conversely there is code in

https://github.com/llvm/llvm-project/blob/a974b33a10745b528c34f0accbd230b0a4e1fb87/llvm/utils/benchmark/test/donotoptimize_assembly_test.cc

This code IS more formatted than the the previous one (not 100% correct but 
close enough) and so having the default to true would cause unnecessary churn 
here.

Then of course there must be other projects that use BreakAfterExtern=true and 
they would get the indentation and want to keep it, so the setting of the 
default value of IndentExternBlock  needs to be dynamic if possible, don't you 
think.

To be honest your change should support actually allowing this some of these 
files to now support keeping its format correclty, which in my view is great! 
but breaking the default styles is always hard, because we get complaints that 
different versions of clang-format can cause huge waves of changes and I've 
seen unless teams are all on the same version then the format can flipflop 
between versions.






Comment at: clang/unittests/Format/FormatTest.cpp:2505
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int foo();\n}", Style);
+

nit: these are a little easier to read when formatted as above

```
verifyFormat("extern \"C\" {\n"
  "  int foo();\n"
  "}", Style);
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75791/new/

https://reviews.llvm.org/D75791



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


[PATCH] D76572: Replace `T(x)` with `reinterpret_cast(x)` everywhere it means reinterpret_cast. No functional change

2020-03-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.

LGTM, with nit, with regards to the llvm-readobj and libObject parts. I haven't 
looked at the other bits though.




Comment at: llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp:150
+ ">= 65536.\n"
+ "(" +
+ Twine(reinterpret_cast()) + ")");

Nit: I think you can fold these two string literals together. Not sure why they 
were separate before.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76572/new/

https://reviews.llvm.org/D76572



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


[PATCH] D75561: Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

2020-03-25 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Can you link what code is actually requiring this change? I just went over the 
patch series and it's not obvious to me what exactly this is used for.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75561/new/

https://reviews.llvm.org/D75561



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


[PATCH] D76595: [clangd-vscode] NFC; Improve wording in documentation and update VSCode tasks

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

In D76595#1938727 , @kbobyrev wrote:

> In D76595#1936408 , @hokein wrote:
>
> > thanks. regarding files in `.vscode`, I think they are just local configs 
> > in VSCode, we can probably remove the whole directory from git since we 
> > already ignore them in the `llvm/.gitignore`.
>
>
> I think those are hand-written VSCode tasks and removing those would result 
> in the absence of compiling and debugging actions in VSCode. 
> `llvm/.gitignore` is intended to ignore the configs, but I'm not sure it is a 
> "config file" in traditional sensee. Am I missing something?


ah, I see. If removing these would cause troubles, then let's keep it (I 
thought these files are generated by VSCode as well).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76595/new/

https://reviews.llvm.org/D76595



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


[clang-tools-extra] 0788acb - [AST] Build recovery expressions by default for C++.

2020-03-25 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-03-25T09:00:48+01:00
New Revision: 0788acbccbec094903a3425ffe5a98f8d55cbd64

URL: 
https://github.com/llvm/llvm-project/commit/0788acbccbec094903a3425ffe5a98f8d55cbd64
DIFF: 
https://github.com/llvm/llvm-project/commit/0788acbccbec094903a3425ffe5a98f8d55cbd64.diff

LOG: [AST] Build recovery expressions by default for C++.

Update the existing tests.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Basic/LangOptions.def
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/OpenMP/target_update_from_messages.cpp
clang/test/OpenMP/target_update_to_messages.cpp
clang/test/Parser/objcxx0x-lambda-expressions.mm
clang/test/Parser/objcxx11-invalid-lambda.cpp
clang/test/SemaCXX/builtins.cpp
clang/test/SemaCXX/cast-conversion.cpp
clang/test/SemaCXX/cxx1z-copy-omission.cpp
clang/test/SemaCXX/decltype-crash.cpp
clang/test/SemaCXX/varargs.cpp
clang/test/SemaOpenCLCXX/address-space-references.cl
clang/test/SemaTemplate/instantiate-init.cpp
clang/unittests/Sema/CodeCompleteTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 0d6e37f00118..f5c90a4677cb 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1195,7 +1195,9 @@ TEST(SignatureHelpTest, OpeningParen) {
 int foo(int a, int b, int c);
 int main() {
 #define ID(X) X
-  ID(foo $p^( foo(10), ^ ))
+  // FIXME: figure out why ID(foo (foo(10), )) doesn't work when preserving
+  // the recovery expression.
+  ID(foo $p^( 10, ^ ))
 })cpp"};
 
   for (auto Test : Tests) {

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 6152e227d599..22c4a87918e9 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -148,7 +148,7 @@ LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed 
matching of template t
 
 LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for 
all language standard modes")
 
-COMPATIBLE_LANGOPT(RecoveryAST, 1, 0, "Preserve expressions in AST when 
encountering errors")
+COMPATIBLE_LANGOPT(RecoveryAST, 1, CPlusPlus, "Preserve expressions in AST 
when encountering errors")
 
 BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
 LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index dc5e932c9460..08e0700671a8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2909,7 +2909,7 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   if (Args.hasArg(OPT_fconcepts_ts))
 Diags.Report(diag::warn_fe_concepts_ts_flag);
   Opts.RecoveryAST =
-  Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, false);
+  Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2e1231c57c28..152d177f147b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -18437,8 +18437,8 @@ bool Sema::IsDependentFunctionNameExpr(Expr *E) {
 
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
 ArrayRef SubExprs) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
+  // RecoveryExpr is type-dependent to suppress bogus diagnostics and this 
trick
+  // does not work in C.
   // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
 return ExprError();

diff  --git a/clang/test/OpenMP/target_update_from_messages.cpp 
b/clang/test/OpenMP/target_update_from_messages.cpp
index eaf862a10582..141cfc38ffeb 100644
--- a/clang/test/OpenMP/target_update_from_messages.cpp
+++ b/clang/test/OpenMP/target_update_from_messages.cpp
@@ -74,7 +74,7 @@ struct S8 {
 #pragma omp target update from(*(this->S->i+this->S->s6[0].pp)) // le45-error 
{{expected expression containing only member accesses and/or array sections 
based on named variables}} le45-error {{expected at least one 'to' clause or 
'from' clause specified to '#pragma omp target update'}}
 #pragma omp target update 

[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D76696#1939513 , @sammccall wrote:

> Do you also want to update LangOpts.td to make the default for the langopt 
> equal to CPlusPlus?
>  (I saw other opts doing that, not sure exactly what it affects, may be 
> voodoo cargo cult stuff)


ah, I missed that.




Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:1198
 #define ID(X) X
-  ID(foo $p^( foo(10), ^ ))
+  ID(foo $p^( 10, ^ ))
 })cpp"};

sammccall wrote:
> Why did the original test start failing? Is this a regression?
> 
> (This certainly seems OK to regress and fix later, but there may be other 
> consequences?)
yes, but I didn't dig into it, it is likely a regression, added a FIXME 
(looking at other cases in this test, they just use `10` as the parameter).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76696/new/

https://reviews.llvm.org/D76696



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


[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252513.
hokein marked an inline comment as done.
hokein added a comment.

address review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76696/new/

https://reviews.llvm.org/D76696

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -487,6 +487,7 @@
 auto x = decltype(&1)(^);
 auto y = new decltype(&1)(^);
   )cpp";
-  EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
+  EXPECT_THAT(collectPreferredTypes(Code),
+  Each("decltype((1))"));
 }
 } // namespace
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int );
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   Noncopyable();
@@ -107,8 +107,10 @@
   sizeof(make_indestructible()); // expected-error {{deleted}}
   sizeof(make_incomplete()); // expected-error {{incomplete}}
   typeid(Indestructible{}); // expected-error {{deleted}}
-  typeid(make_indestructible()); // expected-error {{deleted}}
-  typeid(make_incomplete()); // expected-error {{incomplete}}
+  typeid(make_indestructible()); // expected-error {{deleted}} \
+ // expected-error {{need to include }}
+  typeid(make_incomplete()); // expected-error {{incomplete}} \
+   

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:713
+  StringRef Name;
+  if (const auto *DRE = dyn_cast(ContE->IgnoreParenCasts())) {
+Name = DRE->getDecl()->getName();

baloghadamsoftware wrote:
> NoQ wrote:
> > NoQ wrote:
> > > baloghadamsoftware wrote:
> > > > baloghadamsoftware wrote:
> > > > > NoQ wrote:
> > > > > > Hmm, i think you should instead look at `ContReg`, i.e. whether 
> > > > > > it's a non-anonymous `VarRegion` or a `FieldRegion` or something 
> > > > > > like that (in other patches as well). It would work more often and 
> > > > > > it'll transparently handle references.
> > > > > Unfortunately it is a `SymRegion` so it does not work :-( (Even using 
> > > > > `getMostDerivedRegion()` does not help.)
> > > > You mean the first checking form `SymbolicRegion`, then get its symbol, 
> > > > check for `SymbolRegionValue`, then get its `TypedValueRegion`, check 
> > > > for `DeclRegion` and use its `Decl`? This sound waaay more complicated 
> > > > and less readable. I am not sure which are the side cases: is it always 
> > > > `SymbolicRegion`? Is the `Symbol` of `SymbolicRegion` always a 
> > > > `SymbolRegionValue`? Is ithe `TypedValueRegion` (the return value of 
> > > > its `getRegion()`) always a `DeclRegion`?
> > > > Unfortunately it is a `SymRegion`
> > > 
> > > Emm, that's rarely the case. Only if it's a reference passed into a 
> > > top-level function as a parameter.
> > (or to another unknown location) (please learn what `SymbolicRegion` is, it 
> > is very important for your work)
> > 
> > I guess you should do both then, because when the analyzer is able to 
> > resolve the reference it's better in this case to point out what is the 
> > actual container that's being modified.
> Is it OK now?
Looks good, can we also have tests for this case? I.e., anything where the 
container isn't passed by reference to an unknown location.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73720/new/

https://reviews.llvm.org/D73720



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


[PATCH] D73898: [analyzer] StdLibraryFunctionsChecker: Add argument constraints

2020-03-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:409
 
-  Optional FoundSummary = findFunctionSummary(FD, CE, C);
+  for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
+ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);

martong wrote:
> NoQ wrote:
> > Maybe we should add an assertion that the same argument isn't specified 
> > multiple times.
> I think there could be cases when we want to have e.g. a not-null constraint 
> on the 1st argument, but also we want to express that the 1st argument's size 
> is described by the 2nd argument. I am planning to implement such a 
> constraints in the future. In that case we would have two constraints on the 
> 1st argument and the assert would fire.
Wait, i misunderstood the code. It's even worse than that: you're adding 
transitions in a loop, so it'll cause state splits for every constraint. 
Because you do not intend to create multiple branches here, there needs to be 
exactly one `addTransition` performed every time `checkPreCall` is called. 
I.e., for now this code is breaking everything whenever there's more than one 
constraint, regardless of whether it's on the same argument.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73898/new/

https://reviews.llvm.org/D73898



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


<    1   2