[PATCH] D142933: Add -print-multi-selection-flags-experimental option

2023-03-15 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:237-245
+  // Enumerate boolean flags we care about for the purposes of multilib here.
+  // There must be a smarter way to do it but this gets us started.
+  const struct HasFlag {
+ID Pos, Neg;
+bool Default;
+  } HasFlagList[] = {
+  {OPT_fexceptions, OPT_fno_exceptions, true},

phosek wrote:
> Would it be possible to add this information to 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Driver/Options.td?
>  I think that would be more maintainable.
I thought about that, and it would be nice - it's a shame that this information 
gets copy-pasted across the Clang sources - there are already 5 or so places 
that do this. However for this change I think that would be too much scope 
creep so I've stuck with the status quo.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:441
+   std::vector , bool ForAS,
+   unsigned *OutFPUKind) {
   bool KernelOrKext =

phosek wrote:
> Can we use `ARM::FPUKind` as a type here?
I made a new change, D146141, that makes this possible. I've rebased this patch 
on that change now so this is done.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:556
   // Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=.
   unsigned FPUID = llvm::ARM::FK_INVALID;
   const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ);

phosek wrote:
> Is this variable used anywhere in this function?
Yes, although previously in this scope only for `FPUID == llvm::ARM::FK_NONE`. 
Now we're using it more since we're returning it.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.h:70
+  std::vector , bool ForAS,
+  unsigned *OutFPUKind = nullptr);
 int getARMSubArchVersionNumber(const llvm::Triple );

phosek wrote:
> Using output argument isn't very common in LLVM and even in this particular 
> case seems a bit ad-hoc. I'm wondering if we could instead extract this logic 
> into a new function, for example `getARMFPUFeatures`?
It's not unusual in this area of the code. Usually the name is `ArgFPUKind` 
which I don't find descriptive so I went with `OutFPUKind` to make it clearer 
that it's an output of the function. However since the function had return type 
`void` I've now simply changed it to return `FPUKind` directly.

I spent a chunk of time looking into whether I could get a separate 
FPU-specific function. Finding the FPU is tightly coupled across a lot of code 
with finding the architecture and CPU. Although I'm sure the code could be 
better structured, the problem is also inherent because the floating point 
support is dependent on `-mfpu`, `-march`, `-mcpu`, `--target`, `-mfloat-abi` 
and possibly others so figuring everything out requires parsing many options. 
In short, I think returning FPUKind is the lesser evil here, even if it does 
seem a bit ad-hoc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142933

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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3293
+This builtin is converted to llvm.set.rounding intrinsic in LLVM IR level
+and not all targets support this intrinsic, so only x86 and arm targets
+support this builtin. Since this builtin changes default floating-point

If some other target start supporting `llvm.set_rounding` this statement 
becomes wrong. Maybe just 'some targets'?



Comment at: clang/docs/LanguageExtensions.rst:3295
+support this builtin. Since this builtin changes default floating-point
+environment, ``#pragma STDC FENV_ACCESS ON`` is required.
+

Not necessary. Options `-ffp-model=strict` or `-frounding-math` also can be 
used. I would remove this statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146188

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505691.
francii added a comment.

Add missing bracket


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505689.
francii added a comment.

Add missing bracket


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,56 +232,58 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 

