[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-11 Thread Mott, Jeffrey T via Phabricator via cfe-commits
jtmott-intel added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:327
   return true;
 TheCall->setArg(2, Arg.get());
   }

rjmccall wrote:
> I know this is existing code, but this is a broken mess.  Please change this 
> to:
> 
> ```
>   ExprResult Arg = DefaultFunctionArrayLvalueConversion(TheCall->getArg(2));
>   if (Arg.isInvalid()) return true;
>   TheCall->setArg(2, Arg.get());
> 
>   QualType Ty = Arg.get()->getType();
>   const auto *PtrTy = Ty->getAs();
>   if (!PtrTy ||
>   !PtrTy->getPointeeType()->isIntegerType() ||
>   PtrTy->getPointeeType().isConstQualified()) {
> S.Diag(Arg.get()->getBeginLoc(),
>diag::err_overflow_builtin_must_be_ptr_int)
>   << Ty << Arg.get()->getSourceRange();
> return true;
>   }
> ```
> 
> Test case would be something like (in ObjC):
> 
> ```
> @interface HasPointer
> @property int *pointer;
> @end
> 
> void test(HasPointer *hp) {
>   __builtin_add_overflow(x, y, hp.pointer);
> }
> ```
> 
> And the earlier block needs essentially the same change (but obviously 
> checking for a different type).  You can't check types before doing 
> placeholder conversions, and once you do l-value conversions and a 
> type-check, you really don't need the full parameter-initialization logic.
I've implemented this locally but I have a quick question about the test. It 
passed even before I applied this code change. Is this test expected to fail 
before this change and pass after? Or is it just to prove that the feature 
(placeholder argument types?) works in general?


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

https://reviews.llvm.org/D81420



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:682
 void CodeGenModule::EmitCXXGlobalDtorFunc() {
   if (CXXGlobalDtors.empty())
 return;

hubert.reinterpretcast wrote:
> Following from my previous comments on `CXXGlobalDtors`, I am not convinced 
> that `__sterm` functions match the role.
This function is to be renamed.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:700
+
+Fn = CreateGlobalInitOrDestructFunction(
+FTy, llvm::Twine("__sterm8000_clang_") + GlobalUniqueModuleId, FI,

The called function is to be renamed.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1057
+  /// Add a destructor to the C++ global destructor function.
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {
+CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(),

This function is to be renamed.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4458
+
+void XLCXXABI::emitCXXGlobalVarDeclDestructFunc(const VarDecl ,
+llvm::Function *dtorStub,

This function is to be renamed.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4470
+  const CGFunctionInfo  = CGM.getTypes().arrangeNullaryFunction();
+  llvm::Function *GlobalVDTermFn = CGM.CreateGlobalInitOrDestructFunction(
+  FTy, FnName.str(), FI, D.getLocation());

`Term`, being a short form for "termination", the variable name does not match 
the purpose based on the terminology within the Clang context.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4487
+
+  // Check if the guard variable is zero.
+  CGF.EmitCXXGuardedInitBranch(NeedsDestruct, DestructCallBlock, EndBlock,

This comment is not helpful. It does not say which action is associated with 
which state.



Comment at: clang/test/CodeGen/aix-constructor-attribute.cpp:2
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \

Please split on the `|` with the new line beginning with `FileCheck` indented 
two spaces in relation to the previous line. Apply throughout.


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

https://reviews.llvm.org/D74166



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:2725-2726
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
   // Create a link action to link device IR with device library
   // and generate ISA.
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(

tra wrote:
> The comment about "create link action" should probably be moved down below to 
> where the link action is constructed now.
> 
will do



Comment at: clang/lib/Driver/Driver.cpp:2727-2732
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Backend, CudaDeviceActions[I],
+  AssociatedOffloadKind);
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Assemble, CudaDeviceActions[I],
+  AssociatedOffloadKind);

tra wrote:
> Looks like we're chaining backend/assembly actions here. but it's not easy to 
> spot that we use `CudaDeviceActions[I]`  as an intermediate value. At the 
> first glance it looked like a copy/paste error writing to 
> `CudaDeviceActions[I]` multiple times.
> 
> It would be easier to see what's going on if the code was structured like 
> this:
> ```
> BackendAction = Construct(... CudaDeviceActions[I]);
> AssembleAction  = Construct(... BackendAction);
> AL.push_back(AssembleAction)
> CudaDeviceActions[I] = C.MakeAction(AL);
> ```
> 
will do


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

https://reviews.llvm.org/D81627



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 270302.
yaxunl marked 2 inline comments as done.
yaxunl added a reviewer: ashi1.
yaxunl added a comment.

revised by Artem's comments.


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

https://reviews.llvm.org/D81627

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/cuda-phases.cu
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-opt.hip

Index: clang/test/Driver/hip-toolchain-opt.hip
===
--- clang/test/Driver/hip-toolchain-opt.hip
+++ clang/test/Driver/hip-toolchain-opt.hip
@@ -68,27 +68,9 @@
 // Oz-SAME: "-Oz"
 // Og-SAME: "-Og"
 
-// ALL: "{{.*}}opt"
-// DEFAULT-NOT: "-O{{.}}"
-// O0-SAME: "-O0"
-// O1-SAME: "-O1"
-// O2-SAME: "-O2"
-// O3-SAME: "-O3"
-// Os-SAME: "-Os"
-// Oz-SAME: "-Oz"
-// Og-SAME: "-O1"
-// ALL-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// ALL-NOT: "{{.*}}opt"
 
-// ALL: "{{.*}}llc"
-// DEFAULT-NOT: "-O{{.}}"
-// O0-SAME: "-O0"
-// O1-SAME: "-O1"
-// O2-SAME: "-O2"
-// O3-SAME: "-O3"
-// Os-SAME: "-O2"
-// Oz-SAME: "-O2"
-// Og-SAME: "-O1"
-// ALL-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// ALL-NOT: "{{.*}}llc"
 
 // ALL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // DEFAULT-NOT: "-O{{.}}"
Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -18,25 +18,17 @@
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
-// CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_803:".*o"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC:".*a.cu"]]
 
-// CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_803]]
-// CHECK-SAME: "-o" [[LINKED_BC_DEV_A_803:".*-gfx803-linked-.*bc"]]
-
-// CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx803"
-// CHECK-SAME: "-o" [[OPT_BC_DEV_A_803:".*-gfx803-optimized.*bc"]]
-
-// CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_803]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx803"
-// CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-o" [[OBJ_DEV_A_803:".*-gfx803-.*o"]]
+// CHECK-NOT: {{".*llvm-link"}}
+// CHECK-NOT: {{".*opt"}}
+// CHECK-NOT: {{".*llc"}}
 
 // CHECK: [[LLD: ".*lld.*"]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_803:.*out]]" [[OBJ_DEV_A_803]]
@@ -47,25 +39,17 @@
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
-// CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip"
+// CHECK-SAME: {{.*}} "-o" [[OBJ_DEV_A_900:".*o"]] "-x" "hip"
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
-// CHECK: [[LLVM_LINK:"*.llvm-link"]] [[A_BC_900]]
-// CHECK-SAME: "-o" [[LINKED_BC_DEV_A_900:".*-gfx900-linked-.*bc"]]
-
-// CHECK: [[OPT:".*opt"]] [[LINKED_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx900"
-// CHECK-SAME: "-o" [[OPT_BC_DEV_A_900:".*-gfx900-optimized.*bc"]]
-
-// CHECK: [[LLC: ".*llc"]] [[OPT_BC_DEV_A_900]] "-mtriple=amdgcn-amd-amdhsa"
-// CHECK-SAME: "-mcpu=gfx900"
-// CHECK-SAME: "-filetype=obj"
-// CHECK-SAME: "-o" [[OBJ_DEV_A_900:".*-gfx900-.*o"]]
+// CHECK-NOT: {{".*llvm-link"}}
+// CHECK-NOT: {{".*opt"}}
+// CHECK-NOT: {{".*llc"}}
 
 // CHECK: [[LLD]] "-flavor" "gnu" "--no-undefined" "-shared"
 // CHECK-SAME: "-o" "[[IMG_DEV_A_900:.*out]]" [[OBJ_DEV_A_900]]
@@ -92,25 +76,17 @@
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
-// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
-// CHECK-SAME: {{.*}} "-o" 

[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D81627#2088502 , @arsenm wrote:

> In D81627#2088500 , @arsenm wrote:
>
> > It doesn't matter if we don't support isa linking. We should just use clang 
> > and default to -flto. LTO "just works" as is
>
>
> This is a step forward, but the lack of ISA linking shouldn't block 
> eliminating the use of llc/opt


Agree. Will fix -fgpu-rdc in a different patch.


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

https://reviews.llvm.org/D81627



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


[PATCH] D81713: [HIP] Fix rocm not found on rocm3.5

2020-06-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, arsenm.
Herald added subscribers: kerbowa, nhaehnle, wdng, jvesely.

Currently rocm detector expects device library bitcodes named as *.bc
instead of *.amdgcn.bc. However in rocm3.5 the device library bitcodes
are named as *.amdgcn.bc, which causes rocm3.5 not detected.

This patch fixes that. Tested works with rocm3.5.


https://reviews.llvm.org/D81713

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -25,6 +25,7 @@
   assert(!LibDevicePath.empty());
 
   const StringRef Suffix(".bc");
+  const StringRef Suffix2(".amdgcn.bc");
 
   std::error_code EC;
   for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
@@ -34,7 +35,11 @@
 if (!FileName.endswith(Suffix))
   continue;
 
-StringRef BaseName = FileName.drop_back(Suffix.size());
+StringRef BaseName;
+if (FileName.endswith(Suffix2))
+  BaseName = FileName.drop_back(Suffix2.size());
+else if (FileName.endswith(Suffix))
+  BaseName = FileName.drop_back(Suffix.size());
 
 if (BaseName == "ocml") {
   OCML = FilePath;


Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -25,6 +25,7 @@
   assert(!LibDevicePath.empty());
 
   const StringRef Suffix(".bc");
+  const StringRef Suffix2(".amdgcn.bc");
 
   std::error_code EC;
   for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
@@ -34,7 +35,11 @@
 if (!FileName.endswith(Suffix))
   continue;
 
-StringRef BaseName = FileName.drop_back(Suffix.size());
+StringRef BaseName;
+if (FileName.endswith(Suffix2))
+  BaseName = FileName.drop_back(Suffix2.size());
+else if (FileName.endswith(Suffix))
+  BaseName = FileName.drop_back(Suffix.size());
 
 if (BaseName == "ocml") {
   OCML = FilePath;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:824
   std::tie(CalleeTy, Callee, Arg) = DtorsAndObjects[e - i - 1];
-  llvm::CallInst *CI = Builder.CreateCall(CalleeTy, Callee, Arg);
+  llvm::CallInst *CI = (Arg == nullptr)
+   ? Builder.CreateCall(CalleeTy, Callee)

Please assert that `Arg == nullptr` iff we're dealing with sinit/sterm.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1058
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {
+CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(),
+nullptr);

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > The description of `CXXGlobalDtors` is
> > > Global destructor functions and arguments that need to run on termination.
> > 
> Currently, only Apple Kernal extension will use `AddCXXDtorEntry` to add 
> variable destructor to CXXGlobalDtors.
> An example is:
> 
> ```
> $cat test.cpp
> class test {
>int a;
> public:
> test(int c) {a = c;}
> ~test() {a = 0;}
> } t(1);
> 
> 
> $clang --driver-mode=g++ -target x86_64-apple-darwin10 -fapple-kext -flto -S 
> -o - test.cpp
> 
> ...
> define internal void @_GLOBAL__D_a() #0 {
> entry:
>   call void @_ZN4testD1Ev(%class.test* @t)   #~test() {a = 0;}
>   ret void
> }
> ```
> 
> Since the usage as you said below does not match with our sterm finalizer 
> function `__cxx_global_var_destruct`, I am thinking we can either modify the 
> name and the description of `CXXGlobalDtors` to make it also fit AIX or we 
> can define a brand new `CXXStermFinalizers` vector and also related facility 
> to `GenerateCXXStermFinalizerFunc` instead. 
> 
> An example of modification I have in mind is:
> `CXXGlobalDtorsOrStermFinalizers`
> 
> 
> > Global destructor functions and arguments that need to run on termination;
> > When UseSinitAndSterm is set, it contains sterm finalizer functions instead 
> > that need to run on unloading a shared library.
> 
> 
> 
> I would prefer the modification way to save a lot effort. Any thoughts on it?
I'm fine with renaming but it should include renaming the associated fuctions.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4447
+
+  // Create __dtor function for the var decl.
+  llvm::Function *dtorStub = CGF.createAtExitStub(D, dtor, addr);

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > We should probably report_fatal_error if `CXAAtExit` (the option) is true 
> > before this line. This would imply driver changes to default AIX to using 
> > `-fno-use-cxa-atexit`. An associated test file is 
> > https://github.com/llvm/llvm-project/blame/master/clang/test/Driver/cxa-atexit.cpp.
> Maybe we should add `-fno-use-cxa-atexit` to driver in a follow-up patch?
I'm okay with that.


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

https://reviews.llvm.org/D74166



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:5231
+  CXXNameMangler Mangler(*this, Out);
+  Mangler.getStream() << "__cxx_global_var_destruct_";
+  if (shouldMangleDeclName(D))

I believe these are actually paired with the `__dtor_` functions. The prefix 
can be `__finalize_`.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:562
 
+static StringRef getTransformedFileName(llvm::Module , SmallString<128> 
FileName) {
+  FileName = llvm::sys::path::filename(M.getName());

`FileName` should be a reference?



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:643
+  // When not using sinit and sterm functions, include the filename in the
+  // symbol name. Including "sub_" matches gcc and makes sure these symbols
+  // appear lexicographically behind the symbols with priority emitted above.

The binding of the second sentence in relation to "not using sinit and sterm" 
is not clear in this new version. I still recommend introducing a "block" with 
a colon.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:645
+  // appear lexicographically behind the symbols with priority emitted above.
+  StringRef FuncName;
+  SmallString<128> Storage;

Use a `SmallString` for `FuncName`.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:646
+  StringRef FuncName;
+  SmallString<128> Storage;
+  if (UseSinitAndSterm)

Move `Storage` into the `else` block and use it only for calling 
`getTransformedFileName`.


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

https://reviews.llvm.org/D74166



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


[PATCH] D81045: [LLVM] Change isa<> to a variadic function template

2020-06-11 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Do you need someone to land this for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81045



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:293
+CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Function *dtorStub) {
+  // extern "C" int unatexit(void (*f)(void));
+  assert(dtorStub->getFunctionType() ==

Please add a comment explaining the meaning of the zero and non-zero return 
values.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:603
   if (!PrioritizedCXXGlobalInits.empty()) {
+assert(!UseSinitAndSterm && "Prioritized Sinit and Sterm functions are not"
+" supported yet.");

I don't think we should capitalize "sinit" and "sterm" in comments. Indeed, 
there's a comment below where they are not capitalized.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:639
+  if (CXXGlobalInits.empty())
+return;
 

Can this part be committed in a separate patch? It does not appear to have 
dependencies on other parts of this patch and has the appearance of being a 
possible change for other platforms.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:641
 
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
+  // Include the filename in the symbol name. When not using sinit and sterm
+  // functions, including "sub_" matches gcc and makes sure these symbols

The first sentence does not apply unconditionally in the status quo of this 
patch. Perhaps keep the original comment completely with something like:
```
// When not using sinit and sterm functions:
// ...
```



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:682
 void CodeGenModule::EmitCXXGlobalDtorFunc() {
   if (CXXGlobalDtors.empty())
 return;

Following from my previous comments on `CXXGlobalDtors`, I am not convinced 
that `__sterm` functions match the role.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:704
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }

If this is another drive-by fix, can we put it in a separate patch?



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:817
   std::tie(CalleeTy, Callee, Arg) = DtorsAndObjects[e - i - 1];
-  llvm::CallInst *CI = Builder.CreateCall(CalleeTy, Callee, Arg);
+  llvm::CallInst *CI = (Arg == nullptr)
+   ? Builder.CreateCall(CalleeTy, Callee)

This change would not belong in this function if its scope remains the 
generation of a "GlobalDtorsFunc" (based on my understanding of the latter).



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4445
+  if (D.getTLSKind() != VarDecl::TLS_None)
+llvm::report_fatal_error("thread local storage unimplemented on AIX yet");
+

s/unimplemented on AIX yet/not yet implemented on AIX/;



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4467
+
+  // Create a variable destruction function.
+  const CGFunctionInfo  = CGM.getTypes().arrangeNullaryFunction();

Suggestion:
Create the finalization action associated with a variable.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4480
+
+  llvm::Value *NeedsDestruct = CGF.Builder.CreateIsNull(V, "guard.hasDtor");
+

I don't think this is a real "guard variable". I think the comments need to 
explain this (including scare quotes for "guard variable".


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

https://reviews.llvm.org/D74166



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


[PATCH] D80743: (PR46111) Properly handle elaborated types in an implicit deduction guide

2020-06-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1967
+TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
+TypeSourceInfo *TSI = Context.getTrivialTypeSourceInfo(Transformed);
+

rsmith wrote:
> Retaining the location information here would be good too. (You already have 
> that location info in `InnerTLB`.) I think there might even be a convenience 
> `TypeSourceInfo` -> `TypeSourceInfo` transform you can invoke here.
I think I see what you mean, There is a TypeSourceInfo 
*TransformType(TypeSourceInfo*) that I can use to do the transform, PLUS doing 
InnerTLB.getTypeSourceInfo (instead of ASTContext) seems to keep all the 
required info.

I'll do that before I commit this in the morning.

Thanks again!


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

https://reviews.llvm.org/D80743



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


[PATCH] D81707: [PowerPC][Power10] Implement Vector Clear Left/Rightmost Bytes Builtins in LLVM/Clang

2020-06-11 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: saghir, nemanjai, power-llvm-team, PowerPC, hfinkel.
amyk added projects: clang, LLVM, PowerPC.
Herald added subscribers: shchenz, hiraditya.

This patch implements builtins for the following prototypes:

  vector signed char vec_clrl (vector signed char a, unsigned int n);
  vector unsigned char vec_clrl (vector unsigned char a, unsigned int n);
  vector signed char vec_clrr (vector signed char a, unsigned int n);
  vector signed char vec_clrr (vector unsigned char a, unsigned int n);

Depends on D80935 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81707

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-string-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -15,3 +15,9 @@
 # CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
 # CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
 pextd 1, 2, 4
+# CHECK-BE: vclrlb 1, 4, 3# encoding: [0x10,0x24,0x19,0x8d]
+# CHECK-LE: vclrlb 1, 4, 3# encoding: [0x8d,0x19,0x24,0x10]
+vclrlb 1, 4, 3
+# CHECK-BE: vclrrb 1, 4, 3# encoding: [0x10,0x24,0x19,0xcd]
+# CHECK-LE: vclrrb 1, 4, 3# encoding: [0xcd,0x19,0x24,0x10]
+vclrrb 1, 4, 3
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -12,3 +12,9 @@
 
 # CHECK: pextd 1, 2, 4
 0x7c 0x41 0x21 0x78
+
+# CHECK: vclrlb 1, 4, 3
+0x10 0x24 0x19 0x8d
+
+# CHECK: vclrrb 1, 4, 3
+0x10 0x24 0x19 0xcd
Index: llvm/test/CodeGen/PowerPC/p10-string-ops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-string-ops.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aim to test the vector string isolate builtins on Power10.
+
+declare <16 x i8> @llvm.ppc.altivec.vclrlb(<16 x i8>, i32)
+declare <16 x i8> @llvm.ppc.altivec.vclrrb(<16 x i8>, i32)
+
+define <16 x i8> @test_vclrlb(<16 x i8> %a, i32 %n) {
+; CHECK-LABEL: test_vclrlb:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vclrlb v2, v2, r5
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <16 x i8> @llvm.ppc.altivec.vclrlb(<16 x i8> %a, i32 %n)
+  ret <16 x i8> %tmp
+}
+
+define <16 x i8> @test_vclrrb(<16 x i8> %a, i32 %n) {
+; CHECK-LABEL: test_vclrrb:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vclrrb v2, v2, r5
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <16 x i8> @llvm.ppc.altivec.vclrrb(<16 x i8> %a, i32 %n)
+  ret <16 x i8> %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -516,4 +516,12 @@
def PEXTD : XForm_6<31, 188, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
"pextd $rA, $rS, $rB", IIC_IntGeneral,
[(set i64:$rA, (int_ppc_pextd i64:$rS, i64:$rB))]>;
+   def VCLRLB : VXForm_1<397, (outs vrrc:$vD), (ins vrrc:$vA, gprc:$rB),
+ "vclrlb $vD, $vA, $rB", IIC_VecGeneral,
+ [(set v16i8:$vD,
+ (int_ppc_altivec_vclrlb v16i8:$vA, i32:$rB))]>;
+   def VCLRRB : VXForm_1<461, (outs vrrc:$vD), (ins vrrc:$vA, gprc:$rB),
+ "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
+ [(set v16i8:$vD,
+ (int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
 }
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -426,6 +426,14 @@
   def int_ppc_altivec_vpextd : GCCBuiltin<"__builtin_altivec_vpextd">,
   Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
 [IntrNoMem]>;
+
+   // P10 Vector Clear Bytes
+   def int_ppc_altivec_vclrlb :  GCCBuiltin<"__builtin_altivec_vclrlb">,
+   Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty],
+ [IntrNoMem]>;
+   

[PATCH] D81543: [CodeGen][TLS] Set TLS Model for __tls_guard as well.

2020-06-11 Thread JunMa via Phabricator via cfe-commits
junparser added a comment.

kindly ping~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81543



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


[PATCH] D81242: [StackSafety] Run ThinLTO

2020-06-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:618
+ConstantRange Access = Found->sextOrTrunc(Use.Range.getBitWidth());
+if (Access.signedAddMayOverflow(C.Offset) !=
+ConstantRange::OverflowResult::NeverOverflows)

Do we have a test for this overflow check?



Comment at: llvm/lib/Analysis/StackSafetyAnalysis.cpp:924
+  if (FS)
+FS->setParamAccesses({});
+}

Why is this necessary? This affects only !live || !dso_local functions, right? 
The rest is overwritten in the loop below. As I understand, the post-lto 
function analysis ignores such functions, so that's strictly a space saving 
thing. Explain what's going on in a comment, and why removing this access data 
won't cause false positive results.



Comment at: llvm/lib/LTO/LTO.cpp:1396
 
+  processParamAccessSummary(ThinLTO.CombinedIndex);
+

Bad name - "process" is meaningless here. Consider "generateParamAccessSummary" 
?



Comment at: llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll:55
+; RUN:  -r %t.summ1.bc,Write1,px 2>&1 | FileCheck %s 
--check-prefixes=CHECK,GLOBAL,LTO
+
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"

For my education - how do you come up with these symbol lists?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81242



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/include/clang/AST/Mangle.h:178
 
+  virtual void mangleDynamicDestructor(const VarDecl *D, raw_ostream ) = 0;
+

hubert.reinterpretcast wrote:
> I am not sure "destructor" is the right term here. This seems to be an 
> analogue to the functions named using `mangleDynamicAtExitDestructor`, except 
> that those rather directly perform destruction and are registered with 
> `atexit` during initialization whereas these perform finalization and are 
> "registered" by being called from an "sterm" function. What are the thoughts 
> on `mangleDynamicStermFinalizer`?
`mangleDynamicDestructor` is an analogue to `mangleDynamicInitializer` actually.

From this perspective, I think `mangleDynamicStermFinalizer` is good.



Comment at: clang/lib/CodeGen/CodeGenModule.h:1058
+  void AddCXXDtorEntry(llvm::FunctionCallee DtorFn) {
+CXXGlobalDtors.emplace_back(DtorFn.getFunctionType(), DtorFn.getCallee(),
+nullptr);

hubert.reinterpretcast wrote:
> The description of `CXXGlobalDtors` is
> > Global destructor functions and arguments that need to run on termination.
> 
Currently, only Apple Kernal extension will use `AddCXXDtorEntry` to add 
variable destructor to CXXGlobalDtors.
An example is:

```
$cat test.cpp
class test {
   int a;
public:
test(int c) {a = c;}
~test() {a = 0;}
} t(1);


$clang --driver-mode=g++ -target x86_64-apple-darwin10 -fapple-kext -flto -S -o 
- test.cpp

...
define internal void @_GLOBAL__D_a() #0 {
entry:
  call void @_ZN4testD1Ev(%class.test* @t)   #~test() {a = 0;}
  ret void
}
```

Since the usage as you said below does not match with our sterm finalizer 
function `__cxx_global_var_destruct`, I am thinking we can either modify the 
name and the description of `CXXGlobalDtors` to make it also fit AIX or we can 
define a brand new `CXXStermFinalizers` vector and also related facility to 
`GenerateCXXStermFinalizerFunc` instead. 

An example of modification I have in mind is:
`CXXGlobalDtorsOrStermFinalizers`


> Global destructor functions and arguments that need to run on termination;
> When UseSinitAndSterm is set, it contains sterm finalizer functions instead 
> that need to run on unloading a shared library.



I would prefer the modification way to save a lot effort. Any thoughts on it?



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:4447
+
+  // Create __dtor function for the var decl.
+  llvm::Function *dtorStub = CGF.createAtExitStub(D, dtor, addr);

hubert.reinterpretcast wrote:
> We should probably report_fatal_error if `CXAAtExit` (the option) is true 
> before this line. This would imply driver changes to default AIX to using 
> `-fno-use-cxa-atexit`. An associated test file is 
> https://github.com/llvm/llvm-project/blame/master/clang/test/Driver/cxa-atexit.cpp.
Maybe we should add `-fno-use-cxa-atexit` to driver in a follow-up patch?



Comment at: clang/test/CodeGen/static-init.cpp:15
+
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry:

jasonliu wrote:
> #0 could be removed.
Why I chose to keep this `#0` is because to remove it, we would either remove 
the following `{` which I kinda feel makes the function look not nice or we 
need to match `#0` with regex which I think is redundant. 


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

https://reviews.llvm.org/D74166



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


[PATCH] D81703: [Clang] Don't leave Expr::Classification fields uninitialized in default constructor

2020-06-11 Thread Gui Andrade via Phabricator via cfe-commits
guiand created this revision.
guiand added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
guiand edited the summary of this revision.

This changes `Expr::Classification::{Kind, Modifiable}` fields so that they are 
initialized as `Unknown` rather than left uninitialized. This way, if the 
default `Classification` is accidentally used, Clang will fire an assertion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81703

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ExprClassification.cpp


Index: clang/lib/AST/ExprClassification.cpp
===
--- clang/lib/AST/ExprClassification.cpp
+++ clang/lib/AST/ExprClassification.cpp
@@ -65,6 +65,8 @@
   case Cl::CL_ArrayTemporary:
   case Cl::CL_ObjCMessageRValue:
   case Cl::CL_PRValue: assert(getValueKind() == VK_RValue); break;
+  case Cl::CL_Unknown:
+llvm_unreachable("Tried to classify unknown class!");
   }
 
   Cl::ModifiableType modifiable = Cl::CM_Untested;
@@ -678,6 +680,7 @@
   case Cl::CL_ArrayTemporary: return LV_ArrayTemporary;
   case Cl::CL_ObjCMessageRValue: return LV_InvalidMessageExpression;
   case Cl::CL_PRValue: return LV_InvalidExpression;
+  case Cl::CL_Unknown: break;
   }
   llvm_unreachable("Unhandled kind");
 }
@@ -701,6 +704,7 @@
   case Cl::CL_PRValue:
 return VC.getModifiable() == Cl::CM_LValueCast ?
   MLV_LValueCast : MLV_InvalidExpression;
+  case Cl::CL_Unknown: break;
   }
   assert(VC.getKind() == Cl::CL_LValue && "Unhandled kind");
   switch (VC.getModifiable()) {
@@ -716,6 +720,7 @@
   case Cl::CM_ConstAddrSpace: return MLV_ConstAddrSpace;
   case Cl::CM_ArrayType: return MLV_ArrayType;
   case Cl::CM_IncompleteType: return MLV_IncompleteType;
+  case Cl::CM_Unknown: break;
   }
   llvm_unreachable("Unhandled modifiable type");
 }
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -326,7 +326,8 @@
   CL_ClassTemporary, // A temporary of class type, or subobject thereof.
   CL_ArrayTemporary, // A temporary of array type.
   CL_ObjCMessageRValue, // ObjC message is an rvalue
-  CL_PRValue // A prvalue for any other reason, of any other type
+  CL_PRValue, // A prvalue for any other reason, of any other type
+  CL_Unknown // Null enumeration
 };
 /// The results of modification testing.
 enum ModifiableType {
@@ -340,14 +341,15 @@
   CM_ConstQualifiedField,
   CM_ConstAddrSpace,
   CM_ArrayType,
-  CM_IncompleteType
+  CM_IncompleteType,
+  CM_Unknown // Null enumeration
 };
 
   private:
 friend class Expr;
 
-unsigned short Kind;
-unsigned short Modifiable;
+unsigned short Kind = CL_Unknown;
+unsigned short Modifiable = CM_Unknown;
 
 explicit Classification(Kinds k, ModifiableType m)
   : Kind(k), Modifiable(m)


Index: clang/lib/AST/ExprClassification.cpp
===
--- clang/lib/AST/ExprClassification.cpp
+++ clang/lib/AST/ExprClassification.cpp
@@ -65,6 +65,8 @@
   case Cl::CL_ArrayTemporary:
   case Cl::CL_ObjCMessageRValue:
   case Cl::CL_PRValue: assert(getValueKind() == VK_RValue); break;
+  case Cl::CL_Unknown:
+llvm_unreachable("Tried to classify unknown class!");
   }
 
   Cl::ModifiableType modifiable = Cl::CM_Untested;
@@ -678,6 +680,7 @@
   case Cl::CL_ArrayTemporary: return LV_ArrayTemporary;
   case Cl::CL_ObjCMessageRValue: return LV_InvalidMessageExpression;
   case Cl::CL_PRValue: return LV_InvalidExpression;
+  case Cl::CL_Unknown: break;
   }
   llvm_unreachable("Unhandled kind");
 }
@@ -701,6 +704,7 @@
   case Cl::CL_PRValue:
 return VC.getModifiable() == Cl::CM_LValueCast ?
   MLV_LValueCast : MLV_InvalidExpression;
+  case Cl::CL_Unknown: break;
   }
   assert(VC.getKind() == Cl::CL_LValue && "Unhandled kind");
   switch (VC.getModifiable()) {
@@ -716,6 +720,7 @@
   case Cl::CM_ConstAddrSpace: return MLV_ConstAddrSpace;
   case Cl::CM_ArrayType: return MLV_ArrayType;
   case Cl::CM_IncompleteType: return MLV_IncompleteType;
+  case Cl::CM_Unknown: break;
   }
   llvm_unreachable("Unhandled modifiable type");
 }
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -326,7 +326,8 @@
   CL_ClassTemporary, // A temporary of class type, or subobject thereof.
   CL_ArrayTemporary, // A temporary of array type.
   CL_ObjCMessageRValue, // ObjC message is an rvalue
-  CL_PRValue // A prvalue for any other reason, of any other type
+  CL_PRValue, // A prvalue for any other reason, of any other type
+  CL_Unknown // Null enumeration
 };
 /// The results of modification testing.
 enum ModifiableType {
@@ -340,14 +341,15 @@
   

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 270267.
Xiangling_L marked 21 inline comments as done.
Xiangling_L added a comment.

Address another round of reviews;


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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp

Index: clang/test/CodeGen/static-init.cpp
===
--- clang/test/CodeGen/static-init.cpp
+++ clang/test/CodeGen/static-init.cpp
@@ -1,12 +1,87 @@
-// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck %s
 
-// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ %s \
-// RUN: -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit < %s | \
+// RUN:   FileCheck %s
 
 struct test {
   test();
   ~test();
-} t;
+} t1, t2;
 
-// CHECK: error in backend: Static initialization has not been implemented on XL ABI yet.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_66d40ba2f9a26b497582a82a8a262181, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_66d40ba2f9a26b497582a82a8a262181, i8* null }]
+
+// CHECK: define internal void @__cxx_global_var_init() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t1)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t1)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor_t1() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t1)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_destruct_t1() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t1)
+// CHECK:   %guard.needsDestruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.needsDestruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor_t1()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*) #3
+
+// CHECK: define internal void @__cxx_global_var_init.1() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testC1Ev(%struct.test* @t2)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor_t2)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor_t2() #0 {
+// CHECK: entry:
+// CHECK:   call void @_ZN4testD1Ev(%struct.test* @t2)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_destruct_t2() #0 {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor_t2)
+// CHECK:   %guard.needsDestruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %guard.needsDestruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor_t2()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:  ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sinit8000_clang_66d40ba2f9a26b497582a82a8a262181() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_init()
+// CHECK:   call void @__cxx_global_var_init.1()
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define dso_local void @__sterm8000_clang_66d40ba2f9a26b497582a82a8a262181() #0 {
+// CHECK: entry:
+// CHECK:   call void @__cxx_global_var_destruct_t2()
+// CHECK:   call void @__cxx_global_var_destruct_t1()
+// CHECK:   ret void
+// CHECK: }
Index: clang/test/CodeGen/aix-init-priority-attribute.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-init-priority-attribute.cpp
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -x c++ -emit-llvm < %s \
+// RUN: 2>&1 | FileCheck %s
+
+class test {
+  int a;
+
+public:
+  test(int c) { a = c; }
+  ~test() { a = 0; }
+};
+
+__attribute__((init_priority(2000)))
+test t(1);
+
+// CHECK: fatal error: error in backend: 'init_priority' attribute unsupported on AIX yet
Index: 

[PATCH] D80743: (PR46111) Properly handle elaborated types in an implicit deduction guide

2020-06-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1967
+TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
+TypeSourceInfo *TSI = Context.getTrivialTypeSourceInfo(Transformed);
+

Retaining the location information here would be good too. (You already have 
that location info in `InnerTLB`.) I think there might even be a convenience 
`TypeSourceInfo` -> `TypeSourceInfo` transform you can invoke here.


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

https://reviews.llvm.org/D80743



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


[PATCH] D80977: Diagnose cases where the name of a class member is used within a class definition before the member name is declared.

2020-06-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'm not entirely happy with this approach; there are lots of places where we 
perform lookups that are incidental and shouldn't result in an error if we end 
up looking outside the class, and I'm not sure I've marked them all as 
"synthetic". That said, I've tested this over a fairly substantial amount of 
code and all the issues it reported were true positives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80977



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


[PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally

2020-06-11 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added a comment.

this patch has lasted for a couple of months.  a bug in this area is hard and 
time-consuming to diagnose. 
it's better to get this fix in sooner than later. could someone review and 
approve it?
thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77982



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


[PATCH] D81624: [CodeGen] Simplify the way lifetime of block captures is extended

2020-06-11 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc9a52de00260: [CodeGen] Simplify the way lifetime of block 
captures is extended (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81624

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBlocks.h
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/test/CodeGenCXX/blocks-cxx11.cpp
  clang/test/CodeGenCXX/blocks.cpp
  clang/test/CodeGenObjC/arc-blocks.m
  clang/test/CodeGenObjC/arc-foreach.m
  clang/test/CodeGenObjC/noescape.m
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -95,7 +95,7 @@
   // COMMON: [[WAIT_EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %event_wait_list to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: [[EVNT:%[0-9]+]] = addrspacecast %opencl.clk_event_t{{.*}}** %clk_event to %opencl.clk_event_t{{.*}}* addrspace(4)*
   // COMMON: store i8 addrspace(4)* addrspacecast (i8* bitcast (void (i8 addrspace(4)*)* [[INVL2:@__device_side_enqueue_block_invoke[^ ]*]] to i8*) to i8 addrspace(4)*), i8 addrspace(4)** %block.invoke
-  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to %struct.__opencl_block_literal_generic*
+  // COMMON: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block4 to %struct.__opencl_block_literal_generic*
   // COMMON: [[BL_I8:%[0-9]+]] = addrspacecast %struct.__opencl_block_literal_generic* [[BL]] to i8 addrspace(4)*
   // COMMON-LABEL: call i32 @__enqueue_kernel_basic_events
   // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]],  %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]],
Index: clang/test/CodeGenObjC/noescape.m
===
--- clang/test/CodeGenObjC/noescape.m
+++ clang/test/CodeGenObjC/noescape.m
@@ -95,7 +95,6 @@
 // CHECK-NOARC: store i8* %[[B]], i8** %[[B_ADDR]], align 8
 // CHECK-ARC: store i8* null, i8** %[[B_ADDR]], align 8
 // CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[B_ADDR]], i8* %[[B]])
-// CHECK-ARC: %[[V0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 5
 // CHECK: %[[BLOCK_ISA:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 0
 // CHECK: store i8* bitcast (i8** @_NSConcreteGlobalBlock to i8*), i8** %[[BLOCK_ISA]], align 8
 // CHECK: %[[BLOCK_FLAGS:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]], i32 0, i32 1
@@ -109,7 +108,7 @@
 // CHECK-ARC: %[[V3:.*]] = call i8* @llvm.objc.retain(i8* %[[V2]])
 // CHECK-ARC: store i8* %[[V3]], i8** %[[BLOCK_CAPTURED]], align 8
 // CHECK: call void @noescapeFunc0(
-// CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null)
+// CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[BLOCK_CAPTURED]], i8* null)
 // CHECK-ARC: call void @llvm.objc.storeStrong(i8** %[[B_ADDR]], i8* null)
 
 // Non-escaping blocks don't need copy/dispose helper functions.
Index: clang/test/CodeGenObjC/arc-foreach.m
===
--- clang/test/CodeGenObjC/arc-foreach.m
+++ clang/test/CodeGenObjC/arc-foreach.m
@@ -65,14 +65,13 @@
 // CHECK-LP64-NEXT: [[T3:%.*]] = load i8*, i8** [[T2]]
 // CHECK-LP64-NEXT: store i8* [[T3]], i8** [[X]]
 
-// CHECK-LP64:  [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
-// CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64:  [[CAPTURED:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
 // CHECK-LP64-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
 // CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retain(i8* [[T1]])
-// CHECK-LP64-NEXT: store i8* [[T2]], i8** [[T0]]
+// CHECK-LP64-NEXT: store i8* 

[PATCH] D81691: [clangd] Set CWD in semaCodeComplete

2020-06-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

A slightly tangential thing - we recently got an internal bugreport about 
clangd handling combination of working directory and relative paths for 
`-fmodules-cache-path` combination in compile_command.json incorrectly.
I tried some quick hacks but failed - it seems that ultimately the limiting 
factor is  the code in clang dealing with modules not using VFS. It's on our 
list of things to fix although we don't have a timeframe for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81691



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


[clang] c9a52de - [CodeGen] Simplify the way lifetime of block captures is extended

2020-06-11 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-06-11T16:06:22-07:00
New Revision: c9a52de0026093327daedda7ea2eead8b64657b4

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

LOG: [CodeGen] Simplify the way lifetime of block captures is extended

Rather than pushing inactive cleanups for the block captures at the
entry of a full expression and activating them during the creation of
the block literal, just call pushLifetimeExtendedDestroy to ensure the
cleanups are popped at the end of the scope enclosing the block
expression.

rdar://problem/63996471

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

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGBlocks.h
clang/lib/CodeGen/CGCleanup.cpp
clang/lib/CodeGen/CGCleanup.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/EHScopeStack.h
clang/test/CodeGenCXX/blocks-cxx11.cpp
clang/test/CodeGenCXX/blocks.cpp
clang/test/CodeGenObjC/arc-blocks.m
clang/test/CodeGenObjC/arc-foreach.m
clang/test/CodeGenObjC/noescape.m
clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 9097e51e9c00..615b78235041 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -36,7 +36,7 @@ CGBlockInfo::CGBlockInfo(const BlockDecl *block, StringRef 
name)
   : Name(name), CXXThisIndex(0), CanBeGlobal(false), NeedsCopyDispose(false),
 HasCXXObject(false), UsesStret(false), HasCapturedVariableLayout(false),
 CapturesNonExternalType(false), LocalAddress(Address::invalid()),
-StructureType(nullptr), Block(block), DominatingIP(nullptr) {
+StructureType(nullptr), Block(block) {
 
   // Skip asm prefix, if any.  'name' is usually taken directly from
   // the mangled name of the enclosing function.
@@ -775,151 +775,23 @@ static void computeBlockInfo(CodeGenModule , 
CodeGenFunction *CGF,
 llvm::StructType::get(CGM.getLLVMContext(), elementTypes, true);
 }
 
-/// Enter the scope of a block.  This should be run at the entrance to
-/// a full-expression so that the block's cleanups are pushed at the
-/// right place in the stack.
-static void enterBlockScope(CodeGenFunction , BlockDecl *block) {
-  assert(CGF.HaveInsertPoint());
-
-  // Allocate the block info and place it at the head of the list.
-  CGBlockInfo  =
-*new CGBlockInfo(block, CGF.CurFn->getName());
-  blockInfo.NextBlockInfo = CGF.FirstBlockInfo;
-  CGF.FirstBlockInfo = 
-
-  // Compute information about the layout, etc., of this block,
-  // pushing cleanups as necessary.
-  computeBlockInfo(CGF.CGM, , blockInfo);
-
-  // Nothing else to do if it can be global.
-  if (blockInfo.CanBeGlobal) return;
-
-  // Make the allocation for the block.
-  blockInfo.LocalAddress = CGF.CreateTempAlloca(blockInfo.StructureType,
-blockInfo.BlockAlign, "block");
-
-  // If there are cleanups to emit, enter them (but inactive).
-  if (!blockInfo.NeedsCopyDispose) return;
-
-  // Walk through the captures (in order) and find the ones not
-  // captured by constant.
-  for (const auto  : block->captures()) {
-// Ignore __block captures; there's nothing special in the
-// on-stack block that we need to do for them.
-if (CI.isByRef()) continue;
-
-// Ignore variables that are constant-captured.
-const VarDecl *variable = CI.getVariable();
-CGBlockInfo::Capture  = blockInfo.getCapture(variable);
-if (capture.isConstant()) continue;
-
-// Ignore objects that aren't destructed.
-QualType VT = getCaptureFieldType(CGF, CI);
-QualType::DestructionKind dtorKind = VT.isDestructedType();
-if (dtorKind == QualType::DK_none) continue;
-
-CodeGenFunction::Destroyer *destroyer;
-
-// Block captures count as local values and have imprecise semantics.
-// They also can't be arrays, so need to worry about that.
-//
-// For const-qualified captures, emit clang.arc.use to ensure the captured
-// object doesn't get released while we are still depending on its validity
-// within the block.
-if (VT.isConstQualified() &&
-VT.getObjCLifetime() == Qualifiers::OCL_Strong &&
-CGF.CGM.getCodeGenOpts().OptimizationLevel != 0) {
-  assert(CGF.CGM.getLangOpts().ObjCAutoRefCount &&
- "expected ObjC ARC to be enabled");
-  destroyer = CodeGenFunction::emitARCIntrinsicUse;

[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3537
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType,
-AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 1) {

aaron.ballman wrote:
> njames93 wrote:
> > jkorous wrote:
> > > aaron.ballman wrote:
> > > > njames93 wrote:
> > > > > aaron.ballman wrote:
> > > > > > This is undoing a change that was just added less than two weeks 
> > > > > > ago, so I think the potential for breaking code is small. That 
> > > > > > said, can you explain why you think `hasClass` is a better approach 
> > > > > > than `hasType`?
> > > > > Yeah, as that change hasn't reached landed onto a release branch 
> > > > > breaking code shouldn't be an issue, If it was I'd leave it in.
> > > > > 
> > > > > - `hasType` is very generic, whereas `hasClass` is specific to what a 
> > > > > `CXXBaseSpecifier` supports.
> > > > > - It makes the matchers marginally simpler.
> > > > >   `hasDirectBase(hasType(cxxRecordDecl(hasName("Base"` vs 
> > > > > `hasDirectBase(hasClass(hasName("Base")))`
> > > > > - In the documentation it also specifies that `hasClass` takes a 
> > > > > `Matcher, making it more user friendly.
> > > > FWIW, I prefer `hasType` to `hasClass`. You can inherit from things 
> > > > which are not a class, such as a struct (so the name is a bit of a 
> > > > misnomer, but not too awful), a class template (which you can't match 
> > > > with this interface), or a template type (which you also can't match 
> > > > with this interface).
> > > I don't feel super strongly about this but I also slightly prefer 
> > > `hasType`.
> > > 
> > > To be fair - I didn't really have things like inheritance from template 
> > > parameters on my mind when working on `hasAnyBase` (it's definitely not 
> > > tested) so I'd rather not assume it works.
> > I have decided to put `hasType` back in there as it does have some general 
> > uses. However I have added more class and class template specific matchers 
> > as I feel these are slightly more user friendly. 
> > 
> > LMK what you think of this approach.
> > 
> > Side note what is the correct collective term for classes and structs. I'd 
> > be tempted to refer to them how clang does, records, but `hasRecord` seems 
> > wrong.
> > Side note what is the correct collective term for classes and structs. I'd 
> > be tempted to refer to them how clang does, records, but hasRecord seems 
> > wrong.
> 
> We use the term "record", but I'm not certain how widely used that is.
https://en.cppreference.com/w/cpp/language/class - Going of what that says, it 
states that a class declaration starts with a keyword either `class` or 
`struct`. Nowhere on the page does it mention `record`.
Continuing on from this point, we have many more matchers with `class` in the 
name but work on structs too:
`ofClass`, `hasInClassInitializer` and `injectedClassNameType`. If you're being 
pedantic there is also `classTemplateDecl`, 
`classTemplatePartialSpecializationDecl` and `classTemplateSpecializationDecl`.

Having said all of that I'm still not a huge fan of `hasClass`, but I'm less of 
a fan of `hasType`. I'd thought of `forClass` but that could be misinterpreted 
as the derived class of the `CXXBaseSpecifier` Kind of like the behaviour of 
`forFunction`.
```
class Base {};
class Derived : Base {};
```
Does `cxxBaseSpecifier(forClass(cxxRecordDecl().bind("X")) bind to `Derived` or 
`Base`?



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

jkorous wrote:
> aaron.ballman wrote:
> > jkorous wrote:
> > > Nit: while "[base specifier] `hasType`" sounds natural to me for some 
> > > reason `hasClass` doesn't. English is not my first language though.
> > I agree that `hasClass` seems unnatural here. Out of curiosity, could we 
> > modify the `hasName` matcher to work on base specifiers so you can write: 
> > `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more 
> > wordy version 
> > `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?
> Wouldn't it be strange to treat `hasName` differently than all the other 
> narrowing matchers? Honest question - I feel that `hasName` might be the most 
> commonly used, just don't know if that's enough to justify this.
> https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers
Repurposing `hasName` would be a pain especially considering 99% of its use 
cases wont be for base class matching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552




[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> But it does mess with the ABI; that's why it's being added.

My worry is, that we do not clearly sate it does. I'm worried front-ends will 
use it to attach types to pointers once pointers do not have types anymore. 
I'll stop arguing on this one now, if you think this is restrictive enough, 
feel free to go ahead :)


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

https://reviews.llvm.org/D81311



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


[PATCH] D80462: Fix floating point math function attributes definition.

2020-06-11 Thread John McCall via Phabricator via cfe-commits
rjmccall closed this revision.
rjmccall added a comment.

To ssh://github.com/llvm/llvm-project

  a98d618f6e5f..7fac1acc6171  master -> master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80462



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D81311#2088568 , @jdoerfert wrote:

> In D81311#2088075 , @rjmccall wrote:
>
> > In D81311#2087592 , @jdoerfert 
> > wrote:
> >
> > > In D81311#2086326 , @rjmccall 
> > > wrote:
> > >
> > > > In D81311#2086227 , @jdoerfert 
> > > > wrote:
> > > >
> > > > > Do we allow `inmem` to be used for other purposes? I would assume the 
> > > > > answer is yes, as we do not forbid it.
> > > >
> > > >
> > > > I don't know what else we might use it for off-hand, but yes, I think 
> > > > the frontend could put this down on all value arguments that are 
> > > > actually passed indirectly.
> > >
> > >
> > > Where does it say it is limited to indirectly passed arguments?
> >
> >
> > The argument does have to be a pointer.  And passes aren't allowed to infer 
> > this or it becomes useless for the original purpose.
>
>
> That is what I'm trying to get at. As of right now, I don't see any reason a 
> pass could not add this, or a front-end for that matter, for any call, 
> assuming they now it won't mess with the ABI for the target. We might want to 
> add language to this end?


But it does mess with the ABI; that's why it's being added.  All its 
optimization properties are redundant with existing attributes, and those 
attributes can't be used for Matt's purposes because he's rightly worried about 
them being inferred by passes.  This attribute specifically provides the extra 
information that this is semantically a value parameter being passed by 
reference, which can only be added by a frontend that has that information, 
which an ordinary LLVM pass cannot possibly have.


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

https://reviews.llvm.org/D81311



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81311#2088568 , @jdoerfert wrote:

> In D81311#2088075 , @rjmccall wrote:
>
> > In D81311#2087592 , @jdoerfert 
> > wrote:
> >
> > > In D81311#2086326 , @rjmccall 
> > > wrote:
> > >
> > > > In D81311#2086227 , @jdoerfert 
> > > > wrote:
> > > >
> > > > > Do we allow `inmem` to be used for other purposes? I would assume the 
> > > > > answer is yes, as we do not forbid it.
> > > >
> > > >
> > > > I don't know what else we might use it for off-hand, but yes, I think 
> > > > the frontend could put this down on all value arguments that are 
> > > > actually passed indirectly.
> > >
> > >
> > > Where does it say it is limited to indirectly passed arguments?
> >
> >
> > The argument does have to be a pointer.  And passes aren't allowed to infer 
> > this or it becomes useless for the original purpose.
>
>
> That is what I'm trying to get at. As of right now, I don't see any reason a 
> pass could not add this, or a front-end for that matter, for any call, 
> assuming they now it won't mess with the ABI for the target. We might want to 
> add language to this end?


But why would you want to add it? The intent is to express the ABI


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

https://reviews.llvm.org/D81311



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


[clang] 7fac1ac - Set the LLVM FP optimization flags conservatively.

2020-06-11 Thread John McCall via cfe-commits

Author: John McCall
Date: 2020-06-11T18:16:41-04:00
New Revision: 7fac1acc617113b7a3276ee0f0664bedca978292

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

LOG: Set the LLVM FP optimization flags conservatively.

Functions can have local pragmas that override the global settings.
We set the flags eagerly based on global settings, but if we emit
an expression under the influence of a pragma, we clear the
appropriate flags from the function.

In order to avoid doing a ton of redundant work whenever we emit
an FP expression, configure the IRBuilder to default to global
settings, and only reconfigure it when we see an FP expression
that's not using the global settings.

Patch by Michele Scandale!

https://reviews.llvm.org/D80462

Added: 
clang/test/CodeGen/fp-function-attrs.cpp

Modified: 
clang/include/clang/Basic/LangOptions.h
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index ef56a78b7d48..7b92a8964862 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -529,6 +529,13 @@ class FPOptions {
   unsigned approx_func : 1;
 };
 
+inline bool operator==(FPOptions LHS, FPOptions RHS) {
+  return LHS.getAsOpaqueInt() == RHS.getAsOpaqueInt();
+}
+inline bool operator!=(FPOptions LHS, FPOptions RHS) {
+  return LHS.getAsOpaqueInt() != RHS.getAsOpaqueInt();
+}
+
 /// Describes the kind of translation unit being processed.
 enum TranslationUnitKind {
   /// The translation unit is a complete translation unit.

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index b2bc38b329ef..83614b031543 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -215,23 +215,6 @@ static bool CanElideOverflowCheck(const ASTContext , 
const BinOpInfo ) {
  (2 * Ctx.getTypeSize(RHSTy)) < PromotedSize;
 }
 
-static void setBuilderFlagsFromFPFeatures(CGBuilderTy ,
-  CodeGenFunction ,
-  FPOptions FPFeatures) {
-  auto NewRoundingBehavior = FPFeatures.getRoundingMode();
-  Builder.setDefaultConstrainedRounding(NewRoundingBehavior);
-  auto NewExceptionBehavior =
-  ToConstrainedExceptMD(FPFeatures.getExceptionMode());
-  Builder.setDefaultConstrainedExcept(NewExceptionBehavior);
-  CGF.SetFastMathFlags(FPFeatures);
-  assert((CGF.CurFuncDecl == nullptr || Builder.getIsFPConstrained() ||
-  isa(CGF.CurFuncDecl) ||
-  isa(CGF.CurFuncDecl) ||
-  (NewExceptionBehavior == llvm::fp::ebIgnore &&
-   NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
- "FPConstrained should be enabled on entire function");
-}
-
 class ScalarExprEmitter
   : public StmtVisitor {
   CodeGenFunction 
@@ -764,8 +747,7 @@ class ScalarExprEmitter
 
 if (Ops.LHS->getType()->isFPOrFPVectorTy()) {
   //  Preserve the old values
-  llvm::IRBuilder<>::FastMathFlagGuard FMFG(Builder);
-  setBuilderFlagsFromFPFeatures(Builder, CGF, Ops.FPFeatures);
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures);
   return Builder.CreateFMul(Ops.LHS, Ops.RHS, "mul");
 }
 if (Ops.isFixedPointOp())
@@ -2769,9 +2751,8 @@ Value *ScalarExprEmitter::VisitUnaryLNot(const 
UnaryOperator *E) {
 Value *Zero = llvm::Constant::getNullValue(Oper->getType());
 Value *Result;
 if (Oper->getType()->isFPOrFPVectorTy()) {
-  llvm::IRBuilder<>::FastMathFlagGuard FMFG(Builder);
-  setBuilderFlagsFromFPFeatures(Builder, CGF,
-E->getFPFeatures(CGF.getLangOpts()));
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(
+  CGF, E->getFPFeatures(CGF.getLangOpts()));
   Result = Builder.CreateFCmp(llvm::CmpInst::FCMP_OEQ, Oper, Zero, "cmp");
 } else
   Result = Builder.CreateICmp(llvm::CmpInst::ICMP_EQ, Oper, Zero, "cmp");
@@ -3183,8 +3164,7 @@ Value *ScalarExprEmitter::EmitDiv(const BinOpInfo ) {
 
   if (Ops.LHS->getType()->isFPOrFPVectorTy()) {
 llvm::Value *Val;
-llvm::IRBuilder<>::FastMathFlagGuard FMFG(Builder);
-setBuilderFlagsFromFPFeatures(Builder, CGF, Ops.FPFeatures);
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures);
 Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
 if (CGF.getLangOpts().OpenCL &&
 !CGF.CGM.getCodeGenOpts().CorrectlyRoundedDivSqrt) {
@@ -3562,8 +3542,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo ) {
 return EmitOverflowCheckedBinOp(op);
 
   if (op.LHS->getType()->isFPOrFPVectorTy()) {
-llvm::IRBuilder<>::FastMathFlagGuard 

[PATCH] D81691: [clangd] Set CWD in semaCodeComplete

2020-06-11 Thread Kadir Cetinkaya 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 rGf44d2424f8d7: [clangd] Set CWD in semaCodeComplete (authored 
by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81691

Files:
  clang-tools-extra/clangd/CodeComplete.cpp


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ?  : 
nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ?  : nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81608: Fix incorrect call to ExprResult::get()

2020-06-11 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG385e5f7e147f: Fix incorrect call to ExprResult::get() 
(authored by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81608

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@
   // to function type.
   if (Ty->isFunctionType()) {
 Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-CK_FunctionToPointerDecay).get();
+CK_FunctionToPointerDecay);
 if (Res.isInvalid())
   return ExprError();
   }


Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@
   // to function type.
   if (Ty->isFunctionType()) {
 Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-CK_FunctionToPointerDecay).get();
+CK_FunctionToPointerDecay);
 if (Res.isInvalid())
   return ExprError();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-11 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:305
+  if (llvm::Function *unatexitFn =
+  dyn_cast(unatexit.getCallee()))
+unatexitFn->setDoesNotThrow();

Xiangling_L wrote:
> jasonliu wrote:
> > Is there a valid case that unatexit.getCallee() returns a type which could 
> > not be cast to llvm::Function?
> > i.e. Could we use cast instead of dyn_cast?
> I used `cast` instead of `dyn_cast` before Diff 9 actually, and then I 
> noticed that `clang-tidy` gave error and asked me to use `dyn_cast` instead. 
> Cannot recall what the error says though...
If we expect `cast` to be okay, then we should use it without the `if`.

In Diff 8, an `if` is used with `cast` (thus a `clang-tidy` error make sense):
```
  if (llvm::Function *unatexitFn = cast(unatexit.getCallee()))
```



Repository:
  rL LLVM

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

https://reviews.llvm.org/D74166



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


[PATCH] D81244: [StackSafety] Control paramer access summary from frontend

2020-06-11 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

I like this in principle. Makes a lot more sense to control this directly from 
clang than to rely on function attributes.




Comment at: llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp:31
+   EmitModuleHash);
+  }
   return PreservedAnalyses::all();

What does this chunk do?



Comment at: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp:456
+function_ref AARGetter, Module ,
+function_ref IndexGetter,
+function_ref SSIGetter) {

Why do you need to turn ModuleSummaryIndex into a getter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81244



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D81311#2088075 , @rjmccall wrote:

> In D81311#2087592 , @jdoerfert wrote:
>
> > In D81311#2086326 , @rjmccall 
> > wrote:
> >
> > > In D81311#2086227 , @jdoerfert 
> > > wrote:
> > >
> > > > Do we allow `inmem` to be used for other purposes? I would assume the 
> > > > answer is yes, as we do not forbid it.
> > >
> > >
> > > I don't know what else we might use it for off-hand, but yes, I think the 
> > > frontend could put this down on all value arguments that are actually 
> > > passed indirectly.
> >
> >
> > Where does it say it is limited to indirectly passed arguments?
>
>
> The argument does have to be a pointer.  And passes aren't allowed to infer 
> this or it becomes useless for the original purpose.


That is what I'm trying to get at. As of right now, I don't see any reason a 
pass could not add this, or a front-end for that matter, for any call, assuming 
they now it won't mess with the ABI for the target. We might want to add 
language to this end?


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

https://reviews.llvm.org/D81311



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


[PATCH] D81031: [OpenMP] Add Additional Function Attribute Information to OMPKinds.def

2020-06-11 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 270239.
jhuber6 added a comment.
Herald added subscribers: cfe-commits, aaron.ballman.
Herald added a project: clang.

Adding parameter and return attributes for pointers. There are some arguments I 
wasn't sure how they should be classified, like if every argument should be 
`NoCapture` because the lifetime of the memory isn't visible to the caller. For 
returned void pointers I assumed that they were aligned by eight in cases I 
found that the return value was a pointer to an OpenMP Runtime struct, 
otherwise I set it to one. I might need to double check some of the attributes 
to make sure they make sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81031

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

Index: llvm/test/Transforms/OpenMP/add_attributes.ll
===
--- llvm/test/Transforms/OpenMP/add_attributes.ll
+++ llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -663,6 +663,8 @@
 
 declare void @__kmpc_proxy_task_completed_ooo(i8*)
 
+declare i32 @__kmpc_omp_reg_task_with_affinity(%struct.ident_t*, i32, i8*, i32, i8*)
+
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local void @omp_set_num_threads(i32)
 
@@ -888,370 +890,373 @@
 ; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare dso_local i32 @omp_get_supported_active_levels() #0
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare void @__kmpc_barrier(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: Function Attrs: nounwind
 ; CHECK-NEXT: declare i32 @__kmpc_cancel(%struct.ident_t*, i32, i32)
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_cancel_barrier(%struct.ident_t*, i32)
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare void @__kmpc_flush(%struct.ident_t*)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-Next: declare void @__kmpc_flush(%struct.ident_t*)
 
-; CHECK: Function Attrs: nounwind
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
 
-; CHECK: Function Attrs: nounwind
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
 
-; CHECK-NOT: Function Attrs
-; CHECK: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
+; CHECK: ; Function Attrs: nounwind
+; CHECK-NEXT: declare i32 @__kmpc_omp_taskwait(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare i32 @__kmpc_omp_taskyield(%struct.ident_t*, i32, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_push_num_threads(%struct.ident_t*, i32, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_push_proc_bind(%struct.ident_t*, i32, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_serialized_parallel(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_end_serialized_parallel(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare i32 @__kmpc_master(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_end_master(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_critical_with_hint(%struct.ident_t*, i32, [8 x i32]*, i32)
 
-; CHECK: Function Attrs: inaccessiblemem_or_argmemonly
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_end_critical(%struct.ident_t*, i32, [8 x i32]*)
 
-; CHECK: Function Attrs: nounwind
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_begin(%struct.ident_t*, i32)
 
-; CHECK: Function Attrs: nounwind
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare void @__kmpc_end(%struct.ident_t*)
 
-; CHECK: Function Attrs: nounwind
+; CHECK: ; Function Attrs: nounwind
 ; CHECK-NEXT: declare i32 @__kmpc_reduce(%struct.ident_t*, i32, i32, 

[clang-tools-extra] f44d242 - [clangd] Set CWD in semaCodeComplete

2020-06-11 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-11T23:35:47+02:00
New Revision: f44d2424f8d7735d7ab5ffd96f75300221afd099

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

LOG: [clangd] Set CWD in semaCodeComplete

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index cf79673d821e..a7a4ede23ea4 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@ bool 
semaCodeComplete(std::unique_ptr Consumer,
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ?  : 
nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);



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


LLVM buildmaster will be updated and restarted tonight

2020-06-11 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM PST today.

Thanks

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


[clang] 385e5f7 - Fix incorrect call to ExprResult::get()

2020-06-11 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-06-11T22:23:33+01:00
New Revision: 385e5f7e147fcf792085b365cc48380850612025

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

LOG: Fix incorrect call to ExprResult::get()

Res is already a ExprResult, so if we call .get(), we will convert an
ExprError() result into an unset result. I discovered this in our downstream
CHERI target where this resulted in a crash due to a NULL-dereference.
It appears that this was introduced in SVN revision 201788 
(8690a6860a45ba36e39b4ff0dbe434195e125d11)

Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D81608

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0537d09a09eb..6477979e92fe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -724,7 +724,7 @@ ExprResult Sema::CallExprUnaryConversions(Expr *E) {
   // to function type.
   if (Ty->isFunctionType()) {
 Res = ImpCastExprToType(E, Context.getPointerType(Ty),
-CK_FunctionToPointerDecay).get();
+CK_FunctionToPointerDecay);
 if (Res.isInvalid())
   return ExprError();
   }



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81627#2088500 , @arsenm wrote:

> It doesn't matter if we don't support isa linking. We should just use clang 
> and default to -flto. LTO "just works" as is


This is a step forward, but the lack of ISA linking shouldn't block eliminating 
the use of llc/opt


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

https://reviews.llvm.org/D81627



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D81670#2088304 , @hliao wrote:

> In D81670#2087974 , @arsenm wrote:
>
> > We should instead allow bitcast to perform no-op addrspacecasts
>
>
> That may be a little bit challenging as so far no-op `addrspacecast` is 
> target-specific. There may be no TTI available when `bitcast` is constructed.


Yes, that is the point. You don't need TTI to use it. Addrspace bitcast will be 
just a dumb bit reinterpret, not something that may change the value like 
addrspacecast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

It doesn't matter if we don't support isa linking. We should just use clang and 
default to -flto. LTO "just works" as is


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

https://reviews.llvm.org/D81627



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

OpenMP has the same restriction (no surprise I guess). Thanks for the ping!

I think we do not emit diagnosis right now: https://godbolt.org/z/srDkXZ
I think we also should diagnose this the same way, though it might be beyond 
the scope of this patch: https://godbolt.org/z/rRZFi4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[PATCH] D81691: [clangd] Set CWD in semaCodeComplete

2020-06-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81691

Files:
  clang-tools-extra/clangd/CodeComplete.cpp


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ?  : 
nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ?  : nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81608: Fix incorrect call to ExprResult::get()

2020-06-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks! Great spot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81608



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


[PATCH] D81688: [WebAssembly] WebAssembly doesn't support "protected" visibility

2020-06-11 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
Herald added subscribers: llvm-commits, aheejin, jgravelle-google, sbc100, 
dschuff.
Herald added projects: clang, LLVM.

mplement the `hasProtectedVisibility()` hook to indicate that, like
Darwin, WebAssembly doesn't support "protected" visibility.

On ELF, "protected" visibility is intended to be an optimization, however
in practice it often [isn't], and ELF documentation generally ranges from
[not mentioning it at all] to [strongly discouraging its use].

[isn't]: https://www.airs.com/blog/archives/307
[not mentioning it at all]: https://gcc.gnu.org/wiki/Visibility
[strongly discouraging its use]: https://www.akkadia.org/drepper/dsohowto.pdf

While here, also mention the new Reactor support in the release notes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81688

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -144,8 +144,14 @@
 Changes to the WebAssembly Target
 -
 
-During this release ...
-
+* Programs which don't have a "main" function, called "reactors" are now
+  properly supported, with a new `-mexec-model=reactor` flag. Programs which
+  previously used `-Wl,--no-entry` to avoid having a main function should
+  switch to this new flag, so that static initialization is properly
+  performed.
+
+* `__attribute__((visibility("protected")))` now evokes a warning, as
+  WebAssembly does not support "protected" visibility.
 
 Changes to the OCaml bindings
 -
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -132,7 +132,14 @@
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool hasProtectedVisibility() const override {
+// For compatibility, continue to advertise "protected" support for
+// Emscripten targets.
+return getTriple().isOSEmscripten();
+  }
 };
+
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
 : public WebAssemblyTargetInfo {
 public:


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -144,8 +144,14 @@
 Changes to the WebAssembly Target
 -
 
-During this release ...
-
+* Programs which don't have a "main" function, called "reactors" are now
+  properly supported, with a new `-mexec-model=reactor` flag. Programs which
+  previously used `-Wl,--no-entry` to avoid having a main function should
+  switch to this new flag, so that static initialization is properly
+  performed.
+
+* `__attribute__((visibility("protected")))` now evokes a warning, as
+  WebAssembly does not support "protected" visibility.
 
 Changes to the OCaml bindings
 -
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -132,7 +132,14 @@
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool hasProtectedVisibility() const override {
+// For compatibility, continue to advertise "protected" support for
+// Emscripten targets.
+return getTriple().isOSEmscripten();
+  }
 };
+
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
 : public WebAssemblyTargetInfo {
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 270219.
kpn retitled this revision from "[FPEnv][Clang][Driver][WIP] Disable 
constrained floating point on targets lacking support." to 
"[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking 
support.".
kpn added a comment.
Herald added a subscriber: kbarton.

Added new warnings to a new group "unsupported-floating-point-opt". The warning 
can be disabled. The disabling of constrained floating point is unaffected by 
the status of the warning.

I added PowerPC to the list of targets that are _not_ disabled by this patch 
since that target is close to parity with X86 and SystemZ.

Is there anything left?


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

https://reviews.llvm.org/D80952

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | tee /tmp/1 | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/lib/Frontend/CompilerInstance.cpp

[libunwind] 96e6cbb - [libc++] Allow specifying arbitrary custom executors with the new format

2020-06-11 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-06-11T16:24:29-04:00
New Revision: 96e6cbbf941d0f937b7e823433d4c222967a1817

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

LOG: [libc++] Allow specifying arbitrary custom executors with the new format

The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.

This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.

Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR=" --host ". Similarly, arbitrary
scripts can be provided.

Added: 


Modified: 
libcxx/test/CMakeLists.txt
libcxx/utils/libcxx/test/config.py
libcxxabi/test/CMakeLists.txt
libunwind/test/CMakeLists.txt

Removed: 




diff  --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 5068cbd1b1b0..b68f59f38e76 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -81,7 +81,7 @@ endif()
 
 set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
-set(LIBCXX_EXECUTOR "None" CACHE STRING
+set(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} 
${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
 "Executor to use when running tests.")
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")

diff  --git a/libcxx/utils/libcxx/test/config.py 
b/libcxx/utils/libcxx/test/config.py
index 5eccc2783a74..44cb95943877 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -189,18 +189,22 @@ def get_test_format(self):
 exec_env=self.exec_env)
 
 def configure_executor(self):
-exec_str = self.get_lit_conf('executor', "None")
-te = eval(exec_str)
-if te:
-self.lit_config.note("Using executor: %r" % exec_str)
-if self.lit_config.useValgrind:
-self.lit_config.fatal("The libc++ test suite can't run under 
Valgrind with a custom executor")
-else:
-te = LocalExecutor()
+if self.get_lit_conf('use_old_format'):
+exec_str = self.get_lit_conf('executor', "None")
+te = eval(exec_str)
+if te:
+self.lit_config.note("Using executor: %r" % exec_str)
+if self.lit_config.useValgrind:
+self.lit_config.fatal("The libc++ test suite can't run 
under Valgrind with a custom executor")
+else:
+te = LocalExecutor()
 
-te.target_info = self.target_info
-self.target_info.executor = te
-self.executor = te
+te.target_info = self.target_info
+self.target_info.executor = te
+self.executor = te
+else:
+self.executor = self.get_lit_conf('executor')
+self.lit_config.note("Using executor: {}".format(self.executor))
 
 def configure_target_info(self):
 self.target_info = make_target_info(self)
@@ -751,14 +755,8 @@ def configure_substitutions(self):
 '--codesign_identity "{}"'.format(codesign_ident),
 '--env {}'.format(env_vars)
 ]
-if isinstance(self.executor, SSHExecutor):
-exec_args.append('--host {}'.format(self.executor.user_prefix + 
self.executor.host))
-executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py')
-else:
-executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py')
-sub.append(('%{exec}', '{} {} {} -- 
'.format(pipes.quote(sys.executable),
- pipes.quote(executor),
- ' '.join(exec_args
+if not self.get_lit_conf('use_old_format'):
+sub.append(('%{exec}', '{} {} -- '.format(self.executor, ' 
'.join(exec_args
 if self.get_lit_conf('libcxx_gdb'):
 sub.append(('%{libcxx_gdb}', self.get_lit_conf('libcxx_gdb')))
 

diff  --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index bedfce8bc397..2160f52c3350 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -32,7 +32,7 @@ if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT 
LIBCXX_ENABLE_SHARED)
 endif()
 
 if(DEFINED LIBCXX_ENABLE_STATIC
-   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX 
+   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR 

[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:376-377
+std::string operator()(PathSensitiveBugReport ) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+

Another thing you might want to check is that the warning is coming from your 
checker. The symbol may be marked as interesting by another checker for a 
completely unrelated reason. The easiest way to check that is usually to 
compare the report's bug type to your checker's bug type.

(we should absolutely automate this)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D72705#1871996 , @Szelethus wrote:

> @NoQ, @xazax.hun, @baloghadamsoftware, how do you like this patch? I think 
> the high level idea is correct.


I still don't understand how do we enable this checker, i.e. for whom and how 
often. Is there anything we'll be able to turn on by default, like maybe warn 
on all functions that wear `__attribute__((warn_unused_result))`?




Comment at: clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp:309-311
+void ErrorReturnChecker::checkAccess(CheckerContext , ProgramStateRef State,
+ const Stmt *LoadS, SymbolRef CallSym,
+ const CalledFunctionData *CFD) const {

Why scan parent statements proactively given that we will reach them later 
anyway? Looks like you're using a wrong checker callback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D81670#2087974 , @arsenm wrote:

> We should instead allow bitcast to perform no-op addrspacecasts


That may be a little bit challenging as so far no-op `addrspacecast` is 
target-specific. There may be no TTI available when `bitcast` is constructed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670



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


[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-11 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc08ea0771682: Add to the Coding Standard our that 
single-line bodies omit braces (authored by erichkeane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80947

Files:
  llvm/docs/CodingStandards.rst

Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -669,15 +669,15 @@
 .. code-block:: c++
 
   // Typically there's no reason to copy.
-  for (const auto  : Container) { observe(Val); }
-  for (auto  : Container) { Val.change(); }
+  for (const auto  : Container) observe(Val);
+  for (auto  : Container) Val.change();
 
   // Remove the reference if you really want a new copy.
   for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
 
   // Copy pointers, but make it clear that they're pointers.
-  for (const auto *Ptr : Container) { observe(*Ptr); }
-  for (auto *Ptr : Container) { Ptr->change(); }
+  for (const auto *Ptr : Container) observe(*Ptr);
+  for (auto *Ptr : Container) Ptr->change();
 
 Beware of non-determinism due to ordering of pointers
 ^
@@ -884,7 +884,7 @@
 .. code-block:: c++
 
   Value *doSomething(Instruction *I) {
-// Terminators never need 'something' done to them because ... 
+// Terminators never need 'something' done to them because ...
 if (I->isTerminator())
   return 0;
 
@@ -896,7 +896,7 @@
 // This is really just here for example.
 if (!doOtherThing(I))
   return 0;
-
+
 ... some long code 
   }
 
@@ -1000,7 +1000,7 @@
   Type = Context.getsigjmp_bufType();
 else
   Type = Context.getjmp_bufType();
-
+
 if (Type.isNull()) {
   Error = Signed ? ASTContext::GE_Missing_sigjmp_buf :
ASTContext::GE_Missing_jmp_buf;
@@ -1010,7 +1010,7 @@
 
 The idea is to reduce indentation and the amount of code you have to keep track
 of when reading the code.
-  
+
 Turn Predicate Loops into Predicate Functions
 ^
 
@@ -1081,7 +1081,7 @@
 * **Variable names** should be nouns (as they represent state).  The name should
   be camel case, and start with an upper case letter (e.g. ``Leader`` or
   ``Boats``).
-  
+
 * **Function names** should be verb phrases (as they represent actions), and
   command-like function should be imperative.  The name should be camel case,
   and start with a lower case letter (e.g. ``openFile()`` or ``isFoo()``).
@@ -1091,7 +1091,7 @@
   discriminator for a union, or an indicator of a subclass.  When an enum is
   used for something like this, it should have a ``Kind`` suffix
   (e.g. ``ValueKind``).
-  
+
 * **Enumerators** (e.g. ``enum { Foo, Bar }``) and **public member variables**
   should start with an upper-case letter, just like types.  Unless the
   enumerators are defined in their own small namespace or inside a class,
@@ -1107,7 +1107,7 @@
 MaxSize = 42,
 Density = 12
   };
-  
+
 As an exception, classes that mimic STL classes can have member names in STL's
 style of lower-case words separated by underscores (e.g. ``begin()``,
 ``push_back()``, and ``empty()``). Classes that provide multiple
@@ -1359,7 +1359,7 @@
 The use of ``#include `` in library files is hereby **forbidden**,
 because many common implementations transparently inject a `static constructor`_
 into every translation unit that includes it.
-  
+
 Note that using the other stream headers ( for example) is not
 problematic in this regard --- just . However, ``raw_ostream``
 provides various APIs that are better performing for almost every use than
@@ -1491,7 +1491,7 @@
   public:
 explicit Grokable() { ... }
 virtual ~Grokable() = 0;
-  
+
 ...
 
   };
@@ -1540,8 +1540,8 @@
   };
   } // end anonymous namespace
 
-  static void runHelper() { 
-... 
+  static void runHelper() {
+...
   }
 
   bool StringSort::operator<(const char *RHS) const {
@@ -1569,6 +1569,53 @@
 contrast, when the function is marked static, you don't need to cross-reference
 faraway places in the file to tell that the function is local.
 
+Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
+^
+
+When writing the body of an ``if``, ``else``, or loop statement, omit the braces to
+avoid unnecessary line noise. However, braces should be used in cases where the
+omission of braces harm the readability and maintainability of the code.
+
+Readability is harmed when a single statement is accompanied by a comment that loses
+its meaning if hoisted above the ``if`` or loop statement. Similarly, braces should
+be used when single-statement body is complex enough that it becomes 

[PATCH] D78122: [analyzer][Nullability] Don't emit under the checker name NullabilityBase

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Nope, false alarm! Our buildbot configuration change was at fault. Sorry for 
forgetting to follow up >.<


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78122



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-11 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 270206.
DmitryPolukhin added a comment.

Fix single new line handling, it should be replace with space


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz ";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
-  "foobarbaz'\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
+  "foobarbaz '\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
@@ -305,6 +305,25 @@
   EXPECT_EQ(Original.str1, Deserialized.str1);
   EXPECT_EQ(Original.str2, Deserialized.str2);
   EXPECT_EQ(Original.str3, Deserialized.str3);
+
+  // Check deserialization of single '\n' that should be converted to space.
+  Serialized = "---\n"
+   "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
+   "foobarbaz\n'\n"
+   "str2:'another\none\r"
+   "foobarbaz\n\n'\n"
+   "str3:a one-line string\n"
+   "...\n";
+  {
+Input YIn(Serialized);
+YIn >> Deserialized;
+ASSERT_FALSE(YIn.error())
+<< "Parsing error occurred during deserialization. Serialized string:\n"
+<< Serialized;
+  }
+  EXPECT_EQ(Original.str1, Deserialized.str1);
+  EXPECT_EQ(Original.str2, Deserialized.str2);
+  EXPECT_EQ(Original.str3, Deserialized.str3);
 }
 
 TEST(YAMLIO, NoQuotesForTab) {
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,38 @@
 }
 
 void ScalarTraits::output(const std::string , void *,
- raw_ostream ) {
-  Out << Val;
+   raw_ostream ) {
+  SmallVector Lines;
+  StringRef(Val).split(Lines, '\n');
+  bool First = true;
+  for (StringRef Line : Lines) {
+if (First)
+  First = false;
+else
+  Out << "\n\n";
+Out << Line;
+  }
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string ) {
-  Val = Scalar.str();
+   std::string ) {
+  Val.clear();
+  SmallVector Lines;
+  Scalar.split(Lines, '\n');
+  size_t C = Lines.size();
+  for (size_t I = 0; I < C; ++I) {
+Val += Lines[I];
+// Next empty line means that it was '\n\n' that should convert to '\n'.
+// +2 here because we need separator only if more elements will be added.
+if (I + 2 < C && Lines[I + 1].empty()) {
+  Val += '\n';
+  ++I;
+} else if ((I + 1 < C && !Lines[I + 1].empty()) ||
+   (I + 2 == C && Lines[I + 1].empty())) {
+  // Single '\n' should be converted to space ' '.
+  Val += ' ';
+}
+  }
   return StringRef();
 }
 
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement )
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-  }
-}
+  Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
 clang::tooling::Replacement denormalize(const IO &) {
   return clang::tooling::Replacement(FilePath, Offset, Length,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7327-7330
+  bool IsNonContiguous = false,
+  MapNonContiguousArrayTy *const Offsets = nullptr,
+  MapNonContiguousArrayTy *const Counts = nullptr,
+  MapNonContiguousArrayTy *const Strides = nullptr) const {

I would prefer to pack these 4 params into a single parameter (a struct). Also, 
can we put `Dims` parameter into the list of the optional parameters?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7805
+  // should be [10, 10] and the first stride is 4 btyes.
+  for (const auto  : Components) {
+const Expr *AssocExpr = Component.getAssociatedExpression();

Expand `auto` here to a real type



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7807
+const Expr *AssocExpr = Component.getAssociatedExpression();
+const auto *OASE = dyn_cast(AssocExpr);
+if (OASE) {

Can we have anything else except for array section here? If not, use just 
`cast`. If yes, use `continue` to simplify complexity:
```
if (!OASE)
  continue;
...
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7821
+  Context.getTypeSizeInChars(ElementType).getQuantity();
+} else if (VAT) {
+  ElementType = VAT->getElementType().getTypePtr();

What if the base is a pointer, not an array?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7831-7838
+  llvm::Value *SizeV = nullptr;
+  if (CAT) {
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {
+const Expr *Size = VAT->getSizeExpr();
+SizeV = CGF.EmitScalarExpr(Size);

The code for `SizeV` must be under the control of the next `if`:
```
if (DimSizes.size() < Components.size() - 1) {
 
}
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7834
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {

Create directly as of `CGF.Int64Ty` type.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7859
+  // declaration in target update to/from clause.
+  for (const auto  : Components) {
+const Expr *AssocExpr = Component.getAssociatedExpression();

Expand `auto` here to a real type



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7861-7864
+const auto *OASE = dyn_cast(AssocExpr);
+
+if (OASE) {
+  // Offset

Can we have anything else except for array section here? If not, use just 
`cast`. If yes, use `continue` to simplify complexity:
```
if (!OASE)
  continue;
...
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7872-7873
+  } else {
+Offset = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(OffsetExpr),
+   CGF.Int64Ty,
+   /*isSigned=*/false);

Do you really to pass real offsets here? Can we use pointers instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[clang] efb0413 - [clang][NFC] Assert that the enumerator value of {Type,ArrayType,UnaryExprOrType,Expression}Traits

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: efb0413a5cf9b1481c9b6169c8685f8d71f6de84

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

LOG: [clang][NFC] Assert that the enumerator value of 
{Type,ArrayType,UnaryExprOrType,Expression}Traits

is valid and does not overflow in the bit-field for its storage in more places.
This is a follow-up to 78e636b3f2f0b0487130b31fade4f95ab179a18c. NFC.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 670c0fe80b4e..d31f582264b5 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2509,7 +2509,11 @@ class UnaryExprOrTypeTraitExpr : public Expr {
SourceLocation rp)
   : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, 
OK_Ordinary),
 OpLoc(op), RParenLoc(rp) {
+assert(ExprKind <= UETT_Last && "invalid enum value!");
 UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+assert(static_cast(ExprKind) ==
+   UnaryExprOrTypeTraitExprBits.Kind &&
+   "UnaryExprOrTypeTraitExprBits.Kind overflow!");
 UnaryExprOrTypeTraitExprBits.IsType = true;
 Argument.Ty = TInfo;
 setDependence(computeDependence(this));
@@ -2526,7 +2530,12 @@ class UnaryExprOrTypeTraitExpr : public Expr {
   UnaryExprOrTypeTrait getKind() const {
 return 
static_cast(UnaryExprOrTypeTraitExprBits.Kind);
   }
-  void setKind(UnaryExprOrTypeTrait K) { UnaryExprOrTypeTraitExprBits.Kind = 
K;}
+  void setKind(UnaryExprOrTypeTrait K) {
+assert(K <= UETT_Last && "invalid enum value!");
+UnaryExprOrTypeTraitExprBits.Kind = K;
+assert(static_cast(K) == UnaryExprOrTypeTraitExprBits.Kind &&
+   "UnaryExprOrTypeTraitExprBits.Kind overflow!");
+  }
 
   bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.IsType; }
   QualType getArgumentType() const {

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 379f762275c6..82036a295002 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2749,6 +2749,8 @@ class ArrayTypeTraitExpr : public Expr {
   : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary), ATT(att),
 Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
 QueriedType(queried) {
+assert(att <= ATT_Last && "invalid enum value!");
+assert(static_cast(att) == ATT && "ATT overflow!");
 setDependence(computeDependence(this));
   }
 
@@ -2813,6 +2815,8 @@ class ExpressionTraitExpr : public Expr {
   : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary),
 ET(et), Value(value), Loc(loc), RParen(rparen),
 QueriedExpression(queried) {
+assert(et <= ET_Last && "invalid enum value!");
+assert(static_cast(et) == ET && "ET overflow!");
 setDependence(computeDependence(this));
   }
 

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 71cc159d06fb..89eb8e9c0220 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1535,7 +1535,10 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr(
 SourceLocation op, SourceLocation rp)
 : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary),
   OpLoc(op), RParenLoc(rp) {
+  assert(ExprKind <= UETT_Last && "invalid enum value!");
   UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+  assert(static_cast(ExprKind) == UnaryExprOrTypeTraitExprBits.Kind 
&&
+ "UnaryExprOrTypeTraitExprBits.Kind overflow!");
   UnaryExprOrTypeTraitExprBits.IsType = false;
   Argument.Ex = E;
   setDependence(computeDependence(this));

diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 9d285550ef90..9d4df28c7473 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1579,6 +1579,7 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation 
Loc, TypeTrait Kind,
  SourceLocation RParenLoc, bool Value)
 : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary), Loc(Loc),
   RParenLoc(RParenLoc) {
+  assert(Kind <= TT_Last && "invalid enum value!");
   TypeTraitExprBits.Kind = Kind;
   assert(static_cast(Kind) == TypeTraitExprBits.Kind &&
  "TypeTraitExprBits.Kind overflow!");



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


[clang] a9250c2 - [clang] TextNodeDumper: Dump the trait spelling of {Type,ArrayType,Expression}TraitExpr

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: a9250c281a875d91fb5dd1c8f4ad8ee4ff61b75d

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

LOG: [clang] TextNodeDumper: Dump the trait spelling of 
{Type,ArrayType,Expression}TraitExpr

nodes using the new helper functions introduced
in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

Added: 
clang/test/AST/ast-dump-traits.cpp

Modified: 
clang/include/clang/AST/TextNodeDumper.h
clang/lib/AST/TextNodeDumper.cpp

Removed: 




diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 4636c8ef65d3..b069bd09287a 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -259,6 +259,9 @@ class TextNodeDumper
   void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
   void VisitCXXNewExpr(const CXXNewExpr *Node);
   void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
+  void VisitTypeTraitExpr(const TypeTraitExpr *Node);
+  void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *Node);
+  void VisitExpressionTraitExpr(const ExpressionTraitExpr *Node);
   void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
   void VisitExprWithCleanups(const ExprWithCleanups *Node);
   void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 609a9d7ac2df..7007aa833f3f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -949,6 +949,18 @@ void TextNodeDumper::VisitCXXDeleteExpr(const 
CXXDeleteExpr *Node) {
   }
 }
 
+void TextNodeDumper::VisitTypeTraitExpr(const TypeTraitExpr *Node) {
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
+void TextNodeDumper::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *Node) {
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
+void TextNodeDumper::VisitExpressionTraitExpr(const ExpressionTraitExpr *Node) 
{
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
 void TextNodeDumper::VisitMaterializeTemporaryExpr(
 const MaterializeTemporaryExpr *Node) {
   if (const ValueDecl *VD = Node->getExtendingDecl()) {

diff  --git a/clang/test/AST/ast-dump-traits.cpp 
b/clang/test/AST/ast-dump-traits.cpp
new file mode 100644
index ..92931e2ac67a
--- /dev/null
+++ b/clang/test/AST/ast-dump-traits.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
-strict-whitespace %s
+
+void test_type_trait() {
+  // An unary type trait.
+  enum E {};
+  (void) __is_enum(E);
+  // A binary type trait.
+  (void) __is_same(int ,float);
+  // An n-ary type trait.
+  (void) __is_constructible(int, int, int, int);
+}
+
+void test_array_type_trait() {
+  // An array type trait.
+  (void) __array_rank(int[10][20]);
+}
+
+void test_expression_trait() {
+  // An expression trait.
+  (void) __is_lvalue_expr(1);
+}
+
+void test_unary_expr_or_type_trait() {
+  // Some UETTs.
+  (void) sizeof(int);
+  (void) alignof(int);
+  (void) __alignof(int);
+}
+// CHECK: TranslationUnitDecl {{.*}} <> 
+// CHECK: |-FunctionDecl {{.*}} <{{.*}}ast-dump-traits.cpp:3:1, line:11:1> 
line:3:6 test_type_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   |-DeclStmt {{.*}} 
+// CHECK-NEXT: |   | `-EnumDecl {{.*}}  col:8 referenced E
+// CHECK-NEXT: |   |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: |   | `-TypeTraitExpr {{.*}}  'bool' __is_enum
+// CHECK-NEXT: |   |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: |   | `-TypeTraitExpr {{.*}}  'bool' __is_same
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-TypeTraitExpr {{.*}}  'bool' 
__is_constructible
+// CHECK-NEXT: |-FunctionDecl {{.*}}  line:13:6 
test_array_type_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-ArrayTypeTraitExpr {{.*}}  'unsigned 
long' __array_rank
+// CHECK-NEXT: |-FunctionDecl {{.*}}  line:18:6 
test_expression_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-ExpressionTraitExpr {{.*}}  'bool' 
__is_lvalue_expr
+// CHECK-NEXT: `-FunctionDecl {{.*}}  line:23:6 
test_unary_expr_or_type_trait 'void ()'
+// CHECK-NEXT:   `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}}  
'unsigned long' sizeof 'int'
+// CHECK-NEXT: |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}}  
'unsigned long' alignof 'int'
+// CHECK-NEXT: `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT:   `-UnaryExprOrTypeTraitExpr {{.*}}  

[clang] a06f000 - [clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and ExpressionTrait

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: a06f000326e3362ffb5634957447dd434abab0f9

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

LOG: [clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and 
ExpressionTrait

These two were missed in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

Added: 


Modified: 
clang/lib/Parse/ParseExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index d794977a..48277dc85466 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3649,18 +3649,24 @@ case tok::kw_ ## Spelling: return BTT_ ## Name;
 }
 
 static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind) {
-  switch(kind) {
-  default: llvm_unreachable("Not a known binary type trait");
-  case tok::kw___array_rank: return ATT_ArrayRank;
-  case tok::kw___array_extent:   return ATT_ArrayExtent;
+  switch (kind) {
+  default:
+llvm_unreachable("Not a known array type trait");
+#define ARRAY_TYPE_TRAIT(Spelling, Name, Key)  
\
+  case tok::kw_##Spelling: 
\
+return ATT_##Name;
+#include "clang/Basic/TokenKinds.def"
   }
 }
 
 static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind) {
-  switch(kind) {
-  default: llvm_unreachable("Not a known unary expression trait.");
-  case tok::kw___is_lvalue_expr: return ET_IsLValueExpr;
-  case tok::kw___is_rvalue_expr: return ET_IsRValueExpr;
+  switch (kind) {
+  default:
+llvm_unreachable("Not a known unary expression trait.");
+#define EXPRESSION_TRAIT(Spelling, Name, Key)  
\
+  case tok::kw_##Spelling: 
\
+return ET_##Name;
+#include "clang/Basic/TokenKinds.def"
   }
 }
 



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


[PATCH] D79155: [CodeGen] Increase applicability of ffine-grained-bitfield-accesses for targets with limited native integer widths

2020-06-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please add a comment explaining what OffsetInRecord means; then LGTM.


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

https://reviews.llvm.org/D79155



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Looks OK in general. I'm happy to see reduced opt/llc use.

You may want to get someone more familiar with the AMD GPU compilation process 
to double-check that the compilation pipeline still does the right thing.




Comment at: clang/lib/Driver/Driver.cpp:2725-2726
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
   // Create a link action to link device IR with device library
   // and generate ISA.
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(

The comment about "create link action" should probably be moved down below to 
where the link action is constructed now.




Comment at: clang/lib/Driver/Driver.cpp:2727-2732
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Backend, CudaDeviceActions[I],
+  AssociatedOffloadKind);
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Assemble, CudaDeviceActions[I],
+  AssociatedOffloadKind);

Looks like we're chaining backend/assembly actions here. but it's not easy to 
spot that we use `CudaDeviceActions[I]`  as an intermediate value. At the first 
glance it looked like a copy/paste error writing to `CudaDeviceActions[I]` 
multiple times.

It would be easier to see what's going on if the code was structured like this:
```
BackendAction = Construct(... CudaDeviceActions[I]);
AssembleAction  = Construct(... BackendAction);
AL.push_back(AssembleAction)
CudaDeviceActions[I] = C.MakeAction(AL);
```



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

https://reviews.llvm.org/D81627



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

aaron.ballman wrote:
> jkorous wrote:
> > Nit: while "[base specifier] `hasType`" sounds natural to me for some 
> > reason `hasClass` doesn't. English is not my first language though.
> I agree that `hasClass` seems unnatural here. Out of curiosity, could we 
> modify the `hasName` matcher to work on base specifiers so you can write: 
> `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more wordy 
> version `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?
Wouldn't it be strange to treat `hasName` differently than all the other 
narrowing matchers? Honest question - I feel that `hasName` might be the most 
commonly used, just don't know if that's enough to justify this.
https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3621
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClassOrClassTemplate,
+  internal::Matcher, InnerMatcher) {

I think we should just use `eachOf` matcher for this kind of composition.

https://clang.llvm.org/docs/LibASTMatchersReference.html#traversal-matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81392: [clang] Rename Decl::isHidden() to isUnconditionallyVisible()

2020-06-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I think renaming the flag in the AST dump output would be a good idea, though 
it'll be a lot of churn in the tests. I would prefer that we continue to dump a 
marker only if the declaration is not unconditionally visible rather than 
reversing the sense of the flag in the dump output. Maybe we should dump the 
ModuleOwnershipKind in general, not only an indicator of whether it's Visible 
or something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81392



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


[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D80450#2087938 , @tra wrote:

> Reproducer for the regression. 
> https://gist.github.com/Artem-B/183e9cfc28c6b04c1c862c853b5d9575
>  It's not particularly small, but that's as far as I could get it reduced.
>
> With the patch, an attempt to instantiate `ag` on line 36 (in the reproducer 
> sources I linked to above) results in ambiguity between two templates on 
> lines 33 and 24 that are in different namespaces.
>  Previously it picked the template on line 28.


Managed to simplify the reproducer down to this which now reports that a host 
candidate has been ignored. This may explain why we ended up with the ambiguity 
when other overloads were present.

  template  struct a {};
  namespace b {
  struct c : a {};
  template  void ag(d);
  } // namespace b
  template 
  __attribute__((host)) __attribute__((device)) int ag(a) {
ae e;
ag(e);
  }
  void f() { ag; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80450



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


[clang] 43101d1 - [OPENMP50]Codegen for scan directive in simd loops.

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T14:48:43-04:00
New Revision: 43101d10dbd58d48df732f974e078fd82376039e

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

LOG: [OPENMP50]Codegen for scan directive in simd loops.

Added codegen for scan directives in simd loop. The codegen transforms
original code:
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan inclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  x = x_priv + x;
  x_priv = x;
  
}
```
and
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan exclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  int temp = x;
  x = x_priv + x;
  x_priv = temp;
  
}
```

Differential revision: https://reviews.llvm.org/D78232

Added: 
clang/test/OpenMP/scan_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e9569d4e5658..d51693a4551a 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1730,7 +1730,13 @@ void CodeGenFunction::EmitOMPLoopBody(const 
OMPLoopDirective ,
 // executed in reverse order.
 OMPBeforeScanBlock = createBasicBlock("omp.before.scan.bb");
 OMPAfterScanBlock = createBasicBlock("omp.after.scan.bb");
-OMPScanExitBlock = createBasicBlock("omp.exit.inscan.bb");
+// No need to allocate inscan exit block, in simd mode it is selected in 
the
+// codegen for the scan directive.
+if (D.getDirectiveKind() != OMPD_simd &&
+(!getLangOpts().OpenMPSimd ||
+ isOpenMPSimdDirective(D.getDirectiveKind( {
+  OMPScanExitBlock = createBasicBlock("omp.exit.inscan.bb");
+}
 OMPScanDispatch = createBasicBlock("omp.inscan.dispatch");
 EmitBranch(OMPScanDispatch);
 EmitBlock(OMPBeforeScanBlock);
@@ -2083,6 +2089,15 @@ void CodeGenFunction::EmitOMPSimdInit(const 
OMPLoopDirective ,
   if (const auto *C = D.getSingleClause())
 if (C->getKind() == OMPC_ORDER_concurrent)
   LoopStack.setParallel(/*Enable=*/true);
+  if ((D.getDirectiveKind() == OMPD_simd ||
+   (getLangOpts().OpenMPSimd &&
+isOpenMPSimdDirective(D.getDirectiveKind( &&
+  llvm::any_of(D.getClausesOfKind(),
+   [](const OMPReductionClause *C) {
+ return C->getModifier() == OMPC_REDUCTION_inscan;
+   }))
+// Disable parallel access in case of prefix sum.
+LoopStack.setParallel(/*Enable=*/false);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(
@@ -2278,6 +2293,8 @@ static void emitOMPSimdRegion(CodeGenFunction , const 
OMPLoopDirective ,
 }
 
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective ) {
+  ParentLoopDirectiveForScanRegion ScanRegion(*this, S);
+  OMPFirstScanLoop = true;
   auto & = [](CodeGenFunction , PrePostActionTy ) {
 emitOMPSimdRegion(CGF, S, Action);
   };
@@ -4199,14 +4216,15 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective ) {
 }
 
 void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective ) {
-  // Do not emit code for non-simd directives in simd-only mode.
-  if (getLangOpts().OpenMPSimd && !OMPParentLoopDirectiveForScan)
+  if (!OMPParentLoopDirectiveForScan)
 return;
   const OMPExecutableDirective  = *OMPParentLoopDirectiveForScan;
+  bool IsInclusive = S.hasClausesOfKind();
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector LHSs;
   SmallVector RHSs;
+  SmallVector ReductionOps;
   SmallVector CopyOps;
   SmallVector CopyArrayTemps;
   SmallVector CopyArrayElems;
@@ -4217,13 +4235,109 @@ void CodeGenFunction::EmitOMPScanDirective(const 
OMPScanDirective ) {
 Privates.append(C->privates().begin(), C->privates().end());
 LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
 RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
+ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
 CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
 CopyArrayElems.append(C->copy_array_elems().begin(),
   C->copy_array_elems().end());
   }
-  bool IsInclusive = S.hasClausesOfKind();
+  if (ParentDir.getDirectiveKind() == OMPD_simd ||
+  (getLangOpts().OpenMPSimd &&
+   isOpenMPSimdDirective(ParentDir.getDirectiveKind( {
+// For simd directive and simd-based directives in simd only mode, use the
+// following codegen:
+// int x = 0;
+// #pragma omp simd reduction(inscan, +: x)
+// for (..) {
+//   
+//   #pragma omp 

[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D81311#2087592 , @jdoerfert wrote:

> In D81311#2086326 , @rjmccall wrote:
>
> > In D81311#2086227 , @jdoerfert 
> > wrote:
> >
> > > Do we allow `inmem` to be used for other purposes? I would assume the 
> > > answer is yes, as we do not forbid it.
> >
> >
> > I don't know what else we might use it for off-hand, but yes, I think the 
> > frontend could put this down on all value arguments that are actually 
> > passed indirectly.
>
>
> Where does it say it is limited to indirectly passed arguments?


The argument does have to be a pointer.  And passes aren't allowed to infer 
this or it becomes useless for the original purpose.


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

https://reviews.llvm.org/D81311



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3537
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType,
-AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 1) {

njames93 wrote:
> jkorous wrote:
> > aaron.ballman wrote:
> > > njames93 wrote:
> > > > aaron.ballman wrote:
> > > > > This is undoing a change that was just added less than two weeks ago, 
> > > > > so I think the potential for breaking code is small. That said, can 
> > > > > you explain why you think `hasClass` is a better approach than 
> > > > > `hasType`?
> > > > Yeah, as that change hasn't reached landed onto a release branch 
> > > > breaking code shouldn't be an issue, If it was I'd leave it in.
> > > > 
> > > > - `hasType` is very generic, whereas `hasClass` is specific to what a 
> > > > `CXXBaseSpecifier` supports.
> > > > - It makes the matchers marginally simpler.
> > > >   `hasDirectBase(hasType(cxxRecordDecl(hasName("Base"` vs 
> > > > `hasDirectBase(hasClass(hasName("Base")))`
> > > > - In the documentation it also specifies that `hasClass` takes a 
> > > > `Matcher, making it more user friendly.
> > > FWIW, I prefer `hasType` to `hasClass`. You can inherit from things which 
> > > are not a class, such as a struct (so the name is a bit of a misnomer, 
> > > but not too awful), a class template (which you can't match with this 
> > > interface), or a template type (which you also can't match with this 
> > > interface).
> > I don't feel super strongly about this but I also slightly prefer `hasType`.
> > 
> > To be fair - I didn't really have things like inheritance from template 
> > parameters on my mind when working on `hasAnyBase` (it's definitely not 
> > tested) so I'd rather not assume it works.
> I have decided to put `hasType` back in there as it does have some general 
> uses. However I have added more class and class template specific matchers as 
> I feel these are slightly more user friendly. 
> 
> LMK what you think of this approach.
> 
> Side note what is the correct collective term for classes and structs. I'd be 
> tempted to refer to them how clang does, records, but `hasRecord` seems wrong.
> Side note what is the correct collective term for classes and structs. I'd be 
> tempted to refer to them how clang does, records, but hasRecord seems wrong.

We use the term "record", but I'm not certain how widely used that is.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

jkorous wrote:
> Nit: while "[base specifier] `hasType`" sounds natural to me for some reason 
> `hasClass` doesn't. English is not my first language though.
I agree that `hasClass` seems unnatural here. Out of curiosity, could we modify 
the `hasName` matcher to work on base specifiers so you can write: 
`cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more wordy 
version `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v8.3.1

2020-06-11 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: broadwaylamb, sepavloff.
Herald added subscribers: s.egerton, dexonsmith, simoncook, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.
atrosinenko edited the summary of this revision.

This patch updates the toolchain description for MSP430 target, aligning it 
with the TI-provided sysroot based on msp430-gcc v8.3.1.

It leaves some features (such as sanitizer runtimes, LTO, etc.) unsupported, 
trying to translate the remaining parts of the `link_command` spec description 
from current GCC version as closely as possible.

It introduces support for GCC `-msim` option to Clang that simplifies building 
msp430 binaries to be run on a simulator (such as for unit testing purposes).

This patch contains updated unit tests to prevent silent changing of the 
behavior. Its current behavior can be manually tested as follows:

- Compile and run on the simulator: compiles successfully, runs as expected, 
terminates cleanly

  $ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -I 
$sysroot/msp430-elf/include -msim
  $ $sysroot/bin/msp430-elf-run ./test
  N = 1

- Compile for a real MCU: links successfully

  $ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -I 
$sysroot/msp430-elf/include -mmcu=msp430g2553

Current state:

- can run simple programs on a simulator built into msp430-elf-gdb
- can **link** a program by passing just a 
`--sysroot=/path/to/msp430-gcc/binary/distrib` (still requires specifying `-I 
path`)
- **not** yet tested on a real hardware
- may require further adjustment of `--gcc-toolchain` option handling

name=test.c
  #include 
  
  int main()
  {
printf("N = %d\n", 1);
return 0;
  }

References:

- https://clang.llvm.org/docs/CrossCompilation.html
- https://www.ti.com/tool/MSP430-GCC-OPENSOURCE
- cfe-users: --sysroot and --gcc-toolchain: any docs etc.? 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81676

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o
  

[PATCH] D80360: [PCH] Support writing BuiltinBitCastExprs to PCHs

2020-06-11 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95d7ccb70b9c: [PCH] Support writing BuiltinBitCastExprs to 
PCHs (authored by hyd-dev, committed by erik.pilkington).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80360

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/PCH/builtin-bit-cast.cpp


Index: clang/test/PCH/builtin-bit-cast.cpp
===
--- /dev/null
+++ clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U ) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Index: clang/include/clang/Serialization/ASTBitCodes.h
===
--- clang/include/clang/Serialization/ASTBitCodes.h
+++ clang/include/clang/Serialization/ASTBitCodes.h
@@ -1812,6 +1812,9 @@
   /// A CXXFunctionalCastExpr record.
   EXPR_CXX_FUNCTIONAL_CAST,
 
+  /// A BuiltinBitCastExpr record.
+  EXPR_BUILTIN_BIT_CAST,
+
   /// A UserDefinedLiteral record.
   EXPR_USER_DEFINED_LITERAL,
 
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -4821,6 +4821,8 @@
   : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0,
  DstType),
 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
+  BuiltinBitCastExpr(EmptyShell Empty)
+  : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {}
 
   SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }


Index: clang/test/PCH/builtin-bit-cast.cpp
===
--- /dev/null
+++ clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U ) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Index: 

[PATCH] D72781: [Matrix] Add __builtin_matrix_column_load to Clang.

2020-06-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D72781#2084077 , @rjmccall wrote:

> LGTM.


Thank you very much again John! This patch is pending on a few smallish 
improvements to the load/store intrinsics (D81472 
) and I'll land once that one is wrapped up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72781



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


[clang] 95d7ccb - [PCH] Support writing BuiltinBitCastExprs to PCHs

2020-06-11 Thread Erik Pilkington via cfe-commits

Author: hyd-dev
Date: 2020-06-11T13:37:01-04:00
New Revision: 95d7ccb70b9cbd53f1f137c0b2411852c42c122b

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

LOG: [PCH] Support writing BuiltinBitCastExprs to PCHs

eee944e7f adds the new BuiltinBitCastExpr, but does not set the Code member of
ASTStmtWriter. This is not correct and causes an assertion failue in
ASTStmtWriter::emit() when building PCHs that contain __builtin_bit_cast.  This
commit adds serialization::EXPR_BUILTIN_BIT_CAST and handles
ASTStmtWriter::Code properly.

Differential revision: https://reviews.llvm.org/D80360

Added: 
clang/test/PCH/builtin-bit-cast.cpp

Modified: 
clang/include/clang/AST/ExprCXX.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 56b27d57bd5c..379f762275c6 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4821,6 +4821,8 @@ class BuiltinBitCastExpr final
   : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0,
  DstType),
 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
+  BuiltinBitCastExpr(EmptyShell Empty)
+  : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {}
 
   SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }

diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4008f11daa15..c6f9f1d1a08f 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1812,6 +1812,9 @@ class TypeIdx {
   /// A CXXFunctionalCastExpr record.
   EXPR_CXX_FUNCTIONAL_CAST,
 
+  /// A BuiltinBitCastExpr record.
+  EXPR_BUILTIN_BIT_CAST,
+
   /// A UserDefinedLiteral record.
   EXPR_USER_DEFINED_LITERAL,
 

diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index 5c7bc7a57a9f..86895c319ee8 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile ) {
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index 5e445b6f4627..45cd54f8dc9e 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@ void 
ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {

diff  --git a/clang/test/PCH/builtin-bit-cast.cpp 
b/clang/test/PCH/builtin-bit-cast.cpp
new file mode 100644
index ..5755ce965e33
--- /dev/null
+++ b/clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U ) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

We should instead allow bitcast to perform no-op addrspacecasts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670



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


[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic

2020-06-11 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: gbreynoo, jhenderson, probinson.
Herald added a project: clang.

Commit a945037e8fd0c30e250a62211469eea6765a36ae 
 moved the 
printing of the "PLEASE submit a bug report" message to the crash handler, but 
that means we don't print it when forcing a crash using -gen-reproducer. Fix 
this by calling abort inside of a CrashRecoveryContext so we go through the 
crash handler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  clang/tools/driver/driver.cpp


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -511,6 +511,11 @@
   for (const auto  : C->getJobs())
 if (const Command *C = dyn_cast())
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Crash using abort.
+  llvm::CrashRecoveryContext CRC;
+  CRC.DumpStackAndCleanupOnFailure = true;
+  CRC.RunSafely([&]() { abort(); });
 }
 
 for (const auto  : FailingCommands) {
Index: clang/test/Driver/crash-report-null.test
===
--- clang/test/Driver/crash-report-null.test
+++ clang/test/Driver/crash-report-null.test
@@ -3,5 +3,6 @@
 // FIXME: Investigating. "fatal error: file 'nul' modified since it was first 
processed"
 // XFAIL: windows-gnu
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c
Index: clang/test/Driver/crash-report-modules.m
===
--- clang/test/Driver/crash-report-modules.m
+++ clang/test/Driver/crash-report-modules.m
@@ -19,6 +19,7 @@
 @import simple;
 const int x = MODULE_MACRO;
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
Index: clang/test/Driver/crash-report-crashfile.m
===
--- clang/test/Driver/crash-report-crashfile.m
+++ clang/test/Driver/crash-report-crashfile.m
@@ -18,6 +18,7 @@
 const int x = MODULE_MACRO;
 
 // CRASH_ENV: failing because environment variable 
'FORCE_CLANG_DIAGNOSTICS_CRASH' is set
+// CRASH_ENV: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CRASH_ENV: Preprocessed source(s) and associated run script(s) are located 
at:
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.m
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.cache
@@ -26,6 +27,7 @@
 // CRASH_ENV-NEXT: note: diagnostic msg: 
{{.*}}Library/Logs/DiagnosticReports{{.*}}
 
 // CRASH_FLAG: failing because '-gen-reproducer' is used
+// CRASH_FLAG: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CRASH_FLAG: Preprocessed source(s) and associated run script(s) are located 
at:
 // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.m
 // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.cache


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -511,6 +511,11 @@
   for (const auto  : C->getJobs())
 if (const Command *C = dyn_cast())
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Crash using abort.
+  llvm::CrashRecoveryContext CRC;
+  CRC.DumpStackAndCleanupOnFailure = true;
+  CRC.RunSafely([&]() { abort(); });
 }
 
 for (const auto  : FailingCommands) {
Index: clang/test/Driver/crash-report-null.test
===
--- clang/test/Driver/crash-report-null.test
+++ clang/test/Driver/crash-report-null.test
@@ -3,5 +3,6 @@
 // FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed"
 // XFAIL: windows-gnu
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c
Index: clang/test/Driver/crash-report-modules.m
===
--- clang/test/Driver/crash-report-modules.m
+++ 

[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 270177.
hliao added a comment.

Revise the formatting.

Updating D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.
===

[SROA] Teach SROA to recognize no-op addrspacecast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/SROA/noop-addrspacecast.ll

Index: llvm/test/Transforms/SROA/noop-addrspacecast.ll
===
--- /dev/null
+++ llvm/test/Transforms/SROA/noop-addrspacecast.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -o - -sroa %s | FileCheck %s
+; RUN: opt -S -o - -passes=sroa %s | FileCheck %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+target triple = "amdgcn-amd-amdhsa"
+
+; CHECK-LABEL: @noop_addrspacecast(
+; CHECK-NEXT: = addrspacecast i32 addrspace(1)* %{{.*}} to i32*
+; CHECK-NEXT: store i32 0, i32* %{{.*}}
+; CHECK-NEXT: ret void
+define void @noop_addrspacecast(i32 addrspace(1)* %x.coerce) {
+  %x = alloca i32*, align 8, addrspace(5)
+  %x1 = addrspacecast i32* addrspace(5)* %x to i32**
+  %x2 = bitcast i32** %x1 to i32 addrspace(1)**
+  store i32 addrspace(1)* %x.coerce, i32 addrspace(1)** %x2
+  %x3 = load i32*, i32** %x1
+  store i32 0, i32* %x3
+  ret void
+}
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -123,15 +123,15 @@
 ; CHECK-O-NEXT: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run.
 ; CHECK-O-NEXT: Running pass: SROA
-; These next two can appear in any order since they are accessed as parameters
+; These next three can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
+; CHECK-O1-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-O2-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Os-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Oz-DAG: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on foo
 ; CHECK-O-DAG: Running analysis: AssumptionAnalysis on foo
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
-; CHECK-O1-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-O2-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Os-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Oz-NEXT: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-NEXT: Running analysis: MemorySSAAnalysis
 ; CHECK-O23SZ-NEXT: Running pass: SpeculativeExecutionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/PtrUseVisitor.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
@@ -1677,7 +1678,9 @@
 /// ensure that we only try to convert viable values. The strategy is that we
 /// will peel off single element struct and array wrappings to get to an
 /// underlying value, and convert that value.
-static bool canConvertValue(const DataLayout , Type *OldTy, Type *NewTy) {
+static bool canConvertValue(const DataLayout ,
+const TargetTransformInfo , Type *OldTy,
+Type *NewTy) {
   if (OldTy == NewTy)
 return true;
 
@@ -1703,8 +1706,11 @@
   NewTy = NewTy->getScalarType();
   if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
 if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
-  return cast(NewTy)->getPointerAddressSpace() ==
-cast(OldTy)->getPointerAddressSpace();
+  // Pointers are convertible if they have the same address space or that
+  // address space casting is a no-op.
+  unsigned OldAS = cast(OldTy)->getPointerAddressSpace();
+  unsigned NewAS = cast(NewTy)->getPointerAddressSpace();
+  return OldAS == NewAS || TTI.isNoopAddrSpaceCast(OldAS, NewAS);
 }
 
 // 

[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Reproducer for the regression. 
https://gist.github.com/Artem-B/183e9cfc28c6b04c1c862c853b5d9575
It's not particularly small, but that's as far as I could get it reduced.

With the patch, an attempt to instantiate `ag` on line 36 (in the reproducer 
sources I linked to above) results in ambiguity between two templates on lines 
33 and 24 that are in different namespaces.
Previously it picked the template on line 28.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80450



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: arsenm, chandlerc.
Herald added subscribers: llvm-commits, cfe-commits, kerbowa, dexonsmith, 
steven_wu, hiraditya, nhaehnle, wdng, jvesely.
Herald added projects: clang, LLVM.

So far, SROA could only handle convertible pointer pairs if they are in the
same address space. Just like no-op cast, a no-op `addrspacecast` also changes
no bits, it could also be used to convert pointer pairs from different address
spaces. That benefits `infer-address-spaces` pass to propagate address spaces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81670

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/SROA/noop-addrspacecast.ll

Index: llvm/test/Transforms/SROA/noop-addrspacecast.ll
===
--- /dev/null
+++ llvm/test/Transforms/SROA/noop-addrspacecast.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -o - -sroa %s | FileCheck %s
+; RUN: opt -S -o - -passes=sroa %s | FileCheck %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+target triple = "amdgcn-amd-amdhsa"
+
+; CHECK-LABEL: @noop_addrspacecast(
+; CHECK-NEXT: = addrspacecast i32 addrspace(1)* %{{.*}} to i32*
+; CHECK-NEXT: store i32 0, i32* %{{.*}}
+; CHECK-NEXT: ret void
+define void @noop_addrspacecast(i32 addrspace(1)* %x.coerce) {
+  %x = alloca i32*, align 8, addrspace(5)
+  %x1 = addrspacecast i32* addrspace(5)* %x to i32**
+  %x2 = bitcast i32** %x1 to i32 addrspace(1)**
+  store i32 addrspace(1)* %x.coerce, i32 addrspace(1)** %x2
+  %x3 = load i32*, i32** %x1
+  store i32 0, i32* %x3
+  ret void
+}
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -123,15 +123,15 @@
 ; CHECK-O-NEXT: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run.
 ; CHECK-O-NEXT: Running pass: SROA
-; These next two can appear in any order since they are accessed as parameters
+; These next three can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
+; CHECK-O1-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-O2-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Os-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Oz-DAG: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on foo
 ; CHECK-O-DAG: Running analysis: AssumptionAnalysis on foo
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
-; CHECK-O1-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-O2-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Os-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Oz-NEXT: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-NEXT: Running analysis: MemorySSAAnalysis
 ; CHECK-O23SZ-NEXT: Running pass: SpeculativeExecutionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/PtrUseVisitor.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
@@ -1677,7 +1678,9 @@
 /// ensure that we only try to convert viable values. The strategy is that we
 /// will peel off single element struct and array wrappings to get to an
 /// underlying value, and convert that value.
-static bool canConvertValue(const DataLayout , Type *OldTy, Type *NewTy) {
+static bool canConvertValue(const DataLayout ,
+const TargetTransformInfo , Type *OldTy,
+Type *NewTy) {
   if (OldTy == NewTy)
 return true;
 
@@ -1703,8 +1706,11 @@
   NewTy = NewTy->getScalarType();
   if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
 if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
-  return cast(NewTy)->getPointerAddressSpace() ==
-cast(OldTy)->getPointerAddressSpace();
+  // Pointers are convertible if they have the same address space or that
+  // address space casting is a no-op.
+ 

[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D81407#2087624 , @balazske wrote:

> - Report every path of resource leak.


I thought we agreed on the uniqueing being great?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:524
+  CallConv))
+return;
   EVT ValueVT = Val.getValueType();

efriedma wrote:
> pratlucas wrote:
> > efriedma wrote:
> > > I'm not sure I understand why the standard 
> > > getCopyFromParts/getCopyToParts codepath doesn't work. Is the issue that 
> > > it uses FP_ROUND/FP_EXTEND to promote from f16 to f32?
> > Yes, the issue is the usage of FP_ROUND/FP_EXTEND indeed. Those cause the 
> > argument to be converted from f16 into f32 - with a `vcvtb.f16.f32` for 
> > instance - instead of simply being placed the value in the LSBs as required 
> > by the AAPCS.
> That makes sense.
> 
> It feels a little weird to have a TLI method to do the splitting, as opposed 
> to adding an extra check to the shared codepath, but I guess this way is more 
> flexible if someone else needs a similar change in the future.
> 
> One other thing to consider is that we could make f16 a "legal" type for all 
> ARM subtargets with floating-point registers, regardless of whether the 
> target actually has native f16 arithmetic instructions. We do this on 
> AArch64.  That would reduce the number of different ways to handle f16 
> values, and I think this change would be unnecessary.
> One other thing to consider is that we could make f16 a "legal" type for all 
> ARM subtargets with floating-point registers, regardless of whether the 
> target actually has native f16 arithmetic instructions. We do this on AArch64.

I am partly guilty here and there when I added _Float16 and v8.2 FP16 support. 
When I did this, life was easy for AArch64, because it doesn't have a soft 
float ABI support and it has or hasn't got FP16 support, and so everything is 
straightforward. Life became an awful lot less pleasant for AArch32, because of 
the hard/soft float and different FP16 support, i.e. there are early FPU 
versions with limited fp16 support for the storage only type (some conversion), 
and from v8.2 and up the native fp16 instruction. It's been a few years now so 
can't remember exactly, which is a bit unhelpful,  but somewhere here for these 
corner cases I got into trouble by treating f16 as a legal type.

But in case you're interested / this might be useful, I think this is the mail 
that I wrote to the llvm dev list when I got into trouble here (which I 
actually need to reread too for details):

http://lists.llvm.org/pipermail/llvm-dev/2018-January/120537.html

and as referred in that mail, earlier revisions of this:

https://reviews.llvm.org/D38315

might have taken exactly that approach. Long story short, I am not saying we 
shouldn't do it, just pointing out some background info. And since we're all a 
few years wiser now since that happened, perhaps we should try again ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D81223#2087660 , @rcorcs wrote:

> The way I see it, with size level for LTO, we could have a different LTO 
> optimization pipeline for size or runtime performance.


So this is the important point to settle before going on with any patch: this 
isn't how LTO is setup today.

>   For example, we could have a different tuning for inlining,  vectorization, 
> etc. 

All these are covered by the function attributes already.

> We could also use the size level to automatically enable optimizations such 
> as HotColdSplitting, MergeFunctions, etc., instead of relying on specific 
> enabling flags. We could also have other size-specific optimizations in the 
> future, such as MergeSimilarFunctions (https://reviews.llvm.org/D52896).

All these could be in the LTO pipeline and driven by the attribute as well.

> I believe that function attributes for size are useful for optimizing cold 
> functions that have been outlined by HotColdSplitting, for example.

The attribute is added by the frontend and can change per translation-unit / 
per function though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hi, you can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` 
with the following script

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. You should keep the 
tag. (I have updated my script to use `--date=now` (setting author date to 
committer date))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added inline comments.



Comment at: llvm/include/llvm/IR/PassManager.h:413
 
+/// LLVM-provided high-level optimization levels.
+///

I think this change - moving OptimizationLevel out - should be in its own 
patch, to avoid noise.



Comment at: llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h:22
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/LTO/LTO.h"

It's unfortunate we now need to pull pass management into places that didn't 
have that dependency. IIUC, the goal of this overall effort includes piping 
though the full user-requested optimization parameters (i.e. both speed and 
size). Given the likely diversity of the consumers, it may make sense to move 
OptimizationLevel in its own header?



Comment at: llvm/tools/opt/CMakeLists.txt:20
   ObjCARCOpts
+  Passes
   Remarks

Nit: make this change separately, and since it's just a style change, it can 
probably be just submitted with no review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D78024: [FileCheck] - Fix the false positive when -implicit-check-not is used with an unknown -check-prefix.

2020-06-11 Thread Xing GUO via Phabricator via cfe-commits
Higuoxing added a comment.
Herald added a project: LLVM.

> btw, do you know why FileCheck seems intentionally allows the case when 
> --check-prefixes=KNOWN,UNKNOWN?
>  I've mentioned in the description of D78110 
>  that there are about 1000 tests that have 
> this. but is it a feature or a something that we might want to fix?>

I noticed this strange behavior of `FileCheck` as well. When I try to fix it, 
there are lots of test failures. /subscribe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78024



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 270161.
balazske added a comment.

- Added tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -139,7 +139,7 @@
   if (!p)
 return;
   if(c)
-return; // expected-warning {{Opened File never closed. Potential Resource leak}}
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
   fclose(p);
 }
 
@@ -240,3 +240,26 @@
   fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
   fclose(F);
 }
+
+int Test;
+_Noreturn void handle_error();
+
+void check_leak_noreturn_1() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+handle_error(); // no warning
+  }
+  rewind(F1);
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
+
+void check_leak_noreturn_2() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
+  }
+  rewind(F1);
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
Index: clang/test/Analysis/stream-note.c
===
--- /dev/null
+++ clang/test/Analysis/stream-note.c
@@ -0,0 +1,48 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -analyzer-output text -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void check_note_at_correct_open() {
+  FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  FILE *F2 = tmpfile();
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  rewind(F2);
+  fclose(F2);
+  rewind(F1);
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_fopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_freopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -216,8 +216,8 @@
   "Read function called when stream is in EOF state. "
   "Function has no effect."};
   BuiltinBug BT_ResourceLeak{
-  this, "Resource Leak",
-  "Opened File never closed. Potential Resource leak."};
+  this, "Resource leak",
+  "Opened stream never closed. Potential resource leak."};
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -365,6 +365,20 @@
 
 return FnDescriptions.lookup(Call);
   }
+
+  /// Generate a message for BugReporterVisitor if the stored symbol is
+  /// marked as interesting by the actual bug report.
+  struct NoteFn {
+SymbolRef StreamSym;
+std::string Message;
+
+std::string operator()(PathSensitiveBugReport ) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+
+  return "";
+}
+  };
 };
 
 } // end anonymous namespace
@@ -421,7 +435,8 @@
   StateNull =
   StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{RetSym, "Stream opened here"});
+  C.addTransition(StateNotNull, T);
   C.addTransition(StateNull);
 }
 
@@ -476,7 +491,8 @@
   StateRetNull =
   StateRetNull->set(StreamSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateRetNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{StreamSym, "Stream 

[PATCH] D78122: [analyzer][Nullability] Don't emit under the checker name NullabilityBase

2020-06-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

@NoQ Have you unearthed anything on this matter? Do I need to step in/revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78122



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


[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked 4 inline comments as done.
pratlucas added inline comments.



Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:2267
 
+// Mask f16 arguments if this is a CMSE nonsecure call
+auto ArgVT = Outs[realArgIdx].ArgVT;

ostannard wrote:
> Could this be done more efficiently by changing the ANY_EXTEND above to a 
> ZERO_EXTEND when this is a CMSE call?
Now that the `fp16` type convertion on D75169 was updated to use 
`VMOVhr`/`VMOVrh`, I've updated this patch to only use and `AND` masking when 
the argument are extended by `getCopyToParts`/`getCopyFromParts` prior to the 
calling convention lowering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Sorry I haven't had a chance to review this yet. Added @mtrofin who recently 
added the OptimizationLevel class that this is leveraging, and @yamauchi who 
has also been looking at size optimizations in llvm.

At a first glance it isn't clear to me how much of this is NFC related 
refactoring/cleanup vs behavior change. If it has both, it would be helpful to 
split into an NFC patch first and then a follow on with actual behavior 
changes. Can you clarify?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270160.
pratlucas added a comment.

Addressing review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll

Index: llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
===
--- llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
+++ llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
@@ -4,13 +4,13 @@
 ; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
 ; RUN:   FileCheck %s --check-prefix=CHECK-8M --check-prefix=CHECK-8M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-BE
 
 define float @f1(float (float)* nocapture %fptr) #0 {
 ; CHECK-8M-LABEL: f1:
@@ -809,3 +809,443 @@
   ret void
 }
 
+define half @h1(half (half)* nocapture %hptr) "cmse_nonsecure_entry" nounwind {
+; CHECK-8M-LABEL: h1:
+; CHECK-8M:   @ %bb.0:
+; CHECK-8M-NEXT:push {r7, lr}
+; CHECK-8M-NEXT:vldr s0, .LCPI11_0
+; CHECK-8M-NEXT:blx r0
+; CHECK-8M-NEXT:vmov r0, s0
+; CHECK-8M-NEXT:uxth r0, r0
+; CHECK-8M-NEXT:vmov s0, r0
+; CHECK-8M-NEXT:pop.w {r7, lr}
+; CHECK-8M-NEXT:mrs r12, control
+; CHECK-8M-NEXT:tst.w r12, #8
+; CHECK-8M-NEXT:beq .LBB11_2
+; CHECK-8M-NEXT:  @ %bb.1:
+; CHECK-8M-NEXT:vmrs r12, fpscr
+; CHECK-8M-NEXT:vmov s1, lr
+; CHECK-8M-NEXT:vmov d1, lr, lr
+; CHECK-8M-NEXT:vmov d2, lr, lr
+; CHECK-8M-NEXT:vmov d3, lr, lr
+; CHECK-8M-NEXT:vmov d4, lr, lr
+; CHECK-8M-NEXT:vmov d5, lr, lr
+; CHECK-8M-NEXT:vmov d6, lr, lr
+; CHECK-8M-NEXT:vmov d7, lr, lr
+; CHECK-8M-NEXT:bic r12, r12, #159
+; CHECK-8M-NEXT:bic r12, r12, #4026531840
+; CHECK-8M-NEXT:vmsr fpscr, r12
+; CHECK-8M-NEXT:  .LBB11_2:
+; CHECK-8M-NEXT:mov r0, lr
+; CHECK-8M-NEXT:mov r1, lr
+; CHECK-8M-NEXT:mov r2, lr
+; CHECK-8M-NEXT:mov r3, lr
+; CHECK-8M-NEXT:mov r12, lr
+; CHECK-8M-NEXT:msr apsr_nzcvqg, lr
+; CHECK-8M-NEXT:bxns lr
+; CHECK-8M-NEXT:.p2align 2
+; CHECK-8M-NEXT:  @ %bb.3:
+; CHECK-8M-NEXT:  .LCPI11_0:
+; CHECK-8M-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-NO-MVE-LABEL: h1:
+; CHECK-NO-MVE:   @ %bb.0:
+; CHECK-NO-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-NO-MVE-NEXT:push {r7, lr}
+; CHECK-NO-MVE-NEXT:sub sp, #4
+; CHECK-NO-MVE-NEXT:vldr s0, .LCPI11_0
+; CHECK-NO-MVE-NEXT:blx r0
+; CHECK-NO-MVE-NEXT:vmov r0, s0
+; CHECK-NO-MVE-NEXT:uxth r0, r0
+; CHECK-NO-MVE-NEXT:vmov s0, r0
+; CHECK-NO-MVE-NEXT:add sp, #4
+; CHECK-NO-MVE-NEXT:pop.w {r7, lr}
+; CHECK-NO-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-NO-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-NO-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-NO-MVE-NEXT:bxns lr
+; CHECK-NO-MVE-NEXT:.p2align 2
+; CHECK-NO-MVE-NEXT:  @ %bb.1:
+; CHECK-NO-MVE-NEXT:  .LCPI11_0:
+; CHECK-NO-MVE-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-MVE-LABEL: h1:
+; CHECK-MVE:   @ %bb.0:
+; CHECK-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-MVE-NEXT:push {r7, lr}
+; CHECK-MVE-NEXT:sub sp, #4
+; CHECK-MVE-NEXT:vmov.f16 s0, #1.00e+01
+; CHECK-MVE-NEXT:vmov.f16 r1, s0
+; CHECK-MVE-NEXT:vmov s0, r1
+; CHECK-MVE-NEXT:blx r0
+; CHECK-MVE-NEXT:vmov.f16 r0, s0
+; CHECK-MVE-NEXT:vmov s0, r0
+; CHECK-MVE-NEXT:add sp, #4
+; CHECK-MVE-NEXT:pop.w {r7, lr}
+; CHECK-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-MVE-NEXT:bxns lr
+  %call = call half %hptr(half 10.0) nounwind
+  ret half %call
+}
+
+define half @h2(half (half)* nocapture %hptr) nounwind {
+; 

[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270149.
pratlucas added a comment.

Rebasing and simplifying function attributes on test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll

Index: llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
===
--- llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
+++ llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
@@ -4,13 +4,13 @@
 ; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
 ; RUN:   FileCheck %s --check-prefix=CHECK-8M --check-prefix=CHECK-8M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-BE
 
 define float @f1(float (float)* nocapture %fptr) #0 {
 ; CHECK-8M-LABEL: f1:
@@ -809,3 +809,443 @@
   ret void
 }
 
+define half @h1(half (half)* nocapture %hptr) "cmse_nonsecure_entry" nounwind {
+; CHECK-8M-LABEL: h1:
+; CHECK-8M:   @ %bb.0:
+; CHECK-8M-NEXT:push {r7, lr}
+; CHECK-8M-NEXT:vldr s0, .LCPI11_0
+; CHECK-8M-NEXT:blx r0
+; CHECK-8M-NEXT:vmov r0, s0
+; CHECK-8M-NEXT:uxth r0, r0
+; CHECK-8M-NEXT:vmov s0, r0
+; CHECK-8M-NEXT:pop.w {r7, lr}
+; CHECK-8M-NEXT:mrs r12, control
+; CHECK-8M-NEXT:tst.w r12, #8
+; CHECK-8M-NEXT:beq .LBB11_2
+; CHECK-8M-NEXT:  @ %bb.1:
+; CHECK-8M-NEXT:vmrs r12, fpscr
+; CHECK-8M-NEXT:vmov s1, lr
+; CHECK-8M-NEXT:vmov d1, lr, lr
+; CHECK-8M-NEXT:vmov d2, lr, lr
+; CHECK-8M-NEXT:vmov d3, lr, lr
+; CHECK-8M-NEXT:vmov d4, lr, lr
+; CHECK-8M-NEXT:vmov d5, lr, lr
+; CHECK-8M-NEXT:vmov d6, lr, lr
+; CHECK-8M-NEXT:vmov d7, lr, lr
+; CHECK-8M-NEXT:bic r12, r12, #159
+; CHECK-8M-NEXT:bic r12, r12, #4026531840
+; CHECK-8M-NEXT:vmsr fpscr, r12
+; CHECK-8M-NEXT:  .LBB11_2:
+; CHECK-8M-NEXT:mov r0, lr
+; CHECK-8M-NEXT:mov r1, lr
+; CHECK-8M-NEXT:mov r2, lr
+; CHECK-8M-NEXT:mov r3, lr
+; CHECK-8M-NEXT:mov r12, lr
+; CHECK-8M-NEXT:msr apsr_nzcvqg, lr
+; CHECK-8M-NEXT:bxns lr
+; CHECK-8M-NEXT:.p2align 2
+; CHECK-8M-NEXT:  @ %bb.3:
+; CHECK-8M-NEXT:  .LCPI11_0:
+; CHECK-8M-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-NO-MVE-LABEL: h1:
+; CHECK-NO-MVE:   @ %bb.0:
+; CHECK-NO-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-NO-MVE-NEXT:push {r7, lr}
+; CHECK-NO-MVE-NEXT:sub sp, #4
+; CHECK-NO-MVE-NEXT:vldr s0, .LCPI11_0
+; CHECK-NO-MVE-NEXT:blx r0
+; CHECK-NO-MVE-NEXT:vmov r0, s0
+; CHECK-NO-MVE-NEXT:uxth r0, r0
+; CHECK-NO-MVE-NEXT:vmov s0, r0
+; CHECK-NO-MVE-NEXT:add sp, #4
+; CHECK-NO-MVE-NEXT:pop.w {r7, lr}
+; CHECK-NO-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-NO-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-NO-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-NO-MVE-NEXT:bxns lr
+; CHECK-NO-MVE-NEXT:.p2align 2
+; CHECK-NO-MVE-NEXT:  @ %bb.1:
+; CHECK-NO-MVE-NEXT:  .LCPI11_0:
+; CHECK-NO-MVE-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-MVE-LABEL: h1:
+; CHECK-MVE:   @ %bb.0:
+; CHECK-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-MVE-NEXT:push {r7, lr}
+; CHECK-MVE-NEXT:sub sp, #4
+; CHECK-MVE-NEXT:vmov.f16 s0, #1.00e+01
+; CHECK-MVE-NEXT:vmov.f16 r1, s0
+; CHECK-MVE-NEXT:vmov s0, r1
+; CHECK-MVE-NEXT:blx r0
+; CHECK-MVE-NEXT:vmov.f16 r0, s0
+; CHECK-MVE-NEXT:vmov s0, r0
+; CHECK-MVE-NEXT:add sp, #4
+; CHECK-MVE-NEXT:pop.w {r7, lr}
+; CHECK-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-MVE-NEXT:bxns lr
+  %call = call half %hptr(half 10.0) nounwind
+  ret half %call
+}
+
+define half @h2(half (half)* nocapture 

[clang] fac7259 - Revert "[OPENMP50]Codegen for scan directive in simd loops."

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T11:22:51-04:00
New Revision: fac7259c81671c37140374f3e6ec1fc7472c677c

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

LOG: Revert "[OPENMP50]Codegen for scan directive in simd loops."

This reverts commit fb80e67f10eea7177b0ff9c618c8231363b6f2fc to resolve
the issue with asan buildbots.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 
clang/test/OpenMP/scan_codegen.cpp



diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 1bdb1672b2f4..e9569d4e5658 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2083,15 +2083,6 @@ void CodeGenFunction::EmitOMPSimdInit(const 
OMPLoopDirective ,
   if (const auto *C = D.getSingleClause())
 if (C->getKind() == OMPC_ORDER_concurrent)
   LoopStack.setParallel(/*Enable=*/true);
-  if ((D.getDirectiveKind() == OMPD_simd ||
-   (getLangOpts().OpenMPSimd &&
-isOpenMPSimdDirective(D.getDirectiveKind( &&
-  llvm::any_of(D.getClausesOfKind(),
-   [](const OMPReductionClause *C) {
- return C->getModifier() == OMPC_REDUCTION_inscan;
-   }))
-// Disable parallel access in case of prefix sum.
-LoopStack.setParallel(/*Enable=*/false);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(
@@ -2287,8 +2278,6 @@ static void emitOMPSimdRegion(CodeGenFunction , const 
OMPLoopDirective ,
 }
 
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective ) {
-  ParentLoopDirectiveForScanRegion ScanRegion(*this, S);
-  OMPFirstScanLoop = true;
   auto & = [](CodeGenFunction , PrePostActionTy ) {
 emitOMPSimdRegion(CGF, S, Action);
   };
@@ -4210,15 +4199,14 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective ) {
 }
 
 void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective ) {
-  if (!OMPParentLoopDirectiveForScan)
+  // Do not emit code for non-simd directives in simd-only mode.
+  if (getLangOpts().OpenMPSimd && !OMPParentLoopDirectiveForScan)
 return;
   const OMPExecutableDirective  = *OMPParentLoopDirectiveForScan;
-  bool IsInclusive = S.hasClausesOfKind();
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector LHSs;
   SmallVector RHSs;
-  SmallVector ReductionOps;
   SmallVector CopyOps;
   SmallVector CopyArrayTemps;
   SmallVector CopyArrayElems;
@@ -4229,109 +4217,13 @@ void CodeGenFunction::EmitOMPScanDirective(const 
OMPScanDirective ) {
 Privates.append(C->privates().begin(), C->privates().end());
 LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
 RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
-ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
 CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
 CopyArrayElems.append(C->copy_array_elems().begin(),
   C->copy_array_elems().end());
   }
-  if (ParentDir.getDirectiveKind() == OMPD_simd ||
-  (getLangOpts().OpenMPSimd &&
-   isOpenMPSimdDirective(ParentDir.getDirectiveKind( {
-// For simd directive and simd-based directives in simd only mode, use the
-// following codegen:
-// int x = 0;
-// #pragma omp simd reduction(inscan, +: x)
-// for (..) {
-//   
-//   #pragma omp scan inclusive(x)
-//   
-//  }
-// is transformed to:
-// int x = 0;
-// for (..) {
-//   int x_priv = 0;
-//   
-//   x = x_priv + x;
-//   x_priv = x;
-//   
-// }
-// and
-// int x = 0;
-// #pragma omp simd reduction(inscan, +: x)
-// for (..) {
-//   
-//   #pragma omp scan exclusive(x)
-//   
-// }
-// to
-// int x = 0;
-// for (..) {
-//   int x_priv = 0;
-//   
-//   int temp = x;
-//   x = x_priv + x;
-//   x_priv = temp;
-//   
-// }
-llvm::BasicBlock *OMPScanReduce = createBasicBlock("omp.inscan.reduce");
-EmitBranch(IsInclusive
-   ? OMPScanReduce
-   : BreakContinueStack.back().ContinueBlock.getBlock());
-EmitBlock(OMPScanDispatch);
-{
-  // New scope for correct construction/destruction of temp variables for
-  // exclusive scan.
-  LexicalScope Scope(*this, S.getSourceRange());
-  EmitBranch(IsInclusive ? OMPBeforeScanBlock : OMPAfterScanBlock);
-  EmitBlock(OMPScanReduce);
-  if (!IsInclusive) {
-// Create temp var and copy LHS value to this temp value.
-// TMP = LHS;
-for (unsigned I = 0, E = CopyArrayElems.size(); I < E; ++I) {
-  const Expr 

[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Rodrigo Caetano Rocha via Phabricator via cfe-commits
rcorcs added a comment.

The way I see it, with size level for LTO, we could have a different LTO 
optimization pipeline for size or runtime performance. For example, we could 
have a different tuning for inlining,  vectorization, etc. We could also use 
the size level to automatically enable optimizations such as HotColdSplitting, 
MergeFunctions, etc., instead of relying on specific enabling flags. We could 
also have other size-specific optimizations in the future, such as 
MergeSimilarFunctions (https://reviews.llvm.org/D52896).

I believe that function attributes for size are useful for optimizing cold 
functions that have been outlined by HotColdSplitting, for example. However, an 
ideal size level LTO would involve a different optimization pipeline and also a 
different tuning of those optimizations.

For example, when optimizing for size, we could disable loop vectorization and 
have SLP optimizing based on the code-size cost model. We could also have 
MergeFunctions enabled with Os and both MergeFunctions and 
MergeSimilarFunctions enabled with Oz. A similar logic could be applied to 
other optimizations, such as Inlining, HotColdSplitting, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270143.
pratlucas added a comment.

Fixing failure on CodeGen/ARM/GlobalISel/arm-unsupported.ll and making 
clang-format happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/ARM/ARMCallLowering.cpp
  llvm/lib/Target/ARM/ARMCallingConv.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/test/CodeGen/ARM/GlobalISel/arm-unsupported.ll
  llvm/test/CodeGen/ARM/fp16-args.ll
  llvm/test/CodeGen/ARM/fp16-bitcast.ll
  llvm/test/CodeGen/ARM/fp16-promote.ll
  llvm/test/CodeGen/ARM/fp16-vminmaxnm-safe.ll
  llvm/test/CodeGen/ARM/vecreduce-fadd-legalization-strict.ll
  llvm/test/CodeGen/ARM/vecreduce-fmul-legalization-strict.ll
  llvm/test/CodeGen/Thumb2/mve-shuffle.ll
  llvm/test/CodeGen/Thumb2/mve-vdup.ll
  llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll

Index: llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
===
--- llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
+++ llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
@@ -78,7 +78,6 @@
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 ; CHECK-NEXT:.p2align 1
 ; CHECK-NEXT:  @ %bb.1:
@@ -103,7 +102,6 @@
 ; CHECK-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -125,7 +123,6 @@
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-FP-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v16f16:
@@ -169,7 +166,6 @@
 ; CHECK-NOFP-NEXT:vminnm.f16 s8, s8, s10
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s4
 ; CHECK-NOFP-NEXT:vminnm.f16 s0, s8, s0
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v16f16(<16 x half> %x)
@@ -309,20 +305,20 @@
 define arm_aapcs_vfpcc half @fmin_v4f16_nofast(<4 x half> %x) {
 ; CHECK-FP-LABEL: fmin_v4f16_nofast:
 ; CHECK-FP:   @ %bb.0: @ %entry
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v4f16_nofast:
 ; CHECK-NOFP:   @ %bb.0: @ %entry
-; CHECK-NOFP-NEXT:vmov r1, s1
+; CHECK-NOFP-NEXT:vmov r0, s1
 ; CHECK-NOFP-NEXT:vmovx.f16 s10, s0
-; CHECK-NOFP-NEXT:vdup.32 q1, r1
+; CHECK-NOFP-NEXT:vdup.32 q1, r0
 ; CHECK-NOFP-NEXT:vmovx.f16 s8, s4
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s10
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
@@ -333,7 +329,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v4f16(<4 x half> %x)
@@ -346,13 +341,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v8f16_nofast:
@@ -384,7 +379,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -398,13 +392,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, 

[PATCH] D81658: [OPENMP50]Codegen for scan directive in for simd regions.

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Added codegen for scan directives in parallel for regions.

Emits the code for the directive with inscan reductions.
Original code:

   #pragma omp for simd reduction(inscan, op : ...)
  for(...) {
;
#pragma omp scan (in)exclusive(...)

  }

is transformed to something:

  size num_iters = ;
   buffer[num_iters];
   #pragma omp for simd
  for (i: 0..) {
;
buffer[i] = red;
  }
   #pragma omp barrier
  for (int k = 0; k != ceil(log2(num_iters)); ++k)
  for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
   #pragma omp for simd
  for (0..) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81658

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/for_simd_scan_codegen.cpp

Index: clang/test/OpenMP/for_simd_scan_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_simd_scan_codegen.cpp
@@ -0,0 +1,312 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void foo();
+void bar();
+
+// CHECK: define void @{{.*}}baz{{.*}}(i32 %n)
+void baz(int n) {
+  static float a[10];
+  static double b;
+  // CHECK: call i8* @llvm.stacksave()
+  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
+
+  // float a_buffer[10][n];
+  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
+
+  // double b_buffer[10];
+  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+#pragma omp for simd reduction(inscan, +:a[:n], b)
+  for (int i = 0; i < 10; ++i) {
+// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call i8* @llvm.stacksave()
+// CHECK: store float 0.00e+00, float* %
+// CHECK: store double 0.00e+00, double* [[B_PRIV_ADDR:%.+]],
+// CHECK: br label %[[DISPATCH:[^,]+]]
+// CHECK: [[INPUT_PHASE:.+]]:
+// CHECK: call void @{{.+}}foo{{.+}}()
+
+// a_buffer[i][0..n] = a_priv[[0..n];
+// CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
+// CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
+// CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
+// CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
+// CHECK: [[SRC:%.+]] = bitcast float* [[A_PRIV]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
+
+// b_buffer[i] = b_priv;
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
+// CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
+// CHECK: br label %[[LOOP_CONTINUE:.+]]
+
+// CHECK: [[DISPATCH]]:
+// CHECK: br label %[[INPUT_PHASE]]
+// CHECK: [[LOOP_CONTINUE]]:
+// CHECK: call void @llvm.stackrestore(i8* %
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: call void @__kmpc_barrier(
+foo();
+#pragma omp scan inclusive(a[:n], b)
+// CHECK: [[LOG2_10:%.+]] = call double @llvm.log2.f64(double 1.00e+01)
+// CHECK: [[CEIL_LOG2_10:%.+]] = call double @llvm.ceil.f64(double [[LOG2_10]])
+// CHECK: [[CEIL_LOG2_10_INT:%.+]] = fptoui double [[CEIL_LOG2_10]] to i32
+// CHECK: br label %[[OUTER_BODY:[^,]+]]
+// CHECK: [[OUTER_BODY]]:
+// CHECK: [[K:%.+]] = phi i32 [ 0, %{{.+}} ], [ [[K_NEXT:%.+]], %{{.+}} ]
+// CHECK: [[K2POW:%.+]] = phi i64 [ 1, %{{.+}} ], [ [[K2POW_NEXT:%.+]], %{{.+}} ]
+// CHECK: [[CMP:%.+]] = icmp uge i64 9, [[K2POW]]
+// CHECK: br i1 [[CMP]], label %[[INNER_BODY:[^,]+]], label 

[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-11 Thread Benson Chu via Phabricator via cfe-commits
pestctrl updated this revision to Diff 270139.
pestctrl added a comment.

Moved the extension to C11 group


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/complete-incomplete-pointer-relational-c99.c


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return ( < ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( <= ) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( > ) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( >= ) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ ( == ) &&
+ ( != );
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11563,11 +11563,22 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if ((LCanPointeeTy->isIncompleteType() !=
+ RCanPointeeTy->isIncompleteType()) &&
+!getLangOpts().C11) {
+  Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange()
+  << LHSType << RHSType << LCanPointeeTy->isIncompleteType()
+  << RCanPointeeTy->isIncompleteType();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6443,6 +6443,12 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "pointer comparisons before C11 "
+  "need to be between two complete or two incomplete types; "
+  "%0 is %select{|in}2complete and "
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return ( < ) &&  // expected-warning {{pointer comparisons before C11 need to be between two complete or two incomplete types; 'int (*)[]' is incomplete and 'int 

[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-11 Thread Benson Chu via Phabricator via cfe-commits
pestctrl marked an inline comment as done.
pestctrl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6451
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<

rsmith wrote:
> pestctrl wrote:
> > efriedma wrote:
> > > `InGroup`
> > Sorry, I'm not sure I understand. Isn't this a C99 warning? Why is it being 
> > put in the C11 group?
> Because `C11` really means `C11Extensions`, and this is a C11 extension (ie, 
> it's code that's valid in C11 but not valid in C99):
> ```
> // A warning group for warnings about using C11 features as extensions.
> def C11 : DiagGroup<"c11-extensions">;
> ```
Got it, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 270140.
balazske added a comment.

- Report every path of resource leak.
- Do not report if non-returning function was encountered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -139,7 +139,7 @@
   if (!p)
 return;
   if(c)
-return; // expected-warning {{Opened File never closed. Potential Resource leak}}
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
   fclose(p);
 }
 
Index: clang/test/Analysis/stream-note.c
===
--- /dev/null
+++ clang/test/Analysis/stream-note.c
@@ -0,0 +1,48 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -analyzer-output text -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void check_note_at_correct_open() {
+  FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  FILE *F2 = tmpfile();
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  rewind(F2);
+  fclose(F2);
+  rewind(F1);
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_fopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_freopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -216,8 +216,8 @@
   "Read function called when stream is in EOF state. "
   "Function has no effect."};
   BuiltinBug BT_ResourceLeak{
-  this, "Resource Leak",
-  "Opened File never closed. Potential Resource leak."};
+  this, "Resource leak",
+  "Opened stream never closed. Potential resource leak."};
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -365,6 +365,20 @@
 
 return FnDescriptions.lookup(Call);
   }
+
+  /// Generate a message for BugReporterVisitor if the stored symbol is
+  /// marked as interesting by the actual bug report.
+  struct NoteFn {
+SymbolRef StreamSym;
+std::string Message;
+
+std::string operator()(PathSensitiveBugReport ) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+
+  return "";
+}
+  };
 };
 
 } // end anonymous namespace
@@ -421,7 +435,8 @@
   StateNull =
   StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{RetSym, "Stream opened here"});
+  C.addTransition(StateNotNull, T);
   C.addTransition(StateNull);
 }
 
@@ -476,7 +491,8 @@
   StateRetNull =
   StateRetNull->set(StreamSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateRetNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{StreamSym, "Stream reopened here"});
+  C.addTransition(StateRetNotNull, T);
   C.addTransition(StateRetNull);
 }
 
@@ -921,8 +937,17 @@
 if (!N)
   continue;
 
-C.emitReport(std::make_unique(
-BT_ResourceLeak, BT_ResourceLeak.getDescription(), N));
+// Do not warn for non-closed stream at program exit.
+ExplodedNode *Pred = C.getPredecessor();
+if (Pred && Pred->getCFGBlock() &&
+Pred->getCFGBlock()->hasNoReturnElement())
+  continue;
+
+std::unique_ptr R =
+std::make_unique(
+BT_ResourceLeak, BT_ResourceLeak.getDescription(), N);
+

[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon marked 2 inline comments as done.
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:216
+  if (getLangOpts().SYCLIsDevice)
+if (auto VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)

riccibruno wrote:
> Nit: The convention is `auto *VD`.
Fixed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D81311#2086326 , @rjmccall wrote:

> In D81311#2086227 , @jdoerfert wrote:
>
> > Do we allow `inmem` to be used for other purposes? I would assume the 
> > answer is yes, as we do not forbid it.
>
>
> I don't know what else we might use it for off-hand, but yes, I think the 
> frontend could put this down on all value arguments that are actually passed 
> indirectly.


Where does it say it is limited to indirectly passed arguments?


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

https://reviews.llvm.org/D81311



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 270135.
Fznamznon added a comment.

Fixed code style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+template 
+__attribute__((sycl_kernel))
+// expected-note@+2 2{{called by}}
+void
+kernel_single_task(Func kernelFunc) { kernelFunc(); }
+
+int main() {
+  // expected-note@+1 2{{called by}}
+  kernel_single_task([]() { usage(); });
+  return 0;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -212,6 +212,11 @@
  bool ObjCPropertyAccess,
  bool AvoidPartialAvailabilityChecks,
  ObjCInterfaceDecl *ClassReceiver) {
+  if (getLangOpts().SYCLIsDevice)
+if (auto *VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)
+SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_thread_unsupported);
+
   SourceLocation Loc = Locs.front();
   if (getLangOpts().CPlusPlus && isa(D)) {
 // If there were any diagnostics suppressed by template argument deduction,
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7077,7 +7077,8 @@
diag::err_thread_non_global)
 << DeclSpec::getSpecifierName(TSCS);
 else if (!Context.getTargetInfo().isTLSSupported()) {
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 // Postpone error emission until we've collected attributes required to
 // figure out whether it's a host or device variable and whether the
 // error should be ignored.
@@ -7179,13 +7180,17 @@
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 if (EmitTLSUnsupportedError &&
 ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) ||
  (getLangOpts().OpenMPIsDevice &&
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
+
+if (EmitTLSUnsupportedError && getLangOpts().SYCLIsDevice)
+  SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static
 // storage [duration]."
 if (SC == SC_None && S->getFnParent() != nullptr &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90b54fa045e3: [OPENMP50]Codegen for use_device_addr clauses. 
(authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D80730?vs=269618=270131#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730

Files:
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer
+// 96 = 0x60 = OMP_MAP_TARGET_PARAM | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 96, i64 96, i64 96, i64 96, i64 96]
+// 32 = 0x20 = OMP_MAP_TARGET_PARAM
+// 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 32, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720]
+struct S {
+  int a = 0;
+  int *ptr = 
+  int  = a;
+  int arr[4];
+  S() {}
+  void foo() {
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a])
+++a, ++*ptr, ++ref, ++arr[0];
+  }
+};
+
+int main() {
+  float a = 0;
+  float *ptr = 
+  float  = a;
+  float arr[4];
+  float vla[(int)a];
+  S s;
+  s.foo();
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0])
+  ++a, ++*ptr, ++ref, ++arr[0], ++vla[0];
+  return a;
+}
+
+// CHECK-LABEL: @main()
+// CHECK: [[A_ADDR:%.+]] = alloca float,
+// CHECK: [[PTR_ADDR:%.+]] = alloca float*,
+// CHECK: [[REF_ADDR:%.+]] = alloca float*,
+// CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float],
+// CHECK: [[BPTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[PTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}},
+// CHECK: [[PTR:%.+]] = load float*, float** [[PTR_ADDR]],
+// CHECK: [[REF:%.+]] = load float*, float** [[REF_ADDR]],
+// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[ARR_ADDR]], i64 0, i64 0
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 0
+// CHECK: [[BPTR0_A_ADDR:%.+]] = bitcast i8** [[BPTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[BPTR0_A_ADDR]],
+// CHECK: [[PTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 0
+// CHECK: [[PTR0_A_ADDR:%.+]] = bitcast i8** [[PTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[PTR0_A_ADDR]],
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 1
+// CHECK: [[BPTR1_PTR_ADDR:%.+]] = bitcast i8** [[BPTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[BPTR1_PTR_ADDR]],
+// CHECK: [[PTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 1
+// CHECK: [[PTR1_PTR_ADDR:%.+]] = bitcast i8** [[PTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[PTR1_PTR_ADDR]],
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 2
+// CHECK: [[BPTR2_REF_ADDR:%.+]] = bitcast i8** [[BPTR2]] to float**
+// CHECK: store float* [[REF]], float** [[BPTR2_REF_ADDR]],
+// CHECK: [[PTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 2
+// 

[clang] 90b54fa - [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T09:54:51-04:00
New Revision: 90b54fa045e3f8711e0bfb2d22626b28fd3b131f

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

LOG: [OPENMP50]Codegen for use_device_addr clauses.

Summary:
Added codegen for use_device_addr clause. The components of the list
items are mapped as a kind of RETURN components and then the returned
base address is used instead of the real address of the base declaration
used in the use_device_addr expressions.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Modified: 
clang/lib/AST/OpenMPClause.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 3cb71d3d77bc..6a8b3ce231f2 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1207,8 +1207,8 @@ OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
   Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
 
   // We need to allocate:
-  // 3 x NumVars x Expr* - we have an original list expression for each clause
-  // list entry and an equal number of private copies and inits.
+  // NumVars x Expr* - we have an original list expression for each clause
+  // list entry.
   // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
   // with each component list.
   // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 95b4c81baf9d..d1b1d5c0d911 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7031,7 +7031,7 @@ class MappableExprsHandler {
 OMP_MAP_TARGET_PARAM = 0x20,
 /// Signal that the runtime library has to return the device pointer
 /// in the current position for the data being mapped. Used when we have 
the
-/// use_device_ptr clause.
+/// use_device_ptr or use_device_addr clause.
 OMP_MAP_RETURN_PARAM = 0x40,
 /// This flag signals that the reference being passed is a pointer to
 /// private data.
@@ -7099,26 +7099,30 @@ class MappableExprsHandler {
 ArrayRef MapModifiers;
 bool ReturnDevicePointer = false;
 bool IsImplicit = false;
+bool ForDeviceAddr = false;
 
 MapInfo() = default;
 MapInfo(
 OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
 OpenMPMapClauseKind MapType,
-ArrayRef MapModifiers,
-bool ReturnDevicePointer, bool IsImplicit)
+ArrayRef MapModifiers, bool ReturnDevicePointer,
+bool IsImplicit, bool ForDeviceAddr = false)
 : Components(Components), MapType(MapType), MapModifiers(MapModifiers),
-  ReturnDevicePointer(ReturnDevicePointer), IsImplicit(IsImplicit) {}
+  ReturnDevicePointer(ReturnDevicePointer), IsImplicit(IsImplicit),
+  ForDeviceAddr(ForDeviceAddr) {}
   };
 
-  /// If use_device_ptr is used on a pointer which is a struct member and there
-  /// is no map information about it, then emission of that entry is deferred
-  /// until the whole struct has been processed.
+  /// If use_device_ptr or use_device_addr is used on a decl which is a struct
+  /// member and there is no map information about it, then emission of that
+  /// entry is deferred until the whole struct has been processed.
   struct DeferredDevicePtrEntryTy {
 const Expr *IE = nullptr;
 const ValueDecl *VD = nullptr;
+bool ForDeviceAddr = false;
 
-DeferredDevicePtrEntryTy(const Expr *IE, const ValueDecl *VD)
-: IE(IE), VD(VD) {}
+DeferredDevicePtrEntryTy(const Expr *IE, const ValueDecl *VD,
+ bool ForDeviceAddr)
+: IE(IE), VD(VD), ForDeviceAddr(ForDeviceAddr) {}
   };
 
   /// The target directive from where the mappable clauses were extracted. It
@@ -7306,13 +7310,12 @@ class MappableExprsHandler {
   /// \a IsFirstComponent should be set to true if the provided set of
   /// components is the first associated with a capture.
   void generateInfoForComponentList(
-  OpenMPMapClauseKind MapType,
-  ArrayRef MapModifiers,
+  OpenMPMapClauseKind MapType, ArrayRef 
MapModifiers,
   OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
   MapBaseValuesArrayTy , MapValuesArrayTy ,
   MapValuesArrayTy , MapFlagsArrayTy ,
   StructRangeInfoTy , bool IsFirstComponentList,
-  bool IsImplicit,
+  bool IsImplicit, bool 

[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78e636b3f2f0: [clang][NFC] Generate the 
{Type,ArrayType,UnaryExprOrType,Expression}Traits... (authored by riccibruno).

Changed prior to commit:
  https://reviews.llvm.org/D81455?vs=269467=270121#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81455

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/ExpressionTraits.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeTraits.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/ExpressionTraits.cpp
  clang/lib/Basic/TypeTraits.cpp
  clang/lib/Sema/SemaExpr.cpp

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -3971,7 +3971,7 @@
TraitKind == UETT_PreferredAlignOf)) {
 // sizeof(function)/alignof(function) is allowed as an extension.
 S.Diag(Loc, diag::ext_sizeof_alignof_function_type)
-  << TraitKind << ArgRange;
+<< getTraitSpelling(TraitKind) << ArgRange;
 return false;
   }
 
@@ -3980,7 +3980,7 @@
   if (T->isVoidType()) {
 unsigned DiagID = S.LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
 : diag::ext_sizeof_alignof_void_type;
-S.Diag(Loc, DiagID) << TraitKind << ArgRange;
+S.Diag(Loc, DiagID) << getTraitSpelling(TraitKind) << ArgRange;
 return false;
   }
 
@@ -4059,13 +4059,13 @@
   if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
 if (RequireCompleteSizedType(
 E->getExprLoc(), Context.getBaseElementType(E->getType()),
-diag::err_sizeof_alignof_incomplete_or_sizeless_type, ExprKind,
-E->getSourceRange()))
+diag::err_sizeof_alignof_incomplete_or_sizeless_type,
+getTraitSpelling(ExprKind), E->getSourceRange()))
   return true;
   } else {
 if (RequireCompleteSizedExprType(
-E, diag::err_sizeof_alignof_incomplete_or_sizeless_type, ExprKind,
-E->getSourceRange()))
+E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
+getTraitSpelling(ExprKind), E->getSourceRange()))
   return true;
   }
 
@@ -4075,7 +4075,7 @@
 
   if (ExprTy->isFunctionType()) {
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_function_type)
-  << ExprKind << E->getSourceRange();
+<< getTraitSpelling(ExprKind) << E->getSourceRange();
 return true;
   }
 
@@ -4164,12 +4164,12 @@
 
   if (RequireCompleteSizedType(
   OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
-  ExprKind, ExprRange))
+  getTraitSpelling(ExprKind), ExprRange))
 return true;
 
   if (ExprType->isFunctionType()) {
 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
-  << ExprKind << ExprRange;
+<< getTraitSpelling(ExprKind) << ExprRange;
 return true;
   }
 
Index: clang/lib/Basic/TypeTraits.cpp
===
--- /dev/null
+++ clang/lib/Basic/TypeTraits.cpp
@@ -0,0 +1,86 @@
+//===--- TypeTraits.cpp - Type Traits Support -===//
+//
+// 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 implements the type traits support functions.
+//
+//===--===//
+
+#include "clang/Basic/TypeTraits.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+using namespace clang;
+
+static constexpr const char *TypeTraitNames[] = {
+#define TYPE_TRAIT_1(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_2(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_N(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *TypeTraitSpellings[] = {
+#define TYPE_TRAIT_1(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_2(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_N(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *ArrayTypeTraitNames[] = {
+#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *ArrayTypeTraitSpellings[] = {
+#define 

  1   2   >