[PATCH] D119998: [Clang] Rename `disable-noundef-analysis` flag to `-[no-]enable-noundef-analysis`

2022-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> enable_noundef_analysis

`-enable-noundef-analysis`

If there is a need for an alias `-disable-noundef-analysis`, we can add it 
later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119998

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


[PATCH] D119998: [Clang] Rename `disable-noundef-analysis` flag to `-[no-]enable-noundef-analysis`

2022-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119998

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


[PATCH] D118598: [C++20][Modules][7/8] Find the primary interface name for a module.

2022-02-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Basic/Module.h:527
+}
+return StringRef(Name);
+  }

Here we could return `Name` simply.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118598

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


[PATCH] D118586: [C++20][Modules][3/8] Initial handling for module partitions.

2022-02-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaModule.cpp:177
+  if (IsPartition) {
+ModuleName += ":";
+ModuleName += stringFromPath(Partition);

iains wrote:
> urnathan wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > I chose '-' in my implementation since here ModuleName refers to the 
> > > > name in filesystem, right? And I remember '-' is the choice of GCC. So 
> > > > let's keep consistency.
> > > This is not my understanding.
> > > 
> > > ModuleName is the "user-facing" name of the module that is described in 
> > > the source, and we use this in diagnostics etc.
> > > 
> > > The translation of that name to an on-disk name can be arbitrary and 
> > > there are several mechanisms in clang already (e.g. 
> > > -fmodule-file=A:B=foo.pcm) the module loader uses these to find the 
> > > module on the basis of its user-facing name where required.
> > > 
> > > When we have P1184, it is even more important that the interface is 
> > > supplied with the name that the user will put into the source code.
> > > 
> > > 
> > I agree with Iain, we should use ':' is module names here.  When mapping a 
> > named module to the file system some translation is needed because ':' is 
> > not permitted in file names on some filesystems (you know the ones!)
> (just to expand a little more)
> 
> the on-disk name needs to be chosen suitably for the platform and by the user 
> and/or the build system.
> 
> When the FE chooses a default filename (which is done in building jobs, not 
> in the Parser of course) it chooses one based on the source filename.  It 
> would be most unfortunate if the Parser/Sema needed to understand platform 
> filename rules.
> 
> When you do  'clang -module-file-info' (with the existing or updated version) 
> you should see the module name as per the source code, the translation would 
> only apply to the filename itself.
> 
> - to answer a later comment:
> 
> when we do -fmodule-file=A_B.pcm  and A_B.pcm contains a module named A:B the 
> loader notices this pairing when it pre-loads the module, so that when we ask 
> for "A:B" the loader already knows which on-disk file contains. it.
> 
> if we use the HeaderSearch mechanisms (when we want to figure out a 
> module-name<=> filename pairing without loading the module) we can use 
> -fmodule-name=A:B=A_B.pcm,
> 
> These mechanisms work today, but P1184 is a more flexible mechanism and 
> avoids having  massive command lines with many -fmodule-file= cases.
> 
But what if we need to import multiple modules? In our current workflow, we 
would like to compile importing module in following style:
```
clang++ -std=c++20 -fprebuilt-module-path=path1 -fprebuilt-module-path=path2 
... unit.cpp(m) ...
```

And unit.cpp(m) may look like:
```
export module M;
import :parta;
import :partb;
import :partc;
```

And our compiler would lookup `M-parta.pcm`, `M-partb.pcm` and `M-partc.pcm` in 
the path given in the command line. However, in current implementation, it 
would lookup `M:parta.pcm`, `M:partb.pcm` and `M:partc.pcm` in the path but it 
might fail. So my point here is that the current implementation doesn't work 
well with `fprebuilt-module-path`. And I don't think we should give up 
`fprebuilt-module-path` to support multiple `fmodule-file`. The 
`fprebuilt-module-path` is easier to understand and use for real projects. Even 
if we support multiple `-fmodule-file`, people might be frustrating to add many 
`fmodule-file` if they need to import many units.

So I really insist on this. Or at least let's add one option, something like 
`-fmodule-partition-separator` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118586

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


[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-02-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Thanks for explanation. Now it looks good to me. Let's accept it formally after 
the series of partition landed and so that we could add test about partitions.


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

https://reviews.llvm.org/D118352

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


[PATCH] D120084: [clang][DOC] Document module mangler changes

2022-02-17 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D120084

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


[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

Change title
threat state
to
thread state


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

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


[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-17 Thread David Stone via Phabricator via cfe-commits
davidstone added a comment.

In D99134#3331259 , @rsmith wrote:

> Looks good. Do you need someone to land this for you?

Yes, I do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Support/Host.cpp:1320
+  int Error = sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+  assert(!Error && "Fetching hw.cpufamily failed");
 

Not sure this should be an assert? I think other implementations will fall back 
on generic on errors (e.g. the things that read /proc/cpuinfo will use "" on 
error for the file contents and that gets parsed as generic by the various 
default cases).

Also technically you need to check Length is still sizeof(Family) and not 
smaller (the other direction is an error), but nobody ever bothers so meh.



Comment at: llvm/lib/Support/Host.cpp:1326
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:

ARM only calls it cyclone, AArch64 allows both but apple-a7 is the canonical 
name (the comment above the cyclone alias states it's for old bitcode 
compatibility)



Comment at: llvm/lib/Support/Host.cpp:1340
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:

Maybe a question for AArch64 maintainers about whether apple-a14 or apple-m1 
should be used... they're the same thing from the backend's perspective just 
with different names. Shame the naming doesn't separate out the "generation" 
from the specific configuration like you see for other backends (apple-aN is 
almost that as it omits all the bionic etc marketing name fluff, except 
apple-m1 comes along and ruins that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 409850.
jhuber6 added a comment.

Changing assert


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/OpenMP/target_globals_codegen.cpp
  openmp/libomptarget/DeviceRTL/include/Configuration.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp

Index: openmp/libomptarget/DeviceRTL/src/State.cpp
===
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -285,7 +285,8 @@
 #pragma omp allocate(ThreadStates) allocator(omp_pteam_mem_alloc)
 
 uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
-  if (OMP_LIKELY(TeamState.ICVState.LevelVar == 0))
+  if (OMP_LIKELY(!config::mayUseThreadStates() ||
+ TeamState.ICVState.LevelVar == 0))
 return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
   if (!ThreadStates[TId]) {
@@ -299,13 +300,13 @@
 
 uint32_t &lookup32Impl(uint32_t ICVStateTy::*Var) {
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::mayUseThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
 uint64_t &lookup64Impl(uint64_t ICVStateTy::*Var) {
   uint64_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::mayUseThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
@@ -380,6 +381,9 @@
 }
 
 void state::enterDataEnvironment(IdentTy *Ident) {
+  ASSERT(config::mayUseThreadStates() &&
+ "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   ThreadStateTy *NewThreadState =
   static_cast(__kmpc_alloc_shared(sizeof(ThreadStateTy)));
@@ -388,6 +392,9 @@
 }
 
 void state::exitDataEnvironment() {
+  ASSERT(config::mayUseThreadStates() &&
+ "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   resetStateForThread(TId);
 }
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,7 +20,9 @@
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
+// defined by CGOpenMPRuntimeGPU
+extern uint32_t __omp_rtl_debug_kind;
+extern uint32_t __omp_rtl_assume_no_thread_state;
 
 // TODO: We want to change the name as soon as the old runtime is gone.
 // This variable should be visibile to the plugin so we override the default
@@ -48,4 +50,6 @@
   return config::getDebugKind() & Kind;
 }
 
+bool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state; }
+
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Configuration.h
===
--- openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -38,8 +38,13 @@
 /// Return the amount of dynamic shared memory that was allocated at launch.
 uint64_t getDynamicMemorySize();
 
+/// Return if debugging is enabled for the given debug kind.
 bool isDebugMode(DebugKind Level);
 
+/// Indicates if this kernel may require thread-specific states, or if it was
+/// explicitly disabled by the user.
+bool mayUseThreadStates();
+
 } // namespace config
 } // namespace _OMP
 
Index: clang/test/OpenMP/target_globals_codegen.cpp
===
--- clang/test/OpenMP/target_globals_codegen.cpp
+++ clang/test/OpenMP/target_globals_codegen.cpp
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-DEFAULT
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-threads-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-THREADS
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-teams-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-TEAMS
+// RUN: %clang_cc1 -ver

[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Last nit, otherwise LG




Comment at: openmp/libomptarget/DeviceRTL/src/State.cpp:385
+  if (!config::mayUseThreadStates())
+ASSERT(false && "Thread state modified while explicitly disabled!");
+

My bad, should have been
```
ASSERT(config::mayUseThreadStates() && "...").
```
also below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-17 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Thanks for the tips! I left the default as generic here, but I totally take 
your point on defaulting to the newest and I'm happy to update if you feel 
strongly, lmk what you think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

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


[PATCH] D119788: [AArch64] Add support for -march=native for Apple M1 CPU

2022-02-17 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 409849.
keith added a comment.

Update to read CPU from sysctl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119788

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Support/Host.cpp


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,32 +1299,48 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#include 
+#include 
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
+
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  int Error = sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+  assert(!Error && "Fetching hw.cpufamily failed");
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM");
+  switch (Family) {
+  case CPUFAMILY_ARM_SWIFT:
+return "swift";
+  case CPUFAMILY_ARM_CYCLONE:
+return "apple-a7";
+  case CPUFAMILY_ARM_TYPHOON:
+return "apple-a8";
+  case CPUFAMILY_ARM_TWISTER:
+return "apple-a9";
+  case CPUFAMILY_ARM_HURRICANE:
+return "apple-a10";
+  case CPUFAMILY_ARM_MONSOON_MISTRAL:
+return "apple-a11";
+  case CPUFAMILY_ARM_VORTEX_TEMPEST:
+return "apple-a12";
+  case CPUFAMILY_ARM_LIGHTNING_THUNDER:
+return "apple-a13";
+  case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
+return "apple-m1";
+  default:
 return "generic";
   }
-  switch (hostInfo.cpu_subtype) {
-case CPU_SUBTYPE_ARM_V7S:
-  return "swift";
-default:;
-}
-
-  return "generic";
 }
 #elif defined(_AIX)
 StringRef sys::getHostCPUName() {
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -151,6 +151,8 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
+  if (Split.first == "native")
+ArchKind = 
llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
   if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
   !llvm::AArch64::getArchFeatures(ArchKind, Features))
 return false;


Index: llvm/lib/Support/Host.cpp
===
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1299,32 +1299,48 @@
   bool HaveVectorSupport = CVT[244] & 0x80;
   return getCPUNameFromS390Model(Id, HaveVectorSupport);
 }
-#elif defined(__APPLE__) && defined(__aarch64__)
-StringRef sys::getHostCPUName() {
-  return "cyclone";
-}
-#elif defined(__APPLE__) && defined(__arm__)
-StringRef sys::getHostCPUName() {
-  host_basic_info_data_t hostInfo;
-  mach_msg_type_number_t infoCount;
+#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
+#include 
+#include 
 
-  infoCount = HOST_BASIC_INFO_COUNT;
-  mach_port_t hostPort = mach_host_self();
-  host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
-&infoCount);
-  mach_port_deallocate(mach_task_self(), hostPort);
+#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
+#define CPUFAMILY_ARM_CYCLONE 0x37a09642
+#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
+#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
+#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
+#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
+#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
+#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
+#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
+
+StringRef sys::getHostCPUName() {
+  uint32_t Family;
+  size_t Length = sizeof(Family);
+  int Error = sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
+  assert(!Error && "Fetching hw.cpufamily failed");
 
-  if (hostInfo.cpu_type != CPU_TYPE_ARM) {
-assert(false && "CPUType not equal to ARM should not be possible on ARM"

[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 409847.
jhuber6 added a comment.

Change name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/OpenMP/target_globals_codegen.cpp
  openmp/libomptarget/DeviceRTL/include/Configuration.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp

Index: openmp/libomptarget/DeviceRTL/src/State.cpp
===
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -285,7 +285,8 @@
 #pragma omp allocate(ThreadStates) allocator(omp_pteam_mem_alloc)
 
 uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
-  if (OMP_LIKELY(TeamState.ICVState.LevelVar == 0))
+  if (OMP_LIKELY(!config::mayUseThreadStates() ||
+ TeamState.ICVState.LevelVar == 0))
 return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
   if (!ThreadStates[TId]) {
@@ -299,13 +300,13 @@
 
 uint32_t &lookup32Impl(uint32_t ICVStateTy::*Var) {
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::mayUseThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
 uint64_t &lookup64Impl(uint64_t ICVStateTy::*Var) {
   uint64_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::mayUseThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
@@ -380,6 +381,9 @@
 }
 
 void state::enterDataEnvironment(IdentTy *Ident) {
+  if (!config::mayUseThreadStates())
+ASSERT(false && "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   ThreadStateTy *NewThreadState =
   static_cast(__kmpc_alloc_shared(sizeof(ThreadStateTy)));
@@ -388,6 +392,9 @@
 }
 
 void state::exitDataEnvironment() {
+  if (!config::mayUseThreadStates())
+ASSERT(false && "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   resetStateForThread(TId);
 }
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,7 +20,9 @@
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
+// defined by CGOpenMPRuntimeGPU
+extern uint32_t __omp_rtl_debug_kind;
+extern uint32_t __omp_rtl_assume_no_thread_state;
 
 // TODO: We want to change the name as soon as the old runtime is gone.
 // This variable should be visibile to the plugin so we override the default
@@ -48,4 +50,6 @@
   return config::getDebugKind() & Kind;
 }
 
+bool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state; }
+
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Configuration.h
===
--- openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -38,8 +38,13 @@
 /// Return the amount of dynamic shared memory that was allocated at launch.
 uint64_t getDynamicMemorySize();
 
+/// Return if debugging is enabled for the given debug kind.
 bool isDebugMode(DebugKind Level);
 
+/// Indicates if this kernel may require thread-specific states, or if it was
+/// explicitly disabled by the user.
+bool mayUseThreadStates();
+
 } // namespace config
 } // namespace _OMP
 
Index: clang/test/OpenMP/target_globals_codegen.cpp
===
--- clang/test/OpenMP/target_globals_codegen.cpp
+++ clang/test/OpenMP/target_globals_codegen.cpp
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-DEFAULT
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-threads-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-THREADS
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-teams-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-TEAMS
+// RUN: %clan

[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 409845.
jhuber6 added a comment.

Making suggested changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/OpenMP/target_globals_codegen.cpp
  openmp/libomptarget/DeviceRTL/include/Configuration.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp

Index: openmp/libomptarget/DeviceRTL/src/State.cpp
===
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -285,7 +285,8 @@
 #pragma omp allocate(ThreadStates) allocator(omp_pteam_mem_alloc)
 
 uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
-  if (OMP_LIKELY(TeamState.ICVState.LevelVar == 0))
+  if (OMP_LIKELY(!config::requiresThreadStates() ||
+ TeamState.ICVState.LevelVar == 0))
 return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
   if (!ThreadStates[TId]) {
@@ -299,13 +300,13 @@
 
 uint32_t &lookup32Impl(uint32_t ICVStateTy::*Var) {
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::requiresThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
 uint64_t &lookup64Impl(uint64_t ICVStateTy::*Var) {
   uint64_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::requiresThreadStates() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
@@ -380,6 +381,9 @@
 }
 
 void state::enterDataEnvironment(IdentTy *Ident) {
+  if (!config::requiresThreadStates())
+ASSERT(false && "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   ThreadStateTy *NewThreadState =
   static_cast(__kmpc_alloc_shared(sizeof(ThreadStateTy)));
@@ -388,6 +392,9 @@
 }
 
 void state::exitDataEnvironment() {
+  if (!config::requiresThreadStates())
+ASSERT(false && "Thread state modified while explicitly disabled!");
+
   unsigned TId = mapping::getThreadIdInBlock();
   resetStateForThread(TId);
 }
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,7 +20,9 @@
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
+// defined by CGOpenMPRuntimeGPU
+extern uint32_t __omp_rtl_debug_kind;
+extern uint32_t __omp_rtl_assume_no_thread_state;
 
 // TODO: We want to change the name as soon as the old runtime is gone.
 // This variable should be visibile to the plugin so we override the default
@@ -48,4 +50,6 @@
   return config::getDebugKind() & Kind;
 }
 
+bool config::confiuseThreadState() { return !__omp_rtl_assume_no_thread_state; }
+
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Configuration.h
===
--- openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -38,8 +38,13 @@
 /// Return the amount of dynamic shared memory that was allocated at launch.
 uint64_t getDynamicMemorySize();
 
+/// Return if debugging is enabled for the given debug kind.
 bool isDebugMode(DebugKind Level);
 
+/// Indicates if this kernel may require thread-specific states, or if it was
+/// explicitly disabled by the user.
+bool requiresThreadStates();
+
 } // namespace config
 } // namespace _OMP
 
Index: clang/test/OpenMP/target_globals_codegen.cpp
===
--- clang/test/OpenMP/target_globals_codegen.cpp
+++ clang/test/OpenMP/target_globals_codegen.cpp
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-DEFAULT
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-threads-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-THREADS
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-teams-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix

[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I'd go with `config::mayRequireThreadSpecificState` or sth.
Also some documentation there.

you should be able to use assertions, like `ASSERT(false && "")`. Which 
gives us messages in assert mode if violated.

Clang documentation should be something like
`no thread in parallel region will modify an ICV`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120106

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


[PATCH] D120106: [OpenMP] Add flag for disabling threat state in runtime

2022-02-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
Herald added subscribers: dexonsmith, dang, guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.

The runtime uses thread state values to indicate when we use an ICV or
are in nested parallelism. This is done for OpenMP corectness, but it
not needed in the majority of cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120106

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/OpenMP/target_globals_codegen.cpp
  openmp/libomptarget/DeviceRTL/include/Configuration.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp

Index: openmp/libomptarget/DeviceRTL/src/State.cpp
===
--- openmp/libomptarget/DeviceRTL/src/State.cpp
+++ openmp/libomptarget/DeviceRTL/src/State.cpp
@@ -285,7 +285,7 @@
 #pragma omp allocate(ThreadStates) allocator(omp_pteam_mem_alloc)
 
 uint32_t &lookupForModify32Impl(uint32_t ICVStateTy::*Var, IdentTy *Ident) {
-  if (OMP_LIKELY(TeamState.ICVState.LevelVar == 0))
+  if (OMP_LIKELY(!config::useThreadState() || TeamState.ICVState.LevelVar == 0))
 return TeamState.ICVState.*Var;
   uint32_t TId = mapping::getThreadIdInBlock();
   if (!ThreadStates[TId]) {
@@ -299,13 +299,13 @@
 
 uint32_t &lookup32Impl(uint32_t ICVStateTy::*Var) {
   uint32_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::useThreadState() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
 uint64_t &lookup64Impl(uint64_t ICVStateTy::*Var) {
   uint64_t TId = mapping::getThreadIdInBlock();
-  if (OMP_UNLIKELY(ThreadStates[TId]))
+  if (OMP_UNLIKELY(config::useThreadState() && ThreadStates[TId]))
 return ThreadStates[TId]->ICVState.*Var;
   return TeamState.ICVState.*Var;
 }
@@ -380,6 +380,9 @@
 }
 
 void state::enterDataEnvironment(IdentTy *Ident) {
+  if (!config::useThreadState())
+__builtin_trap();
+
   unsigned TId = mapping::getThreadIdInBlock();
   ThreadStateTy *NewThreadState =
   static_cast(__kmpc_alloc_shared(sizeof(ThreadStateTy)));
@@ -388,6 +391,9 @@
 }
 
 void state::exitDataEnvironment() {
+  if (!config::useThreadState())
+__builtin_trap();
+
   unsigned TId = mapping::getThreadIdInBlock();
   resetStateForThread(TId);
 }
Index: openmp/libomptarget/DeviceRTL/src/Configuration.cpp
===
--- openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,7 +20,9 @@
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
+// defined by CGOpenMPRuntimeGPU
+extern uint32_t __omp_rtl_debug_kind;
+extern uint32_t __omp_rtl_assume_no_thread_state;
 
 // TODO: We want to change the name as soon as the old runtime is gone.
 // This variable should be visibile to the plugin so we override the default
@@ -48,4 +50,6 @@
   return config::getDebugKind() & Kind;
 }
 
+bool config::useThreadState() { return !__omp_rtl_assume_no_thread_state; }
+
 #pragma omp end declare target
Index: openmp/libomptarget/DeviceRTL/include/Configuration.h
===
--- openmp/libomptarget/DeviceRTL/include/Configuration.h
+++ openmp/libomptarget/DeviceRTL/include/Configuration.h
@@ -40,6 +40,8 @@
 
 bool isDebugMode(DebugKind Level);
 
+bool useThreadState();
+
 } // namespace config
 } // namespace _OMP
 
Index: clang/test/OpenMP/target_globals_codegen.cpp
===
--- clang/test/OpenMP/target_globals_codegen.cpp
+++ clang/test/OpenMP/target_globals_codegen.cpp
@@ -6,6 +6,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-DEFAULT
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-threads-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-THREADS
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-assume-teams-oversubscription -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=CHECK-TEAMS
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp

[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Looks good. Do you need someone to land this for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D112916: Confusable identifiers detection

2022-02-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D112916#3290365 , 
@serge-sans-paille wrote:

> @rsmith : once the licensing issue has been fixed, can we merge that patch or 
> do you have any other thought?

I have no concerns once the licensing question is resolved and the other 
reviewers are happy. I agree with Corentin that we should be exactly following 
the Unicode Consortium's recommendations. I think that while this doesn't fully 
address Aaron's concern, it at least gives us a rationale for our treatment of 
different scripts and seems more defensible than our coming up with some 
additional rules of our own.


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

https://reviews.llvm.org/D112916

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


[PATCH] D119609: [Clang][Sema] Don't act on ReturnStmt when parsing the lambda declarator.

2022-02-17 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

gentle ping~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D118525: [modules] Merge ObjC interface ivars with anonymous types.

2022-02-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118525

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


[PATCH] D119682: [clang-format][docs] Fix incorrect 'clang-format 13' configuration options markers

2022-02-17 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry added a comment.

First of all, thanks @MyDeveloperDay for the approval.

In D119682#3321965 , @MyDeveloperDay 
wrote:

> @HazardyKnusperkeks could you validate the `IndentRequiresClause` I know I 
> added `IndentRequires` in 13 but is this the same option renamed or a new 
> option?

This was renamed and it was done in 9aab0db13fb6d21d1b70247a9b5e4cf916ee1c3a 
.

In D119682#3321975 , @MyDeveloperDay 
wrote:

> I understand what you are saying re 'IndentRequiresClause' but this leaves us 
> with people with "IndentRequires" in their .clang-format without any 
> understanding of what it means? i.e. what about the 14.0 people? if we've 
> renamed an option then the documentation should carry something like
>
> 'Previously known as IndentRequires'

I have no problems with adding it myself if you want. I think this is //nice to 
have// and I see nothing wrong in adding it.

In D119682#3322082 , 
@HazardyKnusperkeks wrote:

> In D119682#3321975 , 
> @MyDeveloperDay wrote:
>
>> I understand what you are saying re 'IndentRequiresClause' but this leaves 
>> us with people with "IndentRequires" in their .clang-format without any 
>> understanding of what it means? i.e. what about the 14.0 people? if we've 
>> renamed an option then the documentation should carry something like
>>
>> 'Previously known as IndentRequires'
>
> That's not the first time we renamed something. And most likely not the last 
> time.

But that doesn't mean we can't add "Previously known as IndentRequires", does 
it? :)

To all:
I'm willing to add "Previously known as IndentRequires" but please let me know 
if you're for or against it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119682

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


[clang] 0b5fe2c - [clang] Remove Address::deprecated() in emitVoidPtrDirectVAArg()

2022-02-17 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-17T15:05:50-08:00
New Revision: 0b5fe2c9f2e5bdfb111068fab1f6689c066422aa

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

LOG: [clang] Remove Address::deprecated() in emitVoidPtrDirectVAArg()

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 3e1df744b2ad..a26a1955bcc5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -323,10 +323,10 @@ static Address emitVoidPtrDirectVAArg(CodeGenFunction 
&CGF,
   // If the CC aligns values higher than the slot size, do so if needed.
   Address Addr = Address::invalid();
   if (AllowHigherAlign && DirectAlign > SlotSize) {
-Addr = Address::deprecated(
-emitRoundPointerUpToAlignment(CGF, Ptr, DirectAlign), DirectAlign);
+Addr = Address(emitRoundPointerUpToAlignment(CGF, Ptr, DirectAlign),
+   CGF.Int8Ty, DirectAlign);
   } else {
-Addr = Address::deprecated(Ptr, SlotSize);
+Addr = Address(Ptr, CGF.Int8Ty, SlotSize);
   }
 
   // Advance the pointer past the argument, then store that back.



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


[PATCH] D119207: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-17 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Hi Shangwu,

I've reverted this change to unblock the buildbots and our internal CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119207

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2022-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added subscribers: pirama, srhines, kongyi.
pirama added a comment.

Unrelated to missing resolver definition, this change doesn't accommodate 
resolvers that take parameters.  (Curiously, this verification only fails with 
ThinLTO).

  // with -flto=full or without -flto=thin, below command works
  $ clang -shared ifunc.cpp -fPIC -fuse-ld=lld -flto=thin
  IFunc resolver has incorrect type
  i32 ()* @_Z5ifuncv
  
  $ cat ifunc.cpp
  #include 
  
  typedef int (*fn_ptr_t)();
  
  int ifunc() __attribute__((ifunc("resolver")));
  
  int ret42() {
return 42;
  }
  
  extern "C" fn_ptr_t resolver(uint64_t hwcap) {
return ret42;
  }

I have a change that fixes the above use case but causes some opaque pointer 
tests to fail.  I'll investigate and upload once they're fixed.

I also noticed that this patch didn't add any test for the "IFunc resolver has 
incorrect type" errors cases.  It'd be good to add those in a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[clang] 9ce0909 - Revert "[CUDA][SPIRV] Assign global address space to CUDA kernel arguments"

2022-02-17 Thread Matthew Voss via cfe-commits

Author: Matthew Voss
Date: 2022-02-17T14:32:10-08:00
New Revision: 9ce09099bba4be68d2a269b0bfd2b1dcc67f02d4

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

LOG: Revert "[CUDA][SPIRV] Assign global address space to CUDA kernel arguments"

This reverts commit 9de4fc0f2d3b60542956f7e5254951d049edeb1f.

Reverting due to test failure: 
https://lab.llvm.org/buildbot/#/builders/139/builds/17199

Added: 


Modified: 
clang/lib/Basic/Targets/SPIR.h
clang/lib/CodeGen/TargetInfo.cpp

Removed: 
clang/test/CodeGenCUDASPIRV/kernel-argument.cu



diff  --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index 08c49f018ac79..a40d4b3ca27e1 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -144,16 +144,16 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public 
TargetInfo {
 // FIXME: SYCL specification considers unannotated pointers and references
 // to be pointing to the generic address space. See section 5.9.3 of
 // SYCL 2020 specification.
-// Currently, there is no way of representing SYCL's and HIP/CUDA's default
+// Currently, there is no way of representing SYCL's and HIP's default
 // address space language semantic along with the semantics of embedded C's
 // default address space in the same address space map. Hence the map needs
 // to be reset to allow mapping to the desired value of 'Default' entry for
-// SYCL and HIP/CUDA.
+// SYCL and HIP.
 setAddressSpaceMap(
 /*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
-// The address mapping from HIP/CUDA language for device code is only
-// defined for SPIR-V.
-(getTriple().isSPIRV() && Opts.CUDAIsDevice));
+// The address mapping from HIP language for device code is only 
defined
+// for SPIR-V.
+(getTriple().isSPIRV() && Opts.HIP && Opts.CUDAIsDevice));
   }
 
   void setSupportedOpenCLOpts() override {

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 5a2991dfe1762..3e1df744b2ad7 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10320,10 +10320,10 @@ void CommonSPIRABIInfo::setCCs() {
 }
 
 ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
-  if (getContext().getLangOpts().CUDAIsDevice) {
+  if (getContext().getLangOpts().HIP) {
 // Coerce pointer arguments with default address space to CrossWorkGroup
-// pointers for HIPSPV/CUDASPV. When the language mode is HIP/CUDA, the
-// SPIRTargetInfo maps cuda_device to SPIR-V's CrossWorkGroup address 
space.
+// pointers for HIPSPV. When the language mode is HIP, the SPIRTargetInfo
+// maps cuda_device to SPIR-V's CrossWorkGroup address space.
 llvm::Type *LTy = CGT.ConvertType(Ty);
 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);

diff  --git a/clang/test/CodeGenCUDASPIRV/kernel-argument.cu 
b/clang/test/CodeGenCUDASPIRV/kernel-argument.cu
deleted file mode 100644
index 0ccacffd12a5f..0
--- a/clang/test/CodeGenCUDASPIRV/kernel-argument.cu
+++ /dev/null
@@ -1,17 +0,0 @@
-// Tests CUDA kernel arguments get global address space when targetting SPIR-V.
-
-// REQUIRES: clang-driver
-
-// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv32 \
-// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
-// RUN: llvm-dis %t.bc -o %t.ll
-// RUN: FileCheck %s --input-file=%t.ll
-
-// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv64 \
-// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
-// RUN: llvm-dis %t.bc -o %t.ll
-// RUN: FileCheck %s --input-file=%t.ll
-
-// CHECK: define spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef 
%output.coerce)
-
-__attribute__((global)) void kernel(int* output) { *output = 1; }



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


[PATCH] D118757: [AArch64] Remove unused feature flags from AArch64TargetInfo

2022-02-17 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 updated this revision to Diff 409796.
tyb0807 added a comment.

Remove reference to unused ACLE macro `__ARM_FEATURE_CRYPTO`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118757

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-acle-6.5.c

Index: clang/test/Preprocessor/arm-acle-6.5.c
===
--- clang/test/Preprocessor/arm-acle-6.5.c
+++ clang/test/Preprocessor/arm-acle-6.5.c
@@ -91,14 +91,12 @@
 // RUN: %clang -target armv7-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-EXTENSIONS
 
 // CHECK-NO-EXTENSIONS-NOT: __ARM_FEATURE_CRC32
-// CHECK-NO-EXTENSIONS-NOT: __ARM_FEATURE_CRYPTO
 // CHECK-NO-EXTENSIONS-NOT: __ARM_FEATURE_DIRECTED_ROUNDING
 // CHECK-NO-EXTENSIONS-NOT: __ARM_FEATURE_NUMERIC_MAXMIN
 
 // RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-EXTENSIONS
 
 // CHECK-EXTENSIONS: __ARM_FEATURE_CRC32 1
-// CHECK-EXTENSIONS: __ARM_FEATURE_CRYPTO 1
 // CHECK-EXTENSIONS: __ARM_FEATURE_DIRECTED_ROUNDING 1
 // CHECK-EXTENSIONS: __ARM_FEATURE_NUMERIC_MAXMIN 1
 
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -19,7 +19,6 @@
 // CHECK-NOT: __ARM_FEATURE_BIG_ENDIAN
 // CHECK: __ARM_FEATURE_CLZ 1
 // CHECK-NOT: __ARM_FEATURE_CRC32 1
-// CHECK-NOT: __ARM_FEATURE_CRYPTO 1
 // CHECK: __ARM_FEATURE_DIRECTED_ROUNDING 1
 // CHECK: __ARM_FEATURE_DIV 1
 // CHECK: __ARM_FEATURE_FMA 1
@@ -72,13 +71,11 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEAT-CRYPTO %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEAT-CRYPTO %s
 // CHECK-FEAT-CRYPTO: __ARM_FEATURE_AES 1
-// CHECK-FEAT-CRYPTO: __ARM_FEATURE_CRYPTO 1
 // CHECK-FEAT-CRYPTO: __ARM_FEATURE_SHA2 1
 
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.4-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEAT-CRYPTO-8_4 %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.4-a+crypto -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FEAT-CRYPTO-8_4 %s
 // CHECK-FEAT-CRYPTO-8_4: __ARM_FEATURE_AES 1
-// CHECK-FEAT-CRYPTO-8_4: __ARM_FEATURE_CRYPTO 1
 // CHECK-FEAT-CRYPTO-8_4: __ARM_FEATURE_SHA2 1
 // CHECK-FEAT-CRYPTO-8_4: __ARM_FEATURE_SHA3 1
 // CHECK-FEAT-CRYPTO-8_4: __ARM_FEATURE_SHA512 1
Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -30,7 +30,6 @@
 
   unsigned FPU;
   bool HasCRC;
-  bool HasCrypto;
   bool HasAES;
   bool HasSHA2;
   bool HasSHA3;
@@ -54,7 +53,6 @@
   bool HasMatmulFP32;
   bool HasLSE;
   bool HasFlagM;
-  bool HasHBC;
   bool HasMOPS;
 
   llvm::AArch64::ArchKind ArchKind;
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -343,11 +343,6 @@
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
 
-  // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
-  // macros for AES, SHA2, SHA3 and SM4
-  if (HasAES && HasSHA2)
-Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
-
   if (HasAES)
 Builder.defineMacro("__ARM_FEATURE_AES", "1");
 
@@ -525,7 +520,6 @@
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
   HasCRC = false;
-  HasCrypto = false;
   HasAES = false;
   HasSHA2 = false;
   HasSHA3 = false;
@@ -548,7 +542,6 @@
   HasMatmulFP64 = false;
   HasMatmulFP32 = false;
   HasLSE = false;
-  HasHBC = false;
   HasMOPS = false;
 
   ArchKind = llvm::AArch64::ArchKind::INVALID;
@@ -599,8 +592,6 @@
 }
 if (Feature == "+crc")
   HasCRC = true;
-if (Feature == "+crypto")
-  HasCrypto = true;
 if (Feature == "+aes")
   HasAES = true;
 if (Feature == "+sha2")
@@ -665,8 +656,6 @@
   HasRandGen = true;
 if (Feature == "+flagm")
   HasFlagM = true;
-if (Feature == "+hbc")
-  HasHBC = true;
 if (Feature == "+mops")
   HasMOPS = true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ba9944e - [clang] Remove Address::deprecated() in CGCXXABI.h

2022-02-17 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-17T14:23:02-08:00
New Revision: ba9944ea1dff507839df8e4cf9897a5d4916ec68

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

LOG: [clang] Remove Address::deprecated() in CGCXXABI.h

Added: 


Modified: 
clang/lib/CodeGen/CGCXXABI.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index ba073b3ff4e5..a46f7f37141f 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -56,7 +56,10 @@ class CGCXXABI {
 return CGF.CXXABIThisValue;
   }
   Address getThisAddress(CodeGenFunction &CGF) {
-return Address::deprecated(CGF.CXXABIThisValue, CGF.CXXABIThisAlignment);
+return Address(
+CGF.CXXABIThisValue,
+CGF.ConvertTypeForMem(CGF.CXXABIThisDecl->getType()->getPointeeType()),
+CGF.CXXABIThisAlignment);
   }
 
   /// Issue a diagnostic about unsupported features in the ABI.



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


[PATCH] D120086: Explicitly document that `__is_trivially_relocatable(T)` implies that `T` is implicit-lifetime.

2022-02-17 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre updated this revision to Diff 409794.
devin.jeanpierre added a comment.

Rebase off of D119385 . Sorry, I'm bad at git.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120086

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1372,8 +1372,9 @@
 * ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
   of the given type, and then destroying the source object, is known to be
   functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+  source object on the floor. (Note: any such type is, therefore, 
implicit-lifetime.)
+  This is true of trivial types and types which were made trivially relocatable
+  via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1372,8 +1372,9 @@
 * ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
   of the given type, and then destroying the source object, is known to be
   functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+  source object on the floor. (Note: any such type is, therefore, implicit-lifetime.)
+  This is true of trivial types and types which were made trivially relocatable
+  via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

2022-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 409791.
tianshilei1992 added a comment.

add a small test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_messages.cpp

Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -954,6 +954,10 @@
 // expected-note@+1 {{'read' clause used here}}
 #pragma omp atomic read compare
   a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'compare' clause}}
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
+#pragma omp atomic compare compare capture capture
+  a = b;
 #endif
   // expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}}
   return mixed();
Index: clang/test/OpenMP/atomic_ast_print.cpp
===
--- clang/test/OpenMP/atomic_ast_print.cpp
+++ clang/test/OpenMP/atomic_ast_print.cpp
@@ -20,6 +20,7 @@
 
 template 
 T foo(T argc) {
+  T v = T();
   T c = T();
   T b = T();
   T a = T();
@@ -45,6 +46,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic seq_cst
   a++;
@@ -68,6 +75,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare seq_cst
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture seq_cst
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare seq_cst capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture seq_cst
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic
   a++;
@@ -91,6 +104,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare acq_rel
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture acq_rel
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare acq_rel capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture acq_rel
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic
   a++;
@@ -114,6 +133,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare acquire
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture acquire
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare acquire capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture acquire
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic release
   a++;
@@ -137,6 +162,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare release
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture release
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare release capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture release
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic relaxed
   a++;
@@ -160,6 +191,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare relaxed
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture relaxed
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare relaxed capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture relaxed
+  { v = a == b; if (v) a = c; }
 #endif
 #pragma omp atomic hint(6)
   a++;
@@ -183,6 +220,12 @@
   { a = a < b ? b : a; }
 #pragma omp atomic compare hint(6)
   { a = a == b ? c : a; }
+#pragma omp atomic compare capture hint(6)
+  { v = a; a = a > b ? b : a; }
+#pragma omp atomic compare hint(6) capture
+  { v = a; a = a < b ? b : a; }
+#pragma omp atomic compare capture hint(6)
+  { v = a == b; if (v) a = c; }
 #endif
   return T();
 }
@@ -215,6 +258,22 @@
 // CHECK-51-NEXT: {
 // CHECK-51-NEXT: a = a == b ? c : a;
 // CHECK-51-NEXT: }
+// CHECK-51-NEXT: #pragma omp atomic compare capture
+// CHECK-51-NEXT: {
+// CHECK-51-NEXT: v = a;
+// CHECK-51-NEXT: a = a > b ? b : a;
+// CHECK-51-NEXT: }
+// CHECK-51-NEXT: #pragma omp atomic compare capture
+// CHECK-51-NEXT: {
+// CHECK-51-NEXT: v = a;
+// CHECK-51-NEXT: a = a < b ? b : a;
+// CHECK-51-NEXT: }
+// CHECK-51-NEXT: #pragma omp atomic compare capture
+// CHECK-51-NEXT: {
+// CHECK-51-NEXT: v = a == b;
+// CHECK-51-NEXT: if (v)
+// CHECK-51-NEXT: a = c;
+// CHECK-51-NEXT: }
 // CHECK-NEXT: #pragma omp atomic seq_cst
 // CHECK-NEXT: a++;
 // CHECK-NEXT: #pragma omp atomic read seq_cst
@@ -242,6 +301,22 @@
 // CHECK-51-NEXT: {
 // CHECK-51-NEXT: a = a == b ? c : a;
 // CHECK-51-NEXT: }
+// CHECK-51-NEXT: #pragma omp atomic compare capture seq_cst
+// CHECK-51-NEXT: {
+// CHECK-51-NEXT: v = a;
+// CHECK-51-NEXT: a = a > b ? b : a

[PATCH] D119392: [Clang][OpenMP][Sema] Remove support for floating point values in atomic compare

2022-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 409784.
tianshilei1992 added a comment.

add a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119392

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_messages.c

Index: clang/test/OpenMP/atomic_messages.c
===
--- clang/test/OpenMP/atomic_messages.c
+++ clang/test/OpenMP/atomic_messages.c
@@ -483,5 +483,12 @@
 if (fx > fe)
   fx = fe;
   }
+// omp51-error@+5 {{the statement for 'atomic compare' must be a compound statement of form '{x = expr ordop x ? expr : x;}', '{x = x ordop expr? expr : x;}', '{x = x == e ? d : x;}', '{x = e == x ? d : x;}', or 'if(expr ordop x) {x = expr;}', 'if(x ordop expr) {x = expr;}', 'if(x == e) {x = d;}', 'if(e == x) {x = d;}' where 'x' is an lvalue expression with scalar type, 'expr', 'e', and 'd' are expressions with scalar type, and 'ordop' is one of '<' or '>'.}}
+// omp51-note@+4 {{expect integer value}}
+#pragma omp atomic compare
+  {
+if (fx == fe)
+  fx = fe;
+  }
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -11014,8 +11014,6 @@
   Expr *C = nullptr;
   /// True if the cond expr is in the form of 'x ordop expr'.
   bool IsXBinopExpr = true;
-  /// The atomic compare operator.
-  OMPAtomicCompareOp Op;
 
   /// Check if it is a valid conditional update statement (cond-update-stmt).
   bool checkCondUpdateStmt(IfStmt *S, ErrorInfoTy &ErrorInfo);
@@ -11072,23 +11070,7 @@
   }
 
   switch (Cond->getOpcode()) {
-  case BO_EQ:
-Op = OMPAtomicCompareOp::EQ;
-break;
-  case BO_LT:
-Op = OMPAtomicCompareOp::MIN;
-break;
-  case BO_GT:
-Op = OMPAtomicCompareOp::MAX;
-break;
-  default:
-ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
-ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
-ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
-return false;
-  }
-
-  if (Cond->getOpcode() == BO_EQ) {
+  case BO_EQ: {
 C = Cond;
 D = BO->getRHS();
 if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
@@ -11101,7 +11083,10 @@
   ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
   return false;
 }
-  } else {
+break;
+  }
+  case BO_LT:
+  case BO_GT: {
 E = BO->getRHS();
 if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS()) &&
 checkIfTwoExprsAreSame(ContextRef, E, Cond->getRHS())) {
@@ -6,6 +11101,13 @@
   ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
   return false;
 }
+break;
+  }
+  default:
+ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
+ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+return false;
   }
 
   return true;
@@ -11166,23 +11158,7 @@
   }
 
   switch (Cond->getOpcode()) {
-  case BO_EQ:
-Op = OMPAtomicCompareOp::EQ;
-break;
-  case BO_LT:
-Op = OMPAtomicCompareOp::MIN;
-break;
-  case BO_GT:
-Op = OMPAtomicCompareOp::MAX;
-break;
-  default:
-ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
-ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
-ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
-return false;
-  }
-
-  if (Cond->getOpcode() == BO_EQ) {
+  case BO_EQ: {
 C = Cond;
 D = CO->getTrueExpr();
 if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS())) {
@@ -11195,7 +11171,10 @@
   ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
   return false;
 }
-  } else {
+break;
+  }
+  case BO_LT:
+  case BO_GT: {
 E = CO->getTrueExpr();
 if (checkIfTwoExprsAreSame(ContextRef, X, Cond->getLHS()) &&
 checkIfTwoExprsAreSame(ContextRef, E, Cond->getRHS())) {
@@ -11210,6 +11189,13 @@
   ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
   return false;
 }
+break;
+  }
+  default:
+ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
+ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
+ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
+return false;
   }
 
   return true;
@@ -11219,8 +11205,7 @@
   // 'x' and 'e' cannot be nullptr
   assert(X && E && "X and E cannot be nullptr");
 
-  auto CheckValue = [&ErrorInfo](const Expr *E, OMPAtomicCompareOp Op,
- bool ShouldBeLValue) {
+  auto CheckValue = [&ErrorInfo](const Expr *E, bool ShouldBeLValue) {
 if (ShouldBeLValue && !E->isLValue()) {
   ErrorInfo.Error = ErrorTy::XNotLValue;
   ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = E->getExprLoc();
@@ -11237,7 +11222,7 @@
 return false;
   }
 
-  if (Op != OMPAtomicCompareOp::EQ && !QTy-

[clang] 0e219af - [clang] Remove Address::deprecated() call in CGExprCXX.cpp

2022-02-17 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-17T13:58:26-08:00
New Revision: 0e219af475430ab338c9d76a101a78304a64f78a

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

LOG: [clang] Remove Address::deprecated() call in CGExprCXX.cpp

Added: 


Modified: 
clang/lib/CodeGen/CGExprCXX.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 9596ed34e5e9d..54c87a7361b1c 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -2101,10 +2101,9 @@ void CodeGenFunction::EmitCXXDeleteExpr(const 
CXXDeleteExpr *E) {
   GEP.push_back(Zero);
 }
 
-Ptr = Address::deprecated(Builder.CreateInBoundsGEP(Ptr.getElementType(),
-Ptr.getPointer(), GEP,
-"del.first"),
-  Ptr.getAlignment());
+Ptr = Address(Builder.CreateInBoundsGEP(Ptr.getElementType(),
+Ptr.getPointer(), GEP, 
"del.first"),
+  ConvertTypeForMem(DeleteTy), Ptr.getAlignment());
   }
 
   assert(ConvertTypeForMem(DeleteTy) == Ptr.getElementType());



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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-02-17 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 409783.
zixuw added a comment.

Use `%/t` for path substitution to normalize path separators for file URI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/SymbolGraph/API.h
  clang/include/clang/SymbolGraph/AvailabilityInfo.h
  clang/include/clang/SymbolGraph/DeclarationFragments.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/AST/RawCommentList.cpp
  clang/lib/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/API.cpp
  clang/lib/SymbolGraph/CMakeLists.txt
  clang/lib/SymbolGraph/DeclarationFragments.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/Driver/extract-api.c
  clang/test/SymbolGraph/global_record.c

Index: clang/test/SymbolGraph/global_record.c
===
--- /dev/null
+++ clang/test/SymbolGraph/global_record.c
@@ -0,0 +1,363 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.c -o %t/output.json | FileCheck -allow-empty %s
+// RUN: diff %t/reference.output.json %t/output.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.c
+int num;
+
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "clang"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Variable",
+"identifier": "c.variable"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input.c"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "spelling": "res"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "docComment": {
+"lines": [
+  {
+

[PATCH] D119612: [clang] Pass more flags to ld64.lld

2022-02-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119612

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


[PATCH] D120086: Explicitly document that `__is_trivially_relocatable(T)` implies that `T` is implicit-lifetime.

2022-02-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

FWIW, I think this is a good idea. I even think that the parentheses and 
"Note:" are too self-deprecating, and this deserves to be a bigger deal. 
Perhaps `__is_implicit_lifetime(T)` should be an intrinsic in its own right! 
Then you could say very concretely that `__is_trivially_relocatable(T)` implies 
`__is_implicit_lifetime(T)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120086

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


[PATCH] D109239: Add support for floating-option `-ffp-eval-method` and for new `pragma clang fp eval-method`

2022-02-17 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

If you put "Differential Revision: https://reviews.llvm.org/D109239"; instead of 
just "https://reviews.llvm.org/D109239"; in the commit message, phabricator will 
auto-close the review when the commit lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109239

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


[PATCH] D109239: Add support for floating-option `-ffp-eval-method` and for new `pragma clang fp eval-method`

2022-02-17 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I saw that test failing again. I could repro the problem locally and fixed it 
in 1689b1092ebb2c630f8ef1d3880a9fb4808d16fa 
. I guess 
this did make it into the pch somehow after all. But all good now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109239

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


[PATCH] D119612: [clang] Pass more flags to ld64.lld

2022-02-17 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG383ed82dd1f8: [clang] Pass more flags to ld64.lld (authored 
by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119612

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld-lto-lld.c
  clang/test/Driver/darwin-ld-lto.c
  clang/test/Driver/darwin-ld.c

Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -236,6 +236,9 @@
 // RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \
 // RUN:   -fuse-ld= -mlinker-version=137 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_EXPORT_DYNAMIC %s < %t.log
+// RUN: %clang -target x86_64-apple-darwin12 -rdynamic -### %t.o \
+// RUN:   -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=100 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_EXPORT_DYNAMIC %s < %t.log
 // LINK_EXPORT_DYNAMIC: {{ld(.exe)?"}}
 // LINK_EXPORT_DYNAMIC: "-export_dynamic"
 
Index: clang/test/Driver/darwin-ld-lto.c
===
--- clang/test/Driver/darwin-ld-lto.c
+++ clang/test/Driver/darwin-ld-lto.c
@@ -20,13 +20,13 @@
 
 
 // Check that -object_lto_path is passed correctly to ld64
-// RUN: %clang -target x86_64-apple-darwin10 %s -flto=full -### 2>&1 | \
-// RUN:   FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
+// RUN: %clang -fuse-ld= -target x86_64-apple-darwin10 %s -flto=full -### 2>&1 \
+// RUN: | FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
 // FULL_LTO_OBJECT_PATH: {{ld(.exe)?"}}
 // FULL_LTO_OBJECT_PATH-SAME: "-object_path_lto"
 // FULL_LTO_OBJECT_PATH-SAME: {{cc\-[a-zA-Z0-9_]+.o}}"
-// RUN: %clang -target x86_64-apple-darwin10 %s -flto=thin -### 2>&1 | \
-// RUN:   FileCheck -check-prefix=THIN_LTO_OBJECT_PATH %s
+// RUN: %clang -fuse-ld= -target x86_64-apple-darwin10 %s -flto=thin -### 2>&1 \
+// RUN: | FileCheck -check-prefix=THIN_LTO_OBJECT_PATH %s
 // THIN_LTO_OBJECT_PATH: {{ld(.exe)?"}}
 // THIN_LTO_OBJECT_PATH-SAME: "-object_path_lto"
 // THIN_LTO_OBJECT_PATH-SAME: {{thinlto\-[a-zA-Z0-9_]+}}
Index: clang/test/Driver/darwin-ld-lto-lld.c
===
--- /dev/null
+++ clang/test/Driver/darwin-ld-lto-lld.c
@@ -0,0 +1,19 @@
+// REQUIRES: shell
+
+// Check that lld gets "-lto_library".
+// (Separate test file since darwin-ld-lto requires system-darwin but this
+// test doesn't require that.)
+
+// Check that -object_lto_path is passed correctly to ld64
+// RUN: %clang -fuse-ld=lld -B%S/Inputs/lld -target x86_64-apple-darwin10 \
+// RUN: %s -flto=full -### 2>&1 \
+// RUN: | FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
+// FULL_LTO_OBJECT_PATH: {{ld(.exe)?"}}
+// FULL_LTO_OBJECT_PATH-SAME: "-object_path_lto"
+// FULL_LTO_OBJECT_PATH-SAME: {{cc\-[a-zA-Z0-9_]+.o}}"
+// RUN: %clang -fuse-ld=lld -B%S/Inputs/lld -target x86_64-apple-darwin10 \
+// RUN: %s -flto=thin -### 2>&1 \
+// RUN: | FileCheck -check-prefix=THIN_LTO_OBJECT_PATH %s
+// THIN_LTO_OBJECT_PATH: {{ld(.exe)?"}}
+// THIN_LTO_OBJECT_PATH-SAME: "-object_path_lto"
+// THIN_LTO_OBJECT_PATH-SAME: {{thinlto\-[a-zA-Z0-9_]+}}
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -219,9 +219,8 @@
   !Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
 CmdArgs.push_back("-demangle");
 
-  // FIXME: Pass most of the flags below that check Version if LinkerIsLLD too.
-
-  if (Args.hasArg(options::OPT_rdynamic) && Version >= VersionTuple(137))
+  if (Args.hasArg(options::OPT_rdynamic) &&
+  (Version >= VersionTuple(137) || LinkerIsLLD))
 CmdArgs.push_back("-export_dynamic");
 
   // If we are using App Extension restrictions, pass a flag to the linker
@@ -230,7 +229,8 @@
options::OPT_fno_application_extension, false))
 CmdArgs.push_back("-application_extension");
 
-  if (D.isUsingLTO() && Version >= VersionTuple(116) && NeedsTempPath(Inputs)) {
+  if (D.isUsingLTO() && (Version >= VersionTuple(116) || LinkerIsLLD) &&
+  NeedsTempPath(Inputs)) {
 std::string TmpPathName;
 if (D.getLTOMode() == LTOK_Full) {
   // If we are using full LTO, then automatically create a temporary file
@@ -269,8 +269,11 @@
 CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
   }
 
-  // ld64 version 262 and above run the deduplicate pass by default.
-  if (Version >= VersionTuple(262) && shouldLinkerNotDedup(C.getJobs().empty(), Args))
+  // ld64 version 262 and above runs the deduplicate pass by default.
+  // FIXME: lld doesn't dedup by default. Should we pass `--icf=safe`
+  //if `!shouldLinkerNotDedup()` if LinkerIsLLD here?
+  if (Version >= 

[clang] 383ed82 - [clang] Pass more flags to ld64.lld

2022-02-17 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-02-17T16:45:52-05:00
New Revision: 383ed82dd1f8c4ea7e88a4cf92dd918dda794854

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

LOG: [clang] Pass more flags to ld64.lld

* ld64.lld now completely supports -export_dynamic (D119372), so map -rdynamic
  to -export_dynamic like already done for ld64

* ld64.lld has been supporting -object_path_lto for well over a year (D92537),
  so pass it like already done for ld64

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

Added: 
clang/test/Driver/darwin-ld-lto-lld.c

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-lto.c
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index dc75b2b4621bb..005236c4476f4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -219,9 +219,8 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const 
ArgList &Args,
   !Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
 CmdArgs.push_back("-demangle");
 
-  // FIXME: Pass most of the flags below that check Version if LinkerIsLLD too.
-
-  if (Args.hasArg(options::OPT_rdynamic) && Version >= VersionTuple(137))
+  if (Args.hasArg(options::OPT_rdynamic) &&
+  (Version >= VersionTuple(137) || LinkerIsLLD))
 CmdArgs.push_back("-export_dynamic");
 
   // If we are using App Extension restrictions, pass a flag to the linker
@@ -230,7 +229,8 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const 
ArgList &Args,
options::OPT_fno_application_extension, false))
 CmdArgs.push_back("-application_extension");
 
-  if (D.isUsingLTO() && Version >= VersionTuple(116) && NeedsTempPath(Inputs)) 
{
+  if (D.isUsingLTO() && (Version >= VersionTuple(116) || LinkerIsLLD) &&
+  NeedsTempPath(Inputs)) {
 std::string TmpPathName;
 if (D.getLTOMode() == LTOK_Full) {
   // If we are using full LTO, then automatically create a temporary file
@@ -269,8 +269,11 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const 
ArgList &Args,
 CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
   }
 
-  // ld64 version 262 and above run the deduplicate pass by default.
-  if (Version >= VersionTuple(262) && 
shouldLinkerNotDedup(C.getJobs().empty(), Args))
+  // ld64 version 262 and above runs the deduplicate pass by default.
+  // FIXME: lld doesn't dedup by default. Should we pass `--icf=safe`
+  //if `!shouldLinkerNotDedup()` if LinkerIsLLD here?
+  if (Version >= VersionTuple(262) &&
+  shouldLinkerNotDedup(C.getJobs().empty(), Args))
 CmdArgs.push_back("-no_deduplicate");
 
   // Derived from the "link" spec.
@@ -368,6 +371,7 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const 
ArgList &Args,
 // Check if the toolchain supports bitcode build flow.
 if (MachOTC.SupportsEmbeddedBitcode()) {
   CmdArgs.push_back("-bitcode_bundle");
+  // FIXME: Pass this if LinkerIsLLD too, once it implements this flag.
   if (C.getDriver().embedBitcodeMarkerOnly() &&
   Version >= VersionTuple(278)) {
 CmdArgs.push_back("-bitcode_process_mode");

diff  --git a/clang/test/Driver/darwin-ld-lto-lld.c 
b/clang/test/Driver/darwin-ld-lto-lld.c
new file mode 100644
index 0..2d1ed86ebcda8
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-lto-lld.c
@@ -0,0 +1,19 @@
+// REQUIRES: shell
+
+// Check that lld gets "-lto_library".
+// (Separate test file since darwin-ld-lto requires system-darwin but this
+// test doesn't require that.)
+
+// Check that -object_lto_path is passed correctly to ld64
+// RUN: %clang -fuse-ld=lld -B%S/Inputs/lld -target x86_64-apple-darwin10 \
+// RUN: %s -flto=full -### 2>&1 \
+// RUN: | FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
+// FULL_LTO_OBJECT_PATH: {{ld(.exe)?"}}
+// FULL_LTO_OBJECT_PATH-SAME: "-object_path_lto"
+// FULL_LTO_OBJECT_PATH-SAME: {{cc\-[a-zA-Z0-9_]+.o}}"
+// RUN: %clang -fuse-ld=lld -B%S/Inputs/lld -target x86_64-apple-darwin10 \
+// RUN: %s -flto=thin -### 2>&1 \
+// RUN: | FileCheck -check-prefix=THIN_LTO_OBJECT_PATH %s
+// THIN_LTO_OBJECT_PATH: {{ld(.exe)?"}}
+// THIN_LTO_OBJECT_PATH-SAME: "-object_path_lto"
+// THIN_LTO_OBJECT_PATH-SAME: {{thinlto\-[a-zA-Z0-9_]+}}

diff  --git a/clang/test/Driver/darwin-ld-lto.c 
b/clang/test/Driver/darwin-ld-lto.c
index 252ca148c5200..441a07d0a7e56 100644
--- a/clang/test/Driver/darwin-ld-lto.c
+++ b/clang/test/Driver/darwin-ld-lto.c
@@ -20,13 +20,13 @@
 
 
 // Check that -object_lto_path is passed correctly to ld64
-// RUN: %clang -target x86_64-apple-darwin10 %s -flto=full -### 2>&1 | \
-// RUN:   FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
+// RUN: %clang -fuse-ld= -targ

[PATCH] D120086: Explicitly document that `__is_trivially_relocatable(T)` implies that `T` is implicit-lifetime.

2022-02-17 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre created this revision.
devin.jeanpierre added reviewers: rsmith, rjmccall.
devin.jeanpierre requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previous change: D114732 

The wording here might need some tweaking. What I want to guarantee is that 
everything valid for an implicit-lifetime type is also valid for these types. 
Either they're added to the set of implicit-lifetime types as an extension, or 
the operations are valid for additional non-implicit-lifetime types -- 
something like that.

Something to this effect is required for it to be defined behavior to `memcpy` 
to a new location, and then use the type at that new location. And so, this 
guarantee is necessary for `__is_trivially_relocatable` to be actually useful 
in practice. See e.g. D119385  for how this 
plays out.

AIUI, Clang is already fine with this and needs no code changes. Indeed, we see 
many types which are not what the standard would call implicit-lifetime, yet 
which use memcpy for copying: `std::vector` only checks for trivial move, and 
does not pair this with requiring trivial destroy. (See e.g. 
`__construct_forward_with_exception_guarantees`)

(Specifically: I believe that Clang is already fine with treating any 
non-polymorphic type as if it were implicit-lifetime, but I am not sure how to 
check this belief. There's not much in the way of explicit references to 
"implicit-lifetime" types in the codebase. Had a brief out of band conversation 
with rsmith, but may of course have misunderstood the conclusions here.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120086

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1372,8 +1372,9 @@
 * ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
   of the given type, and then destroying the source object, is known to be
   functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+  source object on the floor. (Note: any such type is, therefore, 
implicit-lifetime.)
+  This is true of trivial types and types which were made trivially relocatable
+  via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1372,8 +1372,9 @@
 * ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
   of the given type, and then destroying the source object, is known to be
   functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+  source object on the floor. (Note: any such type is, therefore, implicit-lifetime.)
+  This is true of trivial types and types which were made trivially relocatable
+  via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

2022-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D116261#3330732 , @tianshilei1992 
wrote:

> We don't have Sema yet, so there is no erroneous test.

But you have the checks for the clauses, repeated several times in a construct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

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


[PATCH] D118632: [Clang]OpenMP] Add the codegen support for `atomic compare`

2022-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.



Comment at: clang/test/OpenMP/atomic_compare_codegen.cpp:6
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 
-fopenmp-simd -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple 
x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s

ABataev wrote:
> tianshilei1992 wrote:
> > CodeGen for `-fopen-simd` is wrong. It doesn't emit corresponding atomic 
> > operations. I'll fix it.
> The logic behind -fopenmp-simd is to emit the code only for simd specific 
> instructions.
Right. `// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}` is used here, same as other cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118632

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


[clang] 1689b10 - unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after 32b73bc6ab82

2022-02-17 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-02-17T16:33:39-05:00
New Revision: 1689b1092ebb2c630f8ef1d3880a9fb4808d16fa

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

LOG: unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after 
32b73bc6ab82

See revision b8b7a9dcdcbc for prior art.

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index f98e173b158c1..c94274ff34b8f 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -41,7 +41,7 @@ namespace serialization {
 /// Version 4 of AST files also requires that the version control branch and
 /// revision match exactly, since there is no backward compatibility of
 /// AST files at this time.
-const unsigned VERSION_MAJOR = 15;
+const unsigned VERSION_MAJOR = 16;
 
 /// AST file minor version number supported by this version of
 /// Clang.



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


[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

2022-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

We don't have Sema yet, so there is no erroneous test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

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


[PATCH] D120084: [clang][DOC] Document module mangler changes

2022-02-17 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan created this revision.
urnathan added reviewers: ChuanqiXu, iains, rsmith.
urnathan requested review of this revision.

Note that the mangling has changed and the demangler's learnt a new trick.  
Obviously dependent upon the mangler and demangler patches.


https://reviews.llvm.org/D120084

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -110,6 +110,13 @@
 C++20 Feature Support
 ^
 
+- The mangling scheme for modules has incompatibally changed. The
+  initial mangling was discovered not to be reversible, and the weak
+  ownership design decision did not give the backwards compatibility
+  that was hoped for. C++20 since added ``extern "C++"`` semantics
+  that can be used for that. The demangler now demangles symbols with
+  named module attachment.
+
 C++2b Feature Support
 ^
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -110,6 +110,13 @@
 C++20 Feature Support
 ^
 
+- The mangling scheme for modules has incompatibally changed. The
+  initial mangling was discovered not to be reversible, and the weak
+  ownership design decision did not give the backwards compatibility
+  that was hoped for. C++20 since added ``extern "C++"`` semantics
+  that can be used for that. The demangler now demangles symbols with
+  named module attachment.
+
 C++2b Feature Support
 ^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

2022-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Erroneous tests?




Comment at: clang/lib/Sema/SemaOpenMP.cpp:11320
+  bool MutexClauseEncountered = false;
+  llvm::SmallSet EncounteredAtomicKinds;
   for (const OMPClause *C : Clauses) {

tianshilei1992 wrote:
> ABataev wrote:
> > ABataev wrote:
> > > tianshilei1992 wrote:
> > > > ABataev wrote:
> > > > > tianshilei1992 wrote:
> > > > > > ABataev wrote:
> > > > > > > tianshilei1992 wrote:
> > > > > > > > ABataev wrote:
> > > > > > > > > SmallVector with 2 elements should be enough, no need to use 
> > > > > > > > > SmallSet here.
> > > > > > > > `SmallVector` doesn't provide `contains`, which we use to check 
> > > > > > > > if `OMPC_compare` and `OMPC_capture` exist at the same time. 
> > > > > > > > Using `SmallVector` requires us to have a complicated 
> > > > > > > > comparison, for example:
> > > > > > > > ```
> > > > > > > > (EncounteredAtomicKinds[0] == OMPC_compare && 
> > > > > > > > EncounteredAtomicKinds[1] == OMPC_capture) || 
> > > > > > > > (EncounteredAtomicKinds[1] == OMPC_compare && 
> > > > > > > > EncounteredAtomicKinds[0] == OMPC_capture)
> > > > > > > > ```
> > > > > > > > which is not as neat as `SmallSet`.
> > > > > > > Use llvm::find
> > > > > > That is linear time. Why it is better than `SmallSet`?
> > > > > Because there are only 2 elements, no?
> > > > It could have more. If user writes it like `atomic compare compare 
> > > > capture capture capture`, then it will have 5 elements. 
> > > > `SmallSet::insert` returns a `pair` and we know if it is already in 
> > > > the set, which I have not added it yet but I'll. `SmallVector` then is 
> > > > not that easy to use. Of course you could say do `llvm::find` 
> > > > beforehand but it's not neat.
> > > Is this correct at all?
> > You still can scan over the small vector and check if it has specified 
> > clause already. 
> It's not correct. We can easily check via the following code:
> ```
> if (!EncounteredAtomicKinds.insert(C->getClauseKind()).second) {
>   // emit an error
> }
> ```
> Using `SmallVector` we need to:
> ```
> if (llvm::find(EncounteredAtomicKinds.begin(), EncounteredAtomicKinds.end(), 
> C->getClauseKind() != EncounteredAtomicKinds.end()) {
>   // emit an error
> } else {
>   EncounteredAtomicKinds.push_back(C->getClauseKind());
> }
> ```
> It's obvious which one looks better and have better readability. I can't see 
> any point of using `SmallVector` here, unless there is huge performance 
> difference, which I really doubt that matters.
```
if (llvm::find(EncounteredAtomicKinds, C->getClauseKind() != 
EncounteredAtomicKinds.end()) {
  // emit an error
} else {
  EncounteredAtomicKinds.push_back(C->getClauseKind());
}
```
but ok, let's keep SmallSet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

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


[PATCH] D118632: [Clang]OpenMP] Add the codegen support for `atomic compare`

2022-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/test/OpenMP/atomic_compare_codegen.cpp:6
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 
-fopenmp-simd -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple 
x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s

tianshilei1992 wrote:
> CodeGen for `-fopen-simd` is wrong. It doesn't emit corresponding atomic 
> operations. I'll fix it.
The logic behind -fopenmp-simd is to emit the code only for simd specific 
instructions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118632

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


[PATCH] D119392: [Clang][OpenMP][Sema] Remove support for floating point values in atomic compare

2022-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119392

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


[PATCH] D120028: [clang-format] Do not add space after return-like keywords in macros.

2022-02-17 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG331e8e4e27be: [clang-format] Do not add space after 
return-like keywords in macros. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120028

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1861,6 +1861,16 @@
"#define BBB }\n",
Style);
   // verifyFormat("#define AAA N { //\n", Style);
+
+  verifyFormat("MACRO(return)");
+  verifyFormat("MACRO(co_await)");
+  verifyFormat("MACRO(co_return)");
+  verifyFormat("MACRO(co_yield)");
+  verifyFormat("MACRO(return, something)");
+  verifyFormat("MACRO(co_return, something)");
+  verifyFormat("MACRO(something##something)");
+  verifyFormat("MACRO(return##something)");
+  verifyFormat("MACRO(co_return##something)");
 }
 
 TEST_F(FormatTest, ShortBlocksInMacrosDontMergeWithCodeAfterMacro) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2989,7 +2989,8 @@
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
-  if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
+  if (Left.is(tok::kw_return) &&
+  !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash))
 return true;
   if (Style.isJson() && Left.is(tok::string_literal) && Right.is(tok::colon))
 return false;
@@ -3026,7 +3027,7 @@
 return false;
   // co_await (x), co_yield (x), co_return (x)
   if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) &&
-  Right.isNot(tok::semi))
+  !Right.isOneOf(tok::semi, tok::r_paren))
 return true;
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren))


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1861,6 +1861,16 @@
"#define BBB }\n",
Style);
   // verifyFormat("#define AAA N { //\n", Style);
+
+  verifyFormat("MACRO(return)");
+  verifyFormat("MACRO(co_await)");
+  verifyFormat("MACRO(co_return)");
+  verifyFormat("MACRO(co_yield)");
+  verifyFormat("MACRO(return, something)");
+  verifyFormat("MACRO(co_return, something)");
+  verifyFormat("MACRO(something##something)");
+  verifyFormat("MACRO(return##something)");
+  verifyFormat("MACRO(co_return##something)");
 }
 
 TEST_F(FormatTest, ShortBlocksInMacrosDontMergeWithCodeAfterMacro) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2989,7 +2989,8 @@
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
-  if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
+  if (Left.is(tok::kw_return) &&
+  !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash))
 return true;
   if (Style.isJson() && Left.is(tok::string_literal) && Right.is(tok::colon))
 return false;
@@ -3026,7 +3027,7 @@
 return false;
   // co_await (x), co_yield (x), co_return (x)
   if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) &&
-  Right.isNot(tok::semi))
+  !Right.isOneOf(tok::semi, tok::r_paren))
 return true;
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 331e8e4 - [clang-format] Do not add space after return-like keywords in macros.

2022-02-17 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-17T22:12:39+01:00
New Revision: 331e8e4e27be5dd673898a89a7cf00e76903216a

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

LOG: [clang-format] Do not add space after return-like keywords in macros.

Fixes https://github.com/llvm/llvm-project/issues/6.

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 206fa4541217c..9a020eb6ca7dc 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2989,7 +2989,8 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const 
FormatToken &Right) const {
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   const FormatToken &Left,
   const FormatToken &Right) {
-  if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
+  if (Left.is(tok::kw_return) &&
+  !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash))
 return true;
   if (Style.isJson() && Left.is(tok::string_literal) && Right.is(tok::colon))
 return false;
@@ -3026,7 +3027,7 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
 return false;
   // co_await (x), co_yield (x), co_return (x)
   if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) &&
-  Right.isNot(tok::semi))
+  !Right.isOneOf(tok::semi, tok::r_paren))
 return true;
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren))

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 73503696741a7..f71f8dc5de456 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1861,6 +1861,16 @@ TEST_F(FormatTest, UnderstandsMacros) {
"#define BBB }\n",
Style);
   // verifyFormat("#define AAA N { //\n", Style);
+
+  verifyFormat("MACRO(return)");
+  verifyFormat("MACRO(co_await)");
+  verifyFormat("MACRO(co_return)");
+  verifyFormat("MACRO(co_yield)");
+  verifyFormat("MACRO(return, something)");
+  verifyFormat("MACRO(co_return, something)");
+  verifyFormat("MACRO(something##something)");
+  verifyFormat("MACRO(return##something)");
+  verifyFormat("MACRO(co_return##something)");
 }
 
 TEST_F(FormatTest, ShortBlocksInMacrosDontMergeWithCodeAfterMacro) {



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


[PATCH] D120034: [clang-format] PROPOSAL - WIP: Added ability to parse template arguments

2022-02-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

+1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120034

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


[PATCH] D120081: [clang][ASTReader] Fix memory leak while reading FriendTemplateDecls

2022-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allocate on ASTContext, rather than just on heap, so that template
parameter lists are freed up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120081

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2103,7 +2103,7 @@
   VisitDecl(D);
   unsigned NumParams = Record.readInt();
   D->NumParams = NumParams;
-  D->Params = new TemplateParameterList*[NumParams];
+  D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
   for (unsigned i = 0; i != NumParams; ++i)
 D->Params[i] = Record.readTemplateParameterList();
   if (Record.readInt()) // HasFriendDecl


Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2103,7 +2103,7 @@
   VisitDecl(D);
   unsigned NumParams = Record.readInt();
   D->NumParams = NumParams;
-  D->Params = new TemplateParameterList*[NumParams];
+  D->Params = new (Reader.getContext()) TemplateParameterList *[NumParams];
   for (unsigned i = 0; i != NumParams; ++i)
 D->Params[i] = Record.readTemplateParameterList();
   if (Record.readInt()) // HasFriendDecl
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-02-17 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan updated this revision to Diff 409761.
urnathan added a subscriber: cfe-commits.
urnathan added a comment.

rebase on top of D116773 


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

https://reviews.llvm.org/D118352

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
  clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
  clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
  clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
  clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
  clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
  clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
  clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
  clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
  clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
  clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
  clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm

Index: clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO;
+
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1MEPS1_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1NIS_3TwoEEvPS1_PT_(
+template void TPL::N (One *, Two *);
+
+namespace NMS {
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1MEPS2_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1NINS_S0_3TwoEEEvPS2_PT_
+template void TPL::N (One *, Two *);
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %S/cxx20-module-sub-1a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAZ;
+import FOO.BAR;
+
+namespace Bob {
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAZ3FooEPS0_W3BAR1APNS_S2_1BE(
+void Foo (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAZ3BarPS_W3BAR1APN3BobS1_1BE(
+void Bar (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAR;
+export class A;
+namespace Bob {
+export class B;
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAR3BarEPS1_1APNS_S1_1BE(
+export void Bar (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAR3FooPS0_1APN3BobS0_1BE(
+export void Foo (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+module;
+# 5 __FILE__ 1
+namespace std {
+template  struct char_traits {};
+} // namespace std
+# 9 "" 2
+export module Bar;
+import RenameString;
+
+// Use Sb as this is global-module std::char_traits
+// CHECK-DAG: void @_ZW3Bar1gRSs(
+void g(str> &s) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+
+export module Foo;
+import RenameString;
+
+namespace std {
+template  struct char_traits {};
+} // namespace std
+
+// use Sb mangling, no

[PATCH] D112081: Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)

2022-02-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D112081#3330585 , @emmenlau wrote:

> Current OpenSSL 1.1.1m requires `__STDC_NO_ATOMICS__` to build with clang-cl 
> against MSVC. Is this on-topic here?

I think stdatomic.h is supposed to work with clang-cl, see this comment here:
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdatomic.h#L16
If it's not working, I'd recommend filing a github issue with more details 
about any compile failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112081

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


[PATCH] D112081: Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)

2022-02-17 Thread Mario Emmenlauer via Phabricator via cfe-commits
emmenlau added a comment.

Current OpenSSL 1.1.1m requires `__STDC_NO_ATOMICS__` to build with clang-cl 
against MSVC. Is this on-topic here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112081

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


[PATCH] D120065: [clang][SemaTemplate] Fix a stack use after scope

2022-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc79c13cae615: [clang][SemaTemplate] Fix a stack use after 
scope (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120065

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/test/SemaTemplate/friend-template.cpp


Index: clang/test/SemaTemplate/friend-template.cpp
===
--- clang/test/SemaTemplate/friend-template.cpp
+++ clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template 
specialization declaration cannot be a friend}}
+  bool aux;
+};
+}
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)
-  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
-Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
+  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
+Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
 
   FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}
 


Index: clang/test/SemaTemplate/friend-template.cpp
===
--- clang/test/SemaTemplate/friend-template.cpp
+++ clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template specialization declaration cannot be a friend}}
+  bool aux;
+};
+}
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  Friend

[clang] c79c13c - [clang][SemaTemplate] Fix a stack use after scope

2022-02-17 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2022-02-17T21:47:50+01:00
New Revision: c79c13cae61564d3a03831013ea24ff483ee3e82

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

LOG: [clang][SemaTemplate] Fix a stack use after scope

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

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/DeclTemplate.cpp
clang/test/SemaTemplate/friend-template.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index d216b359816e8..319e605a8a1c5 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@ class FriendTemplateDecl : public Decl {
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)
-  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
-Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
+  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
+Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
 
   FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}
 

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 223f06b9db1c9..d9ff3517a589c 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@ FriendTemplateDecl::Create(ASTContext &Context, 
DeclContext *DC,
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,

diff  --git a/clang/test/SemaTemplate/friend-template.cpp 
b/clang/test/SemaTemplate/friend-template.cpp
index e9b2b9b8e64e5..2dcee6c76da7d 100644
--- a/clang/test/SemaTemplate/friend-template.cpp
+++ b/clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@ namespace rdar12350696 {
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template 
specialization declaration cannot be a friend}}
+  bool aux;
+};
+}



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


[PATCH] D120065: [clang][SemaTemplate] Fix a stack use after scope

2022-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/include/clang/AST/DeclTemplate.h:2464
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)

sammccall wrote:
> Is this change just to emphasize that this constructor won't copy the 
> contents?
yes and also to keep the implementation of the constructor simple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120065

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


[PATCH] D120065: [clang][SemaTemplate] Fix a stack use after scope

2022-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 409752.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Inline `Params.size()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120065

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/test/SemaTemplate/friend-template.cpp


Index: clang/test/SemaTemplate/friend-template.cpp
===
--- clang/test/SemaTemplate/friend-template.cpp
+++ clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template 
specialization declaration cannot be a friend}}
+  bool aux;
+};
+}
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)
-  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
-Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
+  : Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
+Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}
 
   FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}
 


Index: clang/test/SemaTemplate/friend-template.cpp
===
--- clang/test/SemaTemplate/friend-template.cpp
+++ clang/test/SemaTemplate/friend-template.cpp
@@ -329,3 +329,12 @@
 foo(b); // expected-note {{in instantiation}}
   }
 }
+
+namespace StackUseAfterScope {
+template  class Bar {};
+class Foo {
+  // Make sure this doesn't crash.
+  template <> friend class Bar; // expected-error {{template specialization declaration cannot be a friend}}
+  bool aux;
+};
+}
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1098,7 +1099,13 @@
SourceLocation L,
MutableArrayRef Params,
FriendUnion Friend, SourceLocation FLoc) {
-  return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
+  TemplateParameterList **TPL = nullptr;
+  if (!Params.empty()) {
+TPL = new (Context) TemplateParameterList *[Params.size()];
+llvm::copy(Params, TPL);
+  }
+  return new (Context, DC)
+  FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
 }
 
 FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2461,10 +2461,10 @@
   SourceLocation FriendLoc;
 
   FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
- MutableArrayRef Params,
+ TemplateParameterList **Params, unsigned NumParams,
  FriendUnion Friend, SourceLocation FriendLoc)
-  : Decl(Decl::FriendTemplate, DC, Loc), NumParams

[PATCH] D119601: [analyzer] Refactor makeNull to makeNullWithWidth

2022-02-17 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked 5 inline comments as done.
vabridgers added a comment.

I believe I've addressed all of Artem's comments thus far. This is a NFC patch, 
so will include no test cases. We detected these inconsistencies in getting 
NULL pointers in our downstream target, that supports 2 different pointer sizes 
depending on address space. That review is here,  
https://reviews.llvm.org/D118050, and is dependent upon these fixes (makeNull 
-> makeNullWithWidth refactoring). These two patches will be kept separate, 
with this patch reviewed and submitted first followed by  
https://reviews.llvm.org/D118050.

Please let me know what else needs to be done to move this patch forward. 
Thanks - Vince


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119601

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


[clang] f5b85f1 - Use functions with prototypes when appropriate; NFC

2022-02-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-02-17T15:33:50-05:00
New Revision: f5b85f15510db409277d8492524b2fc040e776d8

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

LOG: Use functions with prototypes when appropriate; NFC

Now that the AST printer properly handles functions with no parameters
in C code, all of the tests relying on AST printing can be updated to
use prototypes where appropriate.

Added: 


Modified: 
clang/test/ARCMT/GC-check-warn-nsalloc.m
clang/test/ARCMT/autoreleases.m
clang/test/ARCMT/autoreleases.m.result
clang/test/ARCMT/checking.m
clang/test/ARCMT/nonobjc-to-objc-cast-2.m
clang/test/ARCMT/objcmt-arc-cf-annotations.m
clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
clang/test/ARCMT/objcmt-instancetype.m
clang/test/ARCMT/objcmt-instancetype.m.result
clang/test/ARCMT/objcmt-property-dot-syntax.m
clang/test/ARCMT/objcmt-property-dot-syntax.m.result
clang/test/ARCMT/objcmt-subscripting-literals.m
clang/test/ARCMT/objcmt-subscripting-literals.m.result
clang/test/ARCMT/objcmt-with-pch.m
clang/test/ARCMT/objcmt-with-pch.m.result
clang/test/ARCMT/releases-driver.m
clang/test/ARCMT/releases-driver.m.result
clang/test/ARCMT/releases.m
clang/test/ARCMT/releases.m.result
clang/test/ARCMT/retains.m
clang/test/ARCMT/retains.m.result
clang/test/ARCMT/rewrite-block-var.m
clang/test/ARCMT/rewrite-block-var.m.result
clang/test/Sema/ast-print.c

Removed: 




diff  --git a/clang/test/ARCMT/GC-check-warn-nsalloc.m 
b/clang/test/ARCMT/GC-check-warn-nsalloc.m
index af17c1d69c5f3..26ead5f6a0907 100644
--- a/clang/test/ARCMT/GC-check-warn-nsalloc.m
+++ b/clang/test/ARCMT/GC-check-warn-nsalloc.m
@@ -6,6 +6,6 @@
 typedef unsigned NSUInteger;
 void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
 
-void test1() {
+void test1(void) {
   NSAllocateCollectable(100, 0);
 }

diff  --git a/clang/test/ARCMT/autoreleases.m b/clang/test/ARCMT/autoreleases.m
index 91413e51ca66f..4c268c09a715c 100644
--- a/clang/test/ARCMT/autoreleases.m
+++ b/clang/test/ARCMT/autoreleases.m
@@ -69,7 +69,7 @@ id test2(A* val) {
   return val;
 }
 
-id test3() {
+id test3(void) {
   id a = [[A alloc] init];
   [a autorelease];
 }

diff  --git a/clang/test/ARCMT/autoreleases.m.result 
b/clang/test/ARCMT/autoreleases.m.result
index 32c7ad3c39710..b3aad804a45be 100644
--- a/clang/test/ARCMT/autoreleases.m.result
+++ b/clang/test/ARCMT/autoreleases.m.result
@@ -64,6 +64,6 @@ id test2(A* val) {
   return val;
 }
 
-id test3() {
+id test3(void) {
   id a = [[A alloc] init];
 }

diff  --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m
index bf08ceaa6fe2a..0c69a7ffaad60 100644
--- a/clang/test/ARCMT/checking.m
+++ b/clang/test/ARCMT/checking.m
@@ -124,7 +124,7 @@ -(id)alloc;
 - (id)initWithInt: (int) i;
 @end
 
-void rdar8861761() {
+void rdar8861761(void) {
   B *o1 = [[B alloc] initWithInt:0];
   B *o2 = [B alloc];
   [o2 initWithInt:0];

diff  --git a/clang/test/ARCMT/nonobjc-to-objc-cast-2.m 
b/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
index 2e308a87ba838..b8f562f8a42dd 100644
--- a/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
+++ b/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
@@ -49,7 +49,7 @@ void f2(NSString *s) {
 // expected-note{{use CFBridgingRetain call to make an ARC object 
available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
 }
 
-CFStringRef f3() {
+CFStringRef f3(void) {
   return (CFStringRef)[[[NSString alloc] init] autorelease]; // expected-error 
{{it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; 
a __bridge cast may result in a pointer to a destroyed object and a 
__bridge_retained may leak the object}} \
 // expected-note {{remove the cast and change return type of function to 
'NSString *' to have the object automatically autoreleased}}
 }

diff  --git a/clang/test/ARCMT/objcmt-arc-cf-annotations.m 
b/clang/test/ARCMT/objcmt-arc-cf-annotations.m
index e33b8801cd4dc..221a8a9e7d4d0 100644
--- a/clang/test/ARCMT/objcmt-arc-cf-annotations.m
+++ b/clang/test/ARCMT/objcmt-arc-cf-annotations.m
@@ -335,7 +335,7 @@ + (id)array;
 // Test cases.
 
//===--===//
 
-CFAbsoluteTime f1() {
+CFAbsoluteTime f1(void) {
   CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
   CFDateRef date = CFDateCreate(0, t);
   CFRetain(date);
@@ -346,7 +346,7 @@ CFAbsoluteTime f1() {
   return t;
 }
 
-CFAbsoluteTime f2() {
+CFAbsoluteTime f2(void) {
   CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
   CFDateRef date = CFDateCreate(0, t);  
   [((NSDate*) date) retain];
@@ -363,7 +363,7 @@ CFAbsoluteTime f2() {
 // Test to see if we suppress an error when we store the pointer
 // to a global.
 
-

[PATCH] D119601: [analyzer] Refactor makeNull to makeNullWithWidth

2022-02-17 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 409750.
vabridgers added a comment.

Address NoQ comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119601

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -61,7 +61,7 @@
 
 DefinedOrUnknownSVal SValBuilder::makeZeroVal(QualType type) {
   if (Loc::isLocType(type))
-return makeNull();
+return makeNullWithType(type);
 
   if (type->isIntegralOrEnumerationType())
 return makeIntVal(0, type);
@@ -359,7 +359,7 @@
 return makeBoolVal(cast(E));
 
   case Stmt::CXXNullPtrLiteralExprClass:
-return makeNull();
+return makeNullWithType(E->getType());
 
   case Stmt::CStyleCastExprClass:
   case Stmt::CXXFunctionalCastExprClass:
@@ -399,7 +399,7 @@
 
 if (Loc::isLocType(E->getType()))
   if (E->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull))
-return makeNull();
+return makeNullWithType(E->getType());
 
 return None;
   }
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2410,7 +2410,7 @@
   SVal V;
 
   if (Loc::isLocType(T))
-V = svalBuilder.makeNull();
+V = svalBuilder.makeNullWithType(T);
   else if (T->isIntegralOrEnumerationType())
 V = svalBuilder.makeZeroVal(T);
   else if (T->isStructureOrClassType() || T->isArrayType()) {
Index: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -460,7 +460,8 @@
 continue;
   } else {
 // If the cast fails on a pointer, bind to 0.
-state = state->BindExpr(CastE, LCtx, svalBuilder.makeNull());
+state = state->BindExpr(CastE, LCtx,
+svalBuilder.makeNullWithType(resultType));
   }
 } else {
   // If we don't know if the cast succeeded, conjure a new symbol.
@@ -498,7 +499,7 @@
 continue;
   }
   case CK_NullToPointer: {
-SVal V = svalBuilder.makeNull();
+SVal V = svalBuilder.makeNullWithType(CastE->getType());
 state = state->BindExpr(CastE, LCtx, V);
 Bldr.generateNode(CastE, Pred, state);
 continue;
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -549,8 +549,9 @@
   State->BindExpr(CE, C.getLocationContext(), *StreamVal);
   // Generate state for NULL return value.
   // Stream switches to OpenFailed state.
-  ProgramStateRef StateRetNull = State->BindExpr(CE, C.getLocationContext(),
- C.getSValBuilder().makeNull());
+  ProgramStateRef StateRetNull =
+  State->BindExpr(CE, C.getLocationContext(),
+  C.getSValBuilder().makeNullWithType(CE->getType()));
 
   StateRetNotNull =
   StateRetNotNull->set(StreamSym, StreamState::getOpened(Desc));
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -71,7 +71,8 @@
   bool handleMoveCtr(const CallEvent &Call, CheckerContext &C,
  const MemRegion *ThisRegion) const;
   bool updateMovedSmartPointers(CheckerContext &C, const MemRegion *ThisRegion,
-const MemRegion *OtherSmartPtrRegion) const;
+const MemRegion *OtherSmartPtrRegion,
+const CallEvent &Call) const;
   void handleBoolConversion(const CallEvent &Call, CheckerContext &C) const;
   bool handleComparisionOp(const CallEvent &Call, CheckerContext &C) const;
   bool handleOstreamOperator(const CallEvent &Call, CheckerContext &C) const;
@@ -119,6 +120,20 @@
   return isStdSmartPtr(E->getType()->getAsCXXRecordDecl

[PATCH] D117522: [clang-tidy] Add modernize-macro-to-enum check

2022-02-17 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Ping.  Waiting for review feedback for about a week now.


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

https://reviews.llvm.org/D117522

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


[PATCH] D119207: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-17 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D119207#3330494 , @shangwuyao 
wrote:

> In D119207#3330385 , @dyung wrote:
>
>> Hi, the test you added is failing on the PS4 Linux bot, can you take a look?
>>
>> https://lab.llvm.org/buildbot/#/builders/139/builds/17199
>
> Looks like the compiled SPIR-V is slightly different for different build 
> settings, for `llvm-clang-x86_64-sie-ubuntu-fast`, it is compiled to
>
>   define hidden spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef 
> %output.coerce) #0 { 
>
> so it is missing that extra `hidden` keyword. 
> And for `clang-ve-ninja`, it is compiled to
>
>   define spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef %0) #0 { 
>
> so the kernel argument identifier is slightly different (`%0` vs 
> `%output.coerce`).
>
> I could fix that, I wonder why it didn't trigger the same issue (for the 
> `hidden` keyword) with this test 
> 
>  tho, it is basically the same.
>
> And why does those build test run only after merging? For future reference, 
> can I try to run those myself before submitting?

These are build bots that run builds when new commits are detected. That's how 
they work. There is some pre-commit testing, but I'm not sure how that works 
exactly.

You can run these builds yourself before submitting, just extract the cmake 
command from the job and then run the build/test the normal way. If you need 
help reproducing a bot failure, an email to the bot owner can help you if you 
have trouble reproducing a failure.

> For this change, should we do a rollback and then re-land it after applying 
> the fix?

If you can fix it soon, a quick fix is fine. If you need time to investigate, a 
revert would be best until you can fix it so that the bot does not keep failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119207

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


[PATCH] D119207: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-17 Thread Shangwu Yao via Phabricator via cfe-commits
shangwuyao added a comment.

In D119207#3330385 , @dyung wrote:

> Hi, the test you added is failing on the PS4 Linux bot, can you take a look?
>
> https://lab.llvm.org/buildbot/#/builders/139/builds/17199

Looks like the compiled SPIR-V is slightly different for different build 
settings, for `llvm-clang-x86_64-sie-ubuntu-fast`, it is compiled to

  define hidden spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef 
%output.coerce) #0 { 

so it is missing that extra `hidden` keyword. 
And for `clang-ve-ninja`, it is compiled to

  define spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef %0) #0 { 

so the kernel argument identifier is slightly different (`%0` vs 
`%output.coerce`).

I could fix that, I wonder why it didn't trigger the same issue (for the 
`hidden` keyword) with this test 

 tho, it is basically the same.

And why does those build test run only after merging? For future reference, can 
I try to run those myself before submitting?

For this change, should we do a rollback and then re-land it after applying the 
fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119207

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


[PATCH] D119184: [clang] [concepts] Check constrained-auto return types for void-returning functions

2022-02-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 409740.
Quuxplusone added a comment.

Rebase and update — this is becoming more and more of a trivial patch, which I 
guess is good!
Add a test case for https://github.com/llvm/llvm-project/issues/53911 (which I 
finally thought to test, and was surprised to find it didn't work either before 
//or// after my patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119184

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaTemplate/concepts.cpp

Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -169,3 +169,42 @@
   template void f(T, U) = delete;
   void g() { f(0, 0); }
 }
+
+namespace PR49188 {
+  template concept C = false; // expected-note 6 {{because 'false' evaluated to false}}
+
+  C auto f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return void();
+  }
+  C auto f2() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return;
+  }
+  C auto f3() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+  }
+  C decltype(auto) f4() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return void();
+  }
+  C decltype(auto) f5() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return;
+  }
+  C decltype(auto) f6() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+  }
+  C auto& f7() { // expected-error {{cannot form a reference to 'void'}}
+return void();
+  }
+  C auto& f8() {
+return; // expected-error {{cannot deduce return type 'C auto &' from omitted return expression}}
+  }
+  C auto& f9() { // expected-error {{cannot deduce return type 'C auto &' for function with no return statements}}
+  }
+}
+namespace PR53911 {
+  template concept C = false;
+
+  C auto *f1() {
+return (void*)nullptr; // FIXME: should error
+  }
+  C auto *f2() {
+return (int*)nullptr; // FIXME: should error
+  }
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3762,8 +3762,8 @@
 bool Sema::DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD,
 SourceLocation ReturnLoc,
 Expr *&RetExpr,
-AutoType *AT) {
-  // If this is the conversion function for a lambda, we choose to deduce it
+const AutoType *AT) {
+  // If this is the conversion function for a lambda, we choose to deduce its
   // type from the corresponding call operator, not from the synthesized return
   // statement within it. See Sema::DeduceReturnType.
   if (isLambdaConversionOperator(FD))
@@ -3808,19 +3808,26 @@
 LocalTypedefNameReferencer Referencer(*this);
 Referencer.TraverseType(RetExpr->getType());
   } else {
-//  In the case of a return with no operand, the initializer is considered
-//  to be void().
-//
-// Deduction here can only succeed if the return type is exactly 'cv auto'
-// or 'decltype(auto)', so just check for that case directly.
+// For a function with a deduced result type to return void,
+// the result type as written must be 'auto' or 'decltype(auto)',
+// possibly cv-qualified or constrained, but not ref-qualified.
 if (!OrigResultType.getType()->getAs()) {
   Diag(ReturnLoc, diag::err_auto_fn_return_void_but_not_auto)
 << OrigResultType.getType();
   return true;
 }
-// We always deduce U = void in this case.
-Deduced = SubstAutoType(OrigResultType.getType(), Context.VoidTy);
-if (Deduced.isNull())
+// In the case of a return with no operand, the initializer is considered
+// to be 'void()'.
+Expr *Dummy = new (Context) CXXScalarValueInitExpr(
+Context.VoidTy,
+Context.getTrivialTypeSourceInfo(Context.VoidTy, ReturnLoc), ReturnLoc);
+DeduceAutoResult DAR = DeduceAutoType(OrigResultType, Dummy, Deduced);
+
+if (DAR == DAR_Failed && !FD->isInvalidDecl())
+  Diag(ReturnLoc, diag::err_auto_fn_deduction_failure)
+  << OrigResultType.getType() << Dummy->getType();
+
+if (DAR != DAR_Succeeded)
   return true;
   }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14660,18 +14660,20 @@
   if (getLangOpts().CPlusPlus14) {
 if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() &&
 FD->getReturnType()->isUndeducedType()) {
-  // If the function has a deduced result type but contains no 'return'
- 

[PATCH] D119562: Provide fine control of color in run-clang-tidy

2022-02-17 Thread Kesavan Yogeswaran via Phabricator via cfe-commits
kesyog marked an inline comment as done.
kesyog added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119562

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D120078: Insert MIRProfile into LLD

2022-02-17 Thread Roger Kim via Phabricator via cfe-commits
Roger created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya.
Roger requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120078

Files:
  clang/test/Pika/MIP/mip-stat-debug-info.c
  llvm/lib/LTO/LTO.cpp


Index: llvm/lib/LTO/LTO.cpp
===
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -52,6 +52,7 @@
 #include "llvm/Transforms/Utils/FunctionImportUtils.h"
 #include "llvm/Transforms/Utils/SplitModule.h"
 #ifdef __FACEBOOK__
+#include "pika/CodeGen/MIRProfileSummary.h"
 #include "pika/Transforms/IPO/IVarDirectAccess.h"
 #endif // __FACEBOOK__
 
@@ -977,10 +978,19 @@
 return StatsFileOrErr.takeError();
   std::unique_ptr StatsFile = std::move(StatsFileOrErr.get());
 
+#ifdef __FACEBOOK__
+  MIRProfileSummary::parseProfile();
+#endif
+
   Error Result = runRegularLTO(AddStream);
   if (!Result)
 Result = runThinLTO(AddStream, Cache, GUIDPreservedSymbols);
 
+#ifdef __FACEBOOK__
+  std::vector temp;
+  MIRProfileSummary::publishFinalOrderedSymbols(temp);
+#endif
+
   if (StatsFile)
 PrintStatisticsJSON(StatsFile->os());
 
Index: clang/test/Pika/MIP/mip-stat-debug-info.c
===
--- clang/test/Pika/MIP/mip-stat-debug-info.c
+++ clang/test/Pika/MIP/mip-stat-debug-info.c
@@ -1,11 +1,28 @@
 // REQUIRES: system-darwin && native && asserts
 // RUN: llvm-odrcov yaml2mip %p/Inputs/mip-stat-debug-info-x86.yaml -p %t.mip
 // RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx -flto 
-c -o %t.o %s
-// RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx 
-Wl,-mllvm,-odrcov-use=%t.mip -Wl,-mllvm,-debug-only=mip-stat -o %t %t.o 
2>/dev/stdout >/dev/null | FileCheck %s
+// RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx 
-Wl,-mllvm,-odrcov-use=%t.mip -Wl,-mllvm,-debug-only=mip-stat -o %t-ld64.out 
%t.o 2>%t/logs-ld64 >/dev/null
+// RUN: FileCheck %s < %t/logs-ld64
+// RUN: llvm-objdump --section=__text -D %t-ld64.out | FileCheck 
--check-prefix OUTPUT-ORDER %s
+// RUN: %clang -fuse-ld=lld.darwinnew -isysroot %macos_sdk_root -g -target 
x86_64-apple-macosx -Wl,-mllvm,-odrcov-use=%t.mip 
-Wl,-mllvm,-debug-only=mip-stat -o %t-lld.out %t.o 2>%t/logs-lld >/dev/null
+// RUN: llvm-objdump --section=__text -D %t-lld.out | FileCheck --check-prefix 
OUTPUT-ORDER %s
+
+// # ld64 and lld should be running the same code for MIRProfile logic so the
+// # output should be exactly the same.
+// RUN: diff %t/logs-ld64 %t/logs-lld
 
 // RUN: llvm-odrcov yaml2mip %p/Inputs/mip-stat-debug-info-arm64.yaml -p 
%t-arm64.mip
 // RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx -flto -c -o 
%t.o %s
-// RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx 
-Wl,-mllvm,-odrcov-use=%t-arm64.mip -Wl,-mllvm,-debug-only=mip-stat -o %t %t.o 
2>/dev/stdout >/dev/null | FileCheck --check-prefix CHECK-ARM64 %s
+// RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx 
-Wl,-mllvm,-odrcov-use=%t-arm64.mip -Wl,-mllvm,-debug-only=mip-stat -o 
%t-arm64-ld64.out %t.o 2>%t/logs-arm64-ld64 >/dev/null
+// RUN: FileCheck --check-prefix CHECK-ARM64 %s < %t/logs-arm64-ld64
+// RUN: llvm-objdump --section=__text -D %t-arm64-ld64.out | FileCheck 
--check-prefix OUTPUT-ORDER %s
+// RUN: %clang -fuse-ld=lld.darwinnew -isysroot %macos_sdk_root -g -target 
arm64-macosx -Wl,-mllvm,-odrcov-use=%t-arm64.mip 
-Wl,-mllvm,-debug-only=mip-stat -o %t-arm64-lld.out %t.o 2>%t/logs-arm64-lld 
>/dev/null
+// RUN: FileCheck --check-prefix CHECK-ARM64 %s < %t/logs-arm64-lld
+// RUN: llvm-objdump --section=__text -D %t-arm64-lld.out | FileCheck 
--check-prefix OUTPUT-ORDER %s
+
+// # ld64 and lld should be running the same code for MIRProfile logic so the
+// # output should be exactly the same.
+// RUN: diff %t/logs-arm64-ld64 %t/logs-arm64-lld
 
 // CHECK:  [OdrCov] Parsed profile [[MIP_PATH:.+\.mip]]
 // CHECK-NEXT: [MachineIRProfileStat] Start
@@ -33,6 +50,12 @@
 // CHECK-ARM64-NEXT:   [MachineIRProfileStat]   f3: 24
 // CHECK-ARM64-NEXT:   [MachineIRProfileStat]   main: 56
 
+// OUTPUT-ORDER: Disassembly of section __TEXT,__text:
+// OUTPUT-ORDER: <_f1>:
+// OUTPUT-ORDER: <_f2>:
+// OUTPUT-ORDER: <_f3>:
+// OUTPUT-ORDER: <_f5>:
+
 #include 
 
 // Hot function


Index: llvm/lib/LTO/LTO.cpp
===
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -52,6 +52,7 @@
 #include "llvm/Transforms/Utils/FunctionImportUtils.h"
 #include "llvm/Transforms/Utils/SplitModule.h"
 #ifdef __FACEBOOK__
+#include "pika/CodeGen/MIRProfileSummary.h"
 #include "pika/Transforms/IPO/IVarDirectAccess.h"
 #endif // __FACEBOOK__
 
@@ -977,10 +978,19 @@
 return StatsFileOrErr.takeError();
   std::unique_ptr StatsFile = std::move(StatsFileOrErr.get());
 
+#ifdef __FACEBOOK

[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82e5f951fd6e: AST: Move __va_list tag back to std 
conditionally on AArch64. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D116774?vs=409716&id=409734#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/arm64-be-hfa-vararg.c
  clang/test/Headers/stdarg.cpp

Index: clang/test/Headers/stdarg.cpp
===
--- clang/test/Headers/stdarg.cpp
+++ clang/test/Headers/stdarg.cpp
@@ -15,7 +15,7 @@
 
 #include 
 
-// AARCH64-C: define {{.*}} @f(i32 noundef %n, %"struct.std::__va_list"* noundef %list)
+// AARCH64-C: define {{.*}} @f(i32 noundef %n, %struct.__va_list* noundef %list)
 // AARCH64-CXX: define {{.*}} @_Z1fiSt9__va_list(i32 noundef %n, %"struct.std::__va_list"* noundef %list)
 // X86_64-C: define {{.*}} @f(i32 noundef %n, %struct.__va_list_tag* noundef %list)
 // X86_64-CXX: define {{.*}} @_Z1fiP13__va_list_tag(i32 noundef %n, %struct.__va_list_tag* noundef %list)
Index: clang/test/CodeGen/arm64-be-hfa-vararg.c
===
--- clang/test/CodeGen/arm64-be-hfa-vararg.c
+++ clang/test/CodeGen/arm64-be-hfa-vararg.c
@@ -4,12 +4,12 @@
 
 // A single member HFA must be aligned just like a non-HFA register argument.
 double callee(int a, ...) {
-// CHECK: [[REGPP:%.*]] = getelementptr inbounds %"struct.std::__va_list", %"struct.std::__va_list"* [[VA:%.*]], i32 0, i32 2
+// CHECK: [[REGPP:%.*]] = getelementptr inbounds %struct.__va_list, %struct.__va_list* [[VA:%.*]], i32 0, i32 2
 // CHECK: [[REGP:%.*]] = load i8*, i8** [[REGPP]], align 8
 // CHECK: [[OFFSET0:%.*]] = getelementptr inbounds i8, i8* [[REGP]], i32 {{.*}}
 // CHECK: [[OFFSET1:%.*]] = getelementptr inbounds i8, i8* [[OFFSET0]], i64 8
 
-// CHECK: [[MEMPP:%.*]] = getelementptr inbounds %"struct.std::__va_list", %"struct.std::__va_list"* [[VA:%.*]], i32 0, i32 0
+// CHECK: [[MEMPP:%.*]] = getelementptr inbounds %struct.__va_list, %struct.__va_list* [[VA:%.*]], i32 0, i32 0
 // CHECK: [[MEMP:%.*]] = load i8*, i8** [[MEMPP]], align 8
 // CHECK: [[NEXTP:%.*]] = getelementptr inbounds i8, i8* [[MEMP]], i64 8
 // CHECK: store i8* [[NEXTP]], i8** [[MEMPP]], align 8
Index: clang/test/CodeGen/aarch64-varargs.c
===
--- clang/test/CodeGen/aarch64-varargs.c
+++ clang/test/CodeGen/aarch64-varargs.c
@@ -11,18 +11,18 @@
 int simple_int(void) {
 // CHECK-LABEL: define{{.*}} i32 @simple_int
   return va_arg(the_list, int);
-// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 3)
+// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0
 // CHECK: br i1 [[EARLY_ONSTACK]], label %[[VAARG_ON_STACK:[a-z_.0-9]+]], label %[[VAARG_MAYBE_REG:[a-z_.0-9]+]]
 
 // CHECK: [[VAARG_MAYBE_REG]]
 // CHECK: [[NEW_REG_OFFS:%[a-z_0-9]+]] = add i32 [[GR_OFFS]], 8
-// CHECK: store i32 [[NEW_REG_OFFS]], i32* getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 3)
+// CHECK: store i32 [[NEW_REG_OFFS]], i32* getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[INREG:%[a-z_0-9]+]] = icmp sle i32 [[NEW_REG_OFFS]], 0
 // CHECK: br i1 [[INREG]], label %[[VAARG_IN_REG:[a-z_.0-9]+]], label %[[VAARG_ON_STACK]]
 
 // CHECK: [[VAARG_IN_REG]]
-// CHECK: [[REG_TOP:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 1)
+// CHECK: [[REG_TOP:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 1)
 // CHECK: [[REG_ADDR:%[a-z_0-9]+]] = getelementptr inbounds i8, i8* [[REG_TOP]], i32 [[GR_OFFS]]
 // CHECK-BE: [[REG_ADDR_ALIGNED:%[0-9]+]] = getelementptr inbounds i8, i8* [[REG_ADDR]], i64 4
 // CHECK-BE: [[FROMREG_ADDR:%[a-z_0-9]+]] = bitcast i8* [[REG_ADDR_ALIGNED]] to i32*
@@ -30,9 +30,9 @@
 // CHECK: br label %[[VAARG_END:[a-z._0-9]+]]
 
 // CHECK: [[VAARG_ON_STACK]]
-// CHECK: [[STACK:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 0)
+// CHECK: [[STACK:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
 // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, i8* [[STACK]], i64 8
-// CHECK: store i8* [[NEW_STACK]], i8

[clang] 18ead23 - AST: Make getEffectiveDeclContext() a member function of ItaniumMangleContextImpl. NFCI.

2022-02-17 Thread Peter Collingbourne via cfe-commits

Author: Peter Collingbourne
Date: 2022-02-17T11:31:40-08:00
New Revision: 18ead23385a4e0e6421d658591b1ee6a1c592b53

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

LOG: AST: Make getEffectiveDeclContext() a member function of 
ItaniumMangleContextImpl. NFCI.

In an upcoming change we are going to need to access mangler state
from the getEffectiveDeclContext() function. Therefore, make it a
member function of ItaniumMangleContextImpl. Any callers that are
not currently members of ItaniumMangleContextImpl or CXXNameMangler
are made members of one or the other depending on where they are
called from.

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 63e40a0f3072..4277a0166f20 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -40,65 +40,10 @@ using namespace clang;
 
 namespace {
 
-/// Retrieve the declaration context that should be used when mangling the 
given
-/// declaration.
-static const DeclContext *getEffectiveDeclContext(const Decl *D) {
-  // The ABI assumes that lambda closure types that occur within
-  // default arguments live in the context of the function. However, due to
-  // the way in which Clang parses and creates function declarations, this is
-  // not the case: the lambda closure type ends up living in the context
-  // where the function itself resides, because the function declaration itself
-  // had not yet been created. Fix the context here.
-  if (const CXXRecordDecl *RD = dyn_cast(D)) {
-if (RD->isLambda())
-  if (ParmVarDecl *ContextParam
-= dyn_cast_or_null(RD->getLambdaContextDecl()))
-return ContextParam->getDeclContext();
-  }
-
-  // Perform the same check for block literals.
-  if (const BlockDecl *BD = dyn_cast(D)) {
-if (ParmVarDecl *ContextParam
-  = dyn_cast_or_null(BD->getBlockManglingContextDecl()))
-  return ContextParam->getDeclContext();
-  }
-
-  const DeclContext *DC = D->getDeclContext();
-  if (isa(DC) || isa(DC) ||
-  isa(DC)) {
-return getEffectiveDeclContext(cast(DC));
-  }
-
-  if (const auto *VD = dyn_cast(D))
-if (VD->isExternC())
-  return VD->getASTContext().getTranslationUnitDecl();
-
-  if (const auto *FD = dyn_cast(D))
-if (FD->isExternC())
-  return FD->getASTContext().getTranslationUnitDecl();
-
-  return DC->getRedeclContext();
-}
-
-static const DeclContext *getEffectiveParentContext(const DeclContext *DC) {
-  return getEffectiveDeclContext(cast(DC));
-}
-
 static bool isLocalContainerContext(const DeclContext *DC) {
   return isa(DC) || isa(DC) || 
isa(DC);
 }
 
-static const RecordDecl *GetLocalClassDecl(const Decl *D) {
-  const DeclContext *DC = getEffectiveDeclContext(D);
-  while (!DC->isNamespace() && !DC->isTranslationUnit()) {
-if (isLocalContainerContext(DC))
-  return dyn_cast(D);
-D = cast(DC);
-DC = getEffectiveDeclContext(D);
-  }
-  return nullptr;
-}
-
 static const FunctionDecl *getStructor(const FunctionDecl *fn) {
   if (const FunctionTemplateDecl *ftd = fn->getPrimaryTemplate())
 return ftd->getTemplatedDecl();
@@ -249,6 +194,14 @@ class ItaniumMangleContextImpl : public 
ItaniumMangleContext {
 return DiscriminatorOverride;
   }
 
+  const DeclContext *getEffectiveDeclContext(const Decl *D);
+  const DeclContext *getEffectiveParentContext(const DeclContext *DC) {
+return getEffectiveDeclContext(cast(DC));
+  }
+
+  bool isInternalLinkageDecl(const NamedDecl *ND);
+  const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC);
+
   /// @}
 };
 
@@ -427,6 +380,15 @@ class CXXNameMangler {
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
+  bool isStd(const NamespaceDecl *NS);
+  bool isStdNamespace(const DeclContext *DC);
+
+  const RecordDecl *GetLocalClassDecl(const Decl *D);
+  const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC);
+  bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A);
+  bool isStdCharSpecialization(const ClassTemplateSpecializationDecl *SD,
+   llvm::StringRef Name, bool HasAllocator);
+
 public:
   CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
  const NamedDecl *D = nullptr, bool NullOut_ = false)
@@ -628,7 +590,48 @@ class CXXNameMangler {
 
 }
 
-static bool isInternalLinkageDecl(const NamedDecl *ND) {
+/// Retrieve the declaration context that should be used when mangling the 
given
+/// declaration.
+const DeclContext *
+ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) {
+  // The ABI assumes that lambda closure types that occur within
+  // defau

[clang] 82e5f95 - AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Peter Collingbourne via cfe-commits

Author: Peter Collingbourne
Date: 2022-02-17T11:31:40-08:00
New Revision: 82e5f951fd6e6ad6323067d8afcf025fc72d9c33

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

LOG: AST: Move __va_list tag back to std conditionally on AArch64.

In post-commit feedback on D104830 Jessica Clarke pointed out that
unconditionally adding __va_list to the std namespace caused namespace
debug info to be emitted in C, which is not only inappropriate but
turned out to confuse the dtrace tool. Therefore, move __va_list back
to std only in C++ so that the correct debug info is generated. We
also considered moving __va_list to the top level unconditionally
but this would contradict the specification and be visible to AST
matchers and such, so make it conditional on the language mode.

To avoid breaking name mangling for __va_list, teach the Itanium
name mangler to always mangle it as if it were in the std namespace
when targeting ARM architectures. This logic is not needed for the
Microsoft name mangler because Microsoft platforms define va_list as
a typedef of char *.

Depends on D116773

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGen/aarch64-varargs.c
clang/test/CodeGen/arm64-be-hfa-vararg.c
clang/test/Headers/stdarg.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 527c8b56159e..f29e90c05713 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8548,21 +8548,18 @@ static TypedefDecl 
*CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context) {
 
 static TypedefDecl *
 CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) {
+  // struct __va_list
   RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list");
-  // namespace std { struct __va_list {
-  // Note that we create the namespace even in C. This is intentional so that
-  // the type is consistent between C and C++, which is important in cases 
where
-  // the types need to match between translation units (e.g. with
-  // -fsanitize=cfi-icall). Ideally we wouldn't have created this namespace at
-  // all, but it's now part of the ABI (e.g. in mangled names), so we can't
-  // change it.
-  auto *NS = NamespaceDecl::Create(
-  const_cast(*Context), Context->getTranslationUnitDecl(),
-  /*Inline*/ false, SourceLocation(), SourceLocation(),
-  &Context->Idents.get("std"),
-  /*PrevDecl*/ nullptr);
-  NS->setImplicit();
-  VaListTagDecl->setDeclContext(NS);
+  if (Context->getLangOpts().CPlusPlus) {
+// namespace std { struct __va_list {
+auto *NS = NamespaceDecl::Create(
+const_cast(*Context), Context->getTranslationUnitDecl(),
+/*Inline*/ false, SourceLocation(), SourceLocation(),
+&Context->Idents.get("std"),
+/*PrevDecl*/ nullptr);
+NS->setImplicit();
+VaListTagDecl->setDeclContext(NS);
+  }
 
   VaListTagDecl->startDefinition();
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 4277a0166f20..d1d7a7c40ceb 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -71,6 +71,7 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
   llvm::DenseMap Discriminator;
   llvm::DenseMap Uniquifier;
   const DiscriminatorOverrideTy DiscriminatorOverride = nullptr;
+  NamespaceDecl *StdNamespace = nullptr;
 
   bool NeedsUniqueInternalLinkageNames = false;
 
@@ -194,6 +195,8 @@ class ItaniumMangleContextImpl : public 
ItaniumMangleContext {
 return DiscriminatorOverride;
   }
 
+  NamespaceDecl *getStdNamespace();
+
   const DeclContext *getEffectiveDeclContext(const Decl *D);
   const DeclContext *getEffectiveParentContext(const DeclContext *DC) {
 return getEffectiveDeclContext(cast(DC));
@@ -590,6 +593,18 @@ class CXXNameMangler {
 
 }
 
+NamespaceDecl *ItaniumMangleContextImpl::getStdNamespace() {
+  if (!StdNamespace) {
+StdNamespace = NamespaceDecl::Create(
+getASTContext(), getASTContext().getTranslationUnitDecl(),
+/*Inline*/ false, SourceLocation(), SourceLocation(),
+&getASTContext().Idents.get("std"),
+/*PrevDecl*/ nullptr);
+StdNamespace->setImplicit();
+  }
+  return StdNamespace;
+}
+
 /// Retrieve the declaration context that should be used when mangling the 
given
 /// declaration.
 const DeclContext *
@@ -614,6 +629,17 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
   return ContextParam->getDeclContext();
   }
 
+  // On ARM and AArch64, the va_list tag is always mangled as if in the std
+  // namespace. We do not represent va_list as actually being in the std
+  // namespace in C because this would resul

[PATCH] D116773: AST: Make getEffectiveDeclContext() a member function of ItaniumMangleContextImpl. NFCI.

2022-02-17 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18ead23385a4: AST: Make getEffectiveDeclContext() a member 
function of… (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D116773?vs=398007&id=409733#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116773

Files:
  clang/lib/AST/ItaniumMangle.cpp

Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -40,65 +40,10 @@
 
 namespace {
 
-/// Retrieve the declaration context that should be used when mangling the given
-/// declaration.
-static const DeclContext *getEffectiveDeclContext(const Decl *D) {
-  // The ABI assumes that lambda closure types that occur within
-  // default arguments live in the context of the function. However, due to
-  // the way in which Clang parses and creates function declarations, this is
-  // not the case: the lambda closure type ends up living in the context
-  // where the function itself resides, because the function declaration itself
-  // had not yet been created. Fix the context here.
-  if (const CXXRecordDecl *RD = dyn_cast(D)) {
-if (RD->isLambda())
-  if (ParmVarDecl *ContextParam
-= dyn_cast_or_null(RD->getLambdaContextDecl()))
-return ContextParam->getDeclContext();
-  }
-
-  // Perform the same check for block literals.
-  if (const BlockDecl *BD = dyn_cast(D)) {
-if (ParmVarDecl *ContextParam
-  = dyn_cast_or_null(BD->getBlockManglingContextDecl()))
-  return ContextParam->getDeclContext();
-  }
-
-  const DeclContext *DC = D->getDeclContext();
-  if (isa(DC) || isa(DC) ||
-  isa(DC)) {
-return getEffectiveDeclContext(cast(DC));
-  }
-
-  if (const auto *VD = dyn_cast(D))
-if (VD->isExternC())
-  return VD->getASTContext().getTranslationUnitDecl();
-
-  if (const auto *FD = dyn_cast(D))
-if (FD->isExternC())
-  return FD->getASTContext().getTranslationUnitDecl();
-
-  return DC->getRedeclContext();
-}
-
-static const DeclContext *getEffectiveParentContext(const DeclContext *DC) {
-  return getEffectiveDeclContext(cast(DC));
-}
-
 static bool isLocalContainerContext(const DeclContext *DC) {
   return isa(DC) || isa(DC) || isa(DC);
 }
 
-static const RecordDecl *GetLocalClassDecl(const Decl *D) {
-  const DeclContext *DC = getEffectiveDeclContext(D);
-  while (!DC->isNamespace() && !DC->isTranslationUnit()) {
-if (isLocalContainerContext(DC))
-  return dyn_cast(D);
-D = cast(DC);
-DC = getEffectiveDeclContext(D);
-  }
-  return nullptr;
-}
-
 static const FunctionDecl *getStructor(const FunctionDecl *fn) {
   if (const FunctionTemplateDecl *ftd = fn->getPrimaryTemplate())
 return ftd->getTemplatedDecl();
@@ -249,6 +194,14 @@
 return DiscriminatorOverride;
   }
 
+  const DeclContext *getEffectiveDeclContext(const Decl *D);
+  const DeclContext *getEffectiveParentContext(const DeclContext *DC) {
+return getEffectiveDeclContext(cast(DC));
+  }
+
+  bool isInternalLinkageDecl(const NamedDecl *ND);
+  const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC);
+
   /// @}
 };
 
@@ -427,6 +380,15 @@
 
   ASTContext &getASTContext() const { return Context.getASTContext(); }
 
+  bool isStd(const NamespaceDecl *NS);
+  bool isStdNamespace(const DeclContext *DC);
+
+  const RecordDecl *GetLocalClassDecl(const Decl *D);
+  const DeclContext *IgnoreLinkageSpecDecls(const DeclContext *DC);
+  bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A);
+  bool isStdCharSpecialization(const ClassTemplateSpecializationDecl *SD,
+   llvm::StringRef Name, bool HasAllocator);
+
 public:
   CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
  const NamedDecl *D = nullptr, bool NullOut_ = false)
@@ -628,7 +590,48 @@
 
 }
 
-static bool isInternalLinkageDecl(const NamedDecl *ND) {
+/// Retrieve the declaration context that should be used when mangling the given
+/// declaration.
+const DeclContext *
+ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) {
+  // The ABI assumes that lambda closure types that occur within
+  // default arguments live in the context of the function. However, due to
+  // the way in which Clang parses and creates function declarations, this is
+  // not the case: the lambda closure type ends up living in the context
+  // where the function itself resides, because the function declaration itself
+  // had not yet been created. Fix the context here.
+  if (const CXXRecordDecl *RD = dyn_cast(D)) {
+if (RD->isLambda())
+  if (ParmVarDecl *ContextParam =
+  dyn_cast_or_null(RD->getLambdaContextDecl()))
+return ContextParam->getDeclContext();
+  }
+
+  // Perform the same check for block literals.
+  if (const BlockDecl *BD = dyn_c

[PATCH] D119829: [Driver] Support Solaris/amd64 GetTls

2022-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/solaris-ld-sanitizer.c:1
+// General tests that the ld -z relax=transtls workaround is only applied
+// on Solaris/amd64. Note that we use sysroot to make these tests

Optional: some folks prefer an alternative comment marker (`///` for C, `##` 
for assembly, etc) for non-RUN non-CHECK comments. It makes the comments stand 
out (they may render differently in an editor). Many tests have check-prefix 
typos and if we teach lit or FileCheck to catch such typos, we can let them 
skip `///` lines to avoid false positives.



Comment at: clang/test/Driver/solaris-ld-sanitizer.c:6
+// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=sparc-sun-solaris2.11 \

Remove -no-canonical-prefixes . See some cleanup advice on D119309.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119829

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


[PATCH] D119309: [Driver][test] Clean up some AIX tests

2022-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119309

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8555-8556
+// namespace std { struct __va_list {
+NamespaceDecl *NS;
+NS = NamespaceDecl::Create(const_cast(*Context),
+   Context->getTranslationUnitDecl(),

jrtc27 wrote:
> aaron.ballman wrote:
> > 
> Hm, the advantage of leaving it as it is is then it completely reverts 
> D104830 (ignoring the added CFI test) rather than being written in a slightly 
> different but equivalent way. Don't really care either way myself though, 
> both have their merits.
I don't insist on the change; I mostly found it odd to have an uninitialized 
local that is initialized on the very next line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D119207: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-17 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, the test you added is failing on the PS4 Linux bot, can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/17199


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119207

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8555-8556
+// namespace std { struct __va_list {
+NamespaceDecl *NS;
+NS = NamespaceDecl::Create(const_cast(*Context),
+   Context->getTranslationUnitDecl(),

aaron.ballman wrote:
> 
Hm, the advantage of leaving it as it is is then it completely reverts D104830 
(ignoring the added CFI test) rather than being written in a slightly different 
but equivalent way. Don't really care either way myself though, both have their 
merits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Only a small nit from me.




Comment at: clang/lib/AST/ASTContext.cpp:8555-8556
+// namespace std { struct __va_list {
+NamespaceDecl *NS;
+NS = NamespaceDecl::Create(const_cast(*Context),
+   Context->getTranslationUnitDecl(),




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D119178: Add support for generating debug-info for structured bindings of structs and arrays

2022-02-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf56cb520d855: [DEBUGINFO] [LLDB] Add support for generating 
debug-info for structured… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119178

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/debug-info-structured-binding.cpp
  lldb/test/API/lang/cpp/structured-binding/Makefile
  lldb/test/API/lang/cpp/structured-binding/TestStructuredBinding.py
  lldb/test/API/lang/cpp/structured-binding/main.cpp

Index: lldb/test/API/lang/cpp/structured-binding/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/structured-binding/main.cpp
@@ -0,0 +1,69 @@
+// Structured binding in C++ can bind identifiers to subobjects of an object.
+//
+// There are three cases we need to test:
+// 1) arrays
+// 2) tuples like objects
+// 3) non-static data members
+//
+// They can also bind by copy, reference or rvalue reference.
+
+#include 
+
+struct A {
+  int x;
+  int y;
+};
+
+// We want to cover a mix of types and also different sizes to make sure we
+// hande the offsets correctly.
+struct MixedTypesAndSizesStruct {
+  A a;
+  char b1;
+  char b2;
+  short b3;
+  int b4;
+  char b5;
+};
+
+int main() {
+  MixedTypesAndSizesStruct b{{20, 30}, 'a', 'b', 50, 60, 'c'};
+
+  auto [a1, b1, c1, d1, e1, f1] = b;
+  auto &[a2, b2, c2, d2, e2, f2] = b;
+  auto &&[a3, b3, c3, d3, e3, f3] =
+  MixedTypesAndSizesStruct{{20, 30}, 'a', 'b', 50, 60, 'c'};
+
+  // Array with different sized types
+  char carr[]{'a', 'b', 'c'};
+  short sarr[]{11, 12, 13};
+  int iarr[]{22, 33, 44};
+
+  auto [carr_copy1, carr_copy2, carr_copy3] = carr;
+  auto [sarr_copy1, sarr_copy2, sarr_copy3] = sarr;
+  auto [iarr_copy1, iarr_copy2, iarr_copy3] = iarr;
+
+  auto &[carr_ref1, carr_ref2, carr_ref3] = carr;
+  auto &[sarr_ref1, sarr_ref2, sarr_ref3] = sarr;
+  auto &[iarr_ref1, iarr_ref2, iarr_ref3] = iarr;
+
+  auto &&[carr_rref1, carr_rref2, carr_rref3] = carr;
+  auto &&[sarr_rref1, sarr_rref2, sarr_rref3] = sarr;
+  auto &&[iarr_rref1, iarr_rref2, iarr_rref3] = iarr;
+
+  float x{4.0};
+  char y{'z'};
+  int z{10};
+
+  std::tuple tpl(x, y, z);
+  auto [tx1, ty1, tz1] = tpl;
+  auto &[tx2, ty2, tz2] = tpl;
+
+  return a1.x + b1 + c1 + d1 + e1 + f1 + a2.y + b2 + c2 + d2 + e2 + f2 + a3.x +
+ b3 + c3 + d3 + e3 + f3 + carr_copy1 + carr_copy2 + carr_copy3 +
+ sarr_copy1 + sarr_copy2 + sarr_copy3 + iarr_copy1 + iarr_copy2 +
+ iarr_copy3 + carr_ref1 + carr_ref2 + carr_ref3 + sarr_ref1 +
+ sarr_ref2 + sarr_ref3 + iarr_ref1 + iarr_ref2 + iarr_ref3 +
+ carr_rref1 + carr_rref2 + carr_rref3 + sarr_rref1 + sarr_rref2 +
+ sarr_rref3 + iarr_rref1 + iarr_rref2 + iarr_rref3 + tx1 + ty1 + tz1 +
+ tx2 + ty2 + tz2; // break here
+}
Index: lldb/test/API/lang/cpp/structured-binding/TestStructuredBinding.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/structured-binding/TestStructuredBinding.py
@@ -0,0 +1,84 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestStructuredBinding(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIf(compiler="clang", compiler_version=['<', '14.0'])
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("a1", result_type="A",
+result_children=[ValueCheck(name="x", type="int"),
+ ValueCheck(name="y", type="int")])
+self.expect_expr("b1", result_type="char", result_value="'a'")
+self.expect_expr("c1", result_type="char", result_value="'b'")
+self.expect_expr("d1", result_type="short", result_value="50")
+self.expect_expr("e1", result_type="int", result_value="60")
+self.expect_expr("f1", result_type="char", result_value="'c'")
+
+self.expect_expr("a2", result_type="A",
+result_children=[ValueCheck(name="x", type="int"),
+ ValueCheck(name="y", type="int")])
+self.expect_expr("b2", result_type="char", result_value="'a'")
+self.expect_expr("c2", result_type="char", result_value="'b'")
+self.expect_expr("d2", result_type="short", result_value="50")
+self.expect_expr("e2", result_type="int", result_value="60")
+self.expect_expr("f2", result_type="char", result_value="'c'")
+
+self.expect_expr("a3", result_type="A",
+result_children=[ValueCheck(name="x", type="int"),
+ ValueCheck(name="y", type="int

[clang] f56cb52 - [DEBUGINFO] [LLDB] Add support for generating debug-info for structured bindings of structs and arrays

2022-02-17 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2022-02-17T11:14:14-08:00
New Revision: f56cb520d8554ca42a215e82ecfa58d0b6c178e4

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

LOG: [DEBUGINFO] [LLDB] Add support for generating debug-info for structured 
bindings of structs and arrays

Currently we are not emitting debug-info for all cases of structured bindings a
C++17 feature which allows us to bind names to subobjects in an initializer.

A structured binding is represented by a DecompositionDecl AST node and the
binding are represented by a BindingDecl. It looks the original implementation
only covered the tuple like case which be represented by a DeclRefExpr which
contains a VarDecl.

If the binding is to a subobject of the struct the binding will contain a
MemberExpr and in the case of arrays it will contain an ArraySubscriptExpr.
This PR adds support emitting debug-info for the MemberExpr and 
ArraySubscriptExpr
cases as well as llvm and lldb tests for these cases as well as the tuple case.

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

Added: 
clang/test/CodeGenCXX/debug-info-structured-binding.cpp
lldb/test/API/lang/cpp/structured-binding/Makefile
lldb/test/API/lang/cpp/structured-binding/TestStructuredBinding.py
lldb/test/API/lang/cpp/structured-binding/main.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d75b5a1a9d125..2203f0aec5c7c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4635,11 +4635,103 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const 
VarDecl *VD,
   return D;
 }
 
+llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const BindingDecl *BD,
+llvm::Value *Storage,
+llvm::Optional ArgNo,
+CGBuilderTy &Builder,
+const bool UsePointerValue) {
+  assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
+  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
+  if (BD->hasAttr())
+return nullptr;
+
+  // Skip the tuple like case, we don't handle that here
+  if (isa(BD->getBinding()))
+return nullptr;
+
+  llvm::DIFile *Unit = getOrCreateFile(BD->getLocation());
+  llvm::DIType *Ty = getOrCreateType(BD->getType(), Unit);
+
+  // If there is no debug info for this type then do not emit debug info
+  // for this variable.
+  if (!Ty)
+return nullptr;
+
+  auto Align = getDeclAlignIfRequired(BD, CGM.getContext());
+  unsigned AddressSpace = 
CGM.getContext().getTargetAddressSpace(BD->getType());
+
+  SmallVector Expr;
+  AppendAddressSpaceXDeref(AddressSpace, Expr);
+
+  // Clang stores the sret pointer provided by the caller in a static alloca.
+  // Use DW_OP_deref to tell the debugger to load the pointer and treat it as
+  // the address of the variable.
+  if (UsePointerValue) {
+assert(!llvm::is_contained(Expr, llvm::dwarf::DW_OP_deref) &&
+   "Debug info already contains DW_OP_deref.");
+Expr.push_back(llvm::dwarf::DW_OP_deref);
+  }
+
+  unsigned Line = getLineNumber(BD->getLocation());
+  unsigned Column = getColumnNumber(BD->getLocation());
+  StringRef Name = BD->getName();
+  auto *Scope = cast(LexicalBlockStack.back());
+  // Create the descriptor for the variable.
+  llvm::DILocalVariable *D = DBuilder.createAutoVariable(
+  Scope, Name, Unit, Line, Ty, CGM.getLangOpts().Optimize,
+  llvm::DINode::FlagZero, Align);
+
+  if (const MemberExpr *ME = dyn_cast(BD->getBinding())) {
+if (const FieldDecl *FD = dyn_cast(ME->getMemberDecl())) {
+  const unsigned fieldIndex = FD->getFieldIndex();
+  const clang::CXXRecordDecl *parent =
+  (const CXXRecordDecl *)FD->getParent();
+  const ASTRecordLayout &layout =
+  CGM.getContext().getASTRecordLayout(parent);
+  const uint64_t fieldOffset = layout.getFieldOffset(fieldIndex);
+
+  if (fieldOffset != 0) {
+Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
+Expr.push_back(
+CGM.getContext().toCharUnitsFromBits(fieldOffset).getQuantity());
+  }
+}
+  } else if (const ArraySubscriptExpr *ASE =
+ dyn_cast(BD->getBinding())) {
+if (const IntegerLiteral *IL = dyn_cast(ASE->getIdx())) {
+  const uint64_t value = IL->getValue().getZExtValue();
+  const uint64_t typeSize = CGM.getContext().getTypeSize(BD->getType());
+
+  if (value != 0) {
+Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
+Expr.push_back(CGM.getContext()
+   .toCharUnitsFromBits(

[PATCH] D119979: [OpenMP] Diagnose bad 'omp declare variant' that references itself

2022-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D119979#3330343 , @mikerice wrote:

> What's the use case? I wasn't aware of any.  We saw it from someone who did 
> it accidently and caused the compiler to crash in codegen.

If you have N overloads/variants and you want to pick the original in a certain 
condition. It might be easier to specify the condition as match clause with a 
high score rather than avoid other match clauses to apply then. Put 
differently, if you disallow this you cannot have a "catch all" variant with a 
low score, e.g., one that issues a compile or runtime failure if picked.
Even if we don't use this now, we still need to stick somewhat to the standard 
or open an issue there if we think the behavior should be forbidden.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119979

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


[PATCH] D119886: [AMDGPU] Promote recursive loads from kernel argument to constant

2022-02-17 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0aa1946dfe1: [AMDGPU] Promote recursive loads from kernel 
argument to constant (authored by rampitec).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119886

Files:
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp
  llvm/test/CodeGen/AMDGPU/promote-kernel-arguments.ll

Index: llvm/test/CodeGen/AMDGPU/promote-kernel-arguments.ll
===
--- llvm/test/CodeGen/AMDGPU/promote-kernel-arguments.ll
+++ llvm/test/CodeGen/AMDGPU/promote-kernel-arguments.ll
@@ -11,11 +11,15 @@
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[I:%.*]] = tail call i32 @llvm.amdgcn.workitem.id.x()
 ; CHECK-NEXT:[[P1:%.*]] = getelementptr inbounds float**, float** addrspace(1)* [[ARG:%.*]], i32 [[I]]
-; CHECK-NEXT:[[P2:%.*]] = load float**, float** addrspace(1)* [[P1]], align 8
-; CHECK-NEXT:[[P2_GLOBAL:%.*]] = addrspacecast float** [[P2]] to float* addrspace(1)*
-; CHECK-NEXT:[[P3:%.*]] = load float*, float* addrspace(1)* [[P2_GLOBAL]], align 8
-; CHECK-NEXT:[[P3_GLOBAL:%.*]] = addrspacecast float* [[P3]] to float addrspace(1)*
-; CHECK-NEXT:store float 0.00e+00, float addrspace(1)* [[P3_GLOBAL]], align 4
+; CHECK-NEXT:[[P1_CONST:%.*]] = addrspacecast float** addrspace(1)* [[P1]] to float** addrspace(4)*
+; CHECK-NEXT:[[P2:%.*]] = load float**, float** addrspace(4)* [[P1_CONST]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = addrspacecast float** [[P2]] to float* addrspace(1)*
+; CHECK-NEXT:[[TMP1:%.*]] = addrspacecast float* addrspace(1)* [[TMP0]] to float**
+; CHECK-NEXT:[[P2_FLAT:%.*]] = addrspacecast float* addrspace(1)* [[TMP0]] to float**
+; CHECK-NEXT:[[P2_CONST:%.*]] = addrspacecast float** [[TMP1]] to float* addrspace(4)*
+; CHECK-NEXT:[[P3:%.*]] = load float*, float* addrspace(4)* [[P2_CONST]], align 8
+; CHECK-NEXT:[[TMP2:%.*]] = addrspacecast float* [[P3]] to float addrspace(1)*
+; CHECK-NEXT:store float 0.00e+00, float addrspace(1)* [[TMP2]], align 4
 ; CHECK-NEXT:ret void
 ;
 entry:
@@ -37,9 +41,11 @@
 ; CHECK-NEXT:[[I:%.*]] = tail call i32 @llvm.amdgcn.workitem.id.x()
 ; CHECK-NEXT:[[P1:%.*]] = getelementptr inbounds float*, float* addrspace(1)* [[ARG_GLOBAL]], i32 [[I]]
 ; CHECK-NEXT:[[P1_CAST:%.*]] = bitcast float* addrspace(1)* [[P1]] to i32* addrspace(1)*
-; CHECK-NEXT:[[P2:%.*]] = load i32*, i32* addrspace(1)* [[P1_CAST]], align 8
-; CHECK-NEXT:[[P2_GLOBAL:%.*]] = addrspacecast i32* [[P2]] to i32 addrspace(1)*
-; CHECK-NEXT:store i32 0, i32 addrspace(1)* [[P2_GLOBAL]], align 4
+; CHECK-NEXT:[[TMP0:%.*]] = addrspacecast i32* addrspace(1)* [[P1_CAST]] to i32**
+; CHECK-NEXT:[[P1_CAST_CONST:%.*]] = addrspacecast i32** [[TMP0]] to i32* addrspace(4)*
+; CHECK-NEXT:[[P2:%.*]] = load i32*, i32* addrspace(4)* [[P1_CAST_CONST]], align 8
+; CHECK-NEXT:[[TMP1:%.*]] = addrspacecast i32* [[P2]] to i32 addrspace(1)*
+; CHECK-NEXT:store i32 0, i32 addrspace(1)* [[TMP1]], align 4
 ; CHECK-NEXT:ret void
 ;
 entry:
@@ -60,10 +66,11 @@
 ; CHECK-LABEL: @ptr_in_struct(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[P:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], [[STRUCT_S]] addrspace(1)* [[ARG:%.*]], i64 0, i32 0
-; CHECK-NEXT:[[P1:%.*]] = load float*, float* addrspace(1)* [[P]], align 8
-; CHECK-NEXT:[[P1_GLOBAL:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)*
+; CHECK-NEXT:[[P_CONST:%.*]] = addrspacecast float* addrspace(1)* [[P]] to float* addrspace(4)*
+; CHECK-NEXT:[[P1:%.*]] = load float*, float* addrspace(4)* [[P_CONST]], align 8
+; CHECK-NEXT:[[TMP0:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)*
 ; CHECK-NEXT:[[ID:%.*]] = tail call i32 @llvm.amdgcn.workitem.id.x()
-; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds float, float addrspace(1)* [[P1_GLOBAL]], i32 [[ID]]
+; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds float, float addrspace(1)* [[TMP0]], i32 [[ID]]
 ; CHECK-NEXT:store float 0.00e+00, float addrspace(1)* [[ARRAYIDX]], align 4
 ; CHECK-NEXT:ret void
 ;
@@ -80,7 +87,14 @@
 
 ; GCN-LABEL: flat_ptr_arg:
 ; GCN-COUNT-2: global_load_dwordx2
-; GCN: global_load_dwordx4
+
+; FIXME: First load is in the constant address space and second is in global
+;because it is clobbered by store. GPU load store vectorizer cannot
+;combine them. Note, this does not happen with -O3 because loads are
+;vectorized in pairs earlier and stay in the global address space.
+
+; GCN: global_load_dword v{{[0-9]+}}, [[PTR:v\[[0-9:]+\]]], off{{$}}
+; GCN: global_load_dwordx3 v[{{[0-9:]+}}], [[PTR]

[clang] b0aa194 - [AMDGPU] Promote recursive loads from kernel argument to constant

2022-02-17 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2022-02-17T11:07:03-08:00
New Revision: b0aa1946dfe1d204e49b8238c4960f64a68f31d5

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

LOG: [AMDGPU] Promote recursive loads from kernel argument to constant

Not clobbered pointer load chains are promoted to global now. That
is possible to promote these loads itself into constant address
space. Loaded pointers still need to point to global because we
need to be able to store into that pointer and because an actual
load from it may occur after a clobber.

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

Added: 


Modified: 
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp
llvm/test/CodeGen/AMDGPU/promote-kernel-arguments.ll

Removed: 




diff  --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index d483803005074..01e0d3db46127 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -18,7 +18,7 @@
 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel1Pi(i32 
addrspace(1)*{{.*}} %x.coerce)
 // CHECK: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
-// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4
+// OPT: [[VAL:%.*]] = load i32, i32 addrspace(4)* %x.coerce.const, align 4
 // OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1
 // OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4
 // OPT: ret void
@@ -30,7 +30,7 @@ __global__ void kernel1(int *x) {
 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel2Ri(i32 
addrspace(1)*{{.*}} nonnull align 4 dereferenceable(4) %x.coerce)
 // CHECK: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
-// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4
+// OPT: [[VAL:%.*]] = load i32, i32 addrspace(4)* %x.coerce.const, align 4
 // OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1
 // OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4
 // OPT: ret void
@@ -68,7 +68,8 @@ struct S {
 // OPT: [[R1:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* 
%0, i64 0, i32 1
 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8
 // OPT: [[G1:%.*]] ={{.*}} addrspacecast float* [[P1]] to float addrspace(1)*
-// OPT: [[V0:%.*]] = load i32, i32 addrspace(1)* [[G0]], align 4
+// OPT: [[G2:%.*]] ={{.*}} addrspacecast i32* [[P0]] to i32 addrspace(4)*
+// OPT: [[V0:%.*]] = load i32, i32 addrspace(4)* [[G2]], align 4
 // OPT: [[INC:%.*]] = add nsw i32 [[V0]], 1
 // OPT: store i32 [[INC]], i32 addrspace(1)* [[G0]], align 4
 // OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4
@@ -103,7 +104,8 @@ struct T {
 // OPT: [[R1:%.*]] = getelementptr inbounds %struct.T, %struct.T addrspace(4)* 
%0, i64 0, i32 0, i64 1
 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8
 // OPT: [[G1:%.*]] ={{.*}} addrspacecast float* [[P1]] to float addrspace(1)*
-// OPT: [[V0:%.*]] = load float, float addrspace(1)* [[G0]], align 4
+// OPT: [[G2:%.*]] ={{.*}} addrspacecast float* [[P0]] to float addrspace(4)*
+// OPT: [[V0:%.*]] = load float, float addrspace(4)* [[G2]], align 4
 // OPT: [[ADD0:%.*]] = fadd contract float [[V0]], 1.00e+00
 // OPT: store float [[ADD0]], float addrspace(1)* [[G0]], align 4
 // OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4
@@ -130,7 +132,7 @@ struct SS {
 // COMMON-LABEL: define{{.*}} amdgpu_kernel void @_Z7kernel82SS(float 
addrspace(1)*{{.*}} %a.coerce)
 // CHECK: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
 // CHECK-NOT: ={{.*}} addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to 
[[TYPE]]*
-// OPT: [[VAL:%.*]] = load float, float addrspace(1)* %a.coerce, align 4
+// OPT: [[VAL:%.*]] = load float, float addrspace(4)* %a.coerce.const, align 4
 // OPT: [[INC:%.*]] = fadd contract float [[VAL]], 3.00e+00
 // OPT: store float [[INC]], float addrspace(1)* %a.coerce, align 4
 // OPT: ret void

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp
index b9b48290dd277..65ad8b2aeacd3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteKernelArguments.cpp
@@ -42,6 +42,8 @@ class AMDGPUPromoteKernelArguments : public FunctionPass {
 
   bool promotePointer(Value *Ptr);
 
+  bool promoteLoad(LoadInst *LI);
+
 public:
   static char ID;
 
@@ -

[clang] 4dfa68e - [NFC] Fix debug-info-hotpatch.cpp failure due to downstream regex issue.

2022-02-17 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-02-17T10:59:54-08:00
New Revision: 4dfa68e483137cc13eb9027c0dd834ede19f2fd4

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

LOG: [NFC] Fix debug-info-hotpatch.cpp failure due to downstream regex issue.

In our downstream, we discovered that the that the .* wildcard
in debug-info-hotpatch.cpp (added https://reviews.llvm.org/D116511)
ended up matching the entire line on our Windows configurations, causing
the -function-padmin check to already be consumed. After digging into it
we weren't able to find any sort of reason why the platform would matter
here, however we suspect there must be some difference in the regex
matcher between systems.
This NFC patch replaces the regex with a more conservative regex that
prevents this from happening by replacing the . match with an 'everything
but double-quote match, [^"].

https://reviews.llvm.org/D120066

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-hotpatch.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-hotpatch.cpp 
b/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
index fde1a6ad085ea..e005c9c5ee489 100644
--- a/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
+++ b/clang/test/CodeGenCXX/debug-info-hotpatch.cpp
@@ -12,7 +12,7 @@
 // RUN: %clang_cl --target=x86_64-windows-msvc /hotpatch -### -- %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix=FUNCTIONPADMIN
 // FUNCTIONPADMIN: clang{{.*}}
-// FUNCTIONPADMIN: {{link.*"}}
+// FUNCTIONPADMIN: {{link[^"]*"}} 
 // FUNCTIONPADMIN: -functionpadmin
 
 int main() {



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


[PATCH] D117091: [Clang] Add attributes alloc_size and alloc_align to mm_malloc

2022-02-17 Thread Dávid Bolvanský 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 rG2c91754a13f3: [Clang] Add attributes alloc_size and 
alloc_align to mm_malloc (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117091

Files:
  clang/lib/Headers/mm_malloc.h
  clang/test/Headers/Inputs/include/malloc.h
  clang/test/Headers/mm_malloc.c


Index: clang/test/Headers/mm_malloc.c
===
--- /dev/null
+++ clang/test/Headers/mm_malloc.c
@@ -0,0 +1,12 @@
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include %s -emit-llvm -O1 
-triple x86_64-linux-gnu -o - | FileCheck %s
+#include 
+
+_Bool align_test(void) {
+// CHECK-LABEL: @align_test(
+// CHECK:ret i1 true
+ void *p = _mm_malloc(1024, 16);
+_Bool ret = ((__UINTPTR_TYPE__)p % 16) == 0;
+_mm_free(p);
+return ret;
+}
Index: clang/test/Headers/Inputs/include/malloc.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/malloc.h
@@ -0,0 +1,7 @@
+#if defined(__MINGW32__)
+void *__mingw_aligned_malloc(size_t, size_t);
+void __mingw_aligned_free(void *);
+#elif defined(_WIN32)
+void *_aligned_malloc(size_t, size_t);
+void _aligned_free(void *);
+#endif
Index: clang/lib/Headers/mm_malloc.h
===
--- clang/lib/Headers/mm_malloc.h
+++ clang/lib/Headers/mm_malloc.h
@@ -28,9 +28,9 @@
 
 #if !(defined(_WIN32) && defined(_mm_malloc))
 static __inline__ void *__attribute__((__always_inline__, __nodebug__,
-   __malloc__))
-_mm_malloc(size_t __size, size_t __align)
-{
+   __malloc__, __alloc_size__(1),
+   __alloc_align__(2)))
+_mm_malloc(size_t __size, size_t __align) {
   if (__align == 1) {
 return malloc(__size);
   }


Index: clang/test/Headers/mm_malloc.c
===
--- /dev/null
+++ clang/test/Headers/mm_malloc.c
@@ -0,0 +1,12 @@
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include %s -emit-llvm -O1 -triple x86_64-linux-gnu -o - | FileCheck %s
+#include 
+
+_Bool align_test(void) {
+// CHECK-LABEL: @align_test(
+// CHECK:ret i1 true
+ void *p = _mm_malloc(1024, 16);
+_Bool ret = ((__UINTPTR_TYPE__)p % 16) == 0;
+_mm_free(p);
+return ret;
+}
Index: clang/test/Headers/Inputs/include/malloc.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/malloc.h
@@ -0,0 +1,7 @@
+#if defined(__MINGW32__)
+void *__mingw_aligned_malloc(size_t, size_t);
+void __mingw_aligned_free(void *);
+#elif defined(_WIN32)
+void *_aligned_malloc(size_t, size_t);
+void _aligned_free(void *);
+#endif
Index: clang/lib/Headers/mm_malloc.h
===
--- clang/lib/Headers/mm_malloc.h
+++ clang/lib/Headers/mm_malloc.h
@@ -28,9 +28,9 @@
 
 #if !(defined(_WIN32) && defined(_mm_malloc))
 static __inline__ void *__attribute__((__always_inline__, __nodebug__,
-   __malloc__))
-_mm_malloc(size_t __size, size_t __align)
-{
+   __malloc__, __alloc_size__(1),
+   __alloc_align__(2)))
+_mm_malloc(size_t __size, size_t __align) {
   if (__align == 1) {
 return malloc(__size);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2c91754 - [Clang] Add attributes alloc_size and alloc_align to mm_malloc

2022-02-17 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2022-02-17T19:59:18+01:00
New Revision: 2c91754a13f333d7fe9f9d3d40fb618e40c48cab

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

LOG: [Clang] Add attributes alloc_size and alloc_align to mm_malloc

LLVM optimizes source codes with mm_malloc better, especially due to alignment 
info.

alloc align https://clang.llvm.org/docs/AttributeReference.html#alloc-align
alloc size https://clang.llvm.org/docs/AttributeReference.html#alloc-size

Reviewed By: aaron.ballman

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

Added: 
clang/test/Headers/Inputs/include/malloc.h
clang/test/Headers/mm_malloc.c

Modified: 
clang/lib/Headers/mm_malloc.h

Removed: 




diff  --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index 933dbaacade59..d32fe59416277 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -28,9 +28,9 @@ extern "C" int posix_memalign(void **__memptr, size_t 
__alignment, size_t __size
 
 #if !(defined(_WIN32) && defined(_mm_malloc))
 static __inline__ void *__attribute__((__always_inline__, __nodebug__,
-   __malloc__))
-_mm_malloc(size_t __size, size_t __align)
-{
+   __malloc__, __alloc_size__(1),
+   __alloc_align__(2)))
+_mm_malloc(size_t __size, size_t __align) {
   if (__align == 1) {
 return malloc(__size);
   }

diff  --git a/clang/test/Headers/Inputs/include/malloc.h 
b/clang/test/Headers/Inputs/include/malloc.h
new file mode 100644
index 0..590263bb010a3
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/malloc.h
@@ -0,0 +1,7 @@
+#if defined(__MINGW32__)
+void *__mingw_aligned_malloc(size_t, size_t);
+void __mingw_aligned_free(void *);
+#elif defined(_WIN32)
+void *_aligned_malloc(size_t, size_t);
+void _aligned_free(void *);
+#endif

diff  --git a/clang/test/Headers/mm_malloc.c b/clang/test/Headers/mm_malloc.c
new file mode 100644
index 0..a436ff3013bf6
--- /dev/null
+++ b/clang/test/Headers/mm_malloc.c
@@ -0,0 +1,12 @@
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include %s -emit-llvm -O1 
-triple x86_64-linux-gnu -o - | FileCheck %s
+#include 
+
+_Bool align_test(void) {
+// CHECK-LABEL: @align_test(
+// CHECK:ret i1 true
+ void *p = _mm_malloc(1024, 16);
+_Bool ret = ((__UINTPTR_TYPE__)p % 16) == 0;
+_mm_free(p);
+return ret;
+}



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


[PATCH] D119979: [OpenMP] Diagnose bad 'omp declare variant' that references itself

2022-02-17 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

What's the use case? I wasn't aware of any.  We saw it from someone who did it 
accidently and caused the compiler to crash in codegen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119979

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


[clang] 5824d2b - Fix the declaration printer to properly handle prototypes in C

2022-02-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-02-17T13:54:09-05:00
New Revision: 5824d2bb0f036e631419ae0993fd03d633398266

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

LOG: Fix the declaration printer to properly handle prototypes in C

Previously, we would take a declaration like void f(void) and print it
as void f(). That's correct in C++ as far as it goes, but is incorrect
in C because that converts the function from having a prototype to one
which does not.

This turns out to matter for some of our tests that use the pretty
printer where we'd like to get rid of the K&R prototypes from the test
but can't because the test is checking the pretty printed function
signature, as done with the ARCMT tests.

Added: 


Modified: 
clang/lib/AST/DeclPrinter.cpp
clang/test/Analysis/cfg.c
clang/test/Analysis/designated-initializer.c
clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
clang/test/Analysis/std-c-library-functions.c
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_reduction_ast_print.c
clang/test/OpenMP/declare_variant_ast_print.c
clang/test/OpenMP/metadirective_ast_print.c
clang/test/PCH/chain-decls.c
clang/test/PCH/chain-macro.c
clang/test/Sema/attr-print.c
clang/test/SemaObjC/static-ivar-ref-1.m

Removed: 




diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index c3f1d1544f79a..faafe307f03cf 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -680,6 +680,10 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
   if (FT->isVariadic()) {
 if (D->getNumParams()) POut << ", ";
 POut << "...";
+  } else if (!D->getNumParams() && !Context.getLangOpts().CPlusPlus) {
+// The function has a prototype, so it needs to retain the prototype
+// in C.
+POut << "void";
   }
 } else if (D->doesThisDeclarationHaveABody() && !D->hasPrototype()) {
   for (unsigned i = 0, e = D->getNumParams(); i != e; ++i) {

diff  --git a/clang/test/Analysis/cfg.c b/clang/test/Analysis/cfg.c
index 4bd84e689f251..fc2523859e49b 100644
--- a/clang/test/Analysis/cfg.c
+++ b/clang/test/Analysis/cfg.c
@@ -40,7 +40,7 @@ void checkWrap(int i) {
   }
 }
 
-// CHECK-LABEL: void checkGCCAsmRValueOutput()
+// CHECK-LABEL: void checkGCCAsmRValueOutput(void)
 // CHECK: [B2 (ENTRY)]
 // CHECK-NEXT: Succs (1): B1
 // CHECK: [B1]

diff  --git a/clang/test/Analysis/designated-initializer.c 
b/clang/test/Analysis/designated-initializer.c
index aba037a3f49bb..6274ed12911a4 100644
--- a/clang/test/Analysis/designated-initializer.c
+++ b/clang/test/Analysis/designated-initializer.c
@@ -16,7 +16,7 @@ void test(void) {
   }; 
 }
 
-// CHECK: void test()
+// CHECK: void test(void)
 // CHECK: [B1]
 // CHECK:   1: getUQ
 // CHECK:   2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, union UQ 
(*)(void))

diff  --git a/clang/test/Analysis/std-c-library-functions-vs-stream-checker.c 
b/clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
index 61106f1f8d6bc..e895b54158de3 100644
--- a/clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
+++ b/clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
@@ -28,7 +28,7 @@
 
 // Verify that the summaries are loaded when the StdLibraryFunctionsChecker is
 // enabled.
-//  CHECK: Loaded summary for: int getchar()
+//  CHECK: Loaded summary for: int getchar(void)
 // CHECK-NEXT: Loaded summary for: unsigned long fread(void *restrict, size_t, 
size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: unsigned long fwrite(const void *restrict, 
size_t, size_t, FILE *restrict)
 

diff  --git a/clang/test/Analysis/std-c-library-functions.c 
b/clang/test/Analysis/std-c-library-functions.c
index 50b36dc84e68b..a4032298734d0 100644
--- a/clang/test/Analysis/std-c-library-functions.c
+++ b/clang/test/Analysis/std-c-library-functions.c
@@ -52,7 +52,7 @@
 // CHECK-NEXT: Loaded summary for: int isxdigit(int)
 // CHECK-NEXT: Loaded summary for: int getc(FILE *)
 // CHECK-NEXT: Loaded summary for: int fgetc(FILE *)
-// CHECK-NEXT: Loaded summary for: int getchar()
+// CHECK-NEXT: Loaded summary for: int getchar(void)
 // CHECK-NEXT: Loaded summary for: unsigned int fread(void *restrict, size_t, 
size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: unsigned int fwrite(const void *restrict, 
size_t, size_t, FILE *restrict)
 // CHECK-NEXT: Loaded summary for: ssize_t read(int, void *, size_t)

diff  --git a/clang/test/OpenMP/declare_mapper_ast_print.c 
b/clang/test/OpenMP/declare_mapper_ast_print.c
index 55ebd8334c587..6b9686f0a15b8 100644
--- a/clang/test/OpenMP/declare_mapper_ast_print.c
+++ b/clang/test/OpenMP/declare_mapper_ast_print.c
@@ -41,7 +41,7 @@ struct dat {

[PATCH] D116773: AST: Make getEffectiveDeclContext() a member function of ItaniumMangleContextImpl. NFCI.

2022-02-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added a comment.
This revision is now accepted and ready to land.

This makes sense to me but I don't know if you want someone with more authority 
in these parts to review it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116773

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 accepted this revision.
jrtc27 added a comment.
This revision is now accepted and ready to land.

Thanks, looks good to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D119979: [OpenMP] Diagnose bad 'omp declare variant' that references itself

2022-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert reopened this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Why is this supposed to be a user error? I don't remember the standard 
disallowing this and I can see use cases for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119979

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


[PATCH] D119612: [clang] Pass more flags to ld64.lld

2022-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:272
 
-  // ld64 version 262 and above run the deduplicate pass by default.
-  if (Version >= VersionTuple(262) && 
shouldLinkerNotDedup(C.getJobs().empty(), Args))
+  // ld64 version 262 and above and lld run the deduplicate pass by default.
+  if ((Version >= VersionTuple(262) || LinkerIsLLD) &&

int3 wrote:
> thakis wrote:
> > MaskRay wrote:
> > > lld runs `--icf=none` (i.e. `-no_deduplicate`) by default.
> > Hm, good point. Should we pass `--icf=safe` for lld if 
> > `!shouldLinkerNotDedup` here then?
> I think our dedup pass is both a lot more effective and a lot more expensive 
> link-time-wise than ld64's so maybe we shouldn't do it by default...
> FIXME: lld doesn't dedup by default.

I agree that we should not do icf by default. It can easily take more than 10% 
time IIRC.


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

https://reviews.llvm.org/D119612

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc marked 2 inline comments as done.
pcc added a comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[clang] 5364b36 - Revert "[Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld"

2022-02-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-02-17T18:41:49Z
New Revision: 5364b36868210364b2ccf8e9f9169ed1fd545ae0

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

LOG: Revert "[Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld"

This reverts commit b9f4dff8ab40250aac2343e86c1289de46af5585.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 1b60541ee846..9e0b259dfcae 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -53,9 +53,9 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 
-  bool IsLLD;
-  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath(&IsLLD));
-  if (IsLLD) {
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
+  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rodynamic");
 CmdArgs.push_back("-z");



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


[PATCH] D119612: [clang] Pass more flags to ld64.lld

2022-02-17 Thread Jez Ng via Phabricator via cfe-commits
int3 accepted this revision.
int3 added a comment.
This revision is now accepted and ready to land.

lgtm!




Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:272
 
-  // ld64 version 262 and above run the deduplicate pass by default.
-  if (Version >= VersionTuple(262) && 
shouldLinkerNotDedup(C.getJobs().empty(), Args))
+  // ld64 version 262 and above and lld run the deduplicate pass by default.
+  if ((Version >= VersionTuple(262) || LinkerIsLLD) &&

thakis wrote:
> MaskRay wrote:
> > lld runs `--icf=none` (i.e. `-no_deduplicate`) by default.
> Hm, good point. Should we pass `--icf=safe` for lld if 
> `!shouldLinkerNotDedup` here then?
I think our dedup pass is both a lot more effective and a lot more expensive 
link-time-wise than ld64's so maybe we shouldn't do it by default...


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

https://reviews.llvm.org/D119612

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


[PATCH] D116774: AST: Move __va_list tag back to std conditionally on AArch64.

2022-02-17 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 409716.
pcc added a comment.

Use isARM() etc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/arm64-be-hfa-vararg.c
  clang/test/Headers/stdarg.cpp

Index: clang/test/Headers/stdarg.cpp
===
--- clang/test/Headers/stdarg.cpp
+++ clang/test/Headers/stdarg.cpp
@@ -15,7 +15,7 @@
 
 #include 
 
-// AARCH64-C: define {{.*}} @f(i32 noundef %n, %"struct.std::__va_list"* noundef %list)
+// AARCH64-C: define {{.*}} @f(i32 noundef %n, %struct.__va_list* noundef %list)
 // AARCH64-CXX: define {{.*}} @_Z1fiSt9__va_list(i32 noundef %n, %"struct.std::__va_list"* noundef %list)
 // X86_64-C: define {{.*}} @f(i32 noundef %n, %struct.__va_list_tag* noundef %list)
 // X86_64-CXX: define {{.*}} @_Z1fiP13__va_list_tag(i32 noundef %n, %struct.__va_list_tag* noundef %list)
Index: clang/test/CodeGen/arm64-be-hfa-vararg.c
===
--- clang/test/CodeGen/arm64-be-hfa-vararg.c
+++ clang/test/CodeGen/arm64-be-hfa-vararg.c
@@ -4,12 +4,12 @@
 
 // A single member HFA must be aligned just like a non-HFA register argument.
 double callee(int a, ...) {
-// CHECK: [[REGPP:%.*]] = getelementptr inbounds %"struct.std::__va_list", %"struct.std::__va_list"* [[VA:%.*]], i32 0, i32 2
+// CHECK: [[REGPP:%.*]] = getelementptr inbounds %struct.__va_list, %struct.__va_list* [[VA:%.*]], i32 0, i32 2
 // CHECK: [[REGP:%.*]] = load i8*, i8** [[REGPP]], align 8
 // CHECK: [[OFFSET0:%.*]] = getelementptr inbounds i8, i8* [[REGP]], i32 {{.*}}
 // CHECK: [[OFFSET1:%.*]] = getelementptr inbounds i8, i8* [[OFFSET0]], i64 8
 
-// CHECK: [[MEMPP:%.*]] = getelementptr inbounds %"struct.std::__va_list", %"struct.std::__va_list"* [[VA:%.*]], i32 0, i32 0
+// CHECK: [[MEMPP:%.*]] = getelementptr inbounds %struct.__va_list, %struct.__va_list* [[VA:%.*]], i32 0, i32 0
 // CHECK: [[MEMP:%.*]] = load i8*, i8** [[MEMPP]], align 8
 // CHECK: [[NEXTP:%.*]] = getelementptr inbounds i8, i8* [[MEMP]], i64 8
 // CHECK: store i8* [[NEXTP]], i8** [[MEMPP]], align 8
Index: clang/test/CodeGen/aarch64-varargs.c
===
--- clang/test/CodeGen/aarch64-varargs.c
+++ clang/test/CodeGen/aarch64-varargs.c
@@ -11,18 +11,18 @@
 int simple_int(void) {
 // CHECK-LABEL: define{{.*}} i32 @simple_int
   return va_arg(the_list, int);
-// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 3)
+// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i32, i32* getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[EARLY_ONSTACK:%[a-z_0-9]+]] = icmp sge i32 [[GR_OFFS]], 0
 // CHECK: br i1 [[EARLY_ONSTACK]], label %[[VAARG_ON_STACK:[a-z_.0-9]+]], label %[[VAARG_MAYBE_REG:[a-z_.0-9]+]]
 
 // CHECK: [[VAARG_MAYBE_REG]]
 // CHECK: [[NEW_REG_OFFS:%[a-z_0-9]+]] = add i32 [[GR_OFFS]], 8
-// CHECK: store i32 [[NEW_REG_OFFS]], i32* getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 3)
+// CHECK: store i32 [[NEW_REG_OFFS]], i32* getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 3)
 // CHECK: [[INREG:%[a-z_0-9]+]] = icmp sle i32 [[NEW_REG_OFFS]], 0
 // CHECK: br i1 [[INREG]], label %[[VAARG_IN_REG:[a-z_.0-9]+]], label %[[VAARG_ON_STACK]]
 
 // CHECK: [[VAARG_IN_REG]]
-// CHECK: [[REG_TOP:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 1)
+// CHECK: [[REG_TOP:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 1)
 // CHECK: [[REG_ADDR:%[a-z_0-9]+]] = getelementptr inbounds i8, i8* [[REG_TOP]], i32 [[GR_OFFS]]
 // CHECK-BE: [[REG_ADDR_ALIGNED:%[0-9]+]] = getelementptr inbounds i8, i8* [[REG_ADDR]], i64 4
 // CHECK-BE: [[FROMREG_ADDR:%[a-z_0-9]+]] = bitcast i8* [[REG_ADDR_ALIGNED]] to i32*
@@ -30,9 +30,9 @@
 // CHECK: br label %[[VAARG_END:[a-z._0-9]+]]
 
 // CHECK: [[VAARG_ON_STACK]]
-// CHECK: [[STACK:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 0)
+// CHECK: [[STACK:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
 // CHECK: [[NEW_STACK:%[a-z_0-9]+]] = getelementptr inbounds i8, i8* [[STACK]], i64 8
-// CHECK: store i8* [[NEW_STACK]], i8** getelementptr inbounds (%"struct.std::__va_list", %"struct.std::__va_list"* @the_list, i32 0, i32 0)
+// CHECK: store i8* [[NEW_STACK]], i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
 // CHECK-BE: [[S

[PATCH] D119979: [OpenMP] Diagnose bad 'omp declare variant' that references itself

2022-02-17 Thread Mike Rice via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG383f3a467c92: [OpenMP] Diagnose bad 'omp declare 
variant' that references itself. (authored by mikerice).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119979

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_messages.c


Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -113,6 +113,15 @@
   return after_use();
 }
 
+// expected-error@+1 {{variant in '#pragma omp declare variant' is the same as 
the base function}}
+#pragma omp declare variant (self) \
+  match(construct={dispatch}, device={arch(arm)})
+void self(int n);
+
+void self_test(int n, int d_no) {
+  #pragma omp dispatch device(d_no) nowait
+  self(n);
+}
 
 #pragma omp declare variant(after_use_variant) match(xxx={}) // 
expected-warning {{'xxx' is not a valid context set in a `declare variant`; set 
ignored}} expected-warning {{'#pragma omp declare variant' cannot be applied 
for function after first usage; the original function might be used}} 
expected-note {{context set options are: 'construct' 'device' 'implementation' 
'user'}} expected-note {{the ignored set spans until here}}
 int after_use(void);
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7171,6 +7171,13 @@
 return None;
   }
 
+  if (FD->getCanonicalDecl() == NewFD->getCanonicalDecl()) {
+Diag(VariantRef->getExprLoc(),
+ diag::err_omp_declare_variant_same_base_function)
+<< VariantRef->getSourceRange();
+return None;
+  }
+
   // Check if function types are compatible in C.
   if (!LangOpts.CPlusPlus) {
 QualType NewType =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10830,6 +10830,8 @@
 def err_omp_declare_variant_incompat_types : Error<
   "variant in '#pragma omp declare variant' with type %0 is incompatible with"
   " type %1%select{| with appended arguments}2">;
+def err_omp_declare_variant_same_base_function : Error<
+  "variant in '#pragma omp declare variant' is the same as the base function">;
 def warn_omp_declare_variant_marked_as_declare_variant : Warning<
   "variant function in '#pragma omp declare variant' is itself marked as 
'#pragma omp declare variant'"
   >, InGroup;


Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -113,6 +113,15 @@
   return after_use();
 }
 
+// expected-error@+1 {{variant in '#pragma omp declare variant' is the same as the base function}}
+#pragma omp declare variant (self) \
+  match(construct={dispatch}, device={arch(arm)})
+void self(int n);
+
+void self_test(int n, int d_no) {
+  #pragma omp dispatch device(d_no) nowait
+  self(n);
+}
 
 #pragma omp declare variant(after_use_variant) match(xxx={}) // expected-warning {{'xxx' is not a valid context set in a `declare variant`; set ignored}} expected-warning {{'#pragma omp declare variant' cannot be applied for function after first usage; the original function might be used}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
 int after_use(void);
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7171,6 +7171,13 @@
 return None;
   }
 
+  if (FD->getCanonicalDecl() == NewFD->getCanonicalDecl()) {
+Diag(VariantRef->getExprLoc(),
+ diag::err_omp_declare_variant_same_base_function)
+<< VariantRef->getSourceRange();
+return None;
+  }
+
   // Check if function types are compatible in C.
   if (!LangOpts.CPlusPlus) {
 QualType NewType =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10830,6 +10830,8 @@
 def err_omp_declare_variant_incompat_types : Error<
   "variant in '#pragma omp declare variant' with type %0 is incompatible with"
   " type %1%select{| with appended arguments}2">;
+def err_omp_declare_variant_same_base_function : Error<
+  "variant in '#pragma omp

[clang] 383f3a4 - [OpenMP] Diagnose bad 'omp declare variant' that references itself.

2022-02-17 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2022-02-17T10:36:28-08:00
New Revision: 383f3a467c92499956ed804eb2bd69ad8576615b

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

LOG: [OpenMP] Diagnose bad 'omp declare variant' that references itself.

When an a variant is specified that is the same as the base function
the compiler will end up crashing in CodeGen. Give an error instead.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/declare_variant_messages.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e7c204fef2a09..8af1bed7b67f1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10830,6 +10830,8 @@ def err_omp_interop_type_not_found : Error<
 def err_omp_declare_variant_incompat_types : Error<
   "variant in '#pragma omp declare variant' with type %0 is incompatible with"
   " type %1%select{| with appended arguments}2">;
+def err_omp_declare_variant_same_base_function : Error<
+  "variant in '#pragma omp declare variant' is the same as the base function">;
 def warn_omp_declare_variant_marked_as_declare_variant : Warning<
   "variant function in '#pragma omp declare variant' is itself marked as 
'#pragma omp declare variant'"
   >, InGroup;

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 79823fcf148b7..64647f59fcb5f 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7171,6 +7171,13 @@ 
Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
 return None;
   }
 
+  if (FD->getCanonicalDecl() == NewFD->getCanonicalDecl()) {
+Diag(VariantRef->getExprLoc(),
+ diag::err_omp_declare_variant_same_base_function)
+<< VariantRef->getSourceRange();
+return None;
+  }
+
   // Check if function types are compatible in C.
   if (!LangOpts.CPlusPlus) {
 QualType NewType =

diff  --git a/clang/test/OpenMP/declare_variant_messages.c 
b/clang/test/OpenMP/declare_variant_messages.c
index 66ead8909ad8f..a049285cdb01c 100644
--- a/clang/test/OpenMP/declare_variant_messages.c
+++ b/clang/test/OpenMP/declare_variant_messages.c
@@ -113,6 +113,15 @@ int bar(void) {
   return after_use();
 }
 
+// expected-error@+1 {{variant in '#pragma omp declare variant' is the same as 
the base function}}
+#pragma omp declare variant (self) \
+  match(construct={dispatch}, device={arch(arm)})
+void self(int n);
+
+void self_test(int n, int d_no) {
+  #pragma omp dispatch device(d_no) nowait
+  self(n);
+}
 
 #pragma omp declare variant(after_use_variant) match(xxx={}) // 
expected-warning {{'xxx' is not a valid context set in a `declare variant`; set 
ignored}} expected-warning {{'#pragma omp declare variant' cannot be applied 
for function after first usage; the original function might be used}} 
expected-note {{context set options are: 'construct' 'device' 'implementation' 
'user'}} expected-note {{the ignored set spans until here}}
 int after_use(void);



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


[PATCH] D120070: [HIP] Support linking archive of bundled bitcode

2022-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/test/Driver/hip-link-bundle-archive.hip:3
+
+// RUN: touch %T/libhipBundled.a
+

tra wrote:
> Is this file necessary? `clang -###` should not need the file to be present 
> in order to print out command lines.
You are right. Will remove it when committing.


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

https://reviews.llvm.org/D120070

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


  1   2   3   >