[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-15 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 created this revision.
xiongji90 added reviewers: rjmccall, sepavloff, aaron.ballman, andrew.w.kaylor.
Herald added a project: All.
xiongji90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch aims to add necessary description for __builtin_flt_rounds and 
__builtins_set_flt_rounds in LanguageExtensions.rst


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146188

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,46 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds``
+--
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+
+Returns the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+See `llvm.get.rounding
+`_ for
+more information on the semantics.
+
+``__builtin_set_flt_rounds``
+--
+
+.. code-block:: c
+
+   void __builtin_set_flt_rounds(int);
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+See `llvm.set.rounding
+`_ for
+more information on the semantics.
+This builtin is converted to llvm.set.rounding intrinsic in LLVM IR level
+and not all targets support this intrinsic, so only x86 and arm targets
+support this builtin. Since this builtin changes default floating-point
+environment, ``#pragma STDC FENV_ACCESS ON`` is required.
+
 String builtins
 ---
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3246,7 +3246,7 @@
 
double __builtin_canonicalize(double);
float __builtin_canonicalizef(float);
-   long double__builtin_canonicalizel(long double);
+   long double __builtin_canonicalizel(long double);
 
 Returns the platform specific canonical encoding of a floating point
 number. This canonicalization is useful for implementing certain
@@ -3254,6 +3254,46 @@
 `_ for
 more information on the semantics.
 
+``__builtin_flt_rounds``
+--
+
+.. code-block:: c
+
+   int __builtin_flt_rounds();
+
+Returns the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+See `llvm.get.rounding
+`_ for
+more information on the semantics.
+
+``__builtin_set_flt_rounds``
+--
+
+.. code-block:: c
+
+   void __builtin_set_flt_rounds(int);
+
+Sets the current rounding mode. Encoding of the returned values is
+same as the result of FLT_ROUNDS, specified by C standard:
+0  - toward zero
+1  - to nearest, ties to even
+2  - toward positive infinity
+3  - toward negative infinity
+4  - to nearest, ties away from zero
+See `llvm.set.rounding
+`_ for
+more information on the semantics.
+This builtin is converted to llvm.set.rounding intrinsic in LLVM IR level
+and not all targets support this intrinsic, so only x86 and arm targets
+support this builtin. Since this builtin changes default floating-point
+environment, ``#pragma STDC FENV_ACCESS ON`` is required.
+
 String builtins
 ---
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146187: [docs] Update the status for coroutines

2023-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: aaron.ballman, bruno, clang-language-wg.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to the discussion in 
https://discourse.llvm.org/t/rfc-could-we-mark-coroutines-as-unreleased-now/69220

We should mark coroutines as "it’s supported fully everywhere but on Windows 
targets".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146187

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1222,10 +1222,7 @@
   https://wg21.link/p0912r5;>P0912R5
   
 Partial
-  The optimizer does not yet handle TLS with
-  __attribute__((const)) attribute correctly. There can be issues 
where the
-  coroutine may resume on a different thread. This feature requires 
further
-  analysis of the C++ Standard to determine what work is necessary for 
conformance.
+  It's supported fully everywhere but on Windows targets.
 
 
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1222,10 +1222,7 @@
   https://wg21.link/p0912r5;>P0912R5
   
 Partial
-  The optimizer does not yet handle TLS with
-  __attribute__((const)) attribute correctly. There can be issues where the
-  coroutine may resume on a different thread. This feature requires further
-  analysis of the C++ Standard to determine what work is necessary for conformance.
+  It's supported fully everywhere but on Windows targets.
 
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D144844#4197067 , @dblaikie wrote:

> I don't think of this as a performance regression for users though - this 
> functionality's never really "shipped" so we get to choose what the baseline 
> is.
>
> And I think a reasonable baseline to compare to isn't this implementation we 
> don't think is ideal (because of the build invalidation issues, if nothing 
> else, caused by having thick PCMs) - I think the baseline is what a users 
> non-modular code is. And in non-modular code these non-inline functions would 
> be in the implementation files, not able to cross-TU inline without LTO.
>
> I think not providing definitions of non-inline functions for cross-TU 
> optimizations is not a regression, but exactly in-line with existing 
> non-modular behavior, which is totally fine.

Yeah, I refer "regression"  to compare the performance of modular codes with 
the non modular codes. Since no users will be happy if they found the 
performance goes down after they convert their existing library to modules.

Then the problem is that the implicitly inline functions in headers may be 
non-inline functions in modules.   And we made some simple experiments for the 
patch, we observed performance regression indeed.

In D144844#4197646 , @iains wrote:

> In D144844#4195633 , @ChuanqiXu 
> wrote:
>
>>> However, "performance" also includes compilation speed in the 'no 
>>> optimisation, debug' case - that is also considered very important. So, 
>>> perhaps, the short-term approach should be (as @dblaikie suggested) to 
>>> include the bodies for -O >= 3?
>>
>> I don't think so. I think "performance" refers to the runtime performance 
>> generally. I don't believe the normal users will be happy if modules will 
>> decrease the performance of their program in any means. So I think we should 
>> include the bodies by default.
>
> I think I must be misunderstanding something here.
>
> The default for clang is to compile without optimisation - this benefits the 
> compile-edit-debug cycle, by providing output that is closest to the original 
> source, and quickest to compile.
>
> The user should not be expecting any optimisations to be applied unless they 
> supply `-ON` (n fact, they might well complain if we optimise something that 
> makes debugging harder).
>
> So, we should try to ensure that adding modules supports that model - and 
> provides the quickest and closest to the original sources for the default 
> options.  If the user wants better optimisation (at the expense of longer 
> compile times), then they provide `-ON`, right?

Oh, we are talking the case that the users will use `-ON` as default. Since 
every C++ programs will use `-ON` in practice.




And I am still wondering how thin the thin BMI will be by removing the 
non-inline function bodies. For example, we'll still need to contain the 
function bodies for templates, right? So I guess if we want a thin BMI, we need 
more refactoring to the current pcm format, which requires more working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/SemaTemplate/concepts-out-of-line-def.cpp:143
+template <>
+template 
+constexpr int S<1>::constrained_method() { return CONSTRAINED_METHOD_1; }

Would also like tests with packs both at this function level, and at the 
containing type, as well as a type constraint on the parent as well.

Bringing in a couple of the similar yet slightly different examples from the 
other bug reports would also be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D145641: [Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions

2023-03-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:500-508
+DirectEmit = [&]() {
+  auto *RVI = S.getReturnValueInit();
+  if (!RVI || CGF.FnRetTy->isVoidType())
+return true;
+  auto GroType = RVI->getType();
+  if (GroType->isVoidType())
+return true;

bruno wrote:
> ChuanqiXu wrote:
> > What's the case about returning void and the return_object type is 
> > different from the returning type?
> In that case we do `DirectEmit` since there's no reason to delay 
> initialization, am I missing something?
I mean it looks invalid if the function returns void and the return_object_type 
returns a non-void type. So we can judge this by `hasSameType()` directly.



Comment at: clang/test/SemaCXX/coroutine-no-move-ctor.cpp:24-26
 invoker f() {
   co_return;
 }

bruno wrote:
> ChuanqiXu wrote:
> > How about adding a failing case that the types are not matched?
> I'm having trouble crafting one. I extracted similar examples from other 
> testcases and even though I can confirm they correctly apply delayed 
> initialization, they don't require copies (usually directly call conversion 
> operators or similar) and we don't trigger the reverse usecase, do you have 
> one testcase in mind I could use?
Oh, I don't have an existing test. Although not the best, maybe you can try to 
emit the codes to LLVM IR and match that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145641

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > erichkeane wrote:
> > > > craig.topper wrote:
> > > > > erichkeane wrote:
> > > > > > craig.topper wrote:
> > > > > > > erichkeane wrote:
> > > > > > > > Can you add a test that shows that we warn on instantiation?  
> > > > > > > > This shouldn't be a dependent declrefexpr when instantiated.
> > > > > > > > 
> > > > > > > > Additionally, this would make sure that we're properly 
> > > > > > > > propoagating `always_inline`.
> > > > > > > Should this warn
> > > > > > > 
> > > > > > > ```
> > > > > > > template [[gnu::noinline]] 
> > > > > > >
> > > > > > > int bar(int x) {  
> > > > > > >
> > > > > > > if constexpr (D > 1)  
> > > > > > >
> > > > > > > [[clang::always_inline]] return bar(x + 1);  
> > > > > > >
> > > > > > > else  
> > > > > > >
> > > > > > > return x; 
> > > > > > >
> > > > > > > } 
> > > > > > >
> > > > > > >   
> > > > > > >
> > > > > > > int baz(int x) {  
> > > > > > >
> > > > > > >   return bar<5>(x);   
> > > > > > >
> > > > > > > }  
> > > > > > > ```
> > > > > > Yes, I would expect that to warn.
> > > > > It looks like handleAlwaysInlineAttr only gets called once so it 
> > > > > doesn't get called after instantiation.
> > > > Hmm... thats unfortunate.  That means we're perhaps not instantiating 
> > > > it correctly.  I'll take some time to poke around as I get a chacne.
> > > Ok, it looks like SemaStmt.cpp's `BuildAttributedStmt` needs to handle 
> > > the attributes.  We should some day do that automatically for a majority 
> > > o f attributes, but for now, just adding the call there is sufficient.
> > What I do need to add?
> You should be able to follow what is already there, but I suspect you just 
> need to call some sort of 'handle' function for those to do this.  There is 
> one there already youc an crib off of.
Can I do that as a separate patch? Fixing the crash seems like a net 
improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D141785: [Clang][LoongArch] Implement patchable function entry

2023-03-15 Thread Lu Weining via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb5dfec9d444: [Clang][LoongArch] Implement patchable 
function entry (authored by WANG Xuerui g...@xen0n.name, committed by 
SixWeining).

Changed prior to commit:
  https://reviews.llvm.org/D141785?vs=497598=505680#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141785

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fpatchable-function-entry.c
  clang/test/Sema/patchable-function-entry-attr.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
  llvm/test/CodeGen/LoongArch/patchable-function-entry.ll

Index: llvm/test/CodeGen/LoongArch/patchable-function-entry.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/patchable-function-entry.ll
@@ -0,0 +1,63 @@
+;; Test the function attribute "patchable-function-entry".
+;; Adapted from the RISCV test case.
+; RUN: llc --mtriple=loongarch32 < %s | FileCheck %s --check-prefixes=CHECK,LA32
+; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s --check-prefixes=CHECK,LA64
+
+define void @f0() "patchable-function-entry"="0" {
+; CHECK-LABEL: f0:
+; CHECK-NEXT:  .Lfunc_begin0:
+; CHECK-NOT: nop
+; CHECK: ret
+; CHECK-NOT:   .section __patchable_function_entries
+  ret void
+}
+
+define void @f1() "patchable-function-entry"="1" {
+; CHECK-LABEL: f1:
+; CHECK-NEXT: .Lfunc_begin1:
+; CHECK: nop
+; CHECK-NEXT:ret
+; CHECK:   .section __patchable_function_entries,"awo",@progbits,f1{{$}}
+; LA32:.p2align 2
+; LA32-NEXT:   .word .Lfunc_begin1
+; LA64:.p2align 3
+; LA64-NEXT:   .dword .Lfunc_begin1
+  ret void
+}
+
+$f5 = comdat any
+define void @f5() "patchable-function-entry"="5" comdat {
+; CHECK-LABEL:   f5:
+; CHECK-NEXT:.Lfunc_begin2:
+; CHECK-COUNT-5:   nop
+; CHECK-NEXT:  ret
+; CHECK: .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
+; LA32:  .p2align 2
+; LA32-NEXT: .word .Lfunc_begin2
+; LA64:  .p2align 3
+; LA64-NEXT: .dword .Lfunc_begin2
+  ret void
+}
+
+;; -fpatchable-function-entry=3,2
+;; "patchable-function-prefix" emits data before the function entry label.
+define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
+; CHECK-LABEL:   .type f3_2,@function
+; CHECK-NEXT:.Ltmp0: # @f3_2
+; CHECK-COUNT-2:   nop
+; CHECK-NEXT:f3_2:
+; CHECK: # %bb.0:
+; CHECK-NEXT:  nop
+; LA32-NEXT:   addi.w $sp, $sp, -16
+; LA64-NEXT:   addi.d $sp, $sp, -16
+;; .size does not include the prefix.
+; CHECK:  .Lfunc_end3:
+; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
+; CHECK:  .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
+; LA32:   .p2align 2
+; LA32-NEXT:  .word .Ltmp0
+; LA64:   .p2align 3
+; LA64-NEXT:  .dword .Ltmp0
+  %frame = alloca i8, i32 16
+  ret void
+}
Index: llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
===
--- llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
+++ llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
@@ -27,6 +27,8 @@
 public:
   explicit LoongArchInstrInfo(LoongArchSubtarget );
 
+  MCInst getNop() const override;
+
   void copyPhysReg(MachineBasicBlock , MachineBasicBlock::iterator MBBI,
const DebugLoc , MCRegister DstReg, MCRegister SrcReg,
bool KillSrc) const override;
Index: llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
===
--- llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
+++ llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
@@ -17,6 +17,7 @@
 #include "MCTargetDesc/LoongArchMCTargetDesc.h"
 #include "MCTargetDesc/LoongArchMatInt.h"
 #include "llvm/CodeGen/RegisterScavenging.h"
+#include "llvm/MC/MCInstBuilder.h"
 
 using namespace llvm;
 
@@ -28,6 +29,13 @@
 LoongArch::ADJCALLSTACKUP),
   STI(STI) {}
 
+MCInst LoongArchInstrInfo::getNop() const {
+  return MCInstBuilder(LoongArch::ANDI)
+  .addReg(LoongArch::R0)
+  .addReg(LoongArch::R0)
+  .addImm(0);
+}
+
 void LoongArchInstrInfo::copyPhysReg(MachineBasicBlock ,
  MachineBasicBlock::iterator MBBI,
  const DebugLoc , MCRegister DstReg,
Index: llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
===
--- llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
+++ llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
@@ -41,6 +41,8 @@
   bool 

[clang] db5dfec - [Clang][LoongArch] Implement patchable function entry

2023-03-15 Thread Weining Lu via cfe-commits

Author: WANG Xuerui
Date: 2023-03-16T09:33:58+08:00
New Revision: db5dfec9d4442c360e9712bbd71b3462cac427e9

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

LOG: [Clang][LoongArch] Implement patchable function entry

Similar to D98610 for RISCV.

This is going to be required by the upcoming Linux/LoongArch
[[ https://git.kernel.org/linus/4733f09d88074 | support for dynamic ftrace ]].

Reviewed By: SixWeining, MaskRay

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

Added: 
llvm/test/CodeGen/LoongArch/patchable-function-entry.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fpatchable-function-entry.c
clang/test/Sema/patchable-function-entry-attr.cpp
llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
llvm/lib/Target/LoongArch/LoongArchInstrInfo.h

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 09a3daee68872..1bcdfaec15fe0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -270,6 +270,9 @@ Windows Support
 LoongArch Support
 ^
 
+- Patchable function entry (``-fpatchable-function-entry``) is now supported
+  on LoongArch.
+
 RISC-V Support
 ^^
 - Added ``-mrvv-vector-bits=`` option to give an upper and lower bound on 
vector

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8858bb6bec850..89a62e83444a3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -792,7 +792,8 @@ def XRayLogArgs : InheritableAttr {
 def PatchableFunctionEntry
 : InheritableAttr,
   TargetSpecificAttr> {
+  ["aarch64", "aarch64_be", "loongarch32", "loongarch64", "riscv32",
+   "riscv64", "x86", "x86_64"]>> {
   let Spellings = [GCC<"patchable_function_entry">];
   let Subjects = SubjectList<[Function, ObjCMethod]>;
   let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index cbf28688a7408..e085e2735b208 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5328,7 +5328,7 @@ takes precedence over the command line option 
``-fpatchable-function-entry=N,M``
 ``M`` defaults to 0 if omitted.
 
 This attribute is only supported on
-aarch64/aarch64-be/riscv32/riscv64/i386/x86-64 targets.
+aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64 targets.
 }];
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 87862e028636f..2327086c91f1f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6277,7 +6277,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   if (Arg *A = Args.getLastArg(options::OPT_fpatchable_function_entry_EQ)) {
 StringRef S0 = A->getValue(), S = S0;
 unsigned Size, Offset = 0;
-if (!Triple.isAArch64() && !Triple.isRISCV() && !Triple.isX86())
+if (!Triple.isAArch64() && !Triple.isLoongArch() && !Triple.isRISCV() &&
+!Triple.isX86())
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 else if (S.consumeInteger(10, Size) ||

diff  --git a/clang/test/Driver/fpatchable-function-entry.c 
b/clang/test/Driver/fpatchable-function-entry.c
index da7370a4d87a7..4d0d609584c8d 100644
--- a/clang/test/Driver/fpatchable-function-entry.c
+++ b/clang/test/Driver/fpatchable-function-entry.c
@@ -2,6 +2,8 @@
 // RUN: %clang -target x86_64 %s -fpatchable-function-entry=1 -c -### 2>&1 | 
FileCheck %s
 // RUN: %clang -target aarch64 %s -fpatchable-function-entry=1 -c -### 2>&1 | 
FileCheck %s
 // RUN: %clang -target aarch64 %s -fpatchable-function-entry=1,0 -c -### 2>&1 
| FileCheck %s
+// RUN: %clang -target loongarch32 %s -fpatchable-function-entry=1,0 -c -### 
2>&1 | FileCheck %s
+// RUN: %clang -target loongarch64 %s -fpatchable-function-entry=1,0 -c -### 
2>&1 | FileCheck %s
 // RUN: %clang -target riscv32 %s -fpatchable-function-entry=1,0 -c -### 2>&1 
| FileCheck %s
 // RUN: %clang -target riscv64 %s -fpatchable-function-entry=1,0 -c -### 2>&1 
| FileCheck %s
 // CHECK: "-fpatchable-function-entry=1"

diff  --git a/clang/test/Sema/patchable-function-entry-attr.cpp 
b/clang/test/Sema/patchable-function-entry-attr.cpp
index 3dd0504987306..9134c851da588 100644
--- a/clang/test/Sema/patchable-function-entry-attr.cpp
+++ b/clang/test/Sema/patchable-function-entry-attr.cpp
@@ -2,6 +2,8 @@
 // RUN: 

[PATCH] D146054: [RISCV] Add -print-supported-marchs and -march=help support

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:153
+  std::set TempSet(Cmp);
+  for (auto E : SupportedExtensions)
+TempSet.insert(E);

Question for the community. Should we maintain SupportedExtensions in the order 
we want printed instead of sorting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:738
+public:
+  enum DepthAdjustmentKind { Diff, Value };
+

I don't really get what you're getting at with "Diff" and "Value"?  Those names 
don't really seem to make sense to me?



Comment at: clang/lib/Sema/SemaConcept.cpp:779
+// The depths calculated for the declarations can be equal but they still
+// may differ from the depths of types inside OldConstr and NewConstr.
+OldConstr =

I don't believe they are supposed to, at least based on what you've said here.  
Can you clarify what you mean?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

craig.topper wrote:
> erichkeane wrote:
> > erichkeane wrote:
> > > craig.topper wrote:
> > > > erichkeane wrote:
> > > > > craig.topper wrote:
> > > > > > erichkeane wrote:
> > > > > > > Can you add a test that shows that we warn on instantiation?  
> > > > > > > This shouldn't be a dependent declrefexpr when instantiated.
> > > > > > > 
> > > > > > > Additionally, this would make sure that we're properly 
> > > > > > > propoagating `always_inline`.
> > > > > > Should this warn
> > > > > > 
> > > > > > ```
> > > > > > template [[gnu::noinline]]   
> > > > > >  
> > > > > > int bar(int x) {
> > > > > >  
> > > > > > if constexpr (D > 1)
> > > > > >  
> > > > > > [[clang::always_inline]] return bar(x + 1);
> > > > > >  
> > > > > > else
> > > > > >  
> > > > > > return x;   
> > > > > >  
> > > > > > }   
> > > > > >  
> > > > > > 
> > > > > >  
> > > > > > int baz(int x) {
> > > > > >  
> > > > > >   return bar<5>(x); 
> > > > > >  
> > > > > > }  
> > > > > > ```
> > > > > Yes, I would expect that to warn.
> > > > It looks like handleAlwaysInlineAttr only gets called once so it 
> > > > doesn't get called after instantiation.
> > > Hmm... thats unfortunate.  That means we're perhaps not instantiating it 
> > > correctly.  I'll take some time to poke around as I get a chacne.
> > Ok, it looks like SemaStmt.cpp's `BuildAttributedStmt` needs to handle the 
> > attributes.  We should some day do that automatically for a majority o f 
> > attributes, but for now, just adding the call there is sufficient.
> What I do need to add?
You should be able to follow what is already there, but I suspect you just need 
to call some sort of 'handle' function for those to do this.  There is one 
there already youc an crib off of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145888: [clang-format] Fix non-case colons in Verilog case lines

2023-03-15 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked an inline comment as done.
sstwcw added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4424
-if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
-  return Style.SpaceBeforeCaseColon;
 const FormatToken *Next = Right.getNextNonComment();

MyDeveloperDay wrote:
> Hmm.. this is going to impact others, did you make a change here before and 
> break something for c++? or was this a bug in the C++ code, is there not a 
> unit test for setting SpaceBeforeCaseColon? 
You can see that the previous rule already covers what this one covers.  This 
rule doesn't change the behavior for C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145888

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


[clang] 7eaa7b0 - [clang] Use *{Map,Set}::contains (NFC)

2023-03-15 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-03-15T18:06:34-07:00
New Revision: 7eaa7b055389799643cd6c2e992985f71de73ee5

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

LOG: [clang] Use *{Map,Set}::contains (NFC)

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/lib/ARCMigrate/FileRemapper.cpp
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGOpenCLRuntime.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Format/FormatTokenSource.h
clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index 74748c8723ce8..970b17be224db 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -125,7 +125,7 @@ class DataflowAnalysisContext {
   ///
   ///  `D` must not be assigned a storage location.
   void setStorageLocation(const ValueDecl , StorageLocation ) {
-assert(DeclToLoc.find() == DeclToLoc.end());
+assert(!DeclToLoc.contains());
 DeclToLoc[] = 
   }
 
@@ -143,7 +143,7 @@ class DataflowAnalysisContext {
   ///  `E` must not be assigned a storage location.
   void setStorageLocation(const Expr , StorageLocation ) {
 const Expr  = ignoreCFGOmittedNodes(E);
-assert(ExprToLoc.find() == ExprToLoc.end());
+assert(!ExprToLoc.contains());
 ExprToLoc[] = 
   }
 

diff  --git a/clang/lib/ARCMigrate/FileRemapper.cpp 
b/clang/lib/ARCMigrate/FileRemapper.cpp
index 92027fe4f1f4b..7e56e0683c129 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -251,8 +251,7 @@ const FileEntry *FileRemapper::getOriginalFile(StringRef 
filePath) {
 I = ToFromMappings.find(file);
   if (I != ToFromMappings.end()) {
 file = I->second;
-assert(FromToMappings.find(file) != FromToMappings.end() &&
-   "Original file not in mappings!");
+assert(FromToMappings.contains(file) && "Original file not in mappings!");
   }
   return file;
 }

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index bc682c92c143f..0056da191765b 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1139,7 +1139,7 @@ unsigned 
ByteCodeExprGen::allocateLocalPrimitive(DeclTy &,
   if (const auto *VD =
   dyn_cast_if_present(Src.dyn_cast())) {
 assert(!P.getGlobal(VD));
-assert(Locals.find(VD) == Locals.end());
+assert(!Locals.contains(VD));
   }
 
   // FIXME: There are cases where Src.is() is wrong, e.g.
@@ -1161,7 +1161,7 @@ ByteCodeExprGen::allocateLocal(DeclTy &, 
bool IsExtended) {
   if (const auto *VD =
   dyn_cast_if_present(Src.dyn_cast())) {
 assert(!P.getGlobal(VD));
-assert(Locals.find(VD) == Locals.end());
+assert(!Locals.contains(VD));
   }
 
   QualType Ty;

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 9bbb291df0639..37e1780e68a60 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -60,7 +60,7 @@ class RegistryMaps {
 
 void RegistryMaps::registerMatcher(
 StringRef MatcherName, std::unique_ptr Callback) {
-  assert(Constructors.find(MatcherName) == Constructors.end());
+  assert(!Constructors.contains(MatcherName));
   Constructors[MatcherName] = std::move(Callback);
 }
 

diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index ea8b73e81ea24..7e93247ba83fc 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3387,8 +3387,7 @@ CFGBlock *CFGBuilder::VisitLabelStmt(LabelStmt *L) {
   if (!LabelBlock)  // This can happen when the body is empty, i.e.
 LabelBlock = createBlock(); // scopes that only contains NullStmts.
 
-  assert(LabelMap.find(L->getDecl()) == LabelMap.end() &&
- "label already in map");
+  assert(!LabelMap.contains(L->getDecl()) && "label already in map");
   LabelMap[L->getDecl()] = JumpTarget(LabelBlock, ScopePos);
 
   

[clang] c7c1d53 - [Lex] Use false instead of 0 (NFC)

2023-03-15 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-03-15T18:06:31-07:00
New Revision: c7c1d531b9a77a735183f67a6d8b538691284f92

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

LOG: [Lex] Use false instead of 0 (NFC)

Added: 


Modified: 
clang/include/clang/Lex/Preprocessor.h

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index b3c3a80deb11f..37e16021071a8 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2850,7 +2850,7 @@ class Preprocessor {
   /// This boolean state keeps track if the current scanned token (by this PP)
   /// is in an "-Wunsafe-buffer-usage" opt-out region. Assuming PP scans a
   /// translation unit in a linear order.
-  bool InSafeBufferOptOutRegion = 0;
+  bool InSafeBufferOptOutRegion = false;
 
   /// Hold the start location of the current "-Wunsafe-buffer-usage" opt-out
   /// region if PP is currently in such a region.  Hold undefined value



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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-15 Thread Aryan Godara via Phabricator via cfe-commits
AryanGodara added a comment.

In D146041#4195992 , @DavidSpickett 
wrote:

>> Since this is my first commit to such a large repository(and project), can 
>> you please guide me with this @DavidSpickett !
>
> Sure, you'll want to make a commit that only has changes to warnings and 
> errors. You can split up this one to do that, see part "A)" of this answer 
> https://stackoverflow.com/questions/6217156/break-a-previous-commit-into-multiple-commits/6217314#6217314.
>  Then you can update this review with that new commit, change the 
> description/title etc. if needed.
>
> If you get confused with updating the review (happens to me all the time) you 
> can just abandon this (there is an entry in the "Add Action..." menu) and 
> make a new review as you did before.
>
> How to identify what changes should be included? I would ignore comments, 
> shell scripts, FIXMEs, or general test data. If the test is producing a 
> warning and looking for it, clearly it should be changed. If it's just random 
> data it's using to test some function, I wouldn't change it.

Thanks for the info @DavidSpickett !!
I will try to split this commit, and update on this asap (Sorry for the late 
update, I have mid-sem exams going on, I haven't abandoned this issue, still 
working on it).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D121175: [clang] Add -Wstart-no-unknown-warning-option/-Wend-no-unknown-warning-option.

2023-03-15 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath abandoned this revision.
mysterymath added a comment.

Given that we didn't reach a consensus on this one, I'll abandon this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121175

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505657.
francii added a comment.
Herald added a subscriber: jplehr.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,57 +232,58 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-03-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: erichkeane, rsmith, aaron.ballman.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The associated github issue: https://github.com/llvm/llvm-project/issues/61414
It also fixes 
https://github.com/llvm/llvm-project/issues/49620#issuecomment-1387667143 and 
https://github.com/llvm/llvm-project/issues/60231

Test plan:
1/ ninja check-all
2/ Bootstrapped Clang passes all the tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146178

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Index: clang/test/SemaTemplate/concepts-out-of-line-def.cpp
===
--- clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -127,3 +127,27 @@
 static_assert(S::specialization("str") == SPECIALIZATION_REQUIRES);
 
 } // namespace multiple_template_parameter_lists
+
+namespace constrained_members {
+
+static constexpr int CONSTRAINED_METHOD_1 = 1;
+static constexpr int CONSTRAINED_METHOD_2 = 2;
+
+template 
+struct S {
+  template 
+  static constexpr int constrained_method();
+};
+
+template <>
+template 
+constexpr int S<1>::constrained_method() { return CONSTRAINED_METHOD_1; }
+
+template <>
+template 
+constexpr int S<2>::constrained_method() { return CONSTRAINED_METHOD_2; }
+
+static_assert(S<1>::constrained_method() == CONSTRAINED_METHOD_1);
+static_assert(S<2>::constrained_method() == CONSTRAINED_METHOD_2);
+
+} // namespace constrained members
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1296,9 +1296,11 @@
 //
 // We check the return type and template parameter lists for function
 // templates first; the remaining checks follow.
+
 bool SameTemplateParameterList = TemplateParameterListsAreEqual(
-NewTemplate->getTemplateParameters(),
-OldTemplate->getTemplateParameters(), false, TPL_TemplateMatch);
+NewTemplate, NewTemplate->getTemplateParameters(), OldTemplate,
+OldTemplate->getTemplateParameters(), false, TPL_TemplateMatch,
+SourceLocation(), false /* PartialOrdering */);
 bool SameReturnType = Context.hasSameType(Old->getDeclaredReturnType(),
   New->getDeclaredReturnType());
 // FIXME(GH58571): Match template parameter list even for non-constrained
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -733,12 +733,19 @@
 }
 
 namespace {
-  class AdjustConstraintDepth : public TreeTransform {
+class AdjustConstraintDepth : public TreeTransform {
+public:
+  enum DepthAdjustmentKind { Diff, Value };
+
+private:
   unsigned TemplateDepth = 0;
-  public:
+  DepthAdjustmentKind Kind;
+
+public:
   using inherited = TreeTransform;
-  AdjustConstraintDepth(Sema , unsigned TemplateDepth)
-  : inherited(SemaRef), TemplateDepth(TemplateDepth) {}
+  AdjustConstraintDepth(Sema , unsigned TemplateDepth,
+DepthAdjustmentKind Kind)
+  : inherited(SemaRef), TemplateDepth(TemplateDepth), Kind(Kind) {}
 
   using inherited::TransformTemplateTypeParmType;
   QualType TransformTemplateTypeParmType(TypeLocBuilder ,
@@ -751,13 +758,13 @@
   TransformDecl(TL.getNameLoc(), OldTTPDecl));
 
 QualType Result = getSema().Context.getTemplateTypeParmType(
-T->getDepth() + TemplateDepth, T->getIndex(), T->isParameterPack(),
-NewTTPDecl);
+Kind == Diff ? T->getDepth() + TemplateDepth : TemplateDepth,
+T->getIndex(), T->isParameterPack(), NewTTPDecl);
 TemplateTypeParmTypeLoc NewTL = TLB.push(Result);
 NewTL.setNameLoc(TL.getNameLoc());
 return Result;
   }
-  };
+};
 } // namespace
 
 bool Sema::AreConstraintExpressionsEqual(const NamedDecl *Old,
@@ -765,22 +772,19 @@
  const NamedDecl *New,
  const Expr *NewConstr) {
   if (Old && New && Old != New) {
-unsigned Depth1 = CalculateTemplateDepthForConstraints(
-*this, Old);
-unsigned Depth2 = CalculateTemplateDepthForConstraints(
-*this, New);
-
-// Adjust the 'shallowest' verison of this to increase the depth to match
-// the 'other'.
-if (Depth2 > Depth1) {
-  OldConstr = AdjustConstraintDepth(*this, Depth2 - Depth1)
-  .TransformExpr(const_cast(OldConstr))
-  .get();
-} else if (Depth1 > Depth2) {
-  

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis 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 rGac1d143b0ef9: [Clang][AIX][p] Manually Claim -p in front end 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if 

[clang] ac1d143 - [Clang][AIX][p] Manually Claim -p in front end

2023-03-15 Thread Michael Francis via cfe-commits

Author: Michael Francis
Date: 2023-03-15T23:26:48Z
New Revision: ac1d143b0ef924cf2725bb36537f18ae2c7f9c4f

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

LOG: [Clang][AIX][p] Manually Claim -p in front end

The current implementation of `-p` does not claim the argument once it
is passed. Since it pushes `-pg` directly, it is only ever referred to
again when linking. As a result, when compiling with `-S`, the compiler
warns that `-p` goes unused even though that is not the case.

With this patch, if both `-p` and `-pg` are passed, the argument that is
passed second will take precedence. `-p` will still throw an error on
unsupported platforms, regardless of precedence.

This revision includes a test case, which has been placed in
`clang/test/Driver/zos-profiling-error.c`. As a result,
`zos-profiling-error.c` has been renamed to `ibm-profiling.c`. This
revision also passes `clang/test/Driver/aix-ld.c`.

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

Added: 
clang/test/Driver/ibm-profiling.c

Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
clang/test/Driver/zos-profiling-error.c



diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 15560e1c81bca..f41fb768fdc06 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@ void aix::Linker::ConstructJob(Compilation , const 
JobAction ,
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 79fcf4526df3e..87862e028636f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))

diff  --git a/clang/test/Driver/ibm-profiling.c 
b/clang/test/Driver/ibm-profiling.c
new file mode 100644
index 0..26bc0d7784373
--- /dev/null
+++ b/clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505653.
francii added a comment.

Rebase for push


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, 

[PATCH] D145369: Emit const globals with constexpr destructor as constant LLVM values

2023-03-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/CodeGen/CGExprAgg.cpp:535
   CGM.getModule(), C->getType(),
-  CGM.isTypeConstant(ArrayQTy, /* ExcludeCtorDtor= */ true),
+  CGM.isTypeConstant(ArrayQTy, /* ExcludeCtor= */ true,
+ /* ExcludeDtor= */ false),

I'm not sure why we're querying isTypeConstant here?  The global shouldn't get 
written to in any case.  But I guess that's a separate issue.


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

https://reviews.llvm.org/D145369

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


[PATCH] D146156: [clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

2023-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D146156#4197289 , @shafik wrote:

> Is there a way to test this?

It was easier to reproduce on small test case than I thought, test added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146156

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


[PATCH] D142986: Enable multilib.yaml in the BareMetal ToolChain

2023-03-15 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505644.
michaelplatings added a comment.

Rebase on D146141 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142986

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal-multilib.yaml
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/lit.local.cfg

Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,7 +1,7 @@
 from lit.llvm import llvm_config
 
 config.suffixes = ['.c', '.cpp', '.cppm', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
-   '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl']
+   '.cu', '.rs', '.cl', '.clcpp', '.hip', '.hipi', '.hlsl', '.yaml']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -118,9 +118,9 @@
 // Verify that the bare metal driver does not include any host system paths:
 // CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+[^"]*}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]{{[/\\]+}}include"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+[^"]*}}include"
 
 // RUN: %clang %s -### --target=riscv64-unknown-elf -o %t.out -L some/directory/user/asked/for \
 // RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
Index: clang/test/Driver/baremetal-multilib.yaml
===
--- /dev/null
+++ clang/test/Driver/baremetal-multilib.yaml
@@ -0,0 +1,142 @@
+# REQUIRES: shell
+# UNSUPPORTED: system-windows
+
+# RUN: rm -rf %T/baremetal_multilib
+# RUN: mkdir -p %T/baremetal_multilib/bin
+# RUN: mkdir -p %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib
+# RUN: touch %T/baremetal_multilib/lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib/libclang_rt.builtins.a
+# RUN: ln -s %clang %T/baremetal_multilib/bin/clang
+# RUN: ln -s %s %T/baremetal_multilib/lib/clang-runtimes/multilib.yaml
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
+# RUN: --target=thumbv8m.main-none-eabihf --sysroot= \
+# RUN:   | FileCheck -DSYSROOT=%T/baremetal_multilib %s
+# CHECK:  "-cc1" "-triple" "thumbv8m.main-none-unknown-eabihf"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include/c++/v1"
+# CHECK-SAME: "-internal-isystem" "[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/include"
+# CHECK-SAME: "-x" "c++" "{{.*}}baremetal-multilib.yaml"
+# CHECK-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+# CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib"
+# CHECK-SAME: "-lc" "-lm" "-lclang_rt.builtins"
+# CHECK-SAME: "-o" "{{.*}}.tmp.out"
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-directory 2>&1 \
+# RUN: --target=thumbv8m.main-none-eabihf --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-DIRECTORY %s
+# CHECK-PRINT-MULTI-DIRECTORY: arm-none-eabi/thumb/v8-m.main/fp
+
+# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -print-multi-lib 2>&1 \
+# RUN: --target=arm-none-eabi --sysroot= \
+# RUN:   | FileCheck --check-prefix=CHECK-PRINT-MULTI-LIB %s
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v6-m/nofp;@-target=thumbv6m-none-eabi@mfloat-abi=soft
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7-m/nofp;@-target=thumbv7m-none-eabi@mfloat-abi=soft
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v7e-m/nofp;@-target=thumbv7em-none-eabi@mfloat-abi=soft@mfpu=none
+# CHECK-PRINT-MULTI-LIB: arm-none-eabi/thumb/v8-m.main/nofp;@-target=arm-none-eabi@mfloat-abi=soft@march=armv8m.main+nofp
+# CHECK-PRINT-MULTI-LIB: 

[PATCH] D142933: Add -print-multi-selection-flags-experimental option

2023-03-15 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 505643.
michaelplatings marked 2 inline comments as done.
michaelplatings added a comment.

Rebase on D146141 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142933

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/test/Driver/print-multi-selection-flags.c

Index: clang/test/Driver/print-multi-selection-flags.c
===
--- /dev/null
+++ clang/test/Driver/print-multi-selection-flags.c
@@ -0,0 +1,54 @@
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-linux -fc++-abi=itanium -fsanitize=address | FileCheck --check-prefix=CHECK-LINUX %s
+// CHECK-LINUX: fc++-abi=itanium
+// CHECK-LINUX: fexceptions
+// CHECK-LINUX: frtti
+// CHECK-LINUX: fsanitize=address
+// CHECK-LINUX: target=aarch64-unknown-linux
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-fuchsia -fsanitize=hwaddress | FileCheck --check-prefix=CHECK-FUCHSIA %s
+// CHECK-FUCHSIA: fsanitize=hwaddress
+// CHECK-FUCHSIA: target=aarch64-unknown-fuchsia
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck --check-prefix=CHECK-ARMV4T %s
+// CHECK-ARMV4T: fno-exceptions
+// CHECK-ARMV4T: fno-rtti
+// CHECK-ARMV4T: mfloat-abi=soft
+// CHECK-ARMV4T: mfpu=none
+// CHECK-ARMV4T: target=armv4t-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=armv7em-none-eabi -mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s
+// CHECK-SOFTFP: mfloat-abi=softfp
+// CHECK-SOFTFP: mfpu=fpv4-sp-d16
+// CHECK-SOFTFP: target=thumbv7em-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabihf -march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s
+// CHECK-HARD: mfloat-abi=hard
+// CHECK-HARD: mfpu=fpv5-d16
+// CHECK-HARD: target=thumbv7em-none-unknown-eabihf
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck --check-prefix=CHECK-V8MMAIN-NOFP %s
+// CHECK-V8MMAIN-NOFP: mfloat-abi=soft
+// CHECK-V8MMAIN-NOFP: mfpu=none
+// CHECK-V8MMAIN-NOFP: target=thumbv8m.main-none-unknown-eabi
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck --check-prefix=CHECK-MVE %s
+// CHECK-MVE: march=+mve
+// CHECK-MVE: march=+mve.fp
+// CHECK-MVE: mfloat-abi=hard
+// CHECK-MVE: mfpu=fp-armv8-fullfp16-sp-d16
+// CHECK-MVE: target=thumbv8.1m.main-none-unknown-eabihf
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=arm-none-eabi -march=armv8.1m.main+mve+nofp | FileCheck --check-prefix=CHECK-MVENOFP %s
+// CHECK-MVENOFP: march=+mve
+// CHECK-MVENOFP-NOT: march=+mve.fp
+// CHECK-MVENOFP: mfpu=none
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s
+// CHECK-LSE: march=+lse
+
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s
+// RUN: %clang -print-multi-selection-flags-experimental --target=aarch64-none-elf -march=armv9-a| FileCheck --check-prefix=CHECK-SVE2 %s
+// CHECK-SVE2: march=+simd
+// CHECK-SVE2: march=+sve
+// CHECK-SVE2: march=+sve2
+// CHECK-SVE2: target=aarch64-none-unknown-elf
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -63,9 +63,11 @@
 void getARMArchCPUFromArgs(const llvm::opt::ArgList ,
llvm::StringRef , llvm::StringRef ,
bool FromAs = false);
-void getARMTargetFeatures(const Driver , const llvm::Triple ,
-  const llvm::opt::ArgList ,
-  std::vector , bool ForAS);
+llvm::ARM::FPUKind getARMTargetFeatures(const Driver ,
+const llvm::Triple ,
+const llvm::opt::ArgList ,
+std::vector ,
+bool ForAS);
 int getARMSubArchVersionNumber(const llvm::Triple );
 bool isARMMProfile(const llvm::Triple );
 bool isARMAProfile(const llvm::Triple );
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ 

[PATCH] D146156: [clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

2023-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 505642.
DmitryPolukhin added a comment.

Test added


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146156

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Preprocessor/Inputs/header-search-crash/foo.hmap.json
  clang/test/Preprocessor/header-search-crash.c


Index: clang/test/Preprocessor/header-search-crash.c
===
--- /dev/null
+++ clang/test/Preprocessor/header-search-crash.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %hmaptool write %S/Inputs/header-search-crash/foo.hmap.json %t/foo.hmap
+// RUN: %clang -cc1 -E %s -I %t/foo.hmap -verify
+
+#include "MissingHeader.h" // expected-error {{'MissingHeader.h' file not 
found}}
Index: clang/test/Preprocessor/Inputs/header-search-crash/foo.hmap.json
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/header-search-crash/foo.hmap.json
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Foo.h" : "Foo/Foo.h"
+}
+}
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -378,15 +378,17 @@
   llvm::StringMap Index(SearchDirs.size());
 
   // Iterate over all filename keys and associate them with the index i.
-  unsigned i = 0;
-  for (; i != SearchDirs.size(); ++i) {
+  for (unsigned i = 0; i != SearchDirs.size(); ++i) {
 auto  = SearchDirs[i];
 
 // We're concerned with only the initial contiguous run of header
 // maps within SearchDirs, which can be 99% of SearchDirs when
 // SearchDirs.size() is ~1.
-if (!Dir.isHeaderMap())
+if (!Dir.isHeaderMap()) {
+  SearchDirHeaderMapIndex = std::move(Index);
+  FirstNonHeaderMapSearchDirIdx = i;
   break;
+}
 
 // Give earlier keys precedence over identical later keys.
 auto Callback = [&](StringRef Filename) {
@@ -394,9 +396,6 @@
 };
 Dir.getHeaderMap()->forEachKey(Callback);
   }
-
-  SearchDirHeaderMapIndex = std::move(Index);
-  FirstNonHeaderMapSearchDirIdx = i;
 }
 
 
//===--===//
@@ -1929,7 +1928,7 @@
 llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile,
 bool *IsSystem) {
   using namespace llvm::sys;
-  
+
   llvm::SmallString<32> FilePath = File;
   // remove_dots switches to backslashes on windows as a side-effect!
   // We always want to suggest forward slashes for includes.


Index: clang/test/Preprocessor/header-search-crash.c
===
--- /dev/null
+++ clang/test/Preprocessor/header-search-crash.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %hmaptool write %S/Inputs/header-search-crash/foo.hmap.json %t/foo.hmap
+// RUN: %clang -cc1 -E %s -I %t/foo.hmap -verify
+
+#include "MissingHeader.h" // expected-error {{'MissingHeader.h' file not found}}
Index: clang/test/Preprocessor/Inputs/header-search-crash/foo.hmap.json
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/header-search-crash/foo.hmap.json
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Foo.h" : "Foo/Foo.h"
+}
+}
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -378,15 +378,17 @@
   llvm::StringMap Index(SearchDirs.size());
 
   // Iterate over all filename keys and associate them with the index i.
-  unsigned i = 0;
-  for (; i != SearchDirs.size(); ++i) {
+  for (unsigned i = 0; i != SearchDirs.size(); ++i) {
 auto  = SearchDirs[i];
 
 // We're concerned with only the initial contiguous run of header
 // maps within SearchDirs, which can be 99% of SearchDirs when
 // SearchDirs.size() is ~1.
-if (!Dir.isHeaderMap())
+if (!Dir.isHeaderMap()) {
+  SearchDirHeaderMapIndex = std::move(Index);
+  FirstNonHeaderMapSearchDirIdx = i;
   break;
+}
 
 // Give earlier keys precedence over identical later keys.
 auto Callback = [&](StringRef Filename) {
@@ -394,9 +396,6 @@
 };
 Dir.getHeaderMap()->forEachKey(Callback);
   }
-
-  SearchDirHeaderMapIndex = std::move(Index);
-  FirstNonHeaderMapSearchDirIdx = i;
 }
 
 //===--===//
@@ -1929,7 +1928,7 @@
 llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile,
 bool *IsSystem) {
   using namespace llvm::sys;
-  
+
   llvm::SmallString<32> FilePath = File;
   // remove_dots switches to backslashes on windows as a side-effect!
   // We always want to suggest forward slashes for includes.
___
cfe-commits 

[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D131307#4197767 , @rsmith wrote:

>> Based on feedback we will provide users to the ability to downgrade this 
>> this diagnostic to a waring to allow for a transition period. We expect to 
>> turn this diagnostic to an error in the next release.
>
> Can we revert this now?

Seems appropriate.  Aaron, WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131307

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


[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:893
+errc::invalid_argument,
+"'zvknhb' requires 'zve64x' extension to also be specified");
+

For consistency with the Zvk* error, use

`"'zvknhb' requires 'v' or 'zve64*' extension to also be specified"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141672

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


[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-03-15 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

FYI, zvkb was discussed at the Architectural Review Committee this week and 
they've asked for some significant changes and expansions.  See the notes 
shared here: https://lists.riscv.org/g/tech-unprivileged/message/450

I actively do not think we need to wait on landing this patch until those 
expansions have been finalized.  I think is fine to land this in experimental 
state, and then transform zvkb into the requested form.   Having a generic 
vector bitmanip extension pulled out seems to make a lot of sense to me, and I 
like (most of) the proposed additions as they close holes we've encountered in 
codegen.

I've skimmed the review and didn't spot anything glaring, but want to leave 
approval to @craig.topper since he's already done one pass and is generally 
more familiar with the MC layer than I am.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141672

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


[PATCH] D131307: [Clang] Allow downgrading to a warning the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-03-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

> Based on feedback we will provide users to the ability to downgrade this this 
> diagnostic to a waring to allow for a transition period. We expect to turn 
> this diagnostic to an error in the next release.

Can we revert this now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131307

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG765d8a192180: [Clang][Sema] Fix incorrect deletion of 
default constructors for some unions (authored by royjacobson).

Changed prior to commit:
  https://reviews.llvm.org/D145851?vs=505620=505635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGen/union-non-trivial-member.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp

Index: clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
===
--- clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -144,3 +144,47 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) {}
+int x;
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union U3 {
+int a;
+non_trivial_constructor b{};
+};
+
+union U4 {
+int a{}; // expected-note {{previous initialization is here}}
+non_trivial_constructor b{}; // expected-error {{initializing multiple members of union}}
+};
+
+U1 u1; // expected-error {{call to implicitly-deleted default constructor}}
+U2 u2;
+U3 u3;
+U4 u4;
+
+static_assert(U2().a == 1000, "");
+static_assert(U3().a == 1000, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'a' of union with active member 'b'}}
+static_assert(U2().b.x == 100, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'b' of union with active member 'a'}}
+static_assert(U3().b.x == 100, "");
+
+} // namespace GH48416
Index: clang/test/CodeGen/union-non-trivial-member.cpp
===
--- /dev/null
+++ clang/test/CodeGen/union-non-trivial-member.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 --std=c++17 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) { }
+int x;
+};
+
+union UnionInt {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union UnionNonTrivial {
+int a;
+non_trivial_constructor b{};
+};
+
+void f() {
+UnionInt u1;
+UnionNonTrivial u2;
+}
+
+// CHECK:  define dso_local void @_Z1fv()
+// CHECK:call void @_ZN8UnionIntC1Ev
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC1Ev
+// CHECK:call void @_ZN8UnionIntC2Ev
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC1Ev
+// CHECK:call void @_ZN15UnionNonTrivialC2Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC2Ev
+// CHECK:store i32 1000
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC2Ev
+// CHECK:call void @_ZN23non_trivial_constructorC1Ev
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9158,7 +9158,18 @@
 // must be accessible and non-deleted, but need not be trivial. Such a
 // destructor is never actually called, but is semantically checked as
 // if it were.
-DiagKind = 4;
+if (CSM == Sema::CXXDefaultConstructor) {
+  // [class.default.ctor]p2:
+  //   A defaulted default constructor for class X is defined as deleted if
+  //   - X is a union that has a variant member with a non-trivial default
+  // constructor and no variant member of X has a default member
+  // initializer
+  const auto *RD = cast(Field->getParent());
+  if (!RD->hasInClassInitializer())
+DiagKind = 4;
+} else {
+  DiagKind = 4;
+}
   }
 
   if (DiagKind == -1)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -225,6 +225,8 @@
 - Fix an issue about ``decltype`` in the members of class templates derived from
   templates with related parameters.
   (`#58674 `_)
+- Fix incorrect deletion of the default constructor of unions in some
+  cases. (`#48416 `_)
 
 Bug Fixes to AST Handling
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 765d8a1 - [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-15 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2023-03-15T23:55:52+02:00
New Revision: 765d8a192180f8f33618087b15c022fe758044af

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

LOG: [Clang][Sema] Fix incorrect deletion of default constructors for some 
unions

If a union has explicit initializers for some members, we shouldn't delete
its default constructor.
Fixes https://github.com/llvm/llvm-project/issues/48416.

Reviewed By: erichkeane

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

Added: 
clang/test/CodeGen/union-non-trivial-member.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/cxx0x-nontrivial-union.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 10be3be259bc..09a3daee6887 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -225,6 +225,8 @@ Bug Fixes to C++ Support
 - Fix an issue about ``decltype`` in the members of class templates derived 
from
   templates with related parameters.
   (`#58674 `_)
+- Fix incorrect deletion of the default constructor of unions in some
+  cases. (`#48416 `_)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 41c76e5c1371..16e1071366b3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9158,7 +9158,18 @@ bool 
SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
 // must be accessible and non-deleted, but need not be trivial. Such a
 // destructor is never actually called, but is semantically checked as
 // if it were.
-DiagKind = 4;
+if (CSM == Sema::CXXDefaultConstructor) {
+  // [class.default.ctor]p2:
+  //   A defaulted default constructor for class X is defined as deleted if
+  //   - X is a union that has a variant member with a non-trivial default
+  // constructor and no variant member of X has a default member
+  // initializer
+  const auto *RD = cast(Field->getParent());
+  if (!RD->hasInClassInitializer())
+DiagKind = 4;
+} else {
+  DiagKind = 4;
+}
   }
 
   if (DiagKind == -1)

diff  --git a/clang/test/CodeGen/union-non-trivial-member.cpp 
b/clang/test/CodeGen/union-non-trivial-member.cpp
new file mode 100644
index ..fdc9fd16911e
--- /dev/null
+++ b/clang/test/CodeGen/union-non-trivial-member.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 --std=c++17 -emit-llvm %s -o - -triple 
x86_64-unknown-linux-gnu | FileCheck %s
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) { }
+int x;
+};
+
+union UnionInt {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union UnionNonTrivial {
+int a;
+non_trivial_constructor b{};
+};
+
+void f() {
+UnionInt u1;
+UnionNonTrivial u2;
+}
+
+// CHECK:  define dso_local void @_Z1fv()
+// CHECK:call void @_ZN8UnionIntC1Ev
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC1Ev
+// CHECK:call void @_ZN8UnionIntC2Ev
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC1Ev
+// CHECK:call void @_ZN15UnionNonTrivialC2Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC2Ev
+// CHECK:store i32 1000
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC2Ev
+// CHECK:call void @_ZN23non_trivial_constructorC1Ev

diff  --git a/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp 
b/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
index ad1f09fee33f..4a4bf7180a47 100644
--- a/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ b/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -144,3 +144,47 @@ namespace pr16061 {
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default 
constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) {}
+int x;
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default 
constructor}}
+};
+
+union U2 {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union U3 {
+int a;
+non_trivial_constructor b{};
+};
+
+union U4 {
+int a{}; // expected-note {{previous initialization is here}}
+non_trivial_constructor b{}; // expected-error {{initializing multiple 
members of union}}
+};
+
+U1 u1; // expected-error {{call to implicitly-deleted default constructor}}
+U2 u2;
+U3 u3;
+U4 u4;
+
+static_assert(U2().a == 1000, "");
+static_assert(U3().a == 1000, "");
+// expected-error@-1 {{static assertion expression is not an integral constant 

[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:7364
   ReadingKindTracker ReadingKind(Read_Decl, *this);
+  Deserializing D(this);
 

shafik wrote:
> Curious, why do we need this here and below.
I'm actually not sure how we got away with not having this before. This was 
probably always broken but just rarely caused problems?

Without this, the following can happen:
1) Deserializing a list of `CXXCtorInitializer`s recursively triggers some 
other deserialization step, that does create a `Deserializing` object (for 
example, we deserialize a new type).
2) That other deserialization step finishes, and the `~Deserializing` 
destructor notices it's the last one, so performs pending actions.
3) Those pending actions perform an ODR checking step (or something else, it 
doesn't matter what -- the point is that during the post-deserialization 
cleanup we do things that assume we're not deserializing any more). Maybe 
there's a static data member for which we loaded multiple definitions from 
different modules.
4) That step triggers loading a variable's initializer, which calls 
`GetExternalDeclStmt`, which moves around the `DeclsCursor` and doesn't put it 
back when it's done. (That should be fine, because we're supposed to be done 
with recursive deserialization at this point -- and `GetExternalDeclStmt` 
asserts that. But the assert doesn't fire because there's no `Deserializing` 
object here.)
5) `~Deserializing` finishes and we continue loading `CXXCtorInitializers`, but 
we crash because the `DeclsCursor` has been moved to some random other place.

Broadly, we should always have a `Deserializing` object whenever we're doing 
any kind of recursive deserialization, in order to delay any pending cleanup 
actions (that assume we're not in the middle of deserialization) until we're 
done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 505631.
rsmith marked an inline comment as done.
rsmith added a comment.

- Add `=` to parameter name comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExternalASTSource.h
  clang/include/clang/AST/MangleNumberingContext.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Sema/ExternalSemaSource.h
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Modules/lambda-in-variable.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp

Index: clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
===
--- clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
+++ clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
@@ -1457,11 +1457,31 @@
 // CHECK2-NEXT:ret void
 //
 //
-// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC2Ei
+// CHECK2-LABEL: define {{[^@]+}}@__cxx_global_var_init
+// CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK2-NEXT:  entry:
+// CHECK2-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 dereferenceable(4) @s, i32 noundef 1)
+// CHECK2-NEXT:ret void
+//
+//
+// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC1Ei
 // CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8:[0-9]+]] align 2 {
 // CHECK2-NEXT:  entry:
 // CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
 // CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
+// CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
+// CHECK2-NEXT:store i32 [[C]], ptr [[C_ADDR]], align 4
+// CHECK2-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
+// CHECK2-NEXT:[[TMP0:%.*]] = load i32, ptr [[C_ADDR]], align 4
+// CHECK2-NEXT:call void @_ZN1SC2Ei(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], i32 noundef [[TMP0]])
+// CHECK2-NEXT:ret void
+//
+//
+// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC2Ei
+// CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8]] align 2 {
+// CHECK2-NEXT:  entry:
+// CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
+// CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
 // CHECK2-NEXT:[[DOTCAPTURE_EXPR_:%.*]] = alloca i8, align 1
 // CHECK2-NEXT:[[DOTCAPTURE_EXPR__CASTED:%.*]] = alloca i64, align 8
 // CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
@@ -1650,26 +1670,6 @@
 // CHECK2-NEXT:ret i32 0
 //
 //
-// CHECK2-LABEL: define {{[^@]+}}@_ZN1SC1Ei
-// CHECK2-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[C:%.*]]) unnamed_addr #[[ATTR8]] align 2 {
-// CHECK2-NEXT:  entry:
-// CHECK2-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
-// CHECK2-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
-// CHECK2-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
-// CHECK2-NEXT:store i32 [[C]], ptr [[C_ADDR]], align 4
-// CHECK2-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
-// CHECK2-NEXT:[[TMP0:%.*]] = load i32, ptr [[C_ADDR]], align 4
-// CHECK2-NEXT:call void @_ZN1SC2Ei(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], i32 noundef [[TMP0]])
-// CHECK2-NEXT:ret void
-//
-//
-// CHECK2-LABEL: define {{[^@]+}}@__cxx_global_var_init
-// CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
-// CHECK2-NEXT:  entry:
-// CHECK2-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 dereferenceable(4) @s, i32 noundef 1)
-// CHECK2-NEXT:ret void
-//
-//
 // CHECK2-LABEL: define {{[^@]+}}@_GLOBAL__sub_I_parallel_master_taskloop_simd_codegen.cpp
 // CHECK2-SAME: () #[[ATTR6]] section "__TEXT,__StaticInit,regular,pure_instructions" {
 // CHECK2-NEXT:  entry:
@@ -3111,8 +3111,28 @@
 // CHECK6-NEXT:ret i32 [[TMP48]]
 //
 //
+// CHECK6-LABEL: define {{[^@]+}}@__cxx_global_var_init
+// CHECK6-SAME: () #[[ATTR2:[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK6-NEXT:  entry:
+// CHECK6-NEXT:call void @_ZN1SC1Ei(ptr noundef nonnull align 4 

[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3897-3899
+  } else if (T->getVectorKind() == VectorType::RVVFixedLengthDataVector) {
+mangleRISCVFixedRVVVectorType(T);
+return;

aaron.ballman wrote:
> Should there be corresponding changes to the Microsoft mangler as well?
Good question. I don't see the equivalent SVE handling in the Microsoft mangler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145088

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


[PATCH] D136515: [builtins] Add __builtin_assume_separate_storage.

2023-03-15 Thread David Goldblatt via Phabricator via cfe-commits
davidtgoldblatt added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2393
+particular object (so for example, it's never correct to call this function
+passing the addresses of fields in the same struct, elements of the same array,
+etc.).

bruno wrote:
> Not necessarily a blocker, but it seems like some of these things you mention 
> can actually be caught by diagnostics without too much effort? Any plans to 
> add them?
I hadn't planned to (at least in the short term). Practically I expect uses of 
this to be mostly backed out from looking at bad assembly (this is the way I've 
been using it so far in experimentation). You wouldn't generally expect people 
to want to try to express "these two struct fields don't alias" and so on 
because alias analysis can already handle those cases fairly well.

My inclination would be to wait on the diagnostics until we see if it's a real 
problem, but I'm not strongly opposed if you'd really like them in v1. 
(Although in that case I'll probably bug you for some help with where / how to 
put the diagnostics).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

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


[PATCH] D146168: [Sema] Stop stripping CV quals from *this captures in lambdas

2023-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 505624.
royjacobson added a comment.

rebase + release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146168

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/cxx1z-lambda-star-this.cpp

Index: clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
+++ clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -88,13 +88,11 @@
   void foo() const { //expected-note{{const}}
 
 auto L = [*this]() mutable {
-  static_assert(is_same);
-  ++d;
+  static_assert(is_same);
   auto M = [this] {
-static_assert(is_same);
-++d;
+static_assert(is_same);
 auto N = [] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -108,9 +106,9 @@
 };
   };
   auto M2 = [*this]() mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -126,9 +124,9 @@
   };
 
   auto M2 = [*this](auto a) mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [](auto b) {
-  static_assert(is_same);
+  static_assert(is_same);
 };
 return N;
   };
@@ -143,13 +141,11 @@
   ++d; //expected-error{{cannot assign}}
 };
 auto GL = [*this](auto a) mutable {
-  static_assert(is_same);
-  ++d;
+  static_assert(is_same);
   auto M = [this](auto b) {
-static_assert(is_same);
-++d;
+static_assert(is_same);
 auto N = [](auto c) {
-  static_assert(is_same);
+  static_assert(is_same);
 };
 N(3.14);
   };
@@ -161,21 +157,21 @@
 auto L = [this]() {
   static_assert(is_same);
   auto M = [*this]() mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [this] {
-  static_assert(is_same);
+  static_assert(is_same);
   auto M = [] {
-static_assert(is_same);
+static_assert(is_same);
   };
 };
 auto N2 = [*this] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
   auto M2 = [*this]() {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [this] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -190,14 +186,13 @@
 auto L = [*this]() mutable {
   auto M = [=](auto a) {
 auto N = [this] {
-  ++d;
-  static_assert(is_same);
+  static_assert(is_same);
   auto O = [*this] {
 static_assert(is_same);
   };
 };
 N();
-static_assert(is_same);
+static_assert(is_same);
   };
   return M;
 };
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1135,8 +1135,7 @@
 auto C = CurLSI->getCXXThisCapture();
 
 if (C.isCopyCapture()) {
-  ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
-  if (!CurLSI->Mutable)
+if (!CurLSI->Mutable)
 ClassType.addConst();
   return ASTCtx.getPointerType(ClassType);
 }
@@ -1175,7 +1174,6 @@
 while (Closure &&
IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
   if (IsByCopyCapture) {
-ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
 if (IsConstCapture)
   ClassType.addConst();
 return ASTCtx.getPointerType(ClassType);
@@ -1362,15 +1360,7 @@
 
 // The type of the corresponding data member (not a 'this' pointer if 'by
 // copy').
-QualType CaptureType = ThisTy;
-if (ByCopy) {
-  // If we are capturing the object referred to by '*this' by copy, ignore
-  // any cv qualifiers inherited from the type of the member function for
-  // the type of the closure-type's corresponding data member and any use
-  // of 'this'.
-  CaptureType = ThisTy->getPointeeType();
-  CaptureType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
-}
+QualType CaptureType = ByCopy ? ThisTy->getPointeeType() : ThisTy;
 
 bool isNested = NumCapturingClosures > 1;
 CSI->addThisCapture(isNested, Loc, CaptureType, ByCopy);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -225,6 +225,9 @@
 - Fix an issue about ``decltype`` in the members of class templates derived from
   templates with related parameters.
   

[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

Still LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

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


[PATCH] D146168: [Sema] Stop stripping CV quals from *this captures in lambdas

2023-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146168

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/cxx1z-lambda-star-this.cpp

Index: clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
+++ clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -88,13 +88,11 @@
   void foo() const { //expected-note{{const}}
 
 auto L = [*this]() mutable {
-  static_assert(is_same);
-  ++d;
+  static_assert(is_same);
   auto M = [this] {
-static_assert(is_same);
-++d;
+static_assert(is_same);
 auto N = [] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -108,9 +106,9 @@
 };
   };
   auto M2 = [*this]() mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -126,9 +124,9 @@
   };
 
   auto M2 = [*this](auto a) mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [](auto b) {
-  static_assert(is_same);
+  static_assert(is_same);
 };
 return N;
   };
@@ -143,13 +141,11 @@
   ++d; //expected-error{{cannot assign}}
 };
 auto GL = [*this](auto a) mutable {
-  static_assert(is_same);
-  ++d;
+  static_assert(is_same);
   auto M = [this](auto b) {
-static_assert(is_same);
-++d;
+static_assert(is_same);
 auto N = [](auto c) {
-  static_assert(is_same);
+  static_assert(is_same);
 };
 N(3.14);
   };
@@ -161,21 +157,21 @@
 auto L = [this]() {
   static_assert(is_same);
   auto M = [*this]() mutable {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [this] {
-  static_assert(is_same);
+  static_assert(is_same);
   auto M = [] {
-static_assert(is_same);
+static_assert(is_same);
   };
 };
 auto N2 = [*this] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
   auto M2 = [*this]() {
-static_assert(is_same);
+static_assert(is_same);
 auto N = [this] {
-  static_assert(is_same);
+  static_assert(is_same);
 };
   };
 };
@@ -190,14 +186,13 @@
 auto L = [*this]() mutable {
   auto M = [=](auto a) {
 auto N = [this] {
-  ++d;
-  static_assert(is_same);
+  static_assert(is_same);
   auto O = [*this] {
 static_assert(is_same);
   };
 };
 N();
-static_assert(is_same);
+static_assert(is_same);
   };
   return M;
 };
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1135,8 +1135,7 @@
 auto C = CurLSI->getCXXThisCapture();
 
 if (C.isCopyCapture()) {
-  ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
-  if (!CurLSI->Mutable)
+if (!CurLSI->Mutable)
 ClassType.addConst();
   return ASTCtx.getPointerType(ClassType);
 }
@@ -1175,7 +1174,6 @@
 while (Closure &&
IsThisCaptured(Closure, IsByCopyCapture, IsConstCapture)) {
   if (IsByCopyCapture) {
-ClassType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
 if (IsConstCapture)
   ClassType.addConst();
 return ASTCtx.getPointerType(ClassType);
@@ -1362,15 +1360,7 @@
 
 // The type of the corresponding data member (not a 'this' pointer if 'by
 // copy').
-QualType CaptureType = ThisTy;
-if (ByCopy) {
-  // If we are capturing the object referred to by '*this' by copy, ignore
-  // any cv qualifiers inherited from the type of the member function for
-  // the type of the closure-type's corresponding data member and any use
-  // of 'this'.
-  CaptureType = ThisTy->getPointeeType();
-  CaptureType.removeLocalCVRQualifiers(Qualifiers::CVRMask);
-}
+QualType CaptureType = ByCopy ? ThisTy->getPointeeType() : ThisTy;
 
 bool isNested = NumCapturingClosures > 1;
 CSI->addThisCapture(isNested, Loc, CaptureType, ByCopy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-15 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D144844#4195633 , @ChuanqiXu wrote:

>> However, "performance" also includes compilation speed in the 'no 
>> optimisation, debug' case - that is also considered very important. So, 
>> perhaps, the short-term approach should be (as @dblaikie suggested) to 
>> include the bodies for -O >= 3?
>
> I don't think so. I think "performance" refers to the runtime performance 
> generally. I don't believe the normal users will be happy if modules will 
> decrease the performance of their program in any means. So I think we should 
> include the bodies by default.

I think I must be misunderstanding something here.

The default for clang is to compile without optimisation - this benefits the 
compile-edit-debug cycle, by providing output that is closest to the original 
source, and quickest to compile.

The user should not be expecting any optimisations to be applied unless they 
supply `-ON` (n fact, they might we complain if we optimise something that 
makes debugging harder).

So, we should try to ensure that adding modules supports that model - and 
provides the quickest and closest to the original sources for the default 
options.  If the user wants better optimisation (at the expense of longer 
compile times), then they provide `-ON`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D145851: [Clang][Sema] Fix incorrect deletion of default constructors for some unions

2023-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 505620.
royjacobson marked an inline comment as done.
royjacobson added a comment.

slimmer codegen test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145851

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGen/union-non-trivial-member.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp

Index: clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
===
--- clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -144,3 +144,47 @@
 
   Test2 t2x;  // expected-error {{call to implicitly-deleted default constructor of 'Test2'}}
 }
+
+namespace GH48416 {
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) {}
+int x;
+};
+
+
+union U1 {
+int a;
+non_trivial_constructor b; // expected-note {{has a non-trivial default constructor}}
+};
+
+union U2 {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union U3 {
+int a;
+non_trivial_constructor b{};
+};
+
+union U4 {
+int a{}; // expected-note {{previous initialization is here}}
+non_trivial_constructor b{}; // expected-error {{initializing multiple members of union}}
+};
+
+U1 u1; // expected-error {{call to implicitly-deleted default constructor}}
+U2 u2;
+U3 u3;
+U4 u4;
+
+static_assert(U2().a == 1000, "");
+static_assert(U3().a == 1000, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'a' of union with active member 'b'}}
+static_assert(U2().b.x == 100, "");
+// expected-error@-1 {{static assertion expression is not an integral constant expression}}
+// expected-note@-2 {{read of member 'b' of union with active member 'a'}}
+static_assert(U3().b.x == 100, "");
+
+} // namespace GH48416
Index: clang/test/CodeGen/union-non-trivial-member.cpp
===
--- /dev/null
+++ clang/test/CodeGen/union-non-trivial-member.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 --std=c++17 -emit-llvm %s -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+struct non_trivial_constructor {
+constexpr non_trivial_constructor() : x(100) { }
+int x;
+};
+
+union UnionInt {
+int a{1000};
+non_trivial_constructor b;
+};
+
+union UnionNonTrivial {
+int a;
+non_trivial_constructor b{};
+};
+
+void f() {
+UnionInt u1;
+UnionNonTrivial u2;
+}
+
+// CHECK:  define dso_local void @_Z1fv()
+// CHECK:call void @_ZN8UnionIntC1Ev
+// CHECK-NEXT:   call void @_ZN15UnionNonTrivialC1Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC1Ev
+// CHECK:call void @_ZN8UnionIntC2Ev
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC1Ev
+// CHECK:call void @_ZN15UnionNonTrivialC2Ev
+
+// CHECK:  define {{.*}}void @_ZN8UnionIntC2Ev
+// CHECK:store i32 1000
+
+// CHECK:  define {{.*}}void @_ZN15UnionNonTrivialC2Ev
+// CHECK:call void @_ZN23non_trivial_constructorC1Ev
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -9157,7 +9157,18 @@
 // must be accessible and non-deleted, but need not be trivial. Such a
 // destructor is never actually called, but is semantically checked as
 // if it were.
-DiagKind = 4;
+if (CSM == Sema::CXXDefaultConstructor) {
+  // [class.default.ctor]p2:
+  //   A defaulted default constructor for class X is defined as deleted if
+  //   - X is a union that has a variant member with a non-trivial default
+  // constructor and no variant member of X has a default member
+  // initializer
+  const auto *RD = cast(Field->getParent());
+  if (!RD->hasInClassInitializer())
+DiagKind = 4;
+} else {
+  DiagKind = 4;
+}
   }
 
   if (DiagKind == -1)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -202,6 +202,8 @@
 - Fix crash when evaluating consteval constructor of derived class whose base
   has more than one field.
   (`#60166 `_)
+- Fix incorrect deletion of the default constructor of unions in some
+  cases. (`#48416 `_)
 
 Bug Fixes to AST Handling
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145435: Choose style (file) from within code for use in IDEs

2023-03-15 Thread bers via Phabricator via cfe-commits
bersbersbers updated this revision to Diff 505615.
bersbersbers added a comment.

Made comment extraction more strict, made sure special comments not affected by 
formatting, added unit tests


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

https://reviews.llvm.org/D145435

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/test/Format/style-comment.cpp

Index: clang/test/Format/style-comment.cpp
===
--- /dev/null
+++ clang/test/Format/style-comment.cpp
@@ -0,0 +1,12 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format | clang-format \
+// RUN:   | FileCheck -strict-whitespace %s
+
+// CHECK: //comment
+// comment
+// CHECK: // clang-format style={BasedOnStyle: LLVM, SpacesInLineCommentPrefix: {Maximum: 0}, PointerAlignment: Left, ReflowComments: true, ColumnLimit: 30}
+// clang-format style={BasedOnStyle: LLVM, SpacesInLineCommentPrefix: {Maximum: 0}, PointerAlignment: Left, ReflowComments: true, ColumnLimit: 30}
+// CHECK: //comment
+// comment
+
+// CHECK: {{^int\*\ i;}}
+ int   *  i  ;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -4063,6 +4063,10 @@
   if (CommentPragmasRegex.match(IndentContent))
 return false;
 
+  // If comment is a style comment, treat as separate section.
+  if (IndentContent.ltrim().startswith(clang::format::StyleComment))
+return false;
+
   // If Line starts with a line comment, then FormatTok continues the comment
   // section if its original column is greater or equal to the original start
   // column of the line.
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3534,6 +3534,29 @@
   if (!getPredefinedStyle(FallbackStyleName, Style.Language, ))
 return make_string_error("Invalid fallback style \"" + FallbackStyleName);
 
+  if (StyleName == "file") {
+// Read style from first style comment at start of line in the code.
+std::string Prefix{std::string("// ") + StyleComment};
+size_t PrefixPos = StringRef::npos;
+while ((PrefixPos = Code.find(Prefix, PrefixPos + 1)) != StringRef::npos) {
+  // For each prefix, locate respective start of line (SoL) and check text
+  // between prefix and start of line for non-whitespace (comments not at
+  // start of line up to whitespace may be quoted, commented out, ...).
+  if (const size_t SoL = Code.substr(0, PrefixPos).find_last_of("\r\n") + 1;
+  !Code.substr(SoL, PrefixPos - SoL).ltrim().empty()) {
+continue;
+  }
+
+  // Use remainder of line as `StyleName` as if passed by `-style=...`;
+  // if no end of line (EoL) found, use remainder of file.
+  const size_t StylePos = PrefixPos + Prefix.size();
+  const size_t EoL = Code.find_first_of("\r\n", StylePos);
+  const size_t StyleLen = EoL - (EoL == StringRef::npos ? 0 : StylePos);
+  StyleName = Code.substr(StylePos, StyleLen);
+  break;
+}
+  }
+
   llvm::SmallVector, 1>
   ChildFormatTextToApply;
 
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -2142,7 +2142,7 @@
 }();
 if (!Style.ReflowComments ||
 CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
-switchesFormatting(Current) || !RegularComments) {
+setsStyle(Current) || switchesFormatting(Current) || !RegularComments) {
   return nullptr;
 }
 return std::make_unique(
Index: clang/lib/Format/BreakableToken.h
===
--- clang/lib/Format/BreakableToken.h
+++ clang/lib/Format/BreakableToken.h
@@ -27,6 +27,10 @@
 namespace clang {
 namespace format {
 
+/// Checks if \p Token sets style, basically, // clang-format style=
+/// \p Token must be a line comment.
+bool setsStyle(const FormatToken );
+
 /// Checks if \p Token switches formatting, like /* clang-format off */.
 /// \p Token must be a comment.
 bool switchesFormatting(const FormatToken );
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -216,6 +216,12 @@
   return BreakableToken::Split(StringRef::npos, 0);
 }
 
+bool setsStyle(const FormatToken ) {
+  assert(Token.is(TT_LineComment) && "style is set by line-comment token");
+  StringRef Content = 

[PATCH] D145435: Choose style (file) from within code for use in IDEs

2023-03-15 Thread bers via Phabricator via cfe-commits
bersbersbers marked an inline comment as done.
bersbersbers added a comment.

> The disadvantage is that it forces everyone else who needs to review or 
> maintain the file to deal with a style that's different from that of the 
> directory.

"different", yes, but as explained, not necessarily incompatible.

> Are there other tools that require their special comments to be at the top of 
> the file?

In a certain sense, yes: `clang-format` itself requires you to put 
`//clang-format off` comments *before* the code you want to turn it off for. So 
if you want to disable `clang-format` for some file, you would need to put that 
special comment near the top as well. So I would find it rather intuitive to 
have to put the style comment near the top. But I get your point, and chose not 
to implement any such restriction with the current revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145435

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


[clang] 6a6994c - Reland [StandardInstrumentations] Check function analysis invalidation in module passes as well

2023-03-15 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-03-15T13:29:21-07:00
New Revision: 6a6994cc9bc0327aaf8b005c650ff5eb29d2bcce

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

LOG: Reland [StandardInstrumentations] Check function analysis invalidation in 
module passes as well

See comments for why we now need to pass in the MAM instead of the FAM.

Reviewed By: nikic

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
flang/lib/Frontend/FrontendActions.cpp
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Passes/PassBuilderBindings.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/tools/opt/NewPMDriver.cpp
llvm/unittests/IR/PassManagerTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 92bef4be9cf8f..485eb3ad2ab85 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -837,7 +837,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   TheModule->getContext(),
   (CodeGenOpts.DebugPassManager || DebugPassStructure),
   /*VerifyEach*/ false, PrintPassOpts);
-  SI.registerCallbacks(PIC, );
+  SI.registerCallbacks(PIC, );
   PassBuilder PB(TM.get(), PTO, PGOOpt, );
 
   if (CodeGenOpts.EnableAssignmentTracking) {

diff  --git a/flang/lib/Frontend/FrontendActions.cpp 
b/flang/lib/Frontend/FrontendActions.cpp
index a6dac4df25d72..15c2b8b05688c 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -699,7 +699,7 @@ void 
CodeGenAction::runOptimizationPipeline(llvm::raw_pwrite_stream ) {
   std::optional pgoOpt;
   llvm::StandardInstrumentations si(llvmModule->getContext(),
 opts.DebugPassManager);
-  si.registerCallbacks(pic, );
+  si.registerCallbacks(pic, );
   llvm::PassBuilder pb(tm.get(), pto, pgoOpt, );
 
   // Attempt to load pass plugins and register their callbacks with PB.

diff  --git a/llvm/include/llvm/Passes/StandardInstrumentations.h 
b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 3b748f5e9f44c..759b79dc2b0ba 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -153,7 +153,7 @@ class PreservedCFGCheckerInstrumentation {
 #endif
 
   void registerCallbacks(PassInstrumentationCallbacks ,
- FunctionAnalysisManager );
+ ModuleAnalysisManager );
 };
 
 // Base class for classes that report changes to the IR.
@@ -574,7 +574,7 @@ class StandardInstrumentations {
   // Register all the standard instrumentation callbacks. If \p FAM is nullptr
   // then PreservedCFGChecker is not enabled.
   void registerCallbacks(PassInstrumentationCallbacks ,
- FunctionAnalysisManager *FAM = nullptr);
+ ModuleAnalysisManager *MAM = nullptr);
 
   TimePassesHandler () { return TimePasses; }
 };

diff  --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 4c41a382276a4..d574ae5737d55 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -260,7 +260,7 @@ static void runNewPMPasses(const Config , Module , 
TargetMachine *TM,
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(Mod.getContext(), Conf.DebugPassManager);
-  SI.registerCallbacks(PIC, );
+  SI.registerCallbacks(PIC, );
   PassBuilder PB(TM, Conf.PTO, PGOOpt, );
 
   RegisterPassPlugins(Conf.PassPlugins, PB);

diff  --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp 
b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 5b137a8f8cb34..595906a44bb44 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -245,7 +245,7 @@ static void optimizeModule(Module , TargetMachine 
,
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(TheModule.getContext(), DebugPassManager);
-  SI.registerCallbacks(PIC, );
+  SI.registerCallbacks(PIC, );
   PipelineTuningOptions PTO;
   PTO.LoopVectorization = true;
   PTO.SLPVectorization = true;

diff  --git a/llvm/lib/Passes/PassBuilderBindings.cpp 
b/llvm/lib/Passes/PassBuilderBindings.cpp
index a87c0e6dc0a37..2a49ae6e30e0a 100644
--- a/llvm/lib/Passes/PassBuilderBindings.cpp
+++ b/llvm/lib/Passes/PassBuilderBindings.cpp
@@ -66,7 +66,7 @@ LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char 
*Passes,
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
   StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach);
-  SI.registerCallbacks(PIC, );
+  SI.registerCallbacks(PIC, );
   ModulePassManager MPM;
   if (VerifyEach) {
 MPM.addPass(VerifierPass());

diff  --git 

[PATCH] D146165: docs: add some documentation on Windows SDK search

2023-03-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Looks reasonable I guess - but I think it would be good to mention the env 
variables `INCLUDE` and `LIB` too, for alternative ways of finding the same 
things - even if it's not strictly the same as what this new section talks 
about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146165

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


[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.

2023-03-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson marked an inline comment as done.
royjacobson added inline comments.



Comment at: clang/test/SemaCXX/type-traits.cpp:2886-2889
+struct UnnamedEmptyBitfield {
+  int named;
+  int : 0;
+};

shafik wrote:
> aaron.ballman wrote:
> > I think there's one more test to add:
> > ```
> > struct UnnamedEmptyBitfieldSplit {
> >   short named;
> >   int : 0;
> >   short also_named;
> > };
> > static_assert(sizeof(UnnamedEmptyBitfieldSplit) != (sizeof(short) * 2));
> > static_assert(!has_unique_object_representations::value,
> >  "Bitfield padding");
> > ```
> Do we also want to check packed structs as well?
Do you have a test case where it would matter? Apparently `packed` is specified 
to ignore zero width bit fields.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145852

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


[PATCH] D144569: [Clang][OpenMP] Fix accessing of aligned arrays in offloaded target regions

2023-03-15 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: jplehr.

Pretty sure this is what we discussed in the meeting. So it should be fine to 
remove the alignment requirement on the declaration since we don't handle it 
properly by ref either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144569

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


[PATCH] D146165: docs: add some documentation on Windows SDK search

2023-03-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: hans, rnk, mstorsjo.
Herald added a project: All.
compnerd requested review of this revision.
Herald added a project: clang.

Add some documentation on the flags and the process by which clang
identifies the headers and libraries for the Windows environment.  It
should identify the flags and their interactions as well as the order in
which the various sources of information are consulted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146165

Files:
  clang/docs/UsersManual.rst

Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -4487,3 +4487,99 @@
 to produce DLLs and EXEs. To link a DLL, pass
 ``clang_rt.asan_dll_thunk-x86_64.lib``. To link an EXE, pass
 ``-wholearchive:clang_rt.asan-x86_64.lib``.
+
+Windows System Headers and Library Lookup
+^
+
+clang-cl uses a set of different approaches to locate the right system libraries
+to link against when building code.  The Windows environment uses libraries from
+three distinct sources:
+
+1. Windows SDK
+2. UCRT (Universal C Runtime)
+3. Visual C++ Tools (VCRuntime)
+
+The Windows SDK provides the import libraries and headers required to build
+programs against the Windows system packages.  Underlying the Windows SDK is the
+UCRT, the universal C runtime.
+
+There are various controls that allow the user control over where clang-cl will
+locate these headers.  The default behaviour for the Windows SDK and UCRT is as
+follows:
+
+1. Consult the command line.
+
+Anything the user specifies is always given precedence.  The following
+extensions are part of the clang-cl toolset:
+
+- `/winsysroot:`
+
+The `/winsysroot:` is used as an equivalent to `-sysroot` on Unix
+environments.  It allows the control of an alternate location to be treated
+as a system root.  When specified, it will be used as the root where the
+`Windows Kits` is located.
+
+- `/winsdkversion:`
+- `/winsdkdir:`
+
+If `/winsysroot:` is not specified, the `/winsdkdir:` argument is consulted
+as a location to identify where the Windows SDK is located.  Contrary to
+`/winsysroot:`, `/winsdkdir:` is expected to be the complete path rather
+than a root to locate `Windows Kits`.
+
+The `/winsdkversion:` flag allows the user to specify a version identifier
+for the SDK to prefer.  When this is specified, no additional validation is
+performed and this version is preferred.  If the version is not specified,
+the highest detected version number will be used.
+
+2. Consult the environment.
+
+TODO: This is not yet implemented.
+
+This will consult the environment variables:
+- `WindowsSdkDir`
+- `UCRTVersion`
+
+3. Fallback to the registry.
+
+If no arguments are used to indicate where the SDK is present, and the
+compiler is running on Windows, the registry is consulted to locate the
+installation.
+
+The Visual C++ Toolset has a slightly more elaborate mechanism for detection.
+
+1. Consult the command line.
+
+- `/winsysroot:`
+
+The `/winsysroot:` is used as an equivalent to `-sysroot` on Unix
+environments.  It allows the control of an alternate location to be treated
+as a system root.  When specified, it will be used as the root where the
+`VC` directory is located.
+
+- `/vctoolsdir:`
+- `/vctoolsversion:`
+
+If `/winsysroot:` is not specified, the `/vctoolsdir:` argument is consulted
+as a location to identify where the Visual C++ Tools are located.  If
+`/vctoolsversion:` is specified, that version is preferred, otherwise, the
+highest version detected is used.
+
+2. Consult the environment.
+
+This will consult the environment variables:
+- `VCToolsInstallDir
+- `VCINSTALLDIR`
+- `Path`
+
+3. Consult `ISetupConfiguration` [Windows Only]
+
+Assuming that the toolchain is built with `USE_MSVC_SETUP_API` defined and
+is running on Windows, the Visual Studio COM interface `ISetupConfiguration`
+will be used to locate the installation of the MSVC toolset.
+
+4. Fallback to the registry [DEPRECATED]
+
+The registry information is used to help locate the installation as a final
+fallback.  This is only possible for pre-VS2017 installations and is
+considered deprecated.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146003: [StandardInstrumentations] Verify function doesn't change if analyses are preserved

2023-03-15 Thread Arthur Eubanks 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 rG20a7ea49f40e: [StandardInstrumentations] Verify function 
doesnt change if analyses are… (authored by aeubanks).

Changed prior to commit:
  https://reviews.llvm.org/D146003?vs=505532=505605#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146003

Files:
  llvm/include/llvm/IR/StructuralHash.h
  llvm/lib/IR/StructuralHash.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
  llvm/unittests/IR/PassManagerTest.cpp

Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -950,4 +950,37 @@
   FPM.addPass(TestSimplifyCFGWrapperPass(InnerFPM));
   FPM.run(*F, FAM);
 }
+
+#ifdef EXPENSIVE_CHECKS
+
+struct WrongFunctionPass : PassInfoMixin {
+  PreservedAnalyses run(Function , FunctionAnalysisManager ) {
+F.getEntryBlock().begin()->eraseFromParent();
+return PreservedAnalyses::all();
+  }
+  static StringRef name() { return "WrongFunctionPass"; }
+};
+
+TEST_F(PassManagerTest, FunctionAnalysisMissedInvalidation) {
+  LLVMContext Context;
+  auto M = parseIR(Context, "define void @foo() {\n"
+"  %a = add i32 0, 0\n"
+"  ret void\n"
+"}\n");
+
+  FunctionAnalysisManager FAM;
+  PassInstrumentationCallbacks PIC;
+  StandardInstrumentations SI(M->getContext(), /*DebugLogging*/ false);
+  SI.registerCallbacks(PIC, );
+  FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
+
+  FunctionPassManager FPM;
+  FPM.addPass(WrongFunctionPass());
+
+  auto *F = M->getFunction("foo");
+  EXPECT_DEATH(FPM.run(*F, FAM), "Function @foo changed by WrongFunctionPass without invalidating analyses");
+}
+
+#endif
+
 }
Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
===
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-analysis-invalidation -debug-pass-manager=verbose 2>&1 | FileCheck %s
+; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-analysis-invalidation=0 -debug-pass-manager=verbose 2>&1 | FileCheck %s
 
 
 ; Running loop-distribute will result in LoopAccessAnalysis being required and
@@ -29,7 +29,6 @@
 ;
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on test6
 ; CHECK-NEXT: Running pass: LoopDistributePass on test6
-; CHECK-NEXT: Running analysis: PreservedCFGCheckerAnalysis on test6
 ; CHECK-NEXT: Running analysis: LoopAccessAnalysis on test6
 
 
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -24,6 +24,7 @@
 #include "llvm/IR/PassInstrumentation.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/PrintPasses.h"
+#include "llvm/IR/StructuralHash.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
@@ -1049,6 +1050,23 @@
 
 AnalysisKey PreservedCFGCheckerAnalysis::Key;
 
+struct PreservedFunctionHashAnalysis
+: public AnalysisInfoMixin {
+  static AnalysisKey Key;
+
+  struct FunctionHash {
+uint64_t Hash;
+  };
+
+  using Result = FunctionHash;
+
+  Result run(Function , FunctionAnalysisManager ) {
+return Result{StructuralHash(F)};
+  }
+};
+
+AnalysisKey PreservedFunctionHashAnalysis::Key;
+
 bool PreservedCFGCheckerInstrumentation::CFG::invalidate(
 Function , const PreservedAnalyses ,
 FunctionAnalysisManager::Invalidator &) {
@@ -1063,6 +1081,7 @@
 return;
 
   FAM.registerPass([&] { return PreservedCFGCheckerAnalysis(); });
+  FAM.registerPass([&] { return PreservedFunctionHashAnalysis(); });
 
   PIC.registerBeforeNonSkippedPassCallback(
   [this, ](StringRef P, Any IR) {
@@ -1076,6 +1095,8 @@
 
 // Make sure a fresh CFG snapshot is available before the pass.
 FAM.getResult(*const_cast(*F));
+FAM.getResult(
+*const_cast(*F));
   });
 
   PIC.registerAfterPassInvalidatedCallback(
@@ -1095,9 +1116,19 @@
 #endif
 (void)this;
 
-const auto **F = any_cast();
-if (!F)
+const auto **MaybeF = any_cast();
+if (!MaybeF)
   return;
+Function  = *const_cast(*MaybeF);
+
+if 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505602.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505601.
francii added a comment.

Don't claim when checking for object file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,7 +164,7 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
   // Enable gprofiling when "-pg" is specified.
   if (A->getOption().matches(options::OPT_pg))
 return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,7 +164,7 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
   // Enable gprofiling when "-pg" is specified.
   if (A->getOption().matches(options::OPT_pg))
 return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146069: [StandardInstrumentations] Rename -verify-cfg-preserved -> -verify-analysis-invalidation

2023-03-15 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG361cba22b201: [StandardInstrumentations] Rename 
-verify-cfg-preserved - -verify-analysis… (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146069

Files:
  clang/test/CodeGen/lto-newpm-pipeline.c
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll

Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
===
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-cfg-preserved -debug-pass-manager=verbose 2>&1 | FileCheck %s
+; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-analysis-invalidation -debug-pass-manager=verbose 2>&1 | FileCheck %s
 
 
 ; Running loop-distribute will result in LoopAccessAnalysis being required and
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -1,5 +1,5 @@
-;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
-;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
+;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-analysis-invalidation=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
+;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-analysis-invalidation=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
 ;REQUIRES: asserts
 
 ; This test is to make sure we invalidate the post dominator pass after loop rotate simplifies the loop latch.
Index: llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
===
--- llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
+++ llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
@@ -1,4 +1,4 @@
-; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-cfg-preserved=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
+; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-analysis-invalidation=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
 
 ; Check that constraint-elimination properly invalidates anlyses.
 
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -1,26 +1,26 @@
 ; Validate ThinLTO prelink pipeline when we have Sample PGO
 ;
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-analysis-invalidation=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-analysis-invalidation=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s 

[clang] 361cba2 - [StandardInstrumentations] Rename -verify-cfg-preserved -> -verify-analysis-invalidation

2023-03-15 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-03-15T13:07:55-07:00
New Revision: 361cba22b2013f66e5b18896ffcf2564b332ab7b

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

LOG: [StandardInstrumentations] Rename -verify-cfg-preserved -> 
-verify-analysis-invalidation

In preparation for adding more checks under this flag.

Reviewed By: nikic

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

Added: 


Modified: 
clang/test/CodeGen/lto-newpm-pipeline.c
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Other/loop-pm-invalidation.ll
llvm/test/Other/new-pass-manager.ll
llvm/test/Other/new-pm-O0-defaults.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
llvm/test/Transforms/LoopRotate/pr35210.ll

llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll

Removed: 




diff  --git a/clang/test/CodeGen/lto-newpm-pipeline.c 
b/clang/test/CodeGen/lto-newpm-pipeline.c
index dfeb7bc96411d..1aaa7d46f3ff0 100644
--- a/clang/test/CodeGen/lto-newpm-pipeline.c
+++ b/clang/test/CodeGen/lto-newpm-pipeline.c
@@ -1,28 +1,28 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=full -O0 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=full -O0 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-FULL-O0
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=thin -O0 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=thin -O0 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-THIN-O0
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=full -O1 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=full -O1 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=thin -O1 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=thin -O1 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=full -O2 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=full -O2 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=thin -O2 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=thin -O2 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=full -O3 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=full -O3 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-FULL-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-cfg-preserved=0 -fdebug-pass-manager -flto=thin -O3 %s 2>&1 | 
FileCheck %s \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=thin -O3 %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu 

[PATCH] D146164: Fix nomerge attribute not working with __builtin_trap().

2023-03-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: hans, craig.topper.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

1. It fixes the problem that `llvm.trap()` not getting the nomerge attribute.
2. It sets nomerge flag for the node if the instruction has nomerge arrtibute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146164

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/X86/nomerge.ll

Index: llvm/test/CodeGen/X86/nomerge.ll
===
--- llvm/test/CodeGen/X86/nomerge.ll
+++ llvm/test/CodeGen/X86/nomerge.ll
@@ -22,6 +22,28 @@
 
 declare dso_local void @bar()
 
+define void @nomerge_trap(i32 %i) {
+entry:
+  switch i32 %i, label %if.end3 [
+i32 5, label %if.then
+i32 7, label %if.then2
+  ]
+
+if.then:
+  tail call void @llvm.trap() #0
+  br label %if.end3
+
+if.then2:
+  tail call void @llvm.trap() #0
+  br label %if.end3
+
+if.end3:
+  tail call void @llvm.trap() #0
+  ret void
+}
+
+declare dso_local void @llvm.trap()
+
 attributes #0 = { nomerge }
 
 ; CHECK-LABEL: foo:
@@ -34,3 +56,16 @@
 ; CHECK: callq bar
 ; CHECK: .LBB0_4: # %if.end3
 ; CHECK: jmp bar # TAILCALL
+
+; CHECK-LABEL: nomerge_trap:
+; CHECK:  # %bb.0: # %entry
+; CHECK:  # %bb.1: # %entry
+; CHECK:  # %bb.2: # %if.then
+; CHECK-NEXT: ud2
+; CHECK-NEXT: ud2
+; CHECK-NEXT: retq
+; CHECK-NEXT: .LBB1_3: # %if.then2
+; CHECK-NEXT: ud2
+; CHECK-NEXT: .LBB1_4: # %if.end3
+; CHECK-NEXT: ud2
+; CHECK-NEXT: retq
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6833,22 +6833,25 @@
 StringRef TrapFuncName =
 I.getAttributes().getFnAttr("trap-func-name").getValueAsString();
 if (TrapFuncName.empty()) {
+  SDValue Node;
   switch (Intrinsic) {
   case Intrinsic::trap:
-DAG.setRoot(DAG.getNode(ISD::TRAP, sdl, MVT::Other, getRoot()));
+Node = DAG.getNode(ISD::TRAP, sdl, MVT::Other, getRoot());
 break;
   case Intrinsic::debugtrap:
-DAG.setRoot(DAG.getNode(ISD::DEBUGTRAP, sdl, MVT::Other, getRoot()));
+Node = DAG.getNode(ISD::DEBUGTRAP, sdl, MVT::Other, getRoot());
 break;
   case Intrinsic::ubsantrap:
-DAG.setRoot(DAG.getNode(
+Node = DAG.getNode(
 ISD::UBSANTRAP, sdl, MVT::Other, getRoot(),
 DAG.getTargetConstant(
 cast(I.getArgOperand(0))->getZExtValue(), sdl,
-MVT::i32)));
+MVT::i32));
 break;
   default: llvm_unreachable("unknown trap intrinsic");
   }
+  DAG.addNoMergeSiteInfo(Node.getNode(), I.hasFnAttr(Attribute::NoMerge));
+  DAG.setRoot(Node);
   return;
 }
 TargetLowering::ArgListTy Args;
Index: clang/test/CodeGen/attr-nomerge.cpp
===
--- clang/test/CodeGen/attr-nomerge.cpp
+++ clang/test/CodeGen/attr-nomerge.cpp
@@ -40,6 +40,8 @@
 
   A *newA = new B();
   delete newA;
+
+  [[clang::nomerge]] __builtin_trap();
 }
 
 int g(int i);
@@ -93,6 +95,7 @@
 // CHECK: load ptr, ptr
 // CHECK: %[[AG:.*]] = load ptr, ptr
 // CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR1]]
+// CHECK: call void @llvm.trap() #[[ATTR0]]
 // CHECK: call void  @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]
 
 // CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3623,7 +3623,8 @@
   CGM.getCodeGenOpts().TrapFuncName);
 TrapCall->addFnAttr(A);
   }
-
+  if (InNoMergeAttributedStmt)
+TrapCall->addFnAttr(llvm::Attribute::NoMerge);
   return TrapCall;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 505596.
craig.topper added a comment.

Fix the same bug for noinline attribute


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

Files:
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-alwaysinline.cpp
  clang/test/Sema/attr-noinline.cpp


Index: clang/test/Sema/attr-noinline.cpp
===
--- clang/test/Sema/attr-noinline.cpp
+++ clang/test/Sema/attr-noinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' 
attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::noinline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/test/Sema/attr-alwaysinline.cpp
===
--- clang/test/Sema/attr-alwaysinline.cpp
+++ clang/test/Sema/attr-alwaysinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::always_inline]] static int i = bar(); // expected-warning 
{{'always_inline' attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -233,7 +233,8 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl &&
+(Decl->hasAttr() || Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 0 : 1);
   }
@@ -259,7 +260,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || 
Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }


Index: clang/test/Sema/attr-noinline.cpp
===
--- clang/test/Sema/attr-noinline.cpp
+++ clang/test/Sema/attr-noinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::noinline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/test/Sema/attr-alwaysinline.cpp
===
--- clang/test/Sema/attr-alwaysinline.cpp
+++ clang/test/Sema/attr-alwaysinline.cpp
@@ -25,3 +25,13 @@
 }
 
 [[clang::always_inline]] static int i = bar(); // expected-warning {{'always_inline' attribute only applies to functions and statements}}
+
+// This used to crash the compiler.
+template
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);
+else
+return x;
+}
+
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -233,7 +233,8 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl &&
+(Decl->hasAttr() || Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 0 : 1);
   }
@@ -259,7 +260,7 @@
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
 const Decl *Decl = CallExpr->getCalleeDecl();
-if (Decl->hasAttr() || Decl->hasAttr())
+if (Decl && (Decl->hasAttr() || Decl->hasAttr()))
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
   << A << (Decl->hasAttr() ? 2 : 1);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

erichkeane wrote:
> erichkeane wrote:
> > craig.topper wrote:
> > > erichkeane wrote:
> > > > craig.topper wrote:
> > > > > erichkeane wrote:
> > > > > > Can you add a test that shows that we warn on instantiation?  This 
> > > > > > shouldn't be a dependent declrefexpr when instantiated.
> > > > > > 
> > > > > > Additionally, this would make sure that we're properly propoagating 
> > > > > > `always_inline`.
> > > > > Should this warn
> > > > > 
> > > > > ```
> > > > > template [[gnu::noinline]] 
> > > > >
> > > > > int bar(int x) {  
> > > > >
> > > > > if constexpr (D > 1)  
> > > > >
> > > > > [[clang::always_inline]] return bar(x + 1);  
> > > > >
> > > > > else  
> > > > >
> > > > > return x; 
> > > > >
> > > > > } 
> > > > >
> > > > >   
> > > > >
> > > > > int baz(int x) {  
> > > > >
> > > > >   return bar<5>(x);   
> > > > >
> > > > > }  
> > > > > ```
> > > > Yes, I would expect that to warn.
> > > It looks like handleAlwaysInlineAttr only gets called once so it doesn't 
> > > get called after instantiation.
> > Hmm... thats unfortunate.  That means we're perhaps not instantiating it 
> > correctly.  I'll take some time to poke around as I get a chacne.
> Ok, it looks like SemaStmt.cpp's `BuildAttributedStmt` needs to handle the 
> attributes.  We should some day do that automatically for a majority o f 
> attributes, but for now, just adding the call there is sufficient.
What I do need to add?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > craig.topper wrote:
> > > > erichkeane wrote:
> > > > > Can you add a test that shows that we warn on instantiation?  This 
> > > > > shouldn't be a dependent declrefexpr when instantiated.
> > > > > 
> > > > > Additionally, this would make sure that we're properly propoagating 
> > > > > `always_inline`.
> > > > Should this warn
> > > > 
> > > > ```
> > > > template [[gnu::noinline]]   
> > > >  
> > > > int bar(int x) {
> > > >  
> > > > if constexpr (D > 1)
> > > >  
> > > > [[clang::always_inline]] return bar(x + 1);
> > > >  
> > > > else
> > > >  
> > > > return x;   
> > > >  
> > > > }   
> > > >  
> > > > 
> > > >  
> > > > int baz(int x) {
> > > >  
> > > >   return bar<5>(x); 
> > > >  
> > > > }  
> > > > ```
> > > Yes, I would expect that to warn.
> > It looks like handleAlwaysInlineAttr only gets called once so it doesn't 
> > get called after instantiation.
> Hmm... thats unfortunate.  That means we're perhaps not instantiating it 
> correctly.  I'll take some time to poke around as I get a chacne.
Ok, it looks like SemaStmt.cpp's `BuildAttributedStmt` needs to handle the 
attributes.  We should some day do that automatically for a majority o f 
attributes, but for now, just adding the call there is sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:32
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);

erichkeane wrote:
> Also, I note the 'if constexpr' branch is unnecessary to reproduce this.
Yes, but I didn't bother to figure out what happened if the template 
recursivley instantiated without bound.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D146069: [StandardInstrumentations] Rename -verify-cfg-preserved -> -verify-analysis-invalidation

2023-03-15 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146069

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:236
 const Decl *Decl = CallExpr->getCalleeDecl();
 if (Decl->hasAttr() || Decl->hasAttr())
   S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)

Same fix + a test probably needed here too.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:32
+int foo(int x) {
+if constexpr (D > 1)
+[[clang::always_inline]] return foo(x + 1);

Also, I note the 'if constexpr' branch is unnecessary to reproduce this.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

craig.topper wrote:
> erichkeane wrote:
> > craig.topper wrote:
> > > erichkeane wrote:
> > > > Can you add a test that shows that we warn on instantiation?  This 
> > > > shouldn't be a dependent declrefexpr when instantiated.
> > > > 
> > > > Additionally, this would make sure that we're properly propoagating 
> > > > `always_inline`.
> > > Should this warn
> > > 
> > > ```
> > > template [[gnu::noinline]] 
> > >
> > > int bar(int x) {  
> > >
> > > if constexpr (D > 1)  
> > >
> > > [[clang::always_inline]] return bar(x + 1);  
> > >
> > > else  
> > >
> > > return x; 
> > >
> > > } 
> > >
> > >   
> > >
> > > int baz(int x) {  
> > >
> > >   return bar<5>(x);   
> > >
> > > }  
> > > ```
> > Yes, I would expect that to warn.
> It looks like handleAlwaysInlineAttr only gets called once so it doesn't get 
> called after instantiation.
Hmm... thats unfortunate.  That means we're perhaps not instantiating it 
correctly.  I'll take some time to poke around as I get a chacne.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145641: [Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions

2023-03-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 505588.
bruno marked 2 inline comments as done.
bruno added a comment.

Update after reviewer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145641

Files:
  clang/include/clang/AST/StmtCXX.h
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/coroutine-no-move-ctor.cpp

Index: clang/test/SemaCXX/coroutine-no-move-ctor.cpp
===
--- clang/test/SemaCXX/coroutine-no-move-ctor.cpp
+++ clang/test/SemaCXX/coroutine-no-move-ctor.cpp
@@ -15,13 +15,10 @@
   };
   using promise_type = invoker_promise;
   invoker() {}
-  // TODO: implement RVO for get_return_object type matching
-  // function return type.
-  //
-  // invoker(const invoker &) = delete;
-  // invoker =(const invoker &) = delete;
-  // invoker(invoker &&) = delete;
-  // invoker =(invoker &&) = delete;
+  invoker(const invoker &) = delete;
+  invoker =(const invoker &) = delete;
+  invoker(invoker &&) = delete;
+  invoker =(invoker &&) = delete;
 };
 
 invoker f() {
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -8066,11 +8066,12 @@
   return StmtError();
 Builder.Deallocate = DeallocRes.get();
 
-assert(S->getResultDecl() && "ResultDecl must already be built");
-StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
-if (ResultDecl.isInvalid())
-  return StmtError();
-Builder.ResultDecl = ResultDecl.get();
+if (auto *ResultDecl = S->getResultDecl()) {
+  StmtResult Res = getDerived().TransformStmt(ResultDecl);
+  if (Res.isInvalid())
+return StmtError();
+  Builder.ResultDecl = Res.get();
+}
 
 if (auto *ReturnStmt = S->getReturnStmt()) {
   StmtResult Res = getDerived().TransformStmt(ReturnStmt);
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1730,13 +1730,22 @@
   assert(!FnRetType->isDependentType() &&
  "get_return_object type must no longer be dependent");
 
+  // The call to get_­return_­object is sequenced before the call to
+  // initial_­suspend and is invoked at most once, but there are caveats
+  // regarding on whether the prvalue result object may be initialized
+  // directly/eager or delayed, depending on the types involved.
+  //
+  // More info at https://github.com/cplusplus/papers/issues/1414
+  bool GroMatchesRetType = S.getASTContext().hasSameType(GroType, FnRetType);
+
   if (FnRetType->isVoidType()) {
 ExprResult Res =
 S.ActOnFinishFullExpr(this->ReturnValue, Loc, /*DiscardedValue*/ false);
 if (Res.isInvalid())
   return false;
 
-this->ResultDecl = Res.get();
+if (!GroMatchesRetType)
+  this->ResultDecl = Res.get();
 return true;
   }
 
@@ -1749,53 +1758,59 @@
 return false;
   }
 
-  // StmtResult ReturnStmt = S.BuildReturnStmt(Loc, ReturnValue);
-  auto *GroDecl = VarDecl::Create(
-  S.Context, , FD.getLocation(), FD.getLocation(),
-  ().get("__coro_gro"), GroType,
-  S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
-  GroDecl->setImplicit();
-
-  S.CheckVariableDeclarationType(GroDecl);
-  if (GroDecl->isInvalidDecl())
-return false;
+  StmtResult ReturnStmt;
+  clang::VarDecl *GroDecl = nullptr;
+  if (GroMatchesRetType) {
+ReturnStmt = S.BuildReturnStmt(Loc, ReturnValue);
+  } else {
+GroDecl = VarDecl::Create(
+S.Context, , FD.getLocation(), FD.getLocation(),
+().get("__coro_gro"), GroType,
+S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
+GroDecl->setImplicit();
+
+S.CheckVariableDeclarationType(GroDecl);
+if (GroDecl->isInvalidDecl())
+  return false;
 
-  InitializedEntity Entity = InitializedEntity::InitializeVariable(GroDecl);
-  ExprResult Res =
-  S.PerformCopyInitialization(Entity, SourceLocation(), ReturnValue);
-  if (Res.isInvalid())
-return false;
+InitializedEntity Entity = InitializedEntity::InitializeVariable(GroDecl);
+ExprResult Res =
+S.PerformCopyInitialization(Entity, SourceLocation(), ReturnValue);
+if (Res.isInvalid())
+  return false;
 
-  Res = S.ActOnFinishFullExpr(Res.get(), /*DiscardedValue*/ false);
-  if (Res.isInvalid())
-return false;
+Res = S.ActOnFinishFullExpr(Res.get(), /*DiscardedValue*/ false);
+if (Res.isInvalid())
+  return false;
 
-  S.AddInitializerToDecl(GroDecl, Res.get(),
- /*DirectInit=*/false);
+S.AddInitializerToDecl(GroDecl, Res.get(),
+   /*DirectInit=*/false);
 
-  S.FinalizeDeclaration(GroDecl);
+

[PATCH] D145641: [Coroutines] Implement fix for cwg2563 issue and enable RVO under certain conditions

2023-03-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno marked 3 inline comments as done.
bruno added inline comments.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:483-499
+// The call to get_­return_­object is sequenced before the call to
+// initial_­suspend and is invoked at most once, but there are caveats
+// regarding on whether the prvalue result object may be initialized
+// directly/eager or delayed, depending on the types involved.
+//
+// The general cases:
+// 1. Same type of get_return_object and coroutine return type (direct

ChuanqiXu wrote:
> I'll feel better if we can attach the conclusion and links from the wg21.
I can add some of that but unfortunately we don't have the working yet, it 
still has a CWG round to go: https://github.com/cplusplus/papers/issues/1414

The best explanation for the problem is under Gor's writeup: 
https://github.com/GorNishanov/await/blob/master/2023_Issaquah/cwg2563-response.md,
 I instead added a comment based on it since we cannot guarantee this link will 
be there forever.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:500-508
+DirectEmit = [&]() {
+  auto *RVI = S.getReturnValueInit();
+  if (!RVI || CGF.FnRetTy->isVoidType())
+return true;
+  auto GroType = RVI->getType();
+  if (GroType->isVoidType())
+return true;

ChuanqiXu wrote:
> What's the case about returning void and the return_object type is different 
> from the returning type?
In that case we do `DirectEmit` since there's no reason to delay 
initialization, am I missing something?



Comment at: clang/test/SemaCXX/coroutine-no-move-ctor.cpp:24-26
 invoker f() {
   co_return;
 }

ChuanqiXu wrote:
> How about adding a failing case that the types are not matched?
I'm having trouble crafting one. I extracted similar examples from other 
testcases and even though I can confirm they correctly apply delayed 
initialization, they don't require copies (usually directly call conversion 
operators or similar) and we don't trigger the reverse usecase, do you have one 
testcase in mind I could use?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145641

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

erichkeane wrote:
> craig.topper wrote:
> > erichkeane wrote:
> > > Can you add a test that shows that we warn on instantiation?  This 
> > > shouldn't be a dependent declrefexpr when instantiated.
> > > 
> > > Additionally, this would make sure that we're properly propoagating 
> > > `always_inline`.
> > Should this warn
> > 
> > ```
> > template [[gnu::noinline]]   
> >  
> > int bar(int x) {
> >  
> > if constexpr (D > 1)
> >  
> > [[clang::always_inline]] return bar(x + 1);
> >  
> > else
> >  
> > return x;   
> >  
> > }   
> >  
> > 
> >  
> > int baz(int x) {
> >  
> >   return bar<5>(x); 
> >  
> > }  
> > ```
> Yes, I would expect that to warn.
It looks like handleAlwaysInlineAttr only gets called once so it doesn't get 
called after instantiation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145970: [MSVC][PS][dllexport/dllimport] Propagate a dllexport/dllimport attribute to template baseclasses

2023-03-15 Thread Wolfgang Pieb 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 rG634430d5857e: [MSVC][dllexport/dllimport] Propagate a 
dllexport/dllimport attribute to… (authored by wolfgangp).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145970

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/SemaCXX/dllexport.cpp
  clang/test/SemaCXX/dllimport.cpp

Index: clang/test/SemaCXX/dllimport.cpp
===
--- clang/test/SemaCXX/dllimport.cpp
+++ clang/test/SemaCXX/dllimport.cpp
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
-// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
-// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI -DPS %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI -DPS %s
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI -DPS %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -1557,7 +1557,7 @@
 class __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate {};
 
 template  struct ExplicitlySpecializedTemplate { void func() {} };
-#ifdef MS
+#if defined(MS) || defined(PS)
 // expected-note@+2{{class template 'ExplicitlySpecializedTemplate' was explicitly specialized here}}
 #endif
 template <> struct ExplicitlySpecializedTemplate { void func() {} };
@@ -1567,7 +1567,7 @@
 template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate { void func() {} };
 
 template  struct ExplicitlyInstantiatedTemplate { void func() {} };
-#ifdef MS
+#if defined(MS) || defined(PS)
 // expected-note@+2{{class template 'ExplicitlyInstantiatedTemplate' was instantiated here}}
 #endif
 template struct ExplicitlyInstantiatedTemplate;
@@ -1576,7 +1576,7 @@
 template  struct ExplicitlyImportInstantiatedTemplate { void func() {} };
 template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate;
 
-#ifdef MS
+#if defined(MS) || defined(PS)
 // expected-warning@+3{{propagating dll attribute to explicitly specialized base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
@@ -1588,7 +1588,7 @@
 // Base class already specialized with import attribute.
 struct __declspec(dllimport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate {};
 
-#ifdef MS
+#if defined(MS) || defined(PS)
 // expected-warning@+3{{propagating dll attribute to already instantiated base class template without dll attribute is not supported}}
 // expected-note@+2{{attribute is here}}
 #endif
Index: clang/test/SemaCXX/dllexport.cpp
===
--- clang/test/SemaCXX/dllexport.cpp
+++ clang/test/SemaCXX/dllexport.cpp
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DGNU %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI  %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++1y -Wunsupported-dll-base-class-template -DWI  %s
-// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI  %s
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec  -verify -std=c++1y -Wunsupported-dll-base-class-template -DWI  %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI -DPS %s
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 

[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

2023-03-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D141451#4179674 , @nickdesaulniers 
wrote:

> Will work on that RFC though!

RFC (PTAL): 
https://discourse.llvm.org/t/rfc-improving-clangs-middle-and-back-end-diagnostics/69261


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141451

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


[clang] 634430d - [MSVC][dllexport/dllimport] Propagate a dllexport/dllimport attribute to template baseclass

2023-03-15 Thread Wolfgang Pieb via cfe-commits

Author: Wolfgang Pieb
Date: 2023-03-15T11:47:54-07:00
New Revision: 634430d5857e395cff62534b11c460f51c6c846a

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

LOG: [MSVC][dllexport/dllimport] Propagate a dllexport/dllimport attribute to 
template baseclass

For the Playstation platform, mimick MSVC in propagating dllexport/dllimport 
attributes
to an instantiated template base class.

Reviewed By: hans

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenCXX/dllexport.cpp
clang/test/CodeGenCXX/dllimport.cpp
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 21c02b7ba4aa1..41c76e5c13715 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2608,7 +2608,8 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
   }
 
   // For the MS ABI, propagate DLL attributes to base class templates.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() ||
+  Context.getTargetInfo().getTriple().isPS()) {
 if (Attr *ClassAttr = getDLLAttr(Class)) {
   if (auto *BaseTemplate = 
dyn_cast_or_null(
   BaseType->getAsCXXRecordDecl())) {

diff  --git a/clang/test/CodeGenCXX/dllexport.cpp 
b/clang/test/CodeGenCXX/dllexport.cpp
index b4e42ed7abab2..c8ac526f4cbe3 100644
--- a/clang/test/CodeGenCXX/dllexport.cpp
+++ b/clang/test/CodeGenCXX/dllexport.cpp
@@ -6,6 +6,8 @@
 
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu
-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | 
FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-gnu  
-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | 
FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-scei-ps4  
-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | 
FileCheck -allow-deprecated-dag-overlap --check-prefix=PS %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-sie-ps5  
-emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | 
FileCheck -allow-deprecated-dag-overlap --check-prefix=PS %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Exported {};
@@ -980,18 +982,21 @@ struct __declspec(dllexport) DerivedFromTemplate : public 
ClassTemplate {};
 USEMEMFUNC(DerivedFromTemplate, func)
 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void 
@"?func@?$ClassTemplate@H@@QAEXXZ"
 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void 
@_ZN13ClassTemplateIiE4funcEv
+// PS-DAG:  define weak_odr dllexport void @_ZN13ClassTemplateIiE4funcEv
 
 // ExportedTemplate is explicitly exported.
 struct __declspec(dllexport) DerivedFromExportedTemplate : public 
ExportedClassTemplate {};
 USEMEMFUNC(DerivedFromExportedTemplate, func)
 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void 
@"?func@?$ExportedClassTemplate@H@@QAEXXZ"
 // G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void 
@_ZN21ExportedClassTemplateIiE4funcEv
+// PS-DAG:  define weak_odr dllexport void 
@_ZN21ExportedClassTemplateIiE4funcEv
 
 // ImportedClassTemplate is explicitly imported.
 struct __declspec(dllexport) DerivedFromImportedTemplate : public 
ImportedClassTemplate {};
 USEMEMFUNC(DerivedFromImportedTemplate, func)
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc 
void @"?func@?$ImportedClassTemplate@H@@QAEXXZ"
 // G32-DAG: declare dllimport x86_thiscallcc void 
@_ZN21ImportedClassTemplateIiE4funcEv
+// PS-DAG:  declare dllimport void @_ZN21ImportedClassTemplateIiE4funcEv
 
 // Base class already implicitly instantiated without dll attribute.
 struct DerivedFromTemplateD : public ClassTemplate {};
@@ -999,6 +1004,7 @@ struct __declspec(dllexport) DerivedFromTemplateD2 : 
public ClassTemplate 
{};
@@ -1006,42 +1012,49 @@ struct __declspec(dllexport) DerivedFromTemplateB2 : 
public ClassTemplate
 USEMEMFUNC(DerivedFromTemplateB2, func)
 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc 
void @"?func@?$ClassTemplate@_N@@QAEXXZ"
 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void 
@_ZN13ClassTemplateIbE4funcEv
+// PS-DAG:  declare dllimport void @_ZN13ClassTemplateIbE4funcEv
 
 // Base class already specialized without dll attribute.
 struct __declspec(dllexport) DerivedFromExplicitlySpecializedTemplate : public 
ExplicitlySpecializedTemplate 

[PATCH] D145074: [clang][RISCV] Fix ABI lowering for _Float16 for FP ABIs

2023-03-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/test/CodeGen/RISCV/riscv64-abi.c:1909
- NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
-// LP64F: {{.*}}

kito-cheng wrote:
> This seems removed accidentally, I saw 
> `clang/test/CodeGen/RISCV/riscv32-abi.c` still keep.
update_cc_test_checks.py is actually correct to remove this. `void 
f_struct_float16_int8_insufficient_fprs` happens to have different output for 
lp64f vs lp64d (it has floats and doubles in its arguments).


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

https://reviews.llvm.org/D145074

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


[PATCH] D136515: [builtins] Add __builtin_assume_separate_storage.

2023-03-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2393
+particular object (so for example, it's never correct to call this function
+passing the addresses of fields in the same struct, elements of the same array,
+etc.).

Not necessarily a blocker, but it seems like some of these things you mention 
can actually be caught by diagnostics without too much effort? Any plans to add 
them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

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


[PATCH] D145074: [clang][RISCV] Fix ABI lowering for _Float16 for FP ABIs

2023-03-15 Thread Alex Bradbury via Phabricator via cfe-commits
asb updated this revision to Diff 505575.
asb added a comment.
Herald added a subscriber: jobnoorman.

Rebase.


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

https://reviews.llvm.org/D145074

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/RISCV/riscv32-abi.c
  clang/test/CodeGen/RISCV/riscv64-abi.c

Index: clang/test/CodeGen/RISCV/riscv64-abi.c
===
--- clang/test/CodeGen/RISCV/riscv64-abi.c
+++ clang/test/CodeGen/RISCV/riscv64-abi.c
@@ -1492,24 +1492,29 @@
 // separate arguments in IR. They are passed by the same rules for returns,
 // but will be lowered to simple two-element structs if necessary (as LLVM IR
 // functions cannot return multiple values).
-// FIXME: Essentially all test cases below involving _Float16 in structs
-// aren't lowered according to the rules in the FP calling convention (i.e.
-// are incorrect for lp64f/lp64d).
 
 struct float16_s { _Float16 f; };
 
 // A struct containing just one floating-point real is passed as though it
 // were a standalone floating-point real.
 
-// LP64-LP64F-LP64D-LABEL: define dso_local void @f_float16_s_arg
-// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local void @f_float16_s_arg
+// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local void @f_float16_s_arg
+// LP64F-LP64D-SAME: (half [[TMP0:%.*]]) #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 void f_float16_s_arg(struct float16_s a) {}
 
-// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_float16_s
-// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local i64 @f_ret_float16_s
+// LP64-SAME: () #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local half @f_ret_float16_s
+// LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 struct float16_s f_ret_float16_s(void) {
   return (struct float16_s){1.0};
@@ -1521,29 +1526,45 @@
 struct zbf_float16_s { int : 0; _Float16 f; };
 struct zbf_float16_zbf_s { int : 0; _Float16 f; int : 0; };
 
-// LP64-LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_s_arg
-// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local void @f_zbf_float16_s_arg
+// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_s_arg
+// LP64F-LP64D-SAME: (half [[TMP0:%.*]]) #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 void f_zbf_float16_s_arg(struct zbf_float16_s a) {}
 
-// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_zbf_float16_s
-// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local i64 @f_ret_zbf_float16_s
+// LP64-SAME: () #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local half @f_ret_zbf_float16_s
+// LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 struct zbf_float16_s f_ret_zbf_float16_s(void) {
   return (struct zbf_float16_s){1.0};
 }
 
-// LP64-LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_zbf_s_arg
-// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local void @f_zbf_float16_zbf_s_arg
+// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_zbf_s_arg
+// LP64F-LP64D-SAME: (half [[TMP0:%.*]]) #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 void f_zbf_float16_zbf_s_arg(struct zbf_float16_zbf_s a) {}
 
-// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_zbf_float16_zbf_s
-// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LABEL: define dso_local i64 @f_ret_zbf_float16_zbf_s
+// LP64-SAME: () #[[ATTR0]] {
+// LP64:  entry:
+//
+// LP64F-LP64D-LABEL: define dso_local half @f_ret_zbf_float16_zbf_s
+// LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64F-LP64D:  entry:
 //
 struct zbf_float16_zbf_s f_ret_zbf_float16_zbf_s(void) {
   return (struct zbf_float16_zbf_s){1.0};
@@ -1554,15 +1575,23 @@
 
 struct double_float16_s { double f; _Float16 g; };
 
-// LP64-LP64F-LP64D-LABEL: define dso_local void @f_double_float16_s_arg
-// LP64-LP64F-LP64D-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// LP64-LP64F-LABEL: define dso_local void @f_double_float16_s_arg
+// LP64-LP64F-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64-LP64F:  entry:
+//
+// LP64D-LABEL: define dso_local void @f_double_float16_s_arg
+// LP64D-SAME: (double [[TMP0:%.*]], half [[TMP1:%.*]]) #[[ATTR0]] {
+// LP64D:  entry:
 //
 void f_double_float16_s_arg(struct double_float16_s a) {}
 
-// LP64-LP64F-LP64D-LABEL: define dso_local [2 x i64] @f_ret_double_float16_s
-// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
-// LP64-LP64F-LP64D:  entry:
+// 

[PATCH] D146156: [clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

2023-03-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Good catch, thanks! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146156

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


[PATCH] D146156: [clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

2023-03-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Is there a way to test this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146156

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

> ! In D143967#4197142 , @jemarch 
> wrote:
>  ...
>  In GCC we also translate from the internal DWARF structures into BTF.
>  So, for us, it would also imply to reoder (before generating the BTF
>  from the interal DWARF) in case we wanted to use a different approach in
>  DWARF than in BTF.

It's not only the BTF generated for BPF programs. There are two ways
to obtain BTF that we should worry about:

1. BTF generated for BPF programs by compiler;
2. BTF generated during kernel build for the whole kernel, this one is 
generated by `pahole` from DWARF.

> I think the question is: what are the consequences of having the
> annotation DIE as a child of the qualifiers instead of the qualified
> type?

Are there any? I just tried the following code with GDB:

  volatile int __attribute__((btf_type_tag("__a"))) a = 1;
  
  void foo(void) {
a = 2;
  }
  
  int main(int argc, char **argv) {
foo();
return 0;
  }

No warnings, `a` can be inspected.

I think there are two sides to this:

- conceptual: is it ok to allow annotations for CVR modifiers?
- technical: what is the point where such reordering is easiest to implement? 
For LLVM / pahole stack the path of least resistance is to modify DWARF 
generation (but again @dblaikie might disagree). How hard is it to adjust DI 
generation in GCC in this way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

craig.topper wrote:
> erichkeane wrote:
> > Can you add a test that shows that we warn on instantiation?  This 
> > shouldn't be a dependent declrefexpr when instantiated.
> > 
> > Additionally, this would make sure that we're properly propoagating 
> > `always_inline`.
> Should this warn
> 
> ```
> template [[gnu::noinline]] 
>
> int bar(int x) {  
>
> if constexpr (D > 1)  
>
> [[clang::always_inline]] return bar(x + 1);  
>
> else  
>
> return x; 
>
> } 
>
>   
>
> int baz(int x) {  
>
>   return bar<5>(x);   
>
> }  
> ```
Yes, I would expect that to warn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145070: [clang][RISCV][test] Add test coverage for _Float16 ABI lowering

2023-03-15 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7e13d6f1b49: [clang][RISCV][test] Add test coverage for 
_Float16 ABI lowering (authored by asb).
Herald added a subscriber: jobnoorman.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145070

Files:
  clang/test/CodeGen/RISCV/riscv32-abi.c
  clang/test/CodeGen/RISCV/riscv64-abi.c

Index: clang/test/CodeGen/RISCV/riscv64-abi.c
===
--- clang/test/CodeGen/RISCV/riscv64-abi.c
+++ clang/test/CodeGen/RISCV/riscv64-abi.c
@@ -66,6 +66,12 @@
 //
 long double f_fp_scalar_3(long double x) { return x; }
 
+// LP64-LP64F-LP64D-LABEL: define dso_local half @f_fp_scalar_4
+// LP64-LP64F-LP64D-SAME: (half noundef [[X:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+_Float16 f_fp_scalar_4(_Float16 x) { return x; }
+
 // Empty structs or unions are ignored.
 
 struct empty_s {};
@@ -322,11 +328,11 @@
 }
 
 // LP64-LP64F-LP64D-LABEL: define dso_local signext i32 @f_scalar_stack_6
-// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], float noundef [[C:%.*]], fp128 noundef [[D:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D-SAME: (i32 noundef signext [[A:%.*]], i128 noundef [[B:%.*]], float noundef [[C:%.*]], fp128 noundef [[D:%.*]], ptr noundef [[TMP0:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]], half noundef [[I:%.*]]) #[[ATTR0]] {
 // LP64-LP64F-LP64D:  entry:
 //
 int f_scalar_stack_6(int32_t a, __int128_t b, float c, long double d, v32i8 e,
- uint8_t f, int8_t g, uint8_t h) {
+ uint8_t f, int8_t g, uint8_t h, _Float16 i) {
   return g + h;
 }
 
@@ -1479,5 +1485,425 @@
 union double_u f_ret_double_u(void) {
   return (union double_u){1.0};
 }
+
+// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
+// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
+// available the widths are <= XLEN and FLEN, and should be expanded to
+// separate arguments in IR. They are passed by the same rules for returns,
+// but will be lowered to simple two-element structs if necessary (as LLVM IR
+// functions cannot return multiple values).
+// FIXME: Essentially all test cases below involving _Float16 in structs
+// aren't lowered according to the rules in the FP calling convention (i.e.
+// are incorrect for lp64f/lp64d).
+
+struct float16_s { _Float16 f; };
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+
+// LP64-LP64F-LP64D-LABEL: define dso_local void @f_float16_s_arg
+// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+void f_float16_s_arg(struct float16_s a) {}
+
+// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_float16_s
+// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+struct float16_s f_ret_float16_s(void) {
+  return (struct float16_s){1.0};
+}
+
+// A struct containing a double and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_float16_s { int : 0; _Float16 f; };
+struct zbf_float16_zbf_s { int : 0; _Float16 f; int : 0; };
+
+// LP64-LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_s_arg
+// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+void f_zbf_float16_s_arg(struct zbf_float16_s a) {}
+
+// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_zbf_float16_s
+// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+struct zbf_float16_s f_ret_zbf_float16_s(void) {
+  return (struct zbf_float16_s){1.0};
+}
+
+// LP64-LP64F-LP64D-LABEL: define dso_local void @f_zbf_float16_zbf_s_arg
+// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+void f_zbf_float16_zbf_s_arg(struct zbf_float16_zbf_s a) {}
+
+// LP64-LP64F-LP64D-LABEL: define dso_local i64 @f_ret_zbf_float16_zbf_s
+// LP64-LP64F-LP64D-SAME: () #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+struct zbf_float16_zbf_s f_ret_zbf_float16_zbf_s(void) {
+  return (struct zbf_float16_zbf_s){1.0};
+}
+
+// Check that structs containing two floating point values (FLEN <= width) are
+// expanded provided sufficient FPRs are available.
+
+struct double_float16_s { double f; _Float16 g; };
+
+// LP64-LP64F-LP64D-LABEL: define dso_local void @f_double_float16_s_arg
+// LP64-LP64F-LP64D-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
+// LP64-LP64F-LP64D:  entry:
+//
+void f_double_float16_s_arg(struct double_float16_s a) {}
+
+// LP64-LP64F-LP64D-LABEL: define dso_local [2 x i64] @f_ret_double_float16_s
+// 

[clang] a7e13d6 - [clang][RISCV][test] Add test coverage for _Float16 ABI lowering

2023-03-15 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-03-15T18:00:39Z
New Revision: a7e13d6f1b49d72b59e9ec2252399eda717ea8f6

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

LOG: [clang][RISCV][test] Add test coverage for _Float16 ABI lowering

By the psABI, any test case where a FPR would be used for a float, it
should also be used if you replaced that float with a _Float16. This
doesn't hold true in current Clang for the special cases in the FP
calling convention involving structs. This patch doesn't attempt to fix
that, simply to add coverage. D145074 contains the fix.

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/riscv32-abi.c
clang/test/CodeGen/RISCV/riscv64-abi.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/riscv32-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-abi.c
index c00365d89c42..5cabbf4d90a1 100644
--- a/clang/test/CodeGen/RISCV/riscv32-abi.c
+++ b/clang/test/CodeGen/RISCV/riscv32-abi.c
@@ -70,6 +70,12 @@ double f_fp_scalar_2(double x) { return x; }
 //
 long double f_fp_scalar_3(long double x) { return x; }
 
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local half @f_fp_scalar_4
+// ILP32-ILP32F-ILP32D-SAME: (half noundef [[X:%.*]]) #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+_Float16 f_fp_scalar_4(_Float16 x) { return x; }
+
 // Empty structs or unions are ignored.
 
 struct empty_s {};
@@ -314,11 +320,11 @@ void f_scalar_stack_4(double a, int64_t b, double c, 
int64_t d, int e,
   int64_t f, float g, double h, long double i) {}
 
 // ILP32-ILP32F-ILP32D-LABEL: define dso_local i32 @f_scalar_stack_5
-// ILP32-ILP32F-ILP32D-SAME: (i32 noundef [[A:%.*]], i64 noundef [[B:%.*]], 
float noundef [[C:%.*]], double noundef [[D:%.*]], fp128 noundef [[E:%.*]], i8 
noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext 
[[H:%.*]]) #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D-SAME: (i32 noundef [[A:%.*]], i64 noundef [[B:%.*]], 
float noundef [[C:%.*]], double noundef [[D:%.*]], fp128 noundef [[E:%.*]], i8 
noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext 
[[H:%.*]], half noundef [[I:%.*]]) #[[ATTR0]] {
 // ILP32-ILP32F-ILP32D:  entry:
 //
 int f_scalar_stack_5(int32_t a, int64_t b, float c, double d, long double e,
- uint8_t f, int8_t g, uint8_t h) {
+ uint8_t f, int8_t g, uint8_t h, _Float16 i) {
   return g + h;
 }
 
@@ -1520,5 +1526,425 @@ void f_float_u_arg(union float_u a) {}
 union float_u f_ret_float_u(void) {
   return (union float_u){1.0};
 }
+
+// Check that fp, fp+fp, and int+fp structs are lowered correctly. These will
+// be passed in FPR, FPR+FPR, or GPR+FPR regs if sufficient registers are
+// available the widths are <= XLEN and FLEN, and should be expanded to
+// separate arguments in IR. They are passed by the same rules for returns,
+// but will be lowered to simple two-element structs if necessary (as LLVM IR
+// functions cannot return multiple values).
+// FIXME: Essentially all test cases below involving _Float16 in structs
+// aren't lowered according to the rules in the FP calling convention (i.e.
+// are incorrect for ilp32f/ilp32d).
+
+struct float16_s { _Float16 f; };
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local void @f_float16_s_arg
+// ILP32-ILP32F-ILP32D-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+void f_float16_s_arg(struct float16_s a) {}
+
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local i32 @f_ret_float16_s
+// ILP32-ILP32F-ILP32D-SAME: () #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+struct float16_s f_ret_float16_s(void) {
+  return (struct float16_s){1.0};
+}
+
+// A struct containing a double and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_float16_s { int : 0; _Float16 f; };
+struct zbf_float16_zbf_s { int : 0; _Float16 f; int : 0; };
+
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local void @f_zbf_float16_s_arg
+// ILP32-ILP32F-ILP32D-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+void f_zbf_float16_s_arg(struct zbf_float16_s a) {}
+
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local i32 @f_ret_zbf_float16_s
+// ILP32-ILP32F-ILP32D-SAME: () #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+struct zbf_float16_s f_ret_zbf_float16_s(void) {
+  return (struct zbf_float16_s){1.0};
+}
+
+// ILP32-ILP32F-ILP32D-LABEL: define dso_local void @f_zbf_float16_zbf_s_arg
+// ILP32-ILP32F-ILP32D-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] {
+// ILP32-ILP32F-ILP32D:  entry:
+//
+void f_zbf_float16_zbf_s_arg(struct zbf_float16_zbf_s a) {}
+
+// 

Re: [PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread Jose E. Marchesi via cfe-commits

> eddyz87 added a comment.
>
> In D143967#4197041 , @dfaust wrote:
>
>> The way I see it both 'volatile' and the type tag are modifying
>> 'int' type here, so the annotation DIE more properly fits as a child
>> of 'int' rather than the 'volatile'.
>>
>> I don't think we discussed this particular case, and I'm not sure whether 
>> there is any precedent here.
>>
>> WDYT @eddyz87, @jemarch ?
>
> This is related to my previous comment. Kernel BTF parser wants all
> type tags to precede modifiers (see this
> 
> code). So such reordering will have to happen either during DWARF
> generation or by `pahole`. Currently `pahole` is "dumb" in a sense
> that it reflects DWARF structure in BTF effectively one-to-one. Adding
> such rewrite at a `pahole` level is possible but one-to-one mapping to
> DWARF would be lost, so the tool would require significant changes.
>
> So, at least for LLVM its a tradeoff, either do it in the compiler
> (less code), or in the pahole (more code). I opted for less code :) If
> you think that this is conceptually unacceptable, I'll do the change
> on the pahole side (DI maintainers on LLVM side might agree, the patch
> has not been reviewed yet).
>
> Another option would be to modify the kernel, but this might impede backwards 
> compatibility.

In GCC we also translate from the internal DWARF structures into BTF.
So, for us, it would also imply to reoder (before generating the BTF
from the interal DWARF) in case we wanted to use a different approach in
DWARF than in BTF.

I think the question is: what are the consequences of having the
annotation DIE as a child of the qualifiers instead of the qualified
type?

>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D143967/new/
>
> https://reviews.llvm.org/D143967
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Sema/attr-alwaysinline.cpp:36
+return x;
+}
+

erichkeane wrote:
> Can you add a test that shows that we warn on instantiation?  This shouldn't 
> be a dependent declrefexpr when instantiated.
> 
> Additionally, this would make sure that we're properly propoagating 
> `always_inline`.
Should this warn

```
template [[gnu::noinline]]   
 
int bar(int x) {
 
if constexpr (D > 1)
 
[[clang::always_inline]] return bar(x + 1);
 
else
 
return x;   
 
}   
 

 
int baz(int x) {
 
  return bar<5>(x); 
 
}  
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D128648: [Clang][AArch64][SME] Add vector read/write (mova) intrinsics

2023-03-15 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin accepted this revision.
kmclaughlin added a comment.
This revision is now accepted and ready to land.

Thank you @bryanpkc, this LGTM




Comment at: clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_read.c:2
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sve -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s 
-check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sve -S -O1 -Werror -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefixes=CHECK,CHECK-CXX

bryanpkc wrote:
> kmclaughlin wrote:
> > I think `-target-feature +sve` can be removed from this test and 
> > `acle_sme_write.c`
> Doing that will cause errors like these:
> ```
> error: SVE vector type 'svbool_t' (aka '__SVBool_t') cannot be used in a 
> target without sve
> ```
> As I have explained in [D127910](https://reviews.llvm.org/D127910#4137844), 
> `-target-feature +sme` does not imply `-target-feature +sve`. But `-march=` 
> processing will work as expected when D142702 lands.
Apologies for leaving the same comment, I missed this on the previous patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128648

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


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.
Herald added a subscriber: jplehr.

Needed to update this after landing with two quick patch fixes:

  [clang-offload-bundler] Fix test failures and document typo (65fb636bd462)
  
  [clang-offload-bundler] Fix error with regex in bundler test (f3b991202689)

There were also two quick fixes by others that overlapped but got in before my 
fixes:

  Mark test modified in e48ae0d as XFAIL for PS4/PS5 until the author ... 
(768211f48f2d)
  
  clang/test/Driver/clang-offload-bundler-standardize.c REQUIRES asserts. 
(fixup D145770) (d4a4d0d79127)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145770

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


[PATCH] D146156: [clang][Lexer] Fix crash/assert clang::HeaderSearch::search_dir_nth

2023-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: bruno, troyj, arphaman, vsapsai, jansvoboda11.
DmitryPolukhin added a project: clang.
Herald added a subscriber: kadircet.
Herald added a project: All.
DmitryPolukhin requested review of this revision.
Herald added a subscriber: ilya-biryukov.

The issue was intrduced in D135801 . When 
there is no header map in the
SearchDirs, out out of bounds values assigned to FirstNonHeaderMapSearchDirIdx.

Reproduced crash on clangd:
V[10:30:24.298] Building first preamble for  version 1
I[10:31:26.018] Indexing c++20 standard library in the context of 
clangd: llvm-project/clang/include/clang/Lex/HeaderSearch.h:817: 
ConstSearchDirIterator clang::HeaderSearch::search_dir_nth(size_t) const: 
Assertion `n < SearchDirs.size()' failed.
`bt
(lldb) bt

- thread #1, name = 'clangd.main', stop reason = hit program assert
  - frame #0: 0x7584eacf libc.so.6`raise + 271 frame #1: 
0x75821ea5 libc.so.6`abort + 295 frame #2: 0x75821d79 
libc.so.6`__assert_fail_base.cold.0 + 15 frame #3: 0x75847426 
libc.so.6`__assert_fail + 70 frame #4: 0x597ec12d 
clangd`clang::HeaderSearch::search_dir_nth(this=0x679d1500, n=1) const 
at HeaderSearch.h:817:5 frame #5: 0x597e47c2 
clangd`clang::HeaderSearch::LookupFile(this=0x679d1500, Filename=(Data 
= "vector>)\n#error Mandatory header  not found in standard 
library!\n#endif\n#if __has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#"..., Length = 6), 
IncludeLoc=(ID = 21), isAngled=true, FromDir=clang::ConstSearchDirIterator @ 
0x7fff4490, CurDirArg=0x7fff4968, 
Includers=ArrayRef > @ 0x7fff44a0, SearchPath=0x, 
RelativePath=0x, RequestingModule=0x, 
SuggestedModule=0x, IsMapped=0x, 
IsFrameworkFound=0x, SkipCache=false, BuildSystemModule=false, 
OpenFile=true, CacheFailures=true) at HeaderSearch.cpp:1031:16 frame #6: 
0x5979490c 
clangd`clang::Preprocessor::LookupFile(this=0x67d44f00, FilenameLoc=(ID 
= 21), Filename=(Data = "vector>)\n#error Mandatory header  not found 
in standard library!\n#endif\n#if __has_include()\n#include 
\n#endif\n#if __has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#if 
__has_include()\n#include \n#endif\n#"..., Length = 6), 
isAngled=true, FromDir=clang::ConstSearchDirIterator @ 0x7fff49f0, 
FromFile=0x, CurDirArg=0x, 
SearchPath=0x, RelativePath=0x, 
SuggestedModule=0x, IsMapped=0x, 
IsFrameworkFound=0x, SkipCache=false, OpenFile=true, 
CacheFailures=true) at PPDirectives.cpp:1014:40 frame #7: 0x59812355 
clangd`EvaluateHasIncludeCommon(Tok=0x7fff6830, II=0x6721c008, 
PP=0x67d44f00, LookupFrom=clang::ConstSearchDirIterator @ 
0x7fff4c98, LookupFromFile=0x) at 
PPMacroExpansion.cpp:1253:10 frame #8: 0x59811e17 
clangd`clang::Preprocessor::EvaluateHasInclude(this=0x67d44f00, 
Tok=0x7fff6830, II=0x6721c008) at PPMacroExpansion.cpp:1269:10 
frame #9: 0x5980f85d 
clangd`clang::Preprocessor::ExpandBuiltinMacro(this=0x67d44f00, 
Tok=0x7fff6830) at PPMacroExpansion.cpp:1802:15 frame #10: 
0x5980ddca 
clangd`clang::Preprocessor::HandleMacroExpandedIdentifier(this=0x67d44f00,
 Identifier=0x7fff6830, M=0x7fff5c50) at 
PPMacroExpansion.cpp:493:5 frame #11: 0x5983ba8b 
clangd`clang::Preprocessor::HandleIdentifier(this=0x67d44f00, 
Identifier=0x7fff6830) at Preprocessor.cpp:825:18 frame #12: 
0x597765f5 

[PATCH] D146155: [clang][NFC] Fix location of 2>&1 in a few -print tests

2023-03-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

While it's apparently valid to place Bash redirections anywhere in a
command-line, it is by far most frequently placed last. This changes
a few tests that did not conform to this convention and which I
originally thought were wrong.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146155

Files:
  clang/test/Driver/print-effective-triple.c
  clang/test/Driver/print-file-name.c
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  clang/test/Driver/print-multi-directory.c
  clang/test/Driver/print-target-triple.c

Index: clang/test/Driver/print-target-triple.c
===
--- clang/test/Driver/print-target-triple.c
+++ clang/test/Driver/print-target-triple.c
@@ -1,6 +1,6 @@
 // Test that -print-target-triple prints correct triple.
 
-// RUN: %clang -print-target-triple 2>&1 \
-// RUN: --target=x86_64-linux-gnu \
+// RUN: %clang -print-target-triple \
+// RUN: --target=x86_64-linux-gnu 2>&1 \
 // RUN:   | FileCheck %s
 // CHECK: x86_64-unknown-linux-gnu
Index: clang/test/Driver/print-multi-directory.c
===
--- clang/test/Driver/print-multi-directory.c
+++ clang/test/Driver/print-multi-directory.c
@@ -1,27 +1,27 @@
-// RUN: %clang -### %s 2>/dev/null \
+// RUN: %clang -### %s \
 // RUN: --target=i386-none-linux \
 // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
-// RUN: -print-multi-directory \
+// RUN: -print-multi-directory 2>/dev/null \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86-MULTILIBS %s
 
 // CHECK-X86-MULTILIBS:  32
 // CHECK-X86-MULTILIBS-NOT:  {{^.+$}}
 
-// RUN: %clang -### %s 2>/dev/null \
+// RUN: %clang -### %s \
 // RUN: --target=i386-none-linux -m64 \
 // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree/usr \
-// RUN: -print-multi-directory \
+// RUN: -print-multi-directory 2>/dev/null \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-X86_64-MULTILIBS %s
 
 // CHECK-X86_64-MULTILIBS:  .
 // CHECK-X86_64-MULTILIBS-NOT:  {{^.+$}}
 
-// RUN: %clang -### %s 2>/dev/null \
+// RUN: %clang -### %s \
 // RUN: --target=arm-linux-androideabi21 \
 // RUN: -mthumb \
 // RUN: --gcc-toolchain=%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
-// RUN: -print-multi-directory \
+// RUN: -print-multi-directory 2>/dev/null \
 // RUN:   | FileCheck --match-full-lines --check-prefix=CHECK-ARM-MULTILIBS %s
 
 // CHECK-ARM-MULTILIBS:  thumb
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -1,65 +1,65 @@
 // Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
 
-// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
 // RUN: --target=x86_64-pc-linux \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
 // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
 
-// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
 // RUN: --target=i386-pc-linux \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
 // CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a
 
 // Check whether alternate arch values map to the correct library.
 //
-// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
 // RUN: --target=i686-pc-linux \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s
 
-// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
 // RUN: --target=arm-linux-gnueabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
 // RUN:   | FileCheck 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505560.
francii added a comment.

Fix segfault


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// Check that -pg throws an error on z/OS.
+// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -pg is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first on AIX.
+// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
+// RUN:| FileCheck --check-prefix=CHECK3 %s
+// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK3: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK3: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK3: "-L[[SYSROOT]]/lib/profiled"
+// CHECK3: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!TC.getTriple().isOSOpenBSD()) {
+
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+if (TC.getTriple().isOSzOS()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
   }
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+

[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

In D143967#4197041 , @dfaust wrote:

> The way I see it both 'volatile' and the type tag are modifying 'int' type 
> here, so the annotation DIE more properly fits as a child of 'int' rather 
> than the 'volatile'.
>
> I don't think we discussed this particular case, and I'm not sure whether 
> there is any precedent here.
>
> WDYT @eddyz87, @jemarch ?

This is related to my previous comment. Kernel BTF parser wants all type tags 
to precede modifiers (see this 
 code). 
So such reordering will have to happen either during DWARF generation or by 
`pahole`. Currently `pahole` is "dumb" in a sense that it reflects DWARF 
structure in BTF effectively one-to-one. Adding such rewrite at a `pahole` 
level is possible but one-to-one mapping to DWARF would be lost, so the tool 
would require significant changes.

So, at least for LLVM its a tradeoff, either do it in the compiler (less code), 
or in the pahole (more code). I opted for less code :) If you think that this 
is conceptually unacceptable, I'll do the change on the pahole side (DI 
maintainers on LLVM side might agree, the patch has not been reviewed yet).

Another option would be to modify the kernel, but this might impede backwards 
compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D146069: [StandardInstrumentations] Rename -verify-cfg-preserved -> -verify-analysis-invalidation

2023-03-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 505558.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146069

Files:
  clang/test/CodeGen/lto-newpm-pipeline.c
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-O0-defaults.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  
llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll

Index: llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
===
--- llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
+++ llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-markloopasdeleted.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-cfg-preserved -debug-pass-manager=verbose 2>&1 | FileCheck %s
+; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch),loop-distribute' -o /dev/null -S -verify-analysis-invalidation -debug-pass-manager=verbose 2>&1 | FileCheck %s
 
 
 ; Running loop-distribute will result in LoopAccessAnalysis being required and
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -1,5 +1,5 @@
-;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
-;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-cfg-preserved=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
+;RUN: opt %s -aa-pipeline= -passes='adce,loop(loop-rotate),adce' -S -verify-analysis-invalidation=0 -debug-pass-manager -debug-only=loop-rotate 2>&1 | FileCheck %s
+;RUN: opt %s -aa-pipeline= -passes='adce,loop-mssa(loop-rotate),adce' -S -verify-analysis-invalidation=0 -debug-pass-manager -debug-only=loop-rotate -verify-memoryssa 2>&1 | FileCheck %s --check-prefix=MSSA
 ;REQUIRES: asserts
 
 ; This test is to make sure we invalidate the post dominator pass after loop rotate simplifies the loop latch.
Index: llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
===
--- llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
+++ llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll
@@ -1,4 +1,4 @@
-; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-cfg-preserved=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
+; RUN: opt -passes='require,constraint-elimination,require' -disable-verify -verify-analysis-invalidation=false -debug-pass-manager -disable-output %s 2>&1 | FileCheck %s
 
 ; Check that constraint-elimination properly invalidates anlyses.
 
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -1,26 +1,26 @@
 ; Validate ThinLTO prelink pipeline when we have Sample PGO
 ;
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-analysis-invalidation=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; RUN: opt -disable-verify -verify-analysis-invalidation=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
 ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \
 ; RUN: -passes='thinlto-pre-link' -S  %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ
-; RUN: opt -disable-verify -verify-cfg-preserved=0 -eagerly-invalidate-analyses=0 -debug-pass-manager \
+; 

[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-15 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin added a comment.

In D125171#4195298 , @owenpan wrote:

> In D125171#4193996 , @jrmolin wrote:
>
>> In D125171#4167866 , @owenpan 
>> wrote:
>>
>>> Please see 
>>> https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options.
>>
>> I am doing this for my team, which writes the security endpoint for Elastic 
>> Defend. The code is currently private, though the binaries are free to 
>> download and run. The number of contributors is around 30, and the lines of 
>> code is in the 100Ks (around 500K). I have not found a way to accomplish 
>> what this does with the available options. I am adding tests and am happy to 
>> maintain this. It is a rather small addition, so it is quite simple to keep 
>> updated.
>
> Do you "have a publicly accessible style guide"?

Unfortunately, we don't. I can create one in the likeness of the others, but 
I'm not sure where it will get published. I will talk to my managers about 
publishing a style doc.




Comment at: clang/docs/ClangFormatStyleOptions.rst:1372
+.. _AlwaysBreakBeforeFunctionParameters:
+
+**AlwaysBreakBeforeFunctionParameters** (``Boolean``) 
:versionbadge:`clang-format 16.0`

MyDeveloperDay wrote:
> Regererate
How do I re-generate? I'm happy to! I just don't see where to do that.



Comment at: clang/lib/Format/Format.cpp:872
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",

MyDeveloperDay wrote:
> Needs a parse test
I will add one. Thanks for the reminder!



Comment at: clang/unittests/Format/FormatTest.cpp:25357
+  // verify that there is no break by default
+  verifyFormat("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n",

MyDeveloperDay wrote:
> Please write it out long form
What do you mean by "long form"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread David Faust via Phabricator via cfe-commits
dfaust added a comment.



> in the final BTF, type tags have to precede CVR modifiers, e.g. TYPE_TAG 
> 'foo' -> CONST -> INT. Right now pahole does not do any reordering, so I 
> ended up putting the type tag annotations on the DIE with outermost modifier. 
> Will see if DI maintainers would be ok with this.

Ok I was not aware of that requirement.
Internally GCC converts DWARF representation to BTF for BTF emission so we get 
(for the volatile example):

  [1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
  [2] TYPE_TAG '__b' type_id=1
  [3] VOLATILE '(anon)' type_id=2
  [4] VAR 'b' type_id=3, linkage=global

i.e. `VOLATILE -> TYPE_TAG -> INT` which doesn't meet the above requirement 
that type tags precede CVR modifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D146075: [flang][driver][openmp] Write MLIR for -save-temps

2023-03-15 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Frontend is in the file name.




Comment at: flang/lib/Frontend/FrontendActions.cpp:79
+  llvm::StringRef inputFile, llvm::StringRef outputTag) {
+  if (!ci.getCodeGenOpts().SaveTempsDir.has_value()) {
+return true;

useless braces



Comment at: flang/lib/Frontend/FrontendActions.cpp:91
+
+  if (llvm::sys::fs::is_directory(outDir)) {
+outDir.append("/");

useless braces



Comment at: flang/lib/Frontend/FrontendActions.cpp:106
+  llvm::ToolOutputFile out(outDir + outFile, ec, llvm::sys::fs::OF_Text);
+  if (ec) {
+return false;

useless braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146075

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


Re: [PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread David Faust via cfe-commits


On 3/15/23 09:17, Eduard Zingerman wrote:
> On Wed, 2023-03-15 at 17:10 +0100, Jose E. Marchesi wrote:
>>> Could you please take a look to verify that this implementation is on
>>> the same page with what is planned for GCC?
>>
>> Sure.  Can you please add David Faust as a subscriber as well?  I don't
>> know if he has an account in reviews.llvm.org.
> 
> I wanted to, but have not found his account for reviews.llvm.org.
> And Phabricator interface does not seem to allow to subscribe non-user
> emails, unfortunately.

I have just created an account and was able to subscribe myself.
Thanks
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-03-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I don't think of this as a performance regression for users though - this 
functionality's never really "shipped" so we get to choose what the baseline is.

And I think a reasonable baseline to compare to isn't this implementation we 
don't think is ideal (because of the build invalidation issues, if nothing 
else, caused by having thick PCMs) - I think the baseline is what a users 
non-modular code is. And in non-modular code these non-inline functions would 
be in the implementation files, not able to cross-TU inline without LTO.

I think not providing definitions of non-inline functions for cross-TU 
optimizations is not a regression, but exactly in-line with existing 
non-modular behavior, which is totally fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144844

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


[PATCH] D146075: [flang][driver][openmp] Write MLIR for -save-temps

2023-03-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D146075#4196998 , @tschuett wrote:

> What is the policy on trivial braces in the frontend?

What do you mean by the frontend? Different people have different understanding 
of what "the frontend" is.

I try to follow 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146075

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread David Faust via Phabricator via cfe-commits
dfaust added a comment.

> Type tag for CVR modifier type
>
> C:
>
>   volatile int __attribute__((btf_type_tag("__b"))) b;
>
> DWARF:
>
>   0x31:   DW_TAG_variable
> DW_AT_name  ("b")
> DW_AT_type  (0x3c "volatile int")
>   
>   0x3c:   DW_TAG_volatile_type
> DW_AT_type  (0x45 "int")
>   
>   0x41: DW_TAG_LLVM_annotation
>   DW_AT_name("btf:type_tag")
>   DW_AT_const_value ("__b")

I am not sure about this case. Do we want the tag on the CVR qualifier or on 
the type being qualified?

Current patches for GCC place the annotation DIE as child of the 'int':

  0x001e:   DW_TAG_variable
  DW_AT_name("b")
  DW_AT_type(0x0047 "volatile int")
  
  0x0032:   DW_TAG_base_type
  DW_AT_byte_size   (0x04)
  DW_AT_name("int")
  
  0x003d: DW_TAG_LLVM_annotation
DW_AT_name  ("btf:type_tag")
DW_AT_const_value   ("__b")
  
  0x0047:   DW_TAG_volatile_type
  DW_AT_type(0x0032 "int")

The way I see it both 'volatile' and the type tag are modifying 'int' type 
here, so the annotation DIE more properly fits as a child of 'int' rather than 
the 'volatile'.

I don't think we discussed this particular case, and I'm not sure whether there 
is any precedent here.

WDYT @eddyz87, @jemarch ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-03-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5250
 
+  if (Args.hasArg(options::OPT_mroptr) || Args.hasArg(options::OPT_mno_roptr)) 
{
+bool HasRoptr =

hubert.reinterpretcast wrote:
> This only checks for `-m[no-]roptr` when the front-end is invoked. When the 
> driver is used just for linking, we get no diagnostic at all for using these 
> options on other platforms.
> 
> @MaskRay:
> 
> As Clang code owner for the Driver, are you concerned if platform-specific 
> options are sometimes silently ignored on other platforms? Is there a better 
> place for the diagnostic?
> 
> For info, in this case, the option would have effects on AIX at both 
> compile-from-C/C++ time and at link time. 
> 
> Also, should `-Wunused-command-line-argument` warnings be generated for cases 
> where the option has no effect (e.g., `-emit-llvm` or `-fsyntax-only`)? I 
> think `-flto` is a bit of an exception because it may be unfriendly to expect 
> users to change other aspects of their compile invocations when adding 
> `-flto`. At the same time, it can be argued instead that generating a 
> `-Wunused-command-line-argument` warning for "back-end" options on `-flto` 
> compiles helps the user realize that they need to provide the option on their 
> link step.
> 
@MaskRay May I ask for your input on this issue where platform-specific options 
are silently ignored on other platforms? What is our current opinion on where 
these checks/diagnostics should go? 

Thanks!! 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

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


[PATCH] D146075: [flang][driver][openmp] Write MLIR for -save-temps

2023-03-15 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

What is the policy on trivial braces in the frontend?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146075

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-03-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a comment.

Hi @dfaust ,

Two head-ups, the following items turned out to be important when I tested 
using kernel BPF testsuite:

- in the final BTF, type tags have to precede CVR modifiers, e.g. TYPE_TAG 
'foo' -> CONST -> INT. Right now `pahole` does not do any reordering, so I 
ended up putting the type tag annotations on the DIE with outermost modifier. 
Will see if DI maintainers would be ok with this.
- CO-RE relocation entries have to point to the actual type, not type tag. For 
both field relocations and variable relocations (this is related to the next 
 patch in a stack).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

2023-03-15 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 marked 2 inline comments as done.
jp4a50 added inline comments.



Comment at: clang/lib/Format/Format.cpp:1372
   LLVMStyle.DerivePointerAlignment = false;
+  LLVMStyle.DesignatedInitializerIndentWidth = 4;
   LLVMStyle.DisableFormat = false;

jp4a50 wrote:
> MyDeveloperDay wrote:
> > so lets say someone is using an IndentWidth of 2 and now you introduce this 
> > as being 4 here as the default
> > 
> > Without them changing anything, all their DesignatedIntializer code will 
> > get refactored to a IndentWidth of 4 rather than the 2 it was previously
> > 
> > This is where we get called out for "changing the defaults", which really 
> > we are not we are just reclassifying how it behaves.
> > 
> > What we normally say here is can you point us to a public style that has an 
> > independent DesignatedIntializerIndentWidth which is independent from the 
> > levels of IndentWidth everywhere else.
> > 
> > Whilst I can see more knobs feels good, this will change code and we'll 
> > have to manage that expectation.
> > 
> > 
> > 
> Yep, so as per my comment in `clang/docs/ClangFormatStyleOptions.rst` I think 
> I am changing my mind about this anyway.
> 
> My motivation for making this change is to support the [[ 
> https://github.com/capnproto/capnproto/blob/master/kjdoc/style-guide.md | KJ 
> style guide ]] which is quoted in the [[ 
> https://github.com/llvm/llvm-project/issues/51070 | github issue ]] - I work 
> on a team that uses the KJ style guide.
> 
> The KJ style guide wants a designated initializer indent width of 2 along 
> with a "normal" indent width of 2, so there is no explicit need for us to 
> have those two values be different.
> 
> When originally making these changes, I did think that having "more knobs" 
> was a good idea, but I agree that this could lead to annoying behaviour for 
> some users and they would probably expect the designated initializer indent 
> to match either the normal indent or the continuation indent.
> 
> How about I change the option to an integer and, when it's -1 (the default), 
> the designated initializer indent matches the continuation indent, but if it 
> is set to a value >= 0 then that number of columns is used instead? 
> 
I've reimplemented the option as a signed integer as per my suggestion above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D146075: [flang][driver][openmp] Write MLIR for -save-temps

2023-03-15 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: flang/lib/Frontend/FrontendActions.cpp:77
+/// specified.
+bool saveMLIRTempFile(const CompilerInvocation , mlir::ModuleOp mlirModule,
+  llvm::StringRef inputFile, llvm::StringRef outputTag) {

static is cuter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146075

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


  1   2   3   >