[clang] clang: Add llvm-mc to CLANG_TEST_DEPS (PR #112032)

2024-10-11 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-fuzzer` running on `sanitizer-buildbot11` while 
building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/159/builds/8046


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
-- Building with -fPIC
-- LLVM host triple: aarch64-unknown-linux-gnu
-- LLVM default target triple: aarch64-unknown-linux-gnu
-- Using libunwind testing configuration: 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/libunwind/test/configs/llvm-libunwind-shared.cfg.in
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE) 
-- Using libc++abi testing configuration: 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
-- Using libc++ testing configuration: 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/libcxx/test/configs/llvm-libc++-shared.cfg.in
-- ABI list file not generated for configuration 
aarch64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew, 
`check-cxx-abilist` will not be available.
CMake Deprecation Warning at 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/cmake/Modules/CMakePolicy.cmake:6
 (cmake_policy):
  The OLD behavior for policy CMP0114 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/CMakeLists.txt:12
 (include)


CMake Deprecation Warning at 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/cmake/Modules/CMakePolicy.cmake:11
 (cmake_policy):
  The OLD behavior for policy CMP0116 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/CMakeLists.txt:12
 (include)


-- Compiler-RT supported architectures: aarch64
-- Generated Sanitizer SUPPORTED_TOOLS list on "Linux" is 
"asan;lsan;hwasan;msan;tsan;ubsan"
-- sanitizer_common tests on "Linux" will run against 
"asan;lsan;hwasan;msan;tsan;ubsan"
-- Configuring done (1.7s)
-- Generating done (0.3s)
-- Build files have been written to: 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/runtimes/runtimes-bins
[22/25] Performing build step for 'runtimes'
[0/7] Performing build step for 'libcxx_fuzzer_aarch64'
ninja: no work to do.
[3/7] Building CXX object 
compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic_version_script_dummy.aarch64.dir/dummy.cpp.o
[5/7] Linking CXX shared library 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/lib/clang/20/lib/aarch64-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
[6/7] Linking CXX shared library 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/lib/clang/20/lib/aarch64-unknown-linux-gnu/libclang_rt.hwasan.so
[7/7] Linking CXX shared library 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/lib/clang/20/lib/aarch64-unknown-linux-gnu/libclang_rt.asan.so
[23/25] No install step for 'runtimes'
[25/25] Completed 'runtimes'
64504f4010e82694a9364aaef2e79946  llvm_build0/bin/clang
@@@BUILD_STEP get fuzzer-test-suite @@@
fatal: unable to access 'https://github.com/google/fuzzer-test-suite.git/': 
gnutls_handshake() failed: The TLS connection was non-properly terminated.
Step 8 (get fuzzer-test-suite) failure: get fuzzer-test-suite (failure)
@@@BUILD_STEP get fuzzer-test-suite @@@
fatal: unable to access 'https://github.com/google/fuzzer-test-suite.git/': 
gnutls_handshake() failed: The TLS connection was non-properly terminated.
program finished with exit code 1
elapsedTime=1030.982419

```



https://github.com/llvm/llvm-project/pull/112032
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-11 Thread Matt Arsenault via cfe-commits


@@ -463,10 +463,11 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(HostTriple.normalize()),
+  ArgStringList McArgs{"-target", Args.MakeArgString(HostTriple.normalize()),
"-o",  Output.getFilename(),
-   McinFile,  "--filetype=obj"};
-  const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
+   "-x",  "assembler",
+   ObjinFile, "-c"};
+  const char *Mc = Args.MakeArgString(TC.GetProgramPath("clang"));

arsenm wrote:

But the toolchain tracked the name of the current clang? Really you want to 
find the current binary

`I don't think it's critical that the clang we invoke here is the amdclang`

It's critical to find the exact clang that you are running 

https://github.com/llvm/llvm-project/pull/112041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HIP] Replace use of `llvm-mc` with `clang` (PR #112041)

2024-10-11 Thread Matt Arsenault via cfe-commits


@@ -463,10 +463,11 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(HostTriple.normalize()),
+  ArgStringList McArgs{"-target", Args.MakeArgString(HostTriple.normalize()),
"-o",  Output.getFilename(),
-   McinFile,  "--filetype=obj"};
-  const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
+   "-x",  "assembler",
+   ObjinFile, "-c"};
+  const char *Mc = Args.MakeArgString(TC.GetProgramPath("clang"));

arsenm wrote:

Shouldn't assume the binary name is clang, other places seem to be doing 
something like this:

`TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName()))`



https://github.com/llvm/llvm-project/pull/112041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (PR #87717)

2024-10-11 Thread via cfe-commits

Moon6688 wrote:

> intrin.h checks for x86_64. But the "x86_64" define is also defined for 
> ARM64EC, and we don't support all the intrinsics in ARM64EC mode. Fix the 
> preprocessor checks to handle this correctly. (If we actually need some of 
> these intrinsics in ARM64EC mode, we can revisit later.)
> 
> Not exactly sure how I didn't run into this issue before now... I think I've 
> built code that requires these headers, but maybe not since the define fix 
> landed.



https://github.com/llvm/llvm-project/pull/87717
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1ac6ef5 - clang: Add llvm-mc to CLANG_TEST_DEPS (#112032)

2024-10-11 Thread via cfe-commits

Author: Matt Arsenault
Date: 2024-10-12T06:42:31+04:00
New Revision: 1ac6ef5af28b72e534496a9833a2b75a2aba66cc

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

LOG: clang: Add llvm-mc to CLANG_TEST_DEPS (#112032)

Attempt to fit sporadic precommit test failures in
hip-partial-link.hip

The driver really shouldn't be using llvm-mc in the first place
though, filed #112031 to fix this.

Added: 


Modified: 
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 2d84b0d73053f6..98829d53db934f 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -127,6 +127,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-dwarfdump
 llvm-ifs
 llvm-lto2
+llvm-mc
 llvm-modextract
 llvm-nm
 llvm-objcopy



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


[clang] clang: Add llvm-mc to CLANG_TEST_DEPS (PR #112032)

2024-10-11 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm closed 
https://github.com/llvm/llvm-project/pull/112032
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread YunQiang Su via cfe-commits


@@ -372,6 +372,31 @@ void foo(double *d, float f, float *fp, long double *l, 
int *i, const char *c) {
 // HAS_MAYTRAP: declare float @llvm.experimental.constrained.minnum.f32(
 // HAS_MAYTRAP: declare x86_fp80 @llvm.experimental.constrained.minnum.f80(
 
+  fmaximum_num(*d,*d);   fmaximum_numf(f,f);  fmaximum_numl(*l,*l);
+
+// NO__ERRNO: declare double @llvm.maximumnum.f64(double, double) 
[[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.maximumnum.f32(float, float) 
[[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.maximumnum.f80(x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @llvm.maximumnum.f64(double, double) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare float @llvm.maximumnum.f32(float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare x86_fp80 @llvm.maximumnum.f80(x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
+// HAS_MAYTRAP: declare double @llvm.maximumnum.f64(
+// HAS_MAYTRAP: declare float @llvm.maximumnum.f32(
+// HAS_MAYTRAP: declare x86_fp80 @llvm.maximumnum.f80(
+
+  fminimum_num(*d,*d);   fminimum_numf(f,f);  fminimum_numl(*l,*l);
+
+// NO__ERRNO: declare double @llvm.minimumnum.f64(double, double) 
[[READNONE_INTRINSIC]]
+// NO__ERRNO: declare float @llvm.minimumnum.f32(float, float) 
[[READNONE_INTRINSIC]]
+// NO__ERRNO: declare x86_fp80 @llvm.minimumnum.f80(x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare double @llvm.minimumnum.f64(double, double) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare float @llvm.minimumnum.f32(float, float) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare x86_fp80 @llvm.minimumnum.f80(x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
+// HAS_MAYTRAP: declare double @llvm.minimumnum.f64(
+// HAS_MAYTRAP: declare float @llvm.minimumnum.f32(

wzssyqa wrote:

Sorry. I don't understand it well. Do you mean that we use `--check-prefixes` 
instead of `--check-prefix`?

https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From e778fad3eafcd78924efd7aa233ac7ba9f4e6a49 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/13] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index a89029b720e788..585b22fd7da502 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2771,6 +2772,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-11 Thread Younan Zhang via cfe-commits


@@ -478,3 +478,166 @@ A a{.f1 = {1}};
 // CHECK-NEXT: `-DeclRefExpr {{.+}}  'int' NonTypeTemplateParm 
{{.+}} 'N' 'int'
 
 } // namespace GH83368
+
+namespace GH60777 {
+
+template  constexpr bool True() { return true; }
+
+template 
+  requires(sizeof(T) == 4)
+struct A {
+  template 
+requires(sizeof...(Ts) == 0)
+  A(T val, Ts... tail)
+requires(True())
+  {}
+};
+
+A a(42);
+
+// `requires (sizeof(T) == 4)` goes into the deduction guide together with
+// `requires (True())`, while `requires(sizeof...(Ts) == 0)` goes into
+// the template parameter list of the synthesized declaration.
+
+// CHECK-LABEL: Dumping GH60777:::
+// CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> {{.+}} implicit 

+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:20 referenced 
typename depth 0 index 0 T
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:25 typename depth 
0 index 1 ... Ts
+// CHECK-NEXT: |-ParenExpr 0x{{.+}} <{{.+}}> 'bool'
+// CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '=='
+// CHECK-NEXT: |   |-SizeOfPackExpr 0x{{.+}} <{{.+}}> 'unsigned long' 0x{{.+}} 
Ts
+// CHECK-NEXT: |   | `-TemplateArgument type 'Ts...':'type-parameter-0-1...'
+// CHECK-NEXT: |   |   `-PackExpansionType 0x{{.+}} 'Ts...' dependent
+// CHECK-NEXT: |   | `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent 
contains_unexpanded_pack depth 0 index 1 pack
+// CHECK-NEXT: |   |   `-TemplateTypeParm 0x{{.+}} 'Ts'
+// CHECK-NEXT: |   `-ImplicitCastExpr 0x{{.+}} <{{.+}}> 'unsigned long' 

+// CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 0
+// CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> line:{{.+}} implicit 
 'auto (T, Ts...) -> A'
+// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} val 'T'
+// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} <{{.+}}> col:{{.+}} tail 'Ts...' pack
+// CHECK-NEXT: | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '&&'
+// CHECK-NEXT: |   |-ParenExpr 0x{{.+}} <{{.+}}> 'bool'
+// CHECK-NEXT: |   | `-BinaryOperator 0x{{.+}} <{{.+}}> 'bool' '=='
+// CHECK-NEXT: |   |   |-UnaryExprOrTypeTraitExpr 0x{{.+}} <{{.+}}> 'unsigned 
long' sizeof 'T'
+// CHECK-NEXT: |   |   `-ImplicitCastExpr 0x{{.+}} <{{.+}}> 'unsigned long' 

+// CHECK-NEXT: |   | `-IntegerLiteral 0x{{.+}} <{{.+}}> 'int' 4
+// CHECK-NEXT: |   `-ParenExpr 0x{{.+}} <{{.+}}> ''
+// CHECK-NEXT: | `-CallExpr 0x{{.+}} <{{.+}}> ''
+// CHECK-NEXT: |   `-UnresolvedLookupExpr 0x{{.+}}  
'' lvalue (ADL) = 'True' 0x{{.+}}
+// CHECK-NEXT: | `-TemplateArgument type 
'Ts...':'type-parameter-0-1...'
+// CHECK-NEXT: |   `-PackExpansionType 0x{{.+}} 'Ts...' dependent
+// CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'Ts' dependent 
contains_unexpanded_pack depth 0 index 1 pack
+// CHECK-NEXT: |   `-TemplateTypeParm 0x{{.+}} 'Ts'
+
+template 
+struct B {
+  template 
+  B(T val, Ts... tail)
+requires(True())
+  {}
+};
+
+B b(42, 43);
+// expected-error@-1 {{no viable constructor}} \
+//   expected-note@-6 {{constraints not satisfied}} \
+//   expected-note@-5 {{because substituted constraint expression is 
ill-formed}} \
+//   expected-note@-6 {{implicit deduction guide declared as 'template 
 B(T val, Ts ...tail) -> B requires 
(True())'}} \
+//   expected-note@-8 {{function template not viable}} \
+//   expected-note@-8 {{implicit deduction guide declared as 'template 
 B(B) -> B'}}
+
+} // namespace GH60777
+
+// Examples from @hokein.
+namespace GH98592 {
+
+template  concept True = true;
+double arr3[3];
+
+template 
+struct X {
+  const int size;
+  template 
+  constexpr X(T, U(&)[3]) requires True : size(sizeof(T)) {}
+};
+
+template 
+X(T, U (&)[3]) -> X;
+
+constexpr X x(3, arr3);
+
+// The synthesized deduction guide is more constrained than the explicit one.
+static_assert(x.size == 4);
+
+// CHECK-LABEL: Dumping GH98592:::
+// CHECK-NEXT: FunctionTemplateDecl 0x{{.+}} <{{.+}}> col:13 implicit 

+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:17 referenced 
class depth 0 index 0 T
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <{{.+}}> col:19 class depth 0 
index 1 U
+// CHECK-NEXT: |-CXXDeductionGuideDecl 0x{{.+}} <{{.+}}> col:13 implicit 
 'auto (T, U (&)[3]) -> X'
+// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}}  col:16 'T'
+// CHECK-NEXT: | |-ParmVarDecl 0x{{.+}}  col:21 'U (&)[3]'
+// CHECK-NEXT: | `-ConceptSpecializationExpr 0x{{.+}}  'bool' 
Concept 0x{{.+}} 'True'
+// CHECK-NEXT: |   |-ImplicitConceptSpecializationDecl 0x{{.+}} <{{.+}}> col:28
+// CHECK-NEXT: |   | `-TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: |   |   `-TemplateTypeParmType 0x{{.+}} 'type-parameter-0-0' 
dependent depth 0 index 0
+// CHECK-NEXT: |   `-TemplateArgument <{{.+}}> type 'T':'type-parameter-0-0'
+// CHECK-NEXT: | `-TemplateTypeParmType 0x{{.+}} 'T' dependent depth 0 
index 0
+// CHECK-NEXT: |   `-TemplateTypeParm 0x{{.+}} 'T'
+// CHECK-NEXT: `-CXXDeductionGuideDecl 0x{{.+}}  col:13 
implicit used  'auto (int, double

[clang] [Clang] fix range calculation for conditionals with throw expressions (PR #112081)

2024-10-11 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/112081

Fixes #111854

>From 67c41612085489a2a17eec49f98dbfa0e5bb97cf Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 12 Oct 2024 08:27:51 +0300
Subject: [PATCH] [Clang] fix range calculation for conditionals with throw
 expressions

---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/lib/Sema/SemaChecking.cpp | 3 +++
 clang/test/SemaCXX/conditional-expr.cpp | 7 +++
 3 files changed, 11 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 337e3fc10bf49d..2ab13640bfa53c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -512,6 +512,7 @@ Bug Fixes to C++ Support
   and undeclared templates. (#GH107047, #GH49093)
 - Clang no longer crashes when a lambda contains an invalid block declaration 
that contains an unexpanded
   parameter pack. (#GH109148)
+- Fixed assertion failure in range calculations for conditional throw 
expressions (#GH111854)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2bcb930acdcb57..b3d88f053872c1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr 
*E, unsigned MaxWidth,
 return IntRange(BitField->getBitWidthValue(C),
 BitField->getType()->isUnsignedIntegerOrEnumerationType());
 
+  if (GetExprType(E)->isVoidType())
+return IntRange{0, true};
+
   return IntRange::forValueOfType(C, GetExprType(E));
 }
 
diff --git a/clang/test/SemaCXX/conditional-expr.cpp 
b/clang/test/SemaCXX/conditional-expr.cpp
index 01effaa189322b..8f17555fd806ff 100644
--- a/clang/test/SemaCXX/conditional-expr.cpp
+++ b/clang/test/SemaCXX/conditional-expr.cpp
@@ -429,3 +429,10 @@ void g() {
   long e = a = b ? throw 0 : throw 1;
 }
 } // namespace PR46484
+
+namespace GH111854 {
+void f() {
+  (true ? throw 0 : 0) <= 0;  // expected-warning {{relational comparison 
result unused}}
+  (false ? 0 : throw 0) <= 0; // expected-warning {{relational comparison 
result unused}}
+}
+}

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


[clang] [Clang] fix range calculation for conditionals with throw expressions (PR #112081)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #111854

---
Full diff: https://github.com/llvm/llvm-project/pull/112081.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+3) 
- (modified) clang/test/SemaCXX/conditional-expr.cpp (+7) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 337e3fc10bf49d..2ab13640bfa53c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -512,6 +512,7 @@ Bug Fixes to C++ Support
   and undeclared templates. (#GH107047, #GH49093)
 - Clang no longer crashes when a lambda contains an invalid block declaration 
that contains an unexpanded
   parameter pack. (#GH109148)
+- Fixed assertion failure in range calculations for conditional throw 
expressions (#GH111854)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2bcb930acdcb57..b3d88f053872c1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -9827,6 +9827,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr 
*E, unsigned MaxWidth,
 return IntRange(BitField->getBitWidthValue(C),
 BitField->getType()->isUnsignedIntegerOrEnumerationType());
 
+  if (GetExprType(E)->isVoidType())
+return IntRange{0, true};
+
   return IntRange::forValueOfType(C, GetExprType(E));
 }
 
diff --git a/clang/test/SemaCXX/conditional-expr.cpp 
b/clang/test/SemaCXX/conditional-expr.cpp
index 01effaa189322b..8f17555fd806ff 100644
--- a/clang/test/SemaCXX/conditional-expr.cpp
+++ b/clang/test/SemaCXX/conditional-expr.cpp
@@ -429,3 +429,10 @@ void g() {
   long e = a = b ? throw 0 : throw 1;
 }
 } // namespace PR46484
+
+namespace GH111854 {
+void f() {
+  (true ? throw 0 : 0) <= 0;  // expected-warning {{relational comparison 
result unused}}
+  (false ? 0 : throw 0) <= 0; // expected-warning {{relational comparison 
result unused}}
+}
+}

``




https://github.com/llvm/llvm-project/pull/112081
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/96281

>From c08b0a8d34107dc4563c434485ba5f326ab8df93 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 21 Jun 2024 14:28:42 +0800
Subject: [PATCH 01/11] Clang: Support minimumnum and maximumnum intrinsics

We just introduce llvm.minimumnum and llvm.maximumnum intrinsics
support to llvm. Let's support them in Clang.

See: #93033
---
 clang/include/clang/Basic/Builtins.td | 28 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 24 
 .../Tooling/Inclusions/Stdlib/CSymbolMap.inc  |  6 
 .../Inclusions/Stdlib/StdSymbolMap.inc| 18 
 clang/test/CodeGen/builtins.c | 18 
 clang/test/CodeGen/math-libcalls.c| 25 +
 6 files changed, 119 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 7068473a0e12ac..a7e2ee30d9d732 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -215,6 +215,18 @@ def FminF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T, T)";
 }
 
+def FmaximumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fmaximum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
+def FminimumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fminimum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
 def Atan2F128 : Builtin {
   let Spellings = ["__builtin_atan2f128"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
@@ -3728,6 +3740,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fmaximum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
+def FminimumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fminimum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
 def Hypot : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["hypot"];
   let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ff678ee04f9c2a..955d6dd2dd1d5e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2869,6 +2869,30 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Intrinsic::minnum,

Intrinsic::experimental_constrained_minnum));
 
+case Builtin::BIfmaximum_num:
+case Builtin::BIfmaximum_numf:
+case Builtin::BIfmaximum_numl:
+case Builtin::BI__builtin_fmaximum_num:
+case Builtin::BI__builtin_fmaximum_numf:
+case Builtin::BI__builtin_fmaximum_numf16:
+case Builtin::BI__builtin_fmaximum_numl:
+case Builtin::BI__builtin_fmaximum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::maximumnum,
+  Intrinsic::experimental_constrained_maximumnum));
+
+case Builtin::BIfminimum_num:
+case Builtin::BIfminimum_numf:
+case Builtin::BIfminimum_numl:
+case Builtin::BI__builtin_fminimum_num:
+case Builtin::BI__builtin_fminimum_numf:
+case Builtin::BI__builtin_fminimum_numf16:
+case Builtin::BI__builtin_fminimum_numl:
+case Builtin::BI__builtin_fminimum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::minimumnum,
+  Intrinsic::experimental_constrained_minimumnum));
+
 // fmod() is a special-case. It maps to the frem instruction rather than an
 // LLVM intrinsic.
 case Builtin::BIfmod:
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672f..af2dcb632fbb64 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -475,6 +475,12 @@ SYMBOL(fmaxl, None, )
 SYMBOL(fmin, None, )
 SYMBOL(fminf, None, )
 SYMBOL(fminl, None, )
+SYMBOL(fmaximum_num, None, )
+SYMBOL(fmaximum_numf, None, )
+SYMBOL(fmaximum_numfl, None, )
+SYMBOL(fminimum_num, None, )
+SYMBOL(fminimum_numf, None, )
+SYMBOL(fminimum_numl, None, )
 SYMBOL(fmod, None, )
 SYMBOL(fmodf, None, )
 SYMBOL(fmodl, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..442316ce8d4ff6 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/S

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2024-10-11 Thread Younan Zhang via cfe-commits


@@ -1109,12 +1109,50 @@ bool Sema::EnsureTemplateArgumentListConstraints(
   return false;
 }
 
-bool Sema::CheckInstantiatedFunctionTemplateConstraints(
+static bool CheckFunctionConstraintsWithoutInstantiation(
+Sema &SemaRef, SourceLocation PointOfInstantiation,
+FunctionTemplateDecl *Template, ArrayRef TemplateArgs,
+ConstraintSatisfaction &Satisfaction) {
+  SmallVector TemplateAC;
+  Template->getAssociatedConstraints(TemplateAC);
+  if (TemplateAC.empty()) {
+Satisfaction.IsSatisfied = true;
+return false;
+  }
+
+  LocalInstantiationScope Scope(SemaRef);
+
+  FunctionDecl *FD = Template->getTemplatedDecl();
+  // Collect the list of template arguments relative to the 'primary'
+  // template. We need the entire list, since the constraint is completely
+  // uninstantiated at this point.
+  MultiLevelTemplateArgumentList MLTAL =
+  SemaRef.getTemplateInstantiationArgs(FD, /*DC=*/nullptr,
+   /*Final=*/false,
+   /*Innermost=*/TemplateArgs,
+   /*RelativeToPrimary=*/true,
+   
/*ForConstraintInstantiation=*/true);
+
+  std::optional ThisScope;
+  if (auto *Method = dyn_cast(FD))
+ThisScope.emplace(SemaRef, /*Record=*/Method->getParent(),
+  /*ThisQuals=*/Method->getMethodQualifiers());

zyn0217 wrote:

Honestly, I don't know. :(

I copied that from the previous implementation, and I was expecting it to make 
a difference in situations where member function calls are involved in a 
constraint evaluation. But I ran the regression tests with that removed and 
everything seemed fine.

I will have another try on a build without this patch. It could also be the 
case we're missing some tests, but I don't know...

https://github.com/llvm/llvm-project/pull/102857
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2024-10-11 Thread Younan Zhang via cfe-commits


@@ -1109,12 +1109,50 @@ bool Sema::EnsureTemplateArgumentListConstraints(
   return false;
 }
 
-bool Sema::CheckInstantiatedFunctionTemplateConstraints(
+static bool CheckFunctionConstraintsWithoutInstantiation(
+Sema &SemaRef, SourceLocation PointOfInstantiation,
+FunctionTemplateDecl *Template, ArrayRef TemplateArgs,
+ConstraintSatisfaction &Satisfaction) {
+  SmallVector TemplateAC;
+  Template->getAssociatedConstraints(TemplateAC);
+  if (TemplateAC.empty()) {
+Satisfaction.IsSatisfied = true;
+return false;
+  }
+
+  LocalInstantiationScope Scope(SemaRef);
+
+  FunctionDecl *FD = Template->getTemplatedDecl();
+  // Collect the list of template arguments relative to the 'primary'
+  // template. We need the entire list, since the constraint is completely
+  // uninstantiated at this point.
+  MultiLevelTemplateArgumentList MLTAL =
+  SemaRef.getTemplateInstantiationArgs(FD, /*DC=*/nullptr,
+   /*Final=*/false,
+   /*Innermost=*/TemplateArgs,
+   /*RelativeToPrimary=*/true,
+   
/*ForConstraintInstantiation=*/true);
+
+  std::optional ThisScope;

zyn0217 wrote:

Yes, I think so - but I couldn't find a case where that affects anything.

https://github.com/llvm/llvm-project/pull/102857
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [clang][RecordLayoutBuilder] Be stricter about inferring packed-ness in ExternalLayouts (PR #97443)

2024-10-11 Thread Michael Buch via cfe-commits

Michael137 wrote:

ping

(btw, @labath is the alignment miscalculation still causing issues for you 
internally? or did you find a workaround?)

https://github.com/llvm/llvm-project/pull/97443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/111846

From a9e1790691e01892f7e1b17523cd43421445f3ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Thu, 10 Oct 2024 16:28:50 +0200
Subject: [PATCH 1/3] [clang][analyzer] PointerSubChecker should not warn on
 pointers converted to numerical value

Pointer values casted to integer (non-pointer) type should be able to be
subtracted as usual.
---
 clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp | 4 
 clang/test/Analysis/pointer-sub.c   | 7 +++
 2 files changed, 11 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index f0dc5efd75f7d6..7a85d9e2073068 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -61,6 +61,10 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator *B,
   if (LR->getSymbolicBase() || RR->getSymbolicBase())
 return;
 
+  if (!B->getLHS()->getType()->isPointerType() ||
+  !B->getRHS()->getType()->isPointerType())
+return;
+
   const auto *ElemLR = dyn_cast(LR);
   const auto *ElemRR = dyn_cast(RR);
 
diff --git a/clang/test/Analysis/pointer-sub.c 
b/clang/test/Analysis/pointer-sub.c
index 1c9d676ebb8f24..7a1dcb653a28c4 100644
--- a/clang/test/Analysis/pointer-sub.c
+++ b/clang/test/Analysis/pointer-sub.c
@@ -10,6 +10,9 @@ void f1(void) {
   d = &x - (&x + 1); // no-warning
   d = (&x + 0) - &x; // no-warning
   d = (z + 10) - z; // no-warning
+  d = (unsigned long)&y - (unsigned long)&x; // no-warning
+  unsigned long l = 1;
+  d = l - (unsigned long)&y; // no-warning
 }
 
 void f2(void) {
@@ -28,6 +31,10 @@ void f2(void) {
 
   d = (int *)((char *)(&a[4]) + sizeof(int)) - &a[4]; // no-warning (pointers 
into the same array data)
   d = (int *)((char *)(&a[4]) + 1) - &a[4]; // expected-warning{{Subtraction 
of two pointers that}}
+
+  long a1 = (long)&a[1];
+  long b1 = (long)&b[1];
+  d = a1 - b1;
 }
 
 void f3(void) {

From 92fa6a06789a4e3cb4ce9ee552e760f521419bd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Thu, 10 Oct 2024 17:55:21 +0200
Subject: [PATCH 2/3] added test for typedef type

---
 clang/test/Analysis/pointer-sub.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/test/Analysis/pointer-sub.c 
b/clang/test/Analysis/pointer-sub.c
index 7a1dcb653a28c4..8f9d7cb4a2148f 100644
--- a/clang/test/Analysis/pointer-sub.c
+++ b/clang/test/Analysis/pointer-sub.c
@@ -1,5 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=security.PointerSub 
-analyzer-output=text-minimal -verify %s
 
+typedef int * Ptr;
+
 void f1(void) {
   int x, y, z[10];
   int d = &y - &x; // expected-warning{{Subtraction of two pointers that do 
not point into the same array is undefined behavior}}
@@ -13,6 +15,9 @@ void f1(void) {
   d = (unsigned long)&y - (unsigned long)&x; // no-warning
   unsigned long l = 1;
   d = l - (unsigned long)&y; // no-warning
+  Ptr p1 = &x;
+  Ptr p2 = &y;
+  d = p1 - p2; // expected-warning{{Subtraction of two pointers that do not 
point into the same array is undefined behavior}}
 }
 
 void f2(void) {

From 4ce3f4f238f264dcc4f8b1b586cac757c55b63f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Fri, 11 Oct 2024 11:03:53 +0200
Subject: [PATCH 3/3] using 'long long' for pointer address

---
 clang/test/Analysis/pointer-sub.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/test/Analysis/pointer-sub.c 
b/clang/test/Analysis/pointer-sub.c
index 8f9d7cb4a2148f..25fb7f043d468c 100644
--- a/clang/test/Analysis/pointer-sub.c
+++ b/clang/test/Analysis/pointer-sub.c
@@ -12,9 +12,9 @@ void f1(void) {
   d = &x - (&x + 1); // no-warning
   d = (&x + 0) - &x; // no-warning
   d = (z + 10) - z; // no-warning
-  d = (unsigned long)&y - (unsigned long)&x; // no-warning
-  unsigned long l = 1;
-  d = l - (unsigned long)&y; // no-warning
+  d = (long long)&y - (long long)&x; // no-warning
+  long long l = 1;
+  d = l - (long long)&y; // no-warning
   Ptr p1 = &x;
   Ptr p2 = &y;
   d = p1 - p2; // expected-warning{{Subtraction of two pointers that do not 
point into the same array is undefined behavior}}
@@ -37,8 +37,8 @@ void f2(void) {
   d = (int *)((char *)(&a[4]) + sizeof(int)) - &a[4]; // no-warning (pointers 
into the same array data)
   d = (int *)((char *)(&a[4]) + 1) - &a[4]; // expected-warning{{Subtraction 
of two pointers that}}
 
-  long a1 = (long)&a[1];
-  long b1 = (long)&b[1];
+  long long a1 = (long long)&a[1];
+  long long b1 = (long long)&b[1];
   d = a1 - b1;
 }
 

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


[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

> > The change LGTM, I think we can merge it.
> 
> I guess the testcase pointer-sub.c have to be fixed to work on the windows 
> buildbot, also. Right?

Right, thanks for catching my mistake!

https://github.com/llvm/llvm-project/pull/111846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Implement __builtin_assume_aligned (PR #111968)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/111968.diff


5 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+70-1) 
- (modified) clang/lib/AST/ExprConstShared.h (+8) 
- (modified) clang/lib/AST/ExprConstant.cpp (+17-18) 
- (modified) clang/test/Sema/builtin-assume-aligned.c (+2) 
- (modified) clang/test/SemaCXX/builtin-assume-aligned.cpp (+1) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1765193f5bebbc..27ba3a3654faf3 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -38,7 +38,6 @@ static T getParam(const InterpFrame *Frame, unsigned Index) {
   return Frame->getParam(Offset);
 }
 
-// static APSInt getAPSIntParam(InterpStack &Stk, size_t Offset = 0) {
 static APSInt getAPSIntParam(const InterpFrame *Frame, unsigned Index) {
   APSInt R;
   unsigned Offset = Frame->getFunction()->getParamOffset(Index);
@@ -1162,6 +1161,71 @@ static bool 
interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
   return false;
 }
 
+/// __builtin_assume_aligned(Ptr, Alignment[, ExtraOffset])
+static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const Function *Func,
+   const CallExpr *Call) {
+  assert(Call->getNumArgs() == 2 || Call->getNumArgs() == 3);
+
+  // Might be called with function pointers in C.
+  std::optional PtrT = S.Ctx.classify(Call->getArg(0));
+  if (PtrT != PT_Ptr)
+return false;
+
+  unsigned ArgSize = callArgSize(S, Call);
+  const Pointer &Ptr = S.Stk.peek(ArgSize);
+  std::optional ExtraOffset;
+  APSInt Alignment;
+  if (Call->getNumArgs() == 2) {
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)));
+  } else {
+PrimType AlignmentT = *S.Ctx.classify(Call->getArg(1));
+PrimType ExtraOffsetT = *S.Ctx.classify(Call->getArg(2));
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)),
+ align(primSize(AlignmentT)) +
+ align(primSize(ExtraOffsetT)));
+ExtraOffset = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(2)));
+  }
+
+  CharUnits Align = CharUnits::fromQuantity(Alignment.getZExtValue());
+
+  // If there is a base object, then it must have the correct alignment.
+  if (Ptr.isBlockPointer()) {
+CharUnits BaseAlignment;
+if (const auto *VD = Ptr.getDeclDesc()->asValueDecl())
+  BaseAlignment = S.getASTContext().getDeclAlign(VD);
+else if (const auto *E = Ptr.getDeclDesc()->asExpr())
+  BaseAlignment = GetAlignOfExpr(S.getASTContext(), E, UETT_AlignOf);
+
+if (BaseAlignment < Align) {
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 0 << BaseAlignment.getQuantity() << Align.getQuantity();
+  return false;
+}
+  }
+
+  APValue AV = Ptr.toAPValue(S.getASTContext());
+  CharUnits AVOffset = AV.getLValueOffset();
+  if (ExtraOffset)
+AVOffset += CharUnits::fromQuantity(-ExtraOffset->getZExtValue());
+  if (AVOffset.alignTo(Align) != AVOffset) {
+if (Ptr.isBlockPointer())
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 1 << AVOffset.getQuantity() << Align.getQuantity();
+else
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_value_insufficient_alignment)
+  << AVOffset.getQuantity() << Align.getQuantity();
+return false;
+  }
+
+  S.Stk.push(Ptr);
+  return true;
+}
+
 static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
@@ -1905,6 +1969,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
   return false;
 break;
 
+  case Builtin::BI__builtin_assume_aligned:
+if (!interp__builtin_assume_aligned(S, OpPC, Frame, F, Call))
+  return false;
+break;
+
   case clang::X86::BI__builtin_ia32_bextr_u32:
   case clang::X86::BI__builtin_ia32_bextr_u64:
   case clang::X86::BI__builtin_ia32_bextri_u32:
diff --git a/clang/lib/AST/ExprConstShared.h b/clang/lib/AST/ExprConstShared.h
index efe8ee986d29b3..401ae629c86bfd 100644
--- a/clang/lib/AST/ExprConstShared.h
+++ b/clang/lib/AST/ExprConstShared.h
@@ -14,12 +14,17 @@
 #ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 #define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 
+#include "clang/Basic/TypeTraits.h"
+
 namespace llvm {
 class APFloat;
 }
 namespace clang {
 class QualType;
 class LangOptions;
+class ASTContext;
+class CharUnits;
+class Expr;
 } // namespace clang
 using namespace clang;
 /// Values returned by __builtin_classify_type

[clang] [clang][bytecode] Implement __builtin_assume_aligned (PR #111968)

2024-10-11 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/111968

None

>From ad01583c5a32d9d3d19d1a0bb459a503c1bccecc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 11 Oct 2024 10:34:52 +0200
Subject: [PATCH] [clang][bytecode] Implement __builtin_assume_aligned

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 71 ++-
 clang/lib/AST/ExprConstShared.h   |  8 +++
 clang/lib/AST/ExprConstant.cpp| 35 +
 clang/test/Sema/builtin-assume-aligned.c  |  2 +
 clang/test/SemaCXX/builtin-assume-aligned.cpp |  1 +
 5 files changed, 98 insertions(+), 19 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1765193f5bebbc..27ba3a3654faf3 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -38,7 +38,6 @@ static T getParam(const InterpFrame *Frame, unsigned Index) {
   return Frame->getParam(Offset);
 }
 
-// static APSInt getAPSIntParam(InterpStack &Stk, size_t Offset = 0) {
 static APSInt getAPSIntParam(const InterpFrame *Frame, unsigned Index) {
   APSInt R;
   unsigned Offset = Frame->getFunction()->getParamOffset(Index);
@@ -1162,6 +1161,71 @@ static bool 
interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
   return false;
 }
 
+/// __builtin_assume_aligned(Ptr, Alignment[, ExtraOffset])
+static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const Function *Func,
+   const CallExpr *Call) {
+  assert(Call->getNumArgs() == 2 || Call->getNumArgs() == 3);
+
+  // Might be called with function pointers in C.
+  std::optional PtrT = S.Ctx.classify(Call->getArg(0));
+  if (PtrT != PT_Ptr)
+return false;
+
+  unsigned ArgSize = callArgSize(S, Call);
+  const Pointer &Ptr = S.Stk.peek(ArgSize);
+  std::optional ExtraOffset;
+  APSInt Alignment;
+  if (Call->getNumArgs() == 2) {
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)));
+  } else {
+PrimType AlignmentT = *S.Ctx.classify(Call->getArg(1));
+PrimType ExtraOffsetT = *S.Ctx.classify(Call->getArg(2));
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)),
+ align(primSize(AlignmentT)) +
+ align(primSize(ExtraOffsetT)));
+ExtraOffset = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(2)));
+  }
+
+  CharUnits Align = CharUnits::fromQuantity(Alignment.getZExtValue());
+
+  // If there is a base object, then it must have the correct alignment.
+  if (Ptr.isBlockPointer()) {
+CharUnits BaseAlignment;
+if (const auto *VD = Ptr.getDeclDesc()->asValueDecl())
+  BaseAlignment = S.getASTContext().getDeclAlign(VD);
+else if (const auto *E = Ptr.getDeclDesc()->asExpr())
+  BaseAlignment = GetAlignOfExpr(S.getASTContext(), E, UETT_AlignOf);
+
+if (BaseAlignment < Align) {
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 0 << BaseAlignment.getQuantity() << Align.getQuantity();
+  return false;
+}
+  }
+
+  APValue AV = Ptr.toAPValue(S.getASTContext());
+  CharUnits AVOffset = AV.getLValueOffset();
+  if (ExtraOffset)
+AVOffset += CharUnits::fromQuantity(-ExtraOffset->getZExtValue());
+  if (AVOffset.alignTo(Align) != AVOffset) {
+if (Ptr.isBlockPointer())
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 1 << AVOffset.getQuantity() << Align.getQuantity();
+else
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_value_insufficient_alignment)
+  << AVOffset.getQuantity() << Align.getQuantity();
+return false;
+  }
+
+  S.Stk.push(Ptr);
+  return true;
+}
+
 static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
@@ -1905,6 +1969,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
   return false;
 break;
 
+  case Builtin::BI__builtin_assume_aligned:
+if (!interp__builtin_assume_aligned(S, OpPC, Frame, F, Call))
+  return false;
+break;
+
   case clang::X86::BI__builtin_ia32_bextr_u32:
   case clang::X86::BI__builtin_ia32_bextr_u64:
   case clang::X86::BI__builtin_ia32_bextri_u32:
diff --git a/clang/lib/AST/ExprConstShared.h b/clang/lib/AST/ExprConstShared.h
index efe8ee986d29b3..401ae629c86bfd 100644
--- a/clang/lib/AST/ExprConstShared.h
+++ b/clang/lib/AST/ExprConstShared.h
@@ -14,12 +14,17 @@
 #ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 #define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 
+#include "clang/Basic/TypeTraits.h"
+
 namespace llvm {
 class APFloat;
 }
 namespace clang {
 clas

[clang] [clang-tools-extra] Add code completion for C++20 keywords. (PR #107982)

2024-10-11 Thread via cfe-commits

https://github.com/16bit-ykiko updated 
https://github.com/llvm/llvm-project/pull/107982

>From fedea9e4fd57b618fe341e0c30982bff0f098c52 Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 14:59:10 +0800
Subject: [PATCH 01/10] add co_return, co_await, co_yield, consteval,
 constinit, concept, requires, char8_t.

---
 clang/lib/Sema/SemaCodeComplete.cpp | 61 +
 1 file changed, 61 insertions(+)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 88d4732c7d5c6a..d8f6b1dada942a 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1837,6 +1837,11 @@ static void AddTypeSpecifierResults(const LangOptions 
&LangOpts,
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
   Results.AddResult(Result(Builder.TakeString()));
 }
+
+if(LangOpts.CPlusPlus20){
+  Results.AddResult(Result("char8_t", CCP_Type));
+  Results.AddResult(Result("concept", CCP_Keyword));
+}
   } else
 Results.AddResult(Result("__auto_type", CCP_Type));
 
@@ -1889,6 +1894,10 @@ 
AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
 Results.AddResult(Result("constexpr"));
 Results.AddResult(Result("thread_local"));
   }
+
+  if (LangOpts.CPlusPlus20) {
+Results.AddResult(Result("constinit"));
+  }
 }
 
 static void
@@ -1912,6 +1921,9 @@ 
AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
   case SemaCodeCompletion::PCC_Template:
 if (LangOpts.CPlusPlus || LangOpts.C99)
   Results.AddResult(Result("inline"));
+
+if (LangOpts.CPlusPlus20)
+  Results.AddResult(Result("consteval"));
 break;
 
   case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
@@ -2487,6 +2499,14 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
   Builder.AddPlaceholderChunk("expression");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
+  // "co_return expression ;" for coroutines(C++20).
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+Builder.AddTypedTextChunk("co_return");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+Results.AddResult(Result(Builder.TakeString()));
+  }
   // When boolean, also add 'return true;' and 'return false;'.
   if (ReturnType->isBooleanType()) {
 Builder.AddTypedTextChunk("return true");
@@ -2707,6 +2727,47 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
 Builder.AddChunk(CodeCompletionString::CK_RightParen);
 Results.AddResult(Result(Builder.TakeString()));
   }
+
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+// co_await expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_await");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// co_yield expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_yield");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// requires (parameters) { requirements }
+Builder.AddResultTypeChunk("bool");
+Builder.AddTypedTextChunk("requires");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+Builder.AddPlaceholderChunk("parameters");
+Builder.AddChunk(CodeCompletionString::CK_RightParen);
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddPlaceholderChunk("requirements");
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+Results.AddResult(Result(Builder.TakeString()));
+
+if(llvm::isa(SemaRef.CurContext)){
+  // requires expression ;
+  Builder.AddResultTypeChunk("");
+  Builder.AddTypedTextChunk("requires");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("expression");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(Result(Builder.TakeString()));
+}
+  }
 }
 
 if (SemaRef.getLangOpts().ObjC) {

>From 36a0db2b827baaabe17c5cd7b576802be586c69c Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 15:50:04 +0800
Subject: [PATCH 02/10] make concept and requires more sensitive to context.

--

[clang] [clang][bytecode] Use PredefinedExpr as base for its variable (PR #111956)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This fixes the error message generated.

---
Full diff: https://github.com/llvm/llvm-project/pull/111956.diff


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5) 
- (modified) clang/lib/AST/ByteCode/Program.cpp (+9-6) 
- (modified) clang/lib/AST/ByteCode/Program.h (+2-1) 
- (modified) clang/test/AST/ByteCode/cxx1z.cpp (+4) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 0a3b38b0dc6e57..b2663714340b93 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2869,6 +2869,11 @@ bool Compiler::VisitPredefinedExpr(const 
PredefinedExpr *E) {
   if (DiscardResult)
 return true;
 
+  if (!Initializing) {
+unsigned StringIndex = P.createGlobalString(E->getFunctionName(), E);
+return this->emitGetPtrGlobal(StringIndex, E);
+  }
+
   return this->delegate(E->getFunctionName());
 }
 
diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 23245a66b578ae..cd2665f755d7cb 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -33,7 +33,7 @@ const void *Program::getNativePointer(unsigned Idx) {
   return NativePointers[Idx];
 }
 
-unsigned Program::createGlobalString(const StringLiteral *S) {
+unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) 
{
   const size_t CharWidth = S->getCharByteWidth();
   const size_t BitWidth = CharWidth * Ctx.getCharBit();
 
@@ -52,12 +52,15 @@ unsigned Program::createGlobalString(const StringLiteral 
*S) {
 llvm_unreachable("unsupported character width");
   }
 
+  if (!Base)
+Base = S;
+
   // Create a descriptor for the string.
-  Descriptor *Desc =
-  allocateDescriptor(S, CharType, Descriptor::GlobalMD, S->getLength() + 1,
- /*isConst=*/true,
- /*isTemporary=*/false,
- /*isMutable=*/false);
+  Descriptor *Desc = allocateDescriptor(Base, CharType, Descriptor::GlobalMD,
+S->getLength() + 1,
+/*isConst=*/true,
+/*isTemporary=*/false,
+/*isMutable=*/false);
 
   // Allocate storage for the string.
   // The byte length does not include the null terminator.
diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h
index be84c40714a60b..f676672fb7ced5 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -64,7 +64,8 @@ class Program final {
   const void *getNativePointer(unsigned Idx);
 
   /// Emits a string literal among global data.
-  unsigned createGlobalString(const StringLiteral *S);
+  unsigned createGlobalString(const StringLiteral *S,
+  const Expr *Base = nullptr);
 
   /// Returns a pointer to a global.
   Pointer getPtrGlobal(unsigned Idx) const;
diff --git a/clang/test/AST/ByteCode/cxx1z.cpp 
b/clang/test/AST/ByteCode/cxx1z.cpp
index 1a06597fa348fe..57f99235a2b201 100644
--- a/clang/test/AST/ByteCode/cxx1z.cpp
+++ b/clang/test/AST/ByteCode/cxx1z.cpp
@@ -13,3 +13,7 @@ namespace Temp {
 
 char arr[3];
 A d; // both-error {{refers to subobject '&arr[1]'}}
+
+void Func() {
+  A a; // both-error {{pointer to subobject of 
predefined '__func__' variable}}
+}

``




https://github.com/llvm/llvm-project/pull/111956
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Daniel Kiss (DanielKristofKiss)


Changes

On Windows there is no platform support for ifunc but we could lower them to 
global function pointers.
This also enables FMV for Windows with Clang and Compiler-rt.

Depends on #111961 and #111960

---
Full diff: https://github.com/llvm/llvm-project/pull/111962.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+4-1) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+4-2) 
- (modified) clang/include/clang/Basic/TargetInfo.h (+4) 
- (modified) clang/test/CodeGen/attr-ifunc.c (+3-1) 
- (added) clang/test/CodeGen/ifunc-win.c (+69) 
- (modified) clang/test/CodeGen/ifunc.c (+5) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+6) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ec3d6e0079f630..c0a540d3890487 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -477,6 +477,9 @@ def TargetELF : TargetSpec {
 def TargetELFOrMachO : TargetSpec {
   let ObjectFormats = ["ELF", "MachO"];
 }
+def TargetIFuncSupport : TargetSpec {
+  let CustomCode = [{ Target.supportsIFunc() }];
+}
 def TargetWindowsArm64EC : TargetSpec {
   let CustomCode = [{ Target.getTriple().isWindowsArm64EC() }];
 }
@@ -1847,7 +1850,7 @@ def IBOutletCollection : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def IFunc : Attr, TargetSpecificAttr {
+def IFunc : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"ifunc">];
   let Args = [StringArgument<"Resolver">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1512e22ee2dd4..5179f30400345d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5800,8 +5800,10 @@ Not all targets support this attribute. ELF target 
support depends on both the
 linker and runtime linker, and is available in at least lld 4.0 and later,
 binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later.
 Mach-O targets support it, but with slightly different semantics: the resolver
-is run at first call, instead of at load time by the runtime linker. Targets
-other than ELF and Mach-O currently do not support this attribute.
+is run at first call, instead of at load time by the runtime linker. Windows on
+AArch64 the ``ifunc`` is replaced with global function pointer and the call is
+replaced by an indirect call. The pointer is initialized by a contructor that
+calls the resolver. Other targets currently do not support this attribute.
   }];
 }
 
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 57783850606290..9d2d7be7cfbd78 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1505,6 +1505,10 @@ class TargetInfo : public TransferrableTargetInfo,
   bool supportsIFunc() const {
 if (getTriple().isOSBinFormatMachO())
   return true;
+if (getTriple().isOSWindows() && getTriple().isAArch64())
+  return true;
+if (getTriple().getArch() == llvm::Triple::ArchType::avr)
+  return true;
 return getTriple().isOSBinFormatELF() &&
((getTriple().isOSLinux() && !getTriple().isMusl()) ||
 getTriple().isOSFreeBSD());
diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 24d66433ae090f..c9e70b17a83023 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -2,8 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvcu -verify -emit-llvm-only %s
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__aarch64__)
 void foo(void) {}
 void bar(void) __attribute__((ifunc("foo")));
 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
diff --git a/clang/test/CodeGen/ifunc-win.c b/clang/test/CodeGen/ifunc-win.c
new file mode 100644
index 00..d8a94df90fc603
--- /dev/null
+++ b/clang/test/CodeGen/ifunc-win.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -O2 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+
+/// The ifunc is emitted before its resolver.
+int foo(int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static

[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Daniel Kiss (DanielKristofKiss)


Changes

On Windows there is no platform support for ifunc but we could lower them to 
global function pointers.
This also enables FMV for Windows with Clang and Compiler-rt.

Depends on #111961 and #111960

---
Full diff: https://github.com/llvm/llvm-project/pull/111962.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+4-1) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+4-2) 
- (modified) clang/include/clang/Basic/TargetInfo.h (+4) 
- (modified) clang/test/CodeGen/attr-ifunc.c (+3-1) 
- (added) clang/test/CodeGen/ifunc-win.c (+69) 
- (modified) clang/test/CodeGen/ifunc.c (+5) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+6) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ec3d6e0079f630..c0a540d3890487 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -477,6 +477,9 @@ def TargetELF : TargetSpec {
 def TargetELFOrMachO : TargetSpec {
   let ObjectFormats = ["ELF", "MachO"];
 }
+def TargetIFuncSupport : TargetSpec {
+  let CustomCode = [{ Target.supportsIFunc() }];
+}
 def TargetWindowsArm64EC : TargetSpec {
   let CustomCode = [{ Target.getTriple().isWindowsArm64EC() }];
 }
@@ -1847,7 +1850,7 @@ def IBOutletCollection : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def IFunc : Attr, TargetSpecificAttr {
+def IFunc : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"ifunc">];
   let Args = [StringArgument<"Resolver">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1512e22ee2dd4..5179f30400345d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5800,8 +5800,10 @@ Not all targets support this attribute. ELF target 
support depends on both the
 linker and runtime linker, and is available in at least lld 4.0 and later,
 binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later.
 Mach-O targets support it, but with slightly different semantics: the resolver
-is run at first call, instead of at load time by the runtime linker. Targets
-other than ELF and Mach-O currently do not support this attribute.
+is run at first call, instead of at load time by the runtime linker. Windows on
+AArch64 the ``ifunc`` is replaced with global function pointer and the call is
+replaced by an indirect call. The pointer is initialized by a contructor that
+calls the resolver. Other targets currently do not support this attribute.
   }];
 }
 
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 57783850606290..9d2d7be7cfbd78 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1505,6 +1505,10 @@ class TargetInfo : public TransferrableTargetInfo,
   bool supportsIFunc() const {
 if (getTriple().isOSBinFormatMachO())
   return true;
+if (getTriple().isOSWindows() && getTriple().isAArch64())
+  return true;
+if (getTriple().getArch() == llvm::Triple::ArchType::avr)
+  return true;
 return getTriple().isOSBinFormatELF() &&
((getTriple().isOSLinux() && !getTriple().isMusl()) ||
 getTriple().isOSFreeBSD());
diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 24d66433ae090f..c9e70b17a83023 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -2,8 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvcu -verify -emit-llvm-only %s
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__aarch64__)
 void foo(void) {}
 void bar(void) __attribute__((ifunc("foo")));
 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
diff --git a/clang/test/CodeGen/ifunc-win.c b/clang/test/CodeGen/ifunc-win.c
new file mode 100644
index 00..d8a94df90fc603
--- /dev/null
+++ b/clang/test/CodeGen/ifunc-win.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -O2 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+
+/// The ifunc is emitted before its resolver.
+int foo(int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static int f2(in

[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-11 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/111962

On Windows there is no platform support for ifunc but we could lower them to 
global function pointers.
This also enables FMV for Windows with Clang and Compiler-rt.

Depends on #111961 and #111960

>From 122864160f098392c4afd1728eb924e7e26e70d9 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Tue, 8 Oct 2024 22:58:37 +0200
Subject: [PATCH] Add ifuncs support for Windows.

---
 clang/include/clang/Basic/Attr.td |  5 +-
 clang/include/clang/Basic/AttrDocs.td |  6 +-
 clang/include/clang/Basic/TargetInfo.h|  4 ++
 clang/test/CodeGen/attr-ifunc.c   |  4 +-
 clang/test/CodeGen/ifunc-win.c| 69 +++
 clang/test/CodeGen/ifunc.c|  5 ++
 .../Target/AArch64/AArch64TargetMachine.cpp   |  6 ++
 7 files changed, 95 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CodeGen/ifunc-win.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ec3d6e0079f630..c0a540d3890487 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -477,6 +477,9 @@ def TargetELF : TargetSpec {
 def TargetELFOrMachO : TargetSpec {
   let ObjectFormats = ["ELF", "MachO"];
 }
+def TargetIFuncSupport : TargetSpec {
+  let CustomCode = [{ Target.supportsIFunc() }];
+}
 def TargetWindowsArm64EC : TargetSpec {
   let CustomCode = [{ Target.getTriple().isWindowsArm64EC() }];
 }
@@ -1847,7 +1850,7 @@ def IBOutletCollection : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def IFunc : Attr, TargetSpecificAttr {
+def IFunc : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"ifunc">];
   let Args = [StringArgument<"Resolver">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1512e22ee2dd4..5179f30400345d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5800,8 +5800,10 @@ Not all targets support this attribute. ELF target 
support depends on both the
 linker and runtime linker, and is available in at least lld 4.0 and later,
 binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later.
 Mach-O targets support it, but with slightly different semantics: the resolver
-is run at first call, instead of at load time by the runtime linker. Targets
-other than ELF and Mach-O currently do not support this attribute.
+is run at first call, instead of at load time by the runtime linker. Windows on
+AArch64 the ``ifunc`` is replaced with global function pointer and the call is
+replaced by an indirect call. The pointer is initialized by a contructor that
+calls the resolver. Other targets currently do not support this attribute.
   }];
 }
 
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 57783850606290..9d2d7be7cfbd78 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1505,6 +1505,10 @@ class TargetInfo : public TransferrableTargetInfo,
   bool supportsIFunc() const {
 if (getTriple().isOSBinFormatMachO())
   return true;
+if (getTriple().isOSWindows() && getTriple().isAArch64())
+  return true;
+if (getTriple().getArch() == llvm::Triple::ArchType::avr)
+  return true;
 return getTriple().isOSBinFormatELF() &&
((getTriple().isOSLinux() && !getTriple().isMusl()) ||
 getTriple().isOSFreeBSD());
diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 24d66433ae090f..c9e70b17a83023 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -2,8 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvcu -verify -emit-llvm-only %s
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__aarch64__)
 void foo(void) {}
 void bar(void) __attribute__((ifunc("foo")));
 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
diff --git a/clang/test/CodeGen/ifunc-win.c b/clang/test/CodeGen/ifunc-win.c
new file mode 100644
index 00..d8a94df90fc603
--- /dev/null
+++ b/clang/test/CodeGen/ifunc-win.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -O2 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 
-emit-llvm -o - %s | FileChe

[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-11 Thread Lu Weining via cfe-commits


@@ -141,6 +141,22 @@ enum NodeType : unsigned {
   VALL_NONZERO,
   VANY_NONZERO,
 
+  // Floating point approximate reciprocal operation
+  FRECIPE_S,

SixWeining wrote:

They are not the same. The iocsrrd_* instructions have same operand type `GPR` 
but frecipe_* instructions have different types: FPR32/FPR64/v8f32/...

Is it right? @wangleiat 

https://github.com/llvm/llvm-project/pull/109917
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] Add code completion for C++20 keywords. (PR #107982)

2024-10-11 Thread via cfe-commits

https://github.com/16bit-ykiko updated 
https://github.com/llvm/llvm-project/pull/107982

>From fedea9e4fd57b618fe341e0c30982bff0f098c52 Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 14:59:10 +0800
Subject: [PATCH 01/11] add co_return, co_await, co_yield, consteval,
 constinit, concept, requires, char8_t.

---
 clang/lib/Sema/SemaCodeComplete.cpp | 61 +
 1 file changed, 61 insertions(+)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 88d4732c7d5c6a..d8f6b1dada942a 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1837,6 +1837,11 @@ static void AddTypeSpecifierResults(const LangOptions 
&LangOpts,
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
   Results.AddResult(Result(Builder.TakeString()));
 }
+
+if(LangOpts.CPlusPlus20){
+  Results.AddResult(Result("char8_t", CCP_Type));
+  Results.AddResult(Result("concept", CCP_Keyword));
+}
   } else
 Results.AddResult(Result("__auto_type", CCP_Type));
 
@@ -1889,6 +1894,10 @@ 
AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
 Results.AddResult(Result("constexpr"));
 Results.AddResult(Result("thread_local"));
   }
+
+  if (LangOpts.CPlusPlus20) {
+Results.AddResult(Result("constinit"));
+  }
 }
 
 static void
@@ -1912,6 +1921,9 @@ 
AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
   case SemaCodeCompletion::PCC_Template:
 if (LangOpts.CPlusPlus || LangOpts.C99)
   Results.AddResult(Result("inline"));
+
+if (LangOpts.CPlusPlus20)
+  Results.AddResult(Result("consteval"));
 break;
 
   case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
@@ -2487,6 +2499,14 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
   Builder.AddPlaceholderChunk("expression");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
+  // "co_return expression ;" for coroutines(C++20).
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+Builder.AddTypedTextChunk("co_return");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+Results.AddResult(Result(Builder.TakeString()));
+  }
   // When boolean, also add 'return true;' and 'return false;'.
   if (ReturnType->isBooleanType()) {
 Builder.AddTypedTextChunk("return true");
@@ -2707,6 +2727,47 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
 Builder.AddChunk(CodeCompletionString::CK_RightParen);
 Results.AddResult(Result(Builder.TakeString()));
   }
+
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+// co_await expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_await");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// co_yield expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_yield");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// requires (parameters) { requirements }
+Builder.AddResultTypeChunk("bool");
+Builder.AddTypedTextChunk("requires");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+Builder.AddPlaceholderChunk("parameters");
+Builder.AddChunk(CodeCompletionString::CK_RightParen);
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddPlaceholderChunk("requirements");
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+Results.AddResult(Result(Builder.TakeString()));
+
+if(llvm::isa(SemaRef.CurContext)){
+  // requires expression ;
+  Builder.AddResultTypeChunk("");
+  Builder.AddTypedTextChunk("requires");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("expression");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(Result(Builder.TakeString()));
+}
+  }
 }
 
 if (SemaRef.getLangOpts().ObjC) {

>From 36a0db2b827baaabe17c5cd7b576802be586c69c Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 15:50:04 +0800
Subject: [PATCH 02/11] make concept and requires more sensitive to context.

--

[clang] 65780f4 - [C++20][Modules] Allow import for a header unit after #pragma (#111662)

2024-10-11 Thread via cfe-commits

Author: Dmitry Polukhin
Date: 2024-10-11T08:23:35+01:00
New Revision: 65780f4d8e34461e6bd3baf2ff77496f97874b94

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

LOG: [C++20][Modules] Allow import for a header unit after #pragma (#111662)

Summary:
`#pragma` and headers that finish with them shouldn't prevent `import
"header_unit.h"` syntax.

Test Plan: check-clang

Added: 
clang/test/Headers/import_header_unit_after_pragma.cpp

Modified: 
clang/lib/Lex/Preprocessor.cpp

Removed: 




diff  --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index f0b4593e0cc22e..ecc5166d7b814c 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -902,6 +902,10 @@ void Preprocessor::Lex(Token &Result) {
 case tok::r_brace:
   StdCXXImportSeqState.handleCloseBrace();
   break;
+#define PRAGMA_ANNOTATION(X) case tok::annot_##X:
+// For `#pragma ...` mimic ';'.
+#include "clang/Basic/TokenKinds.def"
+#undef PRAGMA_ANNOTATION
 // This token is injected to represent the translation of '#include "a.h"'
 // into "import a.h;". Mimic the notional ';'.
 case tok::annot_module_include:

diff  --git a/clang/test/Headers/import_header_unit_after_pragma.cpp 
b/clang/test/Headers/import_header_unit_after_pragma.cpp
new file mode 100644
index 00..b1ad3b07fea29c
--- /dev/null
+++ b/clang/test/Headers/import_header_unit_after_pragma.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -fR %t
+// RUN: split-file %s %t
+// RUN: cd %t
+// RUN: %clang_cc1 -verify -std=c++20 -emit-header-unit -xc++-user-header bz0.h
+// RUN: %clang_cc1 -verify -std=c++20 -emit-header-unit -xc++-user-header 
-fmodule-file=bz0.pcm bz.cpp
+
+//--- compare
+#pragma GCC visibility push(default)
+#pragma GCC visibility pop
+
+//--- bz0.h
+#include "compare"
+// expected-no-diagnostics
+
+//--- bz.cpp
+#include "compare"
+
+import "bz0.h"; // expected-warning {{the implementation of header units is in 
an experimental phase}}



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


[clang] [C++20][Modules] Allow import for a header unit after #pragma (PR #111662)

2024-10-11 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin closed 
https://github.com/llvm/llvm-project/pull/111662
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ff04bb8 - [clang][bytecode] Use PredefinedExpr as base for its variable (#111956)

2024-10-11 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-10-11T09:31:49+02:00
New Revision: ff04bb8f4064274aedcb6e916079132ab6042a10

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

LOG: [clang][bytecode] Use PredefinedExpr as base for its variable (#111956)

This fixes the error message generated.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Program.cpp
clang/lib/AST/ByteCode/Program.h
clang/test/AST/ByteCode/cxx1z.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 0a3b38b0dc6e57..b2663714340b93 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2869,6 +2869,11 @@ bool Compiler::VisitPredefinedExpr(const 
PredefinedExpr *E) {
   if (DiscardResult)
 return true;
 
+  if (!Initializing) {
+unsigned StringIndex = P.createGlobalString(E->getFunctionName(), E);
+return this->emitGetPtrGlobal(StringIndex, E);
+  }
+
   return this->delegate(E->getFunctionName());
 }
 

diff  --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 23245a66b578ae..cd2665f755d7cb 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -33,7 +33,7 @@ const void *Program::getNativePointer(unsigned Idx) {
   return NativePointers[Idx];
 }
 
-unsigned Program::createGlobalString(const StringLiteral *S) {
+unsigned Program::createGlobalString(const StringLiteral *S, const Expr *Base) 
{
   const size_t CharWidth = S->getCharByteWidth();
   const size_t BitWidth = CharWidth * Ctx.getCharBit();
 
@@ -52,12 +52,15 @@ unsigned Program::createGlobalString(const StringLiteral 
*S) {
 llvm_unreachable("unsupported character width");
   }
 
+  if (!Base)
+Base = S;
+
   // Create a descriptor for the string.
-  Descriptor *Desc =
-  allocateDescriptor(S, CharType, Descriptor::GlobalMD, S->getLength() + 1,
- /*isConst=*/true,
- /*isTemporary=*/false,
- /*isMutable=*/false);
+  Descriptor *Desc = allocateDescriptor(Base, CharType, Descriptor::GlobalMD,
+S->getLength() + 1,
+/*isConst=*/true,
+/*isTemporary=*/false,
+/*isMutable=*/false);
 
   // Allocate storage for the string.
   // The byte length does not include the null terminator.

diff  --git a/clang/lib/AST/ByteCode/Program.h 
b/clang/lib/AST/ByteCode/Program.h
index be84c40714a60b..f676672fb7ced5 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -64,7 +64,8 @@ class Program final {
   const void *getNativePointer(unsigned Idx);
 
   /// Emits a string literal among global data.
-  unsigned createGlobalString(const StringLiteral *S);
+  unsigned createGlobalString(const StringLiteral *S,
+  const Expr *Base = nullptr);
 
   /// Returns a pointer to a global.
   Pointer getPtrGlobal(unsigned Idx) const;

diff  --git a/clang/test/AST/ByteCode/cxx1z.cpp 
b/clang/test/AST/ByteCode/cxx1z.cpp
index 1a06597fa348fe..57f99235a2b201 100644
--- a/clang/test/AST/ByteCode/cxx1z.cpp
+++ b/clang/test/AST/ByteCode/cxx1z.cpp
@@ -13,3 +13,7 @@ namespace Temp {
 
 char arr[3];
 A d; // both-error {{refers to subobject '&arr[1]'}}
+
+void Func() {
+  A a; // both-error {{pointer to subobject of 
predefined '__func__' variable}}
+}



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


[clang] [clang][bytecode] Use PredefinedExpr as base for its variable (PR #111956)

2024-10-11 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr closed 
https://github.com/llvm/llvm-project/pull/111956
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ExprConstant] Remove an outdated TODO comment (PR #111959)

2024-10-11 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/111959

Seems like passing the quantities directly seems to work fine.

>From b76af9501358a60b7aaa62c5710dab6c65168bca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 11 Oct 2024 09:33:13 +0200
Subject: [PATCH] [clang][ExprConstant] Remove an outdated TODO comment

Seems like passing the quantities directly seems to work fine.
---
 clang/lib/AST/ExprConstant.cpp | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 4d5af96093cfeb..06e653f96d6de1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9768,11 +9768,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
   if (BaseAlignment < Align) {
 Result.Designator.setInvalid();
-// FIXME: Add support to Diagnostic for long / long long.
-CCEDiag(E->getArg(0),
-diag::note_constexpr_baa_insufficient_alignment) << 0
-  << (unsigned)BaseAlignment.getQuantity()
-  << (unsigned)Align.getQuantity();
+CCEDiag(E->getArg(0), diag::note_constexpr_baa_insufficient_alignment)
+<< 0 << BaseAlignment.getQuantity() << Align.getQuantity();
 return false;
   }
 }
@@ -9783,11 +9780,11 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
   (OffsetResult.Base
? CCEDiag(E->getArg(0),
- diag::note_constexpr_baa_insufficient_alignment) << 1
+ diag::note_constexpr_baa_insufficient_alignment)
+ << 1
: CCEDiag(E->getArg(0),
  diag::note_constexpr_baa_value_insufficient_alignment))
-<< (int)OffsetResult.Offset.getQuantity()
-<< (unsigned)Align.getQuantity();
+  << OffsetResult.Offset.getQuantity() << Align.getQuantity();
   return false;
 }
 

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


[clang] [clang][ExprConstant] Remove an outdated TODO comment (PR #111959)

2024-10-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Seems like passing the quantities directly seems to work fine.

---
Full diff: https://github.com/llvm/llvm-project/pull/111959.diff


1 Files Affected:

- (modified) clang/lib/AST/ExprConstant.cpp (+5-8) 


``diff
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 4d5af96093cfeb..06e653f96d6de1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9768,11 +9768,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
   if (BaseAlignment < Align) {
 Result.Designator.setInvalid();
-// FIXME: Add support to Diagnostic for long / long long.
-CCEDiag(E->getArg(0),
-diag::note_constexpr_baa_insufficient_alignment) << 0
-  << (unsigned)BaseAlignment.getQuantity()
-  << (unsigned)Align.getQuantity();
+CCEDiag(E->getArg(0), diag::note_constexpr_baa_insufficient_alignment)
+<< 0 << BaseAlignment.getQuantity() << Align.getQuantity();
 return false;
   }
 }
@@ -9783,11 +9780,11 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 
   (OffsetResult.Base
? CCEDiag(E->getArg(0),
- diag::note_constexpr_baa_insufficient_alignment) << 1
+ diag::note_constexpr_baa_insufficient_alignment)
+ << 1
: CCEDiag(E->getArg(0),
  diag::note_constexpr_baa_value_insufficient_alignment))
-<< (int)OffsetResult.Offset.getQuantity()
-<< (unsigned)Align.getQuantity();
+  << OffsetResult.Offset.getQuantity() << Align.getQuantity();
   return false;
 }
 

``




https://github.com/llvm/llvm-project/pull/111959
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add support for inline asm constraint vd (PR #111653)

2024-10-11 Thread Sam Elliott via cfe-commits

https://github.com/lenary approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/111653
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bb12ca - [clang][NFC] Update `cxx_dr_status.html`

2024-10-11 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-10-11T11:17:44+03:00
New Revision: 8bb12ca28f7f195aa483fdb5921681ec373564ab

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

LOG: [clang][NFC] Update `cxx_dr_status.html`

Added: 


Modified: 
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 1a67b6103cf43e..6f3cc8247d2e2d 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -17128,11 +17128,11 @@ C++ defect report implementation 
status
 Undesired outcomes with const_cast
 Not resolved
   
-  
+  
 https://cplusplus.github.io/CWG/issues/2880.html";>2880
-open
+accepted
 Accessibility check for destructor of incomplete class type
-Not resolved
+Unknown
   
   
 https://cplusplus.github.io/CWG/issues/2881.html";>2881
@@ -17260,7 +17260,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2901.html";>2901
-review
+tentatively ready
 Unclear semantics for near-match aliased access
 Not resolved
   
@@ -17408,31 +17408,31 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2923.html";>2923
-open
+tentatively ready
 Note about infinite loops and execution steps
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2924.html";>2924
-open
+review
 Undefined behavior during constant evaluation
 Not resolved
   
-  
+  
 https://cplusplus.github.io/CWG/issues/2925.html";>2925
-open
+NAD
 Deleting a pointer to an incomplete enumeration type
-Not resolved
+Unknown
   
   
 https://cplusplus.github.io/CWG/issues/2926.html";>2926
-open
+tentatively ready
 Lookup context for dependent qualified names
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2927.html";>2927
-open
+review
 Unclear status of translation unit with module keyword
 Not resolved
   



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


[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat edited 
https://github.com/llvm/llvm-project/pull/111846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat approved this pull request.

The change LGTM, I think we can merge it.

My only nitpick was that I tweaked the PR title to make it a bit more accurate. 
(Feel free to tweak it further / discuss this if you disagree with my choice.)

https://github.com/llvm/llvm-project/pull/111846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] Add code completion for C++20 keywords. (PR #107982)

2024-10-11 Thread Younan Zhang via cfe-commits


@@ -2265,6 +2318,12 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
   Results.AddResult(Result("template", CodeCompletionResult::RK_Keyword));
 }
 
+if (SemaRef.getLangOpts().CPlusPlus20 &&
+(CCC == SemaCodeCompletion::PCC_Template ||
+ CCC == SemaCodeCompletion::PCC_MemberTemplate)) {
+  Results.AddResult(Result("requires", CCP_Keyword));
+}

zyn0217 wrote:

```suggestion
if (SemaRef.getLangOpts().CPlusPlus20 &&
(CCC == SemaCodeCompletion::PCC_Template ||
 CCC == SemaCodeCompletion::PCC_MemberTemplate))
  Results.AddResult(Result("requires", CCP_Keyword));
```

https://github.com/llvm/llvm-project/pull/107982
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Karl-Johan Karlsson via cfe-commits
=?utf-8?q?Balázs_Kéri?= 
Message-ID:
In-Reply-To: 


karka228 wrote:

> The change LGTM, I think we can merge it.

I guess the testcase pointer-sub.c have to be fixed to work on the windows 
buildbot, also. Right?


https://github.com/llvm/llvm-project/pull/111846
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bytecode] Implement __builtin_assume_aligned (PR #111968)

2024-10-11 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/111968

>From 1fa9d5d93ede0cb84d958d166a5cc725e542e7b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Fri, 11 Oct 2024 10:34:52 +0200
Subject: [PATCH] [clang][bytecode] Implement __builtin_assume_aligned

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 71 ++-
 clang/lib/AST/ExprConstShared.h   |  8 +++
 clang/lib/AST/ExprConstant.cpp| 35 +
 clang/test/Sema/builtin-assume-aligned.c  |  2 +
 clang/test/SemaCXX/builtin-assume-aligned.cpp |  1 +
 5 files changed, 98 insertions(+), 19 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1765193f5bebbc..7d7d9753e18c34 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -38,7 +38,6 @@ static T getParam(const InterpFrame *Frame, unsigned Index) {
   return Frame->getParam(Offset);
 }
 
-// static APSInt getAPSIntParam(InterpStack &Stk, size_t Offset = 0) {
 static APSInt getAPSIntParam(const InterpFrame *Frame, unsigned Index) {
   APSInt R;
   unsigned Offset = Frame->getFunction()->getParamOffset(Index);
@@ -1162,6 +1161,71 @@ static bool 
interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
   return false;
 }
 
+/// __builtin_assume_aligned(Ptr, Alignment[, ExtraOffset])
+static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const Function *Func,
+   const CallExpr *Call) {
+  assert(Call->getNumArgs() == 2 || Call->getNumArgs() == 3);
+
+  // Might be called with function pointers in C.
+  std::optional PtrT = S.Ctx.classify(Call->getArg(0));
+  if (PtrT != PT_Ptr)
+return false;
+
+  unsigned ArgSize = callArgSize(S, Call);
+  const Pointer &Ptr = S.Stk.peek(ArgSize);
+  std::optional ExtraOffset;
+  APSInt Alignment;
+  if (Call->getNumArgs() == 2) {
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)));
+  } else {
+PrimType AlignmentT = *S.Ctx.classify(Call->getArg(1));
+PrimType ExtraOffsetT = *S.Ctx.classify(Call->getArg(2));
+Alignment = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(1)),
+ align(primSize(AlignmentT)) +
+ align(primSize(ExtraOffsetT)));
+ExtraOffset = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(2)));
+  }
+
+  CharUnits Align = CharUnits::fromQuantity(Alignment.getZExtValue());
+
+  // If there is a base object, then it must have the correct alignment.
+  if (Ptr.isBlockPointer()) {
+CharUnits BaseAlignment;
+if (const auto *VD = Ptr.getDeclDesc()->asValueDecl())
+  BaseAlignment = S.getASTContext().getDeclAlign(VD);
+else if (const auto *E = Ptr.getDeclDesc()->asExpr())
+  BaseAlignment = GetAlignOfExpr(S.getASTContext(), E, UETT_AlignOf);
+
+if (BaseAlignment < Align) {
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 0 << BaseAlignment.getQuantity() << Align.getQuantity();
+  return false;
+}
+  }
+
+  APValue AV = Ptr.toAPValue(S.getASTContext());
+  CharUnits AVOffset = AV.getLValueOffset();
+  if (ExtraOffset)
+AVOffset -= CharUnits::fromQuantity(ExtraOffset->getZExtValue());
+  if (AVOffset.alignTo(Align) != AVOffset) {
+if (Ptr.isBlockPointer())
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_insufficient_alignment)
+  << 1 << AVOffset.getQuantity() << Align.getQuantity();
+else
+  S.CCEDiag(Call->getArg(0),
+diag::note_constexpr_baa_value_insufficient_alignment)
+  << AVOffset.getQuantity() << Align.getQuantity();
+return false;
+  }
+
+  S.Stk.push(Ptr);
+  return true;
+}
+
 static bool interp__builtin_ia32_bextr(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const Function *Func,
@@ -1905,6 +1969,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const Function *F,
   return false;
 break;
 
+  case Builtin::BI__builtin_assume_aligned:
+if (!interp__builtin_assume_aligned(S, OpPC, Frame, F, Call))
+  return false;
+break;
+
   case clang::X86::BI__builtin_ia32_bextr_u32:
   case clang::X86::BI__builtin_ia32_bextr_u64:
   case clang::X86::BI__builtin_ia32_bextri_u32:
diff --git a/clang/lib/AST/ExprConstShared.h b/clang/lib/AST/ExprConstShared.h
index efe8ee986d29b3..401ae629c86bfd 100644
--- a/clang/lib/AST/ExprConstShared.h
+++ b/clang/lib/AST/ExprConstShared.h
@@ -14,12 +14,17 @@
 #ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 #define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
 
+#include "clang/Basic/TypeTraits.h"
+
 namespace llvm {
 class APFloat;
 }
 namespace clang {
 class QualT

[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread Sebastian Kreutzer via cfe-commits

https://github.com/sebastiankreutzer edited 
https://github.com/llvm/llvm-project/pull/90959
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a440203 - [XRay] Add support for instrumentation of DSOs on x86_64 (#90959)

2024-10-11 Thread via cfe-commits

Author: Sebastian Kreutzer
Date: 2024-10-11T11:23:34+02:00
New Revision: a4402039bffd788b9af82435fd5a2fb311fdc6e8

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

LOG: [XRay] Add support for instrumentation of DSOs on x86_64 (#90959)

This PR introduces shared library (DSO) support for XRay based on a
revised version of the implementation outlined in [this
RFC](https://discourse.llvm.org/t/rfc-upstreaming-dso-instrumentation-support-for-xray/73000).
The feature enables the patching and handling of events from DSOs,
supporting both libraries linked at startup or explicitly loaded, e.g.
via `dlopen`.
This patch adds the following:
- The `-fxray-shared` flag to enable the feature (turned off by default)
- A small runtime library that is linked into every instrumented DSO,
providing position-independent trampolines and code to register with the
main XRay runtime
- Changes to the XRay runtime to support management and patching of
multiple objects

These changes are fully backward compatible, i.e. running without
instrumented DSOs will produce identical traces (in terms of recorded
function IDs) to the previous implementation.

Due to my limited ability to test on other architectures, this feature
is only implemented and tested with x86_64. Extending support to other
architectures is fairly straightforward, requiring only a
position-independent implementation of the architecture-specific
trampoline implementation (see
`compiler-rt/lib/xray/xray_trampoline_x86_64.S` for reference).

This patch does not include any functionality to resolve function IDs
from DSOs for the provided logging/tracing modes. These modes still work
and will record calls from DSOs, but symbol resolution for these
functions in not available. Getting this to work properly requires
recording information about the loaded DSOs and should IMO be discussed
in a separate RFC, as there are mulitple feasible approaches.

@petrhosek @jplehr

Added: 
clang/test/Driver/XRay/xray-shared.cpp
compiler-rt/lib/xray/xray_dso_init.cpp
compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp
compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp
compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/XRayArgs.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/XRayArgs.cpp
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
compiler-rt/cmake/config-ix.cmake
compiler-rt/include/xray/xray_interface.h
compiler-rt/lib/xray/CMakeLists.txt
compiler-rt/lib/xray/xray_init.cpp
compiler-rt/lib/xray/xray_interface.cpp
compiler-rt/lib/xray/xray_interface_internal.h
compiler-rt/lib/xray/xray_trampoline_x86_64.S
compiler-rt/lib/xray/xray_x86_64.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index eac831278ee20d..e45370bde74a5d 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -136,6 +136,8 @@ CODEGENOPT(XRayIgnoreLoops , 1, 0)
 ///< Emit the XRay function index section.
 CODEGENOPT(XRayFunctionIndex , 1, 1)
 
+///< Set when -fxray-shared is enabled
+CODEGENOPT(XRayShared , 1, 0)
 
 ///< Set the minimum number of instructions in a function to determine 
selective
 ///< XRay instrumentation.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d306c751505e98..4ee16e213d0e13 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2946,6 +2946,11 @@ def fxray_selected_function_group :
   HelpText<"When using -fxray-function-groups, select which group of functions 
to instrument. Valid range is 0 to fxray-function-groups - 1">,
   MarshallingInfoInt, "0">;
 
+defm xray_shared : BoolFOption<"xray-shared",
+  CodeGenOpts<"XRayShared">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 
 defm fine_grained_bitfield_accesses : BoolOption<"f", 
"fine-grained-bitfield-accesses",
   CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultFalse,

diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index bdd3d979547eed..8fbcf469e5bad1 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -27,6 +27,7 @@ class XRayArgs {
   XRayInstrSet InstrumentationBundle;
   llvm::opt::Arg *XRayInstrument = nullptr;
   bool XRayRT = true;
+  bool XRayShared = false;
 
 public:
   /// Parses t

[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread Jan Patrick Lehr via cfe-commits

https://github.com/jplehr closed https://github.com/llvm/llvm-project/pull/90959
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread via cfe-commits

github-actions[bot] wrote:



@sebastiankreutzer Congratulations on having your first Pull Request (PR) 
merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/90959
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

ivanradanov wrote:

@jdoerfert Could you have a quick look at the clang-side change if that is 
acceptable?

https://github.com/llvm/llvm-project/pull/06
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits


@@ -1103,6 +1105,13 @@ bool ConstructDecompositionT::applyClause(
   return applyToOutermost(node);
 }
 
+template 
+bool ConstructDecompositionT::applyClause(
+const tomp::clause::OmpxBareT &clause,
+const ClauseTy *node) {
+  return applyToAll(node);

ivanradanov wrote:

We need to know whether ompx_bare was present, because the runtime _must_ run 
the target region with the number of threads and teams specified (instead of 
`thread_limit` and `num_teams` being just mere hints otherwise). So I think the 
easiest way to do that is to represent the clause in the dialect. I am fine 
with having in on either `omp.target` or `omp.teams` (or both) and which one we 
have it on only has minor implications on the op verification and translation 
implementation and does not matter much in my opinion, so having it on the 
`omp.target` should be fine in my opinion?

https://github.com/llvm/llvm-project/pull/06
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang & libcxx] constexpr pointer tagging (DO NOT MERGE) (PR #111861)

2024-10-11 Thread Hana Dusíková via cfe-commits

hanickadot wrote:

I'm struggling to make sensible API with composition. When I tried that all 
`const|static|dynamic|reinterpret|schema_cast` weren't consistent with rest of 
std library.

https://github.com/llvm/llvm-project/pull/111861
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-11 Thread Finn Plummer via cfe-commits

https://github.com/inbelic updated 
https://github.com/llvm/llvm-project/pull/111010

>From 70089645ec5cf62b491a56df96ec46f4328fbc11 Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Thu, 3 Oct 2024 11:43:51 -0700
Subject: [PATCH 01/14] [HLSL] Implement `WaveReadLaneAt` intrinsic

- create a clang built-in in Builtins.td
- add semantic checking in SemaHLSL.cpp
- link the WaveReadLaneAt api in hlsl_intrinsics.h
- add lowering to spirv backend op GroupNonUniformShuffle
  with Scope = 2 (Group) in SPIRVInstructionSelector.cpp

- add tests for HLSL intrinsic lowering to spirv intrinsic in
  WaveReadLaneAt.hlsl
- add tests for sema checks in WaveReadLaneAt-errors.hlsl
- add spir-v backend tests in WaveReadLaneAt.ll
---
 clang/include/clang/Basic/Builtins.td |  6 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 16 
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  |  7 
 clang/lib/Sema/SemaHLSL.cpp   | 20 ++
 .../CodeGenHLSL/builtins/WaveReadLaneAt.hlsl  | 40 +++
 .../BuiltIns/WaveReadLaneAt-errors.hlsl   | 21 ++
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp | 15 +++
 .../SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll   | 28 +
 10 files changed, 155 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/builtins/WaveReadLaneAt.hlsl
 create mode 100644 clang/test/SemaHLSL/BuiltIns/WaveReadLaneAt-errors.hlsl
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 8090119e512fbb..eec9acd4d27d7d 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4703,6 +4703,12 @@ def HLSLWaveIsFirstLane : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "bool()";
 }
 
+def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_wave_read_lane_at"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(...)";
+}
+
 def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_elementwise_clamp"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index da3eca73bfb575..dff56af9282e9d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18835,6 +18835,22 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic();
 return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID));
   }
+  case Builtin::BI__builtin_hlsl_wave_read_lane_at: {
+// Due to the use of variadic arguments we must explicitly retreive them 
and
+// create our function type.
+Value *OpExpr = EmitScalarExpr(E->getArg(0));
+Value *OpIndex = EmitScalarExpr(E->getArg(1));
+llvm::FunctionType *FT = llvm::FunctionType::get(
+OpExpr->getType(), ArrayRef{OpExpr->getType(), OpIndex->getType()},
+false);
+
+// Get overloaded name
+std::string name =
+Intrinsic::getName(CGM.getHLSLRuntime().getWaveReadLaneAtIntrinsic(),
+   ArrayRef{OpExpr->getType()}, &CGM.getModule());
+return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, name, {}, false, 
true),
+   ArrayRef{OpExpr, OpIndex}, 
"hlsl.wave.read.lane.at");
+  }
   case Builtin::BI__builtin_hlsl_elementwise_sign: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
 llvm::Type *Xty = Op0->getType();
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index a8aabca7348ffb..a639ce2d784f4a 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -87,6 +87,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_read_lane_at)
 
   
//===--===//
   // End of reserved area for HLSL intrinsic getters.
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 810a16d75f0228..a7bdc353ae71bf 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -2015,6 +2015,13 @@ _HLSL_AVAILABILITY(shadermodel, 6.0)
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane)
 __attribute__((convergent)) bool WaveIsFirstLane();
 
+// \brief Returns the value of the expression for the given lane index within
+// the specified wave.
+template 
+_HLSL_AVAILABILITY(shadermodel, 6.0)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
+__attribute__((convergent)) T WaveReadLaneAt(T, int32_t);
+
 
//===-

[clang] [Clang] Add explicit visibility symbol macros (PR #108276)

2024-10-11 Thread Thomas Fransham via cfe-commits

https://github.com/fsfod updated 
https://github.com/llvm/llvm-project/pull/108276

>From fff6064a63ddf85857ea5036333866317a156ffc Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Tue, 10 Sep 2024 02:22:18 +0100
Subject: [PATCH 1/9] [Clang] Add explicit visibility symbol macros and update
 CMake to control them

We need a different set of visibility macros to LLVM's since on windows you 
need a
different attribute to import and export a symbol unlike other platforms and 
many
translation units will be importing LLVM symbols and export some of Clangs.
Updated Clang CMake to define a macro to enable the symbol visibility macros.
---
 clang/cmake/modules/AddClang.cmake |  4 ++
 clang/include/clang/Support/Compiler.h | 69 ++
 clang/tools/libclang/CMakeLists.txt|  2 +-
 3 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 clang/include/clang/Support/Compiler.h

diff --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 5327b5d2f08928..dcdea378fb 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -108,6 +108,10 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
+  if(NOT ARG_SHARED AND NOT ARG_STATIC)
+target_compile_definitions("obj.${name}" PRIVATE CLANG_EXPORTS)
+  endif()
+
   set(libs ${name})
   if(ARG_SHARED AND ARG_STATIC)
 list(APPEND libs ${name}_static)
diff --git a/clang/include/clang/Support/Compiler.h 
b/clang/include/clang/Support/Compiler.h
new file mode 100644
index 00..4a584e190dc16e
--- /dev/null
+++ b/clang/include/clang/Support/Compiler.h
@@ -0,0 +1,69 @@
+//===-- clang/Support/Compiler.h - Compiler abstraction support -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines explicit visibility macros used to export symbols from
+// clang-cpp
+//
+//===--===//
+
+#ifndef CLANG_SUPPORT_COMPILER_H
+#define CLANG_SUPPORT_COMPILER_H
+
+#include "llvm/Support/Compiler.h"
+
+/// CLANG_ABI is the main export/visibility macro to mark something as
+/// explicitly exported when clang is built as a shared library with everything
+/// else that is unannotated will have internal visibility.
+///
+/// CLANG_EXPORT_TEMPLATE is used on explicit template instantiations in source
+/// files that were declared extern in a header. This macro is only set as a
+/// compiler export attribute on windows, on other platforms it does nothing.
+///
+/// CLANG_TEMPLATE_ABI is for annotating extern template declarations in 
headers
+/// for both functions and classes. On windows its turned in to dllimport for
+/// library consumers, for other platforms its a default visibility attribute.
+#ifndef CLANG_ABI_GENERATING_ANNOTATIONS
+// Marker to add to classes or functions in public headers that should not have
+// export macros added to them by the clang tool
+#define CLANG_ABI_NOT_EXPORTED
+#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS)
+// Some libraries like those for tablegen are linked in to tools that used
+// in the build so can't depend on the llvm shared library. If export macros
+// were left enabled when building these we would get duplicate or
+// missing symbol linker errors on windows.
+#if defined(CLANG_BUILD_STATIC)
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(_WIN32) && !defined(__MINGW32__)
+#if defined(CLANG_EXPORTS)
+#define CLANG_ABI __declspec(dllexport)
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE __declspec(dllexport)
+#else
+#define CLANG_ABI __declspec(dllimport)
+#define CLANG_TEMPLATE_ABI __declspec(dllimport)
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_EXPORT_TEMPLATE
+#elif defined(__MACH__) || defined(__WASM__)
+#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#else
+#define CLANG_ABI
+#define CLANG_TEMPLATE_ABI
+#define CLANG_EXPORT_TEMPLATE
+#endif
+#endif
+
+#endif
\ No newline at end of file
diff --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 968b46acb784cb..8c6a07f9e52a8c 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -166,7 +166,7 @@ if(ENABLE_SHARED)
 set_target_properties(libclang
   PROPERTIES
   VERSION ${LIBCLANG_LIBRARY_VERSION}
-  DEFINE_SYMBOL _CINDEX_LIB_)
+  DEFINE_SYMBO

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits


@@ -19,8 +19,10 @@ namespace usage_invalid {
 namespace usage_ok {
   struct IntRef { int *target; };
 
+  const int *defaultparam(const int &def1 [[clang::lifetimebound]] = 0); // 
#def1
   int &refparam(int ¶m [[clang::lifetimebound]]);
   int &classparam(IntRef param [[clang::lifetimebound]]);
+  const int *c = defaultparam(); // expected-warning {{temporary whose address 
is used as value of local variable 'c' will be destroyed at the end of the 
full-expression}} expected-note@#def1 {{default argument declared here}}

zygoloid wrote:

This note doesn't seem very clear -- it's not obvious why you're pointing at a 
default argument or what it has to do with the diagnostic. You could copy what 
we do for `note_init_with_default_member_initializer` and add a note something 
like "initializing parameter with default argument" (which is still not great, 
but it's consistent and it at least shows why the default argument is relevant 
to the error).

https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits

https://github.com/zygoloid commented:

Thanks, this seems reasonable.

https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits

https://github.com/zygoloid edited 
https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits


@@ -532,6 +533,11 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
 }
   } while (Init != Old);
 
+  if (auto *DAE = dyn_cast(Init)) {
+Path.push_back({IndirectLocalPathEntry::DefaultArg, DAE, DAE->getParam()});
+Init = DAE->getExpr();
+  }

zygoloid wrote:

I think this should be in the loop above -- the default argument could itself 
contain one of the other expressions that we want to skip over.

https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)

2024-10-11 Thread Finn Plummer via cfe-commits

https://github.com/inbelic updated 
https://github.com/llvm/llvm-project/pull/111010

>From 70089645ec5cf62b491a56df96ec46f4328fbc11 Mon Sep 17 00:00:00 2001
From: Finn Plummer 
Date: Thu, 3 Oct 2024 11:43:51 -0700
Subject: [PATCH 01/14] [HLSL] Implement `WaveReadLaneAt` intrinsic

- create a clang built-in in Builtins.td
- add semantic checking in SemaHLSL.cpp
- link the WaveReadLaneAt api in hlsl_intrinsics.h
- add lowering to spirv backend op GroupNonUniformShuffle
  with Scope = 2 (Group) in SPIRVInstructionSelector.cpp

- add tests for HLSL intrinsic lowering to spirv intrinsic in
  WaveReadLaneAt.hlsl
- add tests for sema checks in WaveReadLaneAt-errors.hlsl
- add spir-v backend tests in WaveReadLaneAt.ll
---
 clang/include/clang/Basic/Builtins.td |  6 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 16 
 clang/lib/CodeGen/CGHLSLRuntime.h |  1 +
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  |  7 
 clang/lib/Sema/SemaHLSL.cpp   | 20 ++
 .../CodeGenHLSL/builtins/WaveReadLaneAt.hlsl  | 40 +++
 .../BuiltIns/WaveReadLaneAt-errors.hlsl   | 21 ++
 llvm/include/llvm/IR/IntrinsicsSPIRV.td   |  1 +
 .../Target/SPIRV/SPIRVInstructionSelector.cpp | 15 +++
 .../SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll   | 28 +
 10 files changed, 155 insertions(+)
 create mode 100644 clang/test/CodeGenHLSL/builtins/WaveReadLaneAt.hlsl
 create mode 100644 clang/test/SemaHLSL/BuiltIns/WaveReadLaneAt-errors.hlsl
 create mode 100644 llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveReadLaneAt.ll

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 8090119e512fbb..eec9acd4d27d7d 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4703,6 +4703,12 @@ def HLSLWaveIsFirstLane : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "bool()";
 }
 
+def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_wave_read_lane_at"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(...)";
+}
+
 def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_elementwise_clamp"];
   let Attributes = [NoThrow, Const];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index da3eca73bfb575..dff56af9282e9d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18835,6 +18835,22 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic();
 return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID));
   }
+  case Builtin::BI__builtin_hlsl_wave_read_lane_at: {
+// Due to the use of variadic arguments we must explicitly retreive them 
and
+// create our function type.
+Value *OpExpr = EmitScalarExpr(E->getArg(0));
+Value *OpIndex = EmitScalarExpr(E->getArg(1));
+llvm::FunctionType *FT = llvm::FunctionType::get(
+OpExpr->getType(), ArrayRef{OpExpr->getType(), OpIndex->getType()},
+false);
+
+// Get overloaded name
+std::string name =
+Intrinsic::getName(CGM.getHLSLRuntime().getWaveReadLaneAtIntrinsic(),
+   ArrayRef{OpExpr->getType()}, &CGM.getModule());
+return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, name, {}, false, 
true),
+   ArrayRef{OpExpr, OpIndex}, 
"hlsl.wave.read.lane.at");
+  }
   case Builtin::BI__builtin_hlsl_elementwise_sign: {
 Value *Op0 = EmitScalarExpr(E->getArg(0));
 llvm::Type *Xty = Op0->getType();
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index a8aabca7348ffb..a639ce2d784f4a 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -87,6 +87,7 @@ class CGHLSLRuntime {
   GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
   GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
+  GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_read_lane_at)
 
   
//===--===//
   // End of reserved area for HLSL intrinsic getters.
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 810a16d75f0228..a7bdc353ae71bf 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -2015,6 +2015,13 @@ _HLSL_AVAILABILITY(shadermodel, 6.0)
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane)
 __attribute__((convergent)) bool WaveIsFirstLane();
 
+// \brief Returns the value of the expression for the given lane index within
+// the specified wave.
+template 
+_HLSL_AVAILABILITY(shadermodel, 6.0)
+_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
+__attribute__((convergent)) T WaveReadLaneAt(T, int32_t);
+
 
//===-

[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits

https://github.com/zygoloid commented:

Please can you also add tests for the case where the default argument is a 
pointer, eg:
```c++
using T = int[];
int *f([[clang::lifetimebound]] int *p = T{1, 2, 3});
int *p = f();
```
I expect that won't be caught, and you'll need to make a similar change to 
`visitLocalsRetainedByInitializer` to handle it.

https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CGOpenMPRuntime] Avoid Type::getPointerTo() (NFC) (PR #112017)

2024-10-11 Thread Youngsuk Kim via cfe-commits

https://github.com/JOE1994 closed 
https://github.com/llvm/llvm-project/pull/112017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread YunQiang Su via cfe-commits


@@ -15314,6 +15314,32 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
   Result = RHS;

wzssyqa wrote:

I guess it was due to that the `APFloat::minnum` claims that it fellow 
`IEEE-754 2019 minimumNumber semantics`.
and `fmin` needs to follow the libc's behavior.
We need to fix them.

https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-11 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx updated 
https://github.com/llvm/llvm-project/pull/110897

>From 9f3cac44dde7d0adcf6cd090c0b91f57cb1c4dca Mon Sep 17 00:00:00 2001
From: Alex Voicu 
Date: Wed, 2 Oct 2024 11:18:36 +0100
Subject: [PATCH 1/2] Enable `InferAddressSpaces` for SPIR-V.

---
 .../amdgpu-kernel-arg-pointer-type.cu |  62 ++---
 llvm/lib/Target/SPIRV/CMakeLists.txt  |   2 +
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp  |  92 +++
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.h|   7 +
 .../Target/SPIRV/SPIRVTargetTransformInfo.h   |   4 +
 .../SPIRV/assumed-addrspace.ll|  31 +++
 .../InferAddressSpaces/SPIRV/basic.ll | 236 ++
 .../SPIRV/infer-address-space.ll  | 211 
 .../SPIRV/infer-addrspacecast.ll  |  65 +
 .../SPIRV/infer-getelementptr.ll  | 108 
 .../SPIRV/insert-pos-assert.ll| 158 
 .../InferAddressSpaces/SPIRV/is.constant.ll   |  57 +
 .../InferAddressSpaces/SPIRV/lit.local.cfg|   2 +
 .../SPIRV/mem-intrinsics.ll   | 145 +++
 .../SPIRV/multiple-uses-of-val.ll |  70 ++
 .../InferAddressSpaces/SPIRV/prefetch.ll  |  60 +
 .../preserving-debugloc-addrspacecast.ll  |  48 
 .../SPIRV/redundant-addrspacecast.ll  |  28 +++
 .../InferAddressSpaces/SPIRV/self-phi.ll  |  29 +++
 .../InferAddressSpaces/SPIRV/volatile.ll  | 187 ++
 20 files changed, 1567 insertions(+), 35 deletions(-)
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/assumed-addrspace.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/basic.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-address-space.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/infer-getelementptr.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/insert-pos-assert.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/is.constant.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/lit.local.cfg
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/mem-intrinsics.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/multiple-uses-of-val.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/prefetch.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/preserving-debugloc-addrspacecast.ll
 create mode 100644 
llvm/test/Transforms/InferAddressSpaces/SPIRV/redundant-addrspacecast.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/self-phi.ll
 create mode 100644 llvm/test/Transforms/InferAddressSpaces/SPIRV/volatile.ll

diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu 
b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
index b295bbbdaaf955..15c8b46d278ea1 100644
--- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -58,13 +58,11 @@
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel1Pi(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef [[X_COERCE:%.*]]) 
local_unnamed_addr addrspace(4) #[[ATTR0:[0-9]+]] {
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP2]], 1
-// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(4) [[TMP1]], align 4
+// OPT-SPIRV-NEXT:[[TMP0:%.*]] = load i32, ptr addrspace(1) [[X_COERCE]], 
align 4
+// OPT-SPIRV-NEXT:[[INC:%.*]] = add nsw i32 [[TMP0]], 1
+// OPT-SPIRV-NEXT:store i32 [[INC]], ptr addrspace(1) [[X_COERCE]], align 4
 // OPT-SPIRV-NEXT:ret void
 //
 // HOST-LABEL: define dso_local void @_Z22__device_stub__kernel1Pi(
@@ -126,13 +124,11 @@ __global__ void kernel1(int *x) {
 // OPT-NEXT:ret void
 //
 // OPT-SPIRV-LABEL: define spir_kernel void @_Z7kernel2Ri(
-// OPT-SPIRV-SAME: ptr addrspace(1) noundef align 4 dereferenceable(4) 
[[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] {
+// OPT-SPIRV-SAME: ptr addrspace(1) nocapture noundef align 4 
dereferenceable(4) [[X_COERCE:%.*]]) local_unnamed_addr addrspace(4) #[[ATTR0]] 
{
 // OPT-SPIRV-NEXT:  [[ENTRY:.*:]]
-// OPT-SPIRV-NEXT:[[TMP0:%.*]] = ptrtoint ptr addrspace(1) [[X_COERCE]] to 
i64
-// OPT-SPIRV-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr addrspace(4)
-// OPT-SPIRV-NEXT:[[TMP2:%.*]] = load i32, ptr addrspace(4) [[TMP1]], 
align 4
-// OPT-SPIRV-NEXT:[[INC:%.*]] = add n

[clang] [llvm] [WebAssembly] Enable nontrapping-fptoint and bulk-memory by default. (PR #112049)

2024-10-11 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112049

>From 92eccc19f25177edf44c2c37f92381bcca7ff661 Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 13:31:13 -0700
Subject: [PATCH 1/2] [WebAssembly] Enable nontrapping-fptoint and bulk-memory
 by default.

We were prepared to enable these features [back in February], but they
got pulled for what appear to be unrelated reasons. So let's have another
try at enabling them!

Another motivation here is that it'd be convenient for the
[Trail1 proposal] if "trail1" is a superset of "generic".

[back in February]: 
https://github.com/WebAssembly/tool-conventions/issues/158#issuecomment-1931119512
[Trail1 proposal]: https://github.com/llvm/llvm-project/pull/112035
---
 clang/docs/ReleaseNotes.rst| 9 +
 clang/lib/Basic/Targets/WebAssembly.cpp| 2 ++
 llvm/docs/ReleaseNotes.md  | 9 +
 llvm/lib/Target/WebAssembly/WebAssembly.td | 3 ++-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e74dd1a5fb32da..aec48e32dc85a8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -627,6 +627,15 @@ NetBSD Support
 WebAssembly Support
 ^^^
 
+The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
+and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
+and [Non-trapping float-to-int Conversions] language features, which are
+[widely implemented in engines].
+
+[Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
+[Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
+[widely implemented in engines]: https://webassembly.org/features/
+
 AVR Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 5ac9421663adea..1ac8f14f8cb175 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -151,8 +151,10 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU,
 const std::vector &FeaturesVec) const {
   auto addGenericFeatures = [&]() {
+Features["bulk-memory"] = true;
 Features["multivalue"] = true;
 Features["mutable-globals"] = true;
+Features["nontrapping-fptoint"] = true;
 Features["reference-types"] = true;
 Features["sign-ext"] = true;
   };
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index dcdd7a25c7fbee..1d4197f25f4422 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -164,6 +164,15 @@ Changes to the RISC-V Backend
 Changes to the WebAssembly Backend
 --
 
+The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
+and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
+and [Non-trapping float-to-int Conversions] language features, which are
+[widely implemented in engines].
+
+[Bulk Memory Operations]: 
https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
+[Non-trapping float-to-int Conversions]: 
https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
+[widely implemented in engines]: https://webassembly.org/features/
+
 Changes to the Windows Target
 -
 
diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.td 
b/llvm/lib/Target/WebAssembly/WebAssembly.td
index c632d4a74355d8..1e22707db23e91 100644
--- a/llvm/lib/Target/WebAssembly/WebAssembly.td
+++ b/llvm/lib/Target/WebAssembly/WebAssembly.td
@@ -110,7 +110,8 @@ def : ProcessorModel<"mvp", NoSchedModel, []>;
 // consideration given to available support in relevant engines and tools, and
 // the importance of the features.
 def : ProcessorModel<"generic", NoSchedModel,
-  [FeatureMultivalue, FeatureMutableGlobals,
+  [FeatureBulkMemory, FeatureMultivalue,
+   FeatureMutableGlobals, FeatureNontrappingFPToInt,
FeatureReferenceTypes, FeatureSignExt]>;
 
 // Latest and greatest experimental version of WebAssembly. Bugs included!

>From 00f5c6f7bdbd8134ffc3f59ee005807a12dfd38e Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 16:58:39 -0700
Subject: [PATCH 2/2] Update tests.

---
 .../test/CodeGen/WebAssembly/cfg-stackify-eh-legacy.ll | 10 +-
 llvm/test/CodeGen/WebAssembly/target-features-cpus.ll  |  8 +++-
 llvm/test/MC/WebAssembly/extern-functype-intrinsic.ll  |  4 ++--
 llvm/test/MC/WebAssembly/libcall.ll|  2 +-
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/llvm/test/CodeGen/WebAssembly/cfg-stackify

[clang] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-11 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx edited 
https://github.com/llvm/llvm-project/pull/110897
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [llvm][opt][Transforms][SPIR-V] Enable `InferAddressSpaces` for SPIR-V (PR #110897)

2024-10-11 Thread Alex Voicu via cfe-commits

https://github.com/AlexVlx commented:

> Move to separate change, not sure this is necessarily valid for spirv  

I think that I'd prefer to keep this around, definitely for AMDGCNSPIRV where 
we know it is both correct and empirically beneficial. For vanilla SPIR-V I'll 
defer to folks on that side - I cannot think about cases where it'd be legal to 
put anything but a pointer to global (CrossWorkgroup) in constant 
(UniformConstant), but that might simply be ignorance on my part.

https://github.com/llvm/llvm-project/pull/110897
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] [WebAssembly] Define a new "Trail1" CPU (PR #112035)

2024-10-11 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode updated 
https://github.com/llvm/llvm-project/pull/112035

>From b8f33cd68d11759ad774e16b4d25491a1c9fc3e4 Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Fri, 11 Oct 2024 04:30:32 -0700
Subject: [PATCH 1/2] [WebAssembly] Define a new "Trail1" CPU

First, define some new target features. These are subsets of existing features
that reflect implemenetation concerns:

 - "call-indirect-overlong" - implied by "reference-types"; just the overlong
   encoding for the `call_indirect` immediate, and not the actual reference
   types.

 - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and
   `memory.fill`, and not the other instructions in the bulk-memory
proposal.

Next, define a new target CPU, "Trail1", which enables mutable-globals,
bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const,
and call-indirect-overlong. Unlike the default "generic" CPU, "trail1" is meant
to be frozen, and followed up by "trail2" and so on when new features are
desired.
---
 clang/lib/Basic/Targets/WebAssembly.cpp   | 45 +++
 clang/lib/Basic/Targets/WebAssembly.h |  2 +
 lld/test/wasm/compress-relocs.ll  |  2 +-
 lld/test/wasm/import-table-explicit.s |  2 +-
 lld/test/wasm/invalid-mvp-table-use.s |  2 +-
 lld/wasm/InputFiles.cpp   | 11 ++---
 lld/wasm/SyntheticSections.cpp|  2 +-
 .../AsmParser/WebAssemblyAsmParser.cpp| 12 ++---
 llvm/lib/Target/WebAssembly/WebAssembly.td| 14 ++
 .../WebAssembly/WebAssemblyFastISel.cpp   |  2 +-
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  2 +-
 .../WebAssembly/WebAssemblyInstrBulkMemory.td | 15 ---
 .../WebAssembly/WebAssemblyInstrInfo.td   |  8 
 .../WebAssemblySelectionDAGInfo.cpp   |  4 +-
 .../Target/WebAssembly/WebAssemblySubtarget.h |  4 ++
 .../WebAssembly/WebAssemblyUtilities.cpp  |  4 +-
 llvm/test/CodeGen/WebAssembly/bulk-memory.ll  |  6 +--
 .../test/CodeGen/WebAssembly/bulk-memory64.ll |  6 +--
 18 files changed, 110 insertions(+), 33 deletions(-)

diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 5ac9421663adea..aa3a2770727c3a 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   return llvm::StringSwitch(Feature)
   .Case("atomics", HasAtomics)
   .Case("bulk-memory", HasBulkMemory)
+  .Case("bulk-memory-opt", HasBulkMemoryOpt)
   .Case("exception-handling", HasExceptionHandling)
   .Case("extended-const", HasExtendedConst)
   .Case("fp16", HasFP16)
@@ -55,6 +56,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) 
const {
   .Case("mutable-globals", HasMutableGlobals)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("reference-types", HasReferenceTypes)
+  .Case("call-indirect-overlong", HasCallIndirectOverlong)
   .Case("relaxed-simd", SIMDLevel >= RelaxedSIMD)
   .Case("sign-ext", HasSignExt)
   .Case("simd128", SIMDLevel >= SIMD128)
@@ -78,6 +80,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 Builder.defineMacro("__wasm_atomics__");
   if (HasBulkMemory)
 Builder.defineMacro("__wasm_bulk_memory__");
+  if (HasBulkMemoryOpt)
+Builder.defineMacro("__wasm_bulk_memory_opt__");
   if (HasExceptionHandling)
 Builder.defineMacro("__wasm_exception_handling__");
   if (HasExtendedConst)
@@ -154,12 +158,23 @@ bool WebAssemblyTargetInfo::initFeatureMap(
 Features["multivalue"] = true;
 Features["mutable-globals"] = true;
 Features["reference-types"] = true;
+Features["call-indirect-overlong"] = true;
 Features["sign-ext"] = true;
   };
+  auto addTrail1Features = [&]() {
+Features["multivalue"] = true;
+Features["mutable-globals"] = true;
+Features["call-indirect-overlong"] = true;
+Features["sign-ext"] = true;
+Features["bulk-memory-opt"] = true;
+Features["nontrapping-fptoint"] = true;
+Features["extended-const"] = true;
+  };
   auto addBleedingEdgeFeatures = [&]() {
 addGenericFeatures();
 Features["atomics"] = true;
 Features["bulk-memory"] = true;
+Features["bulk-memory-opt"] = true;
 Features["exception-handling"] = true;
 Features["extended-const"] = true;
 Features["fp16"] = true;
@@ -170,6 +185,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
   };
   if (CPU == "generic") {
 addGenericFeatures();
+  } else if (CPU == "trail1") {
+addTrail1Features();
   } else if (CPU == "bleeding-edge") {
 addBleedingEdgeFeatures();
   }
@@ -196,6 +213,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
   HasBulkMemory = false;
   continue;
 }
+if (Feature == "+bulk-memory-opt") {
+  HasBulkMemoryOpt = true;
+  continue;
+}
+if (Feature == "-bulk-memory-opt") {
+

[clang] 6d4edf2 - [clang][CGOpenMPRuntime] Avoid Type::getPointerTo() (NFC) (#112017)

2024-10-11 Thread via cfe-commits

Author: Youngsuk Kim
Date: 2024-10-11T20:09:24-04:00
New Revision: 6d4edf2f75f7ec09420f18f7806f480f5b090b40

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

LOG: [clang][CGOpenMPRuntime] Avoid Type::getPointerTo() (NFC) (#112017)

`llvm::Type::getPointerTo()` is to be deprecated & removed soon.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 8593cb5ffdd97d..3747b00d4893ad 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1713,25 +1713,15 @@ llvm::Function 
*CGOpenMPRuntime::emitThreadPrivateVarDefinition(
 if (!Ctor && !Dtor)
   return nullptr;
 
-llvm::Type *CopyCtorTyArgs[] = {CGM.VoidPtrTy, CGM.VoidPtrTy};
-auto *CopyCtorTy = llvm::FunctionType::get(CGM.VoidPtrTy, CopyCtorTyArgs,
-   /*isVarArg=*/false)
-   ->getPointerTo();
 // Copying constructor for the threadprivate variable.
 // Must be NULL - reserved by runtime, but currently it requires that this
 // parameter is always NULL. Otherwise it fires assertion.
-CopyCtor = llvm::Constant::getNullValue(CopyCtorTy);
+CopyCtor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
 if (Ctor == nullptr) {
-  auto *CtorTy = llvm::FunctionType::get(CGM.VoidPtrTy, CGM.VoidPtrTy,
- /*isVarArg=*/false)
- ->getPointerTo();
-  Ctor = llvm::Constant::getNullValue(CtorTy);
+  Ctor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
 }
 if (Dtor == nullptr) {
-  auto *DtorTy = llvm::FunctionType::get(CGM.VoidTy, CGM.VoidPtrTy,
- /*isVarArg=*/false)
- ->getPointerTo();
-  Dtor = llvm::Constant::getNullValue(DtorTy);
+  Dtor = llvm::Constant::getNullValue(CGM.UnqualPtrTy);
 }
 if (!CGF) {
   auto *InitFunctionTy =
@@ -1817,7 +1807,7 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_threadprivate_cached),
   Args),
-  VarLVType->getPointerTo(/*AddrSpace=*/0)),
+  CGF.Builder.getPtrTy(0)),
   VarLVType, CGM.getContext().getTypeAlignInChars(VarType));
 }
 
@@ -2131,10 +2121,7 @@ static Address emitAddrOfVarFromArray(CodeGenFunction 
&CGF, Address Array,
   llvm::Value *Ptr = CGF.Builder.CreateLoad(PtrAddr);
 
   llvm::Type *ElemTy = CGF.ConvertTypeForMem(Var->getType());
-  return Address(
-  CGF.Builder.CreateBitCast(
-  Ptr, ElemTy->getPointerTo(Ptr->getType()->getPointerAddressSpace())),
-  ElemTy, CGF.getContext().getDeclAlign(Var));
+  return Address(Ptr, ElemTy, CGF.getContext().getDeclAlign(Var));
 }
 
 static llvm::Value *emitCopyprivateCopyFunction(
@@ -2166,11 +2153,11 @@ static llvm::Value *emitCopyprivateCopyFunction(
   // Src = (void*[n])(RHSArg);
   Address LHS(CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(&LHSArg)),
-  ArgsElemType->getPointerTo()),
+  CGF.Builder.getPtrTy(0)),
   ArgsElemType, CGF.getPointerAlign());
   Address RHS(CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(&RHSArg)),
-  ArgsElemType->getPointerTo()),
+  CGF.Builder.getPtrTy(0)),
   ArgsElemType, CGF.getPointerAlign());
   // *(Type0*)Dst[0] = *(Type0*)Src[0];
   // *(Type1*)Dst[1] = *(Type1*)Src[1];
@@ -3681,9 +3668,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, 
SourceLocation Loc,
   QualType KmpTaskTWithPrivatesQTy = 
C.getRecordType(KmpTaskTWithPrivatesQTyRD);
   QualType KmpTaskTWithPrivatesPtrQTy =
   C.getPointerType(KmpTaskTWithPrivatesQTy);
-  llvm::Type *KmpTaskTWithPrivatesTy = 
CGF.ConvertType(KmpTaskTWithPrivatesQTy);
-  llvm::Type *KmpTaskTWithPrivatesPtrTy =
-  KmpTaskTWithPrivatesTy->getPointerTo();
+  llvm::Type *KmpTaskTWithPrivatesPtrTy = CGF.Builder.getPtrTy(0);
   llvm::Value *KmpTaskTWithPrivatesTySize =
   CGF.getTypeSize(KmpTaskTWithPrivatesQTy);
   QualType SharedsPtrTy = C.getPointerType(SharedsTy);
@@ -4399,7 +4384,7 @@ Address CGOpenMPRuntime::emitDepobjDependClause(
   Args, ".dep.arr.addr");
   llvm::Type *KmpDependInfoLlvmTy = CGF.ConvertTypeForMem(KmpDependInfoTy);
   Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-  Addr, KmpDependInfoLlvmTy->getPointerTo());
+  Addr, CGF.Builder.getPtrTy(0));
   DependenciesArray

[clang-tools-extra] f1367a4 - [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (#110448)

2024-10-11 Thread via cfe-commits

Author: Nicolas van Kempen
Date: 2024-10-11T21:00:38-04:00
New Revision: f1367a473d9682a058c7f8c397ed2a787d071826

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

LOG: [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with 
patterns (#110448)

Add support for the following two patterns:
```
haystack.compare(haystack.length() - needle.length(), needle.length(), needle) 
== 0;
haystack.rfind(needle) == (haystack.size() - needle.size());
```

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize/use-starts-ends-with.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string

clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 89ee45faecd7f3..5eb3267adb0799 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "UseStartsEndsWithCheck.h"
 
+#include "../utils/ASTUtils.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 
@@ -16,6 +17,63 @@
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::modernize {
+struct NotLengthExprForStringNode {
+  NotLengthExprForStringNode(std::string ID, DynTypedNode Node,
+ ASTContext *Context)
+  : ID(std::move(ID)), Node(std::move(Node)), Context(Context) {}
+  bool operator()(const internal::BoundNodesMap &Nodes) const {
+// Match a string literal and an integer size or strlen() call.
+if (const auto *StringLiteralNode = Nodes.getNodeAs(ID)) {
+  if (const auto *IntegerLiteralSizeNode = Node.get()) {
+return StringLiteralNode->getLength() !=
+   IntegerLiteralSizeNode->getValue().getZExtValue();
+  }
+
+  if (const auto *StrlenNode = Node.get()) {
+if (StrlenNode->getDirectCallee()->getName() != "strlen" ||
+StrlenNode->getNumArgs() != 1) {
+  return true;
+}
+
+if (const auto *StrlenArgNode = dyn_cast(
+StrlenNode->getArg(0)->IgnoreParenImpCasts())) {
+  return StrlenArgNode->getLength() != StringLiteralNode->getLength();
+}
+  }
+}
+
+// Match a string variable and a call to length() or size().
+if (const auto *ExprNode = Nodes.getNodeAs(ID)) {
+  if (const auto *MemberCallNode = Node.get()) {
+const CXXMethodDecl *MethodDeclNode = MemberCallNode->getMethodDecl();
+const StringRef Name = MethodDeclNode->getName();
+if (!MethodDeclNode->isConst() || MethodDeclNode->getNumParams() != 0 
||
+(Name != "size" && Name != "length")) {
+  return true;
+}
+
+if (const auto *OnNode =
+dyn_cast(MemberCallNode->getImplicitObjectArgument())) {
+  return !utils::areStatementsIdentical(OnNode->IgnoreParenImpCasts(),
+
ExprNode->IgnoreParenImpCasts(),
+*Context);
+}
+  }
+}
+
+return true;
+  }
+
+private:
+  std::string ID;
+  DynTypedNode Node;
+  ASTContext *Context;
+};
+
+AST_MATCHER_P(Expr, lengthExprForStringNode, std::string, ID) {
+  return Builder->removeBindings(NotLengthExprForStringNode(
+  ID, DynTypedNode::create(Node), &(Finder->getASTContext(;
+}
 
 UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name,
ClangTidyContext *Context)
@@ -23,6 +81,7 @@ UseStartsEndsWithCheck::UseStartsEndsWithCheck(StringRef Name,
 
 void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) {
   const auto ZeroLiteral = integerLiteral(equals(0));
+
   const auto HasStartsWithMethodWithName = [](const std::string &Name) {
 return hasMethod(
 cxxMethodDecl(hasName(Name), isConst(), parameterCountIs(1))
@@ -32,119 +91,104 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   anyOf(HasStartsWithMethodWithName("starts_with"),
 HasStartsWithMethodWithName("startsWith"),
 HasStartsWithMethodWithName("startswith"));
-  const auto ClassWithStartsWithFunction = cxxRecordDecl(anyOf(
-  HasStartsWithMethod, hasAnyBase(hasType(hasCanonicalType(hasDeclaration(
-   cxxRecordDecl(HasStartsWithMethod)));
+  const auto OnClassWithStartsWithFunction =
+  on(hasType(hasCanonica

[clang-tools-extra] [clang-tidy][modernize-use-starts-ends-with] Add support for two ends_with patterns (PR #110448)

2024-10-11 Thread Nicolas van Kempen via cfe-commits

https://github.com/nicovank closed 
https://github.com/llvm/llvm-project/pull/110448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (PR #87717)

2024-10-11 Thread Freddy Ye via cfe-commits


@@ -44,7 +44,7 @@ unsigned char _InterlockedCompareExchange128_rel(__int64 
volatile *_Destination,
  __int64 *_ComparandResult);
 #endif
 
-#ifdef __x86_64__
+#ifdef __x86_64__ && !defined(__arm64ec__)

FreddyLeaf wrote:

Hello, we found compile errors on this line:
```
(47,19): error: extra tokens at end of #ifdef directive [-Werror,-Wextra-tokens]
```
Seems like this line forgot to change #ifdef when changed into expression


https://github.com/llvm/llvm-project/pull/87717
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [polly] [NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (PR #111752)

2024-10-11 Thread Rahul Joshi via cfe-commits

jurahul wrote:

Btw, the findDeclaration was a temporary state and the plan is to switch to
getDeclaration eventually. The findDeclaration was for staging the rename.

On Fri, Oct 11, 2024 at 2:55 PM Rahul Joshi ***@***.***> wrote:

> That’s a possibility. I was trying to keep the naming consistent with
> similar functions in the Module class.  But if folks feel its too much
> churn and are ok with the inconsistent naming convention, I am fine with
> reverting it and going with the naming scheme proposed above.
>
> On Fri, Oct 11, 2024 at 2:51 PM Nikita Popov ***@***.***>
> wrote:
>
>> TBH I am wondering if we should revert this rename. I don't think it's a
>> good idea to reuse getDeclaration with substantially different semantics,
>> and if we're not reusing it, then there's not much point to rename...
>>
>> Instead of having getOrInsertDeclaration + getDeclaration with a meaning
>> inversion, we can have getDeclaration and getDeclarationIfExists without
>> the inversion.
>>
>> —
>> Reply to this email directly, view it on GitHub
>> ,
>> or unsubscribe
>> 
>> .
>> You are receiving this because you were mentioned.Message ID:
>> ***@***.***>
>>
>


https://github.com/llvm/llvm-project/pull/111752
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread via cfe-commits

https://github.com/higher-performance updated 
https://github.com/llvm/llvm-project/pull/112047

>From 33da8c34977110619fa9ec2e9c9e830c993ce31a Mon Sep 17 00:00:00 2001
From: higher-performance 
Date: Fri, 11 Oct 2024 17:09:13 -0400
Subject: [PATCH] Make [[clang::lifetimebound]] work for expressions coming
 from default arguments

---
 clang/lib/Sema/CheckExprLifetime.cpp  | 20 +++-
 clang/test/SemaCXX/attr-lifetimebound.cpp |  6 ++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index f62e18543851c1..de639e951b8f28 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -194,6 +194,7 @@ struct IndirectLocalPathEntry {
 GslReferenceInit,
 GslPointerInit,
 GslPointerAssignment,
+DefaultArg,
   } Kind;
   Expr *E;
   union {
@@ -532,6 +533,11 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
 }
   } while (Init != Old);
 
+  if (auto *DAE = dyn_cast(Init)) {
+Path.push_back({IndirectLocalPathEntry::DefaultArg, DAE, DAE->getParam()});
+Init = DAE->getExpr();
+  }
+
   if (auto *MTE = dyn_cast(Init)) {
 if (Visit(Path, Local(MTE), RK))
   visitLocalsRetainedByInitializer(Path, MTE->getSubExpr(), Visit, true);
@@ -916,6 +922,9 @@ static SourceRange nextPathEntryRange(const 
IndirectLocalPath &Path, unsigned I,
   if (!Path[I].Capture->capturesVariable())
 continue;
   return Path[I].E->getSourceRange();
+
+case IndirectLocalPathEntry::DefaultArg:
+  return cast(Path[I].E)->getUsedLocation();
 }
   }
   return E->getSourceRange();
@@ -1221,7 +1230,7 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
 break;
   }
 
-  case IndirectLocalPathEntry::LambdaCaptureInit:
+  case IndirectLocalPathEntry::LambdaCaptureInit: {
 if (!Elem.Capture->capturesVariable())
   break;
 // FIXME: We can't easily tell apart an init-capture from a nested
@@ -1234,6 +1243,15 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
 << nextPathEntryRange(Path, I + 1, L);
 break;
   }
+
+  case IndirectLocalPathEntry::DefaultArg: {
+const auto *DAE = cast(Elem.E);
+SemaRef.Diag(DAE->getParam()->getDefaultArgRange().getBegin(),
+ diag::note_default_argument_declared_here)
+<< DAE->getParam() << nextPathEntryRange(Path, I + 1, L);
+break;
+  }
+  }
 }
 
 // We didn't lifetime-extend, so don't go any further; we don't need more
diff --git a/clang/test/SemaCXX/attr-lifetimebound.cpp 
b/clang/test/SemaCXX/attr-lifetimebound.cpp
index 0fb997a5671085..d39d7e9eb54bff 100644
--- a/clang/test/SemaCXX/attr-lifetimebound.cpp
+++ b/clang/test/SemaCXX/attr-lifetimebound.cpp
@@ -19,8 +19,10 @@ namespace usage_invalid {
 namespace usage_ok {
   struct IntRef { int *target; };
 
+  const int *defaultparam(const int &def1 [[clang::lifetimebound]] = 0); // 
#def1
   int &refparam(int ¶m [[clang::lifetimebound]]);
   int &classparam(IntRef param [[clang::lifetimebound]]);
+  const int *c = defaultparam(); // expected-warning {{temporary whose address 
is used as value of local variable 'c' will be destroyed at the end of the 
full-expression}} expected-note@#def1 {{default argument declared here}}
 
   // Do not diagnose non-void return types; they can still be lifetime-bound.
   long long ptrintcast(int ¶m [[clang::lifetimebound]]) {
@@ -34,13 +36,17 @@ namespace usage_ok {
   struct A {
 A();
 A(int);
+A(const char*, const int& def2 [[clang::lifetimebound]] = 0); // #def2
 int *class_member() [[clang::lifetimebound]];
 operator int*() [[clang::lifetimebound]];
+const int *defaulted_param(const int &def3 [[clang::lifetimebound]] = 0); 
// #def3
   };
 
   int *p = A().class_member(); // expected-warning {{temporary whose address 
is used as value of local variable 'p' will be destroyed at the end of the 
full-expression}}
   int *q = A(); // expected-warning {{temporary whose address is used as value 
of local variable 'q' will be destroyed at the end of the full-expression}}
   int *r = A(1); // expected-warning {{temporary whose address is used as 
value of local variable 'r' will be destroyed at the end of the 
full-expression}}
+  A a = A(""); // expected-warning {{temporary whose address is used as value 
of local variable 'a' will be destroyed at the end of the full-expression}} 
expected-note@#def2 {{default argument declared here}}
+  const int *s = A().defaulted_param(); // expected-warning {{temporary whose 
address is used as value of local variable 's' will be destroyed at the end of 
the full-expression}} expected-note@#def3 {{default argument declared here}}
 
   void test_assignment() {
 p = A().class_member(); // expected-warning {{object backing the pointer p 
will be destroyed at the end of the full-expression}}

__

[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-11 Thread via cfe-commits


@@ -141,6 +141,22 @@ enum NodeType : unsigned {
   VALL_NONZERO,
   VANY_NONZERO,
 
+  // Floating point approximate reciprocal operation
+  FRECIPE_S,

tangaac wrote:

The code has been updated. 
Only `FRECIPE` and  `FRSQRTE` are left.

https://github.com/llvm/llvm-project/pull/109917
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)

2024-10-11 Thread via cfe-commits


@@ -141,6 +141,22 @@ enum NodeType : unsigned {
   VALL_NONZERO,
   VANY_NONZERO,
 
+  // Floating point approximate reciprocal operation
+  FRECIPE_S,

wangleiat wrote:

> They are not the same. The iocsrrd_* instructions have same operand type 
> `GPR` but frecipe_* instructions have different types: FPR32/FPR64/v8f32/...
> 
> Is it right? @wangleiat

yes, just like a generic ISD node, ADD/FADD ...

https://github.com/llvm/llvm-project/pull/109917
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-11 Thread Martin Storsjö via cfe-commits


@@ -5800,8 +5800,10 @@ Not all targets support this attribute. ELF target 
support depends on both the
 linker and runtime linker, and is available in at least lld 4.0 and later,
 binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later.
 Mach-O targets support it, but with slightly different semantics: the resolver
-is run at first call, instead of at load time by the runtime linker. Targets
-other than ELF and Mach-O currently do not support this attribute.
+is run at first call, instead of at load time by the runtime linker. Windows on

mstorsjo wrote:

The sentence starting with "Windows on AArch64" feels like it's missing some 
word at the start, maybe it should start with "On Windows ..."?

https://github.com/llvm/llvm-project/pull/111962
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] Add code completion for C++20 keywords. (PR #107982)

2024-10-11 Thread via cfe-commits

https://github.com/16bit-ykiko updated 
https://github.com/llvm/llvm-project/pull/107982

>From fedea9e4fd57b618fe341e0c30982bff0f098c52 Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 14:59:10 +0800
Subject: [PATCH 01/11] add co_return, co_await, co_yield, consteval,
 constinit, concept, requires, char8_t.

---
 clang/lib/Sema/SemaCodeComplete.cpp | 61 +
 1 file changed, 61 insertions(+)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 88d4732c7d5c6a..d8f6b1dada942a 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1837,6 +1837,11 @@ static void AddTypeSpecifierResults(const LangOptions 
&LangOpts,
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
   Results.AddResult(Result(Builder.TakeString()));
 }
+
+if(LangOpts.CPlusPlus20){
+  Results.AddResult(Result("char8_t", CCP_Type));
+  Results.AddResult(Result("concept", CCP_Keyword));
+}
   } else
 Results.AddResult(Result("__auto_type", CCP_Type));
 
@@ -1889,6 +1894,10 @@ 
AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
 Results.AddResult(Result("constexpr"));
 Results.AddResult(Result("thread_local"));
   }
+
+  if (LangOpts.CPlusPlus20) {
+Results.AddResult(Result("constinit"));
+  }
 }
 
 static void
@@ -1912,6 +1921,9 @@ 
AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC,
   case SemaCodeCompletion::PCC_Template:
 if (LangOpts.CPlusPlus || LangOpts.C99)
   Results.AddResult(Result("inline"));
+
+if (LangOpts.CPlusPlus20)
+  Results.AddResult(Result("consteval"));
 break;
 
   case SemaCodeCompletion::PCC_ObjCInstanceVariableList:
@@ -2487,6 +2499,14 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
   Builder.AddPlaceholderChunk("expression");
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
+  // "co_return expression ;" for coroutines(C++20).
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+Builder.AddTypedTextChunk("co_return");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+Results.AddResult(Result(Builder.TakeString()));
+  }
   // When boolean, also add 'return true;' and 'return false;'.
   if (ReturnType->isBooleanType()) {
 Builder.AddTypedTextChunk("return true");
@@ -2707,6 +2727,47 @@ 
AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
 Builder.AddChunk(CodeCompletionString::CK_RightParen);
 Results.AddResult(Result(Builder.TakeString()));
   }
+
+  if (SemaRef.getLangOpts().CPlusPlus20) {
+// co_await expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_await");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// co_yield expression
+Builder.AddResultTypeChunk("");
+Builder.AddTypedTextChunk("co_yield");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("expression");
+Results.AddResult(Result(Builder.TakeString()));
+
+// requires (parameters) { requirements }
+Builder.AddResultTypeChunk("bool");
+Builder.AddTypedTextChunk("requires");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+Builder.AddPlaceholderChunk("parameters");
+Builder.AddChunk(CodeCompletionString::CK_RightParen);
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddPlaceholderChunk("requirements");
+Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+Results.AddResult(Result(Builder.TakeString()));
+
+if(llvm::isa(SemaRef.CurContext)){
+  // requires expression ;
+  Builder.AddResultTypeChunk("");
+  Builder.AddTypedTextChunk("requires");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("expression");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(Result(Builder.TakeString()));
+}
+  }
 }
 
 if (SemaRef.getLangOpts().ObjC) {

>From 36a0db2b827baaabe17c5cd7b576802be586c69c Mon Sep 17 00:00:00 2001
From: ykiko 
Date: Tue, 10 Sep 2024 15:50:04 +0800
Subject: [PATCH 02/11] make concept and requires more sensitive to context.

--

[clang] [clang][CGOpenMPRuntime] Avoid Type::getPointerTo() (NFC) (PR #112017)

2024-10-11 Thread Nikita Popov via cfe-commits

https://github.com/nikic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/112017
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Driver][SYCL] Add initial SYCL offload compilation support (PR #107493)

2024-10-11 Thread Michael Toguchi via cfe-commits

mdtoguchi wrote:

Hello - any additional feedback on this?

https://github.com/llvm/llvm-project/pull/107493
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Make [[clang::lifetimebound]] work for expressions coming from default arguments (PR #112047)

2024-10-11 Thread Richard Smith via cfe-commits

zygoloid wrote:

> I expect that won't be caught, and you'll need to make a similar change to 
> `visitLocalsRetainedByInitializer` to handle it.

Actually, maybe the best thing would be to change `visitFunctionCallArguments` 
to step over `CXXDefaultArgExpr` in `Args`. That should cover both cases, and 
the only place we should see a `CXXDefaultArgExpr` is at the top level in some 
form of function call.

https://github.com/llvm/llvm-project/pull/112047
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)

2024-10-11 Thread Tom Honermann via cfe-commits

https://github.com/tahonermann updated 
https://github.com/llvm/llvm-project/pull/111389

>From 3c4a2b8a52d3f1c730df88a308dece21a67834ef Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Fri, 4 Oct 2024 11:10:32 -0700
Subject: [PATCH 1/3] [SYCL] The sycl_kernel_entry_point attribute.

The `sycl_kernel_entry_point` attribute is used to declare a function that
defines a pattern for an offload kernel to be emitted. The attribute requires
a single type argument that specifies the type used as a SYCL kernel name as
described in section 5.2, "Naming of kernels", of the SYCL 2020 specification.

Properties of the offload kernel are collected when a function declared with
the `sycl_kernel_entry_point` attribute is parsed or instantiated. These
properties, such as the kernel name type, are stored in the AST context where
they are (or will be) used for diagnostic purposes and to facilitate reflection
to a SYCL run-time library. These properties are not serialized with the AST
but are recreated upon deserialization.

The `sycl_kernel_entry_point` attribute is intended to replace the existing
`sycl_kernel` attribute which is intended to be deprecated in a future change
and removed following an appropriate deprecation period. The new attribute
differs in that it is enabled for both SYCL host and device compilation, may
be used with non-template functions, explicitly indicates the type used as
the kernel name type, and will impact AST generation.

This change adds the basic infrastructure for the new attribute. Future
changes will add diagnostics and new AST support that will be used to drive
generation of the corresponding offload kernel.
---
 clang/include/clang/AST/ASTContext.h  |  12 ++
 clang/include/clang/AST/SYCLKernelInfo.h  |  47 ++
 clang/include/clang/Basic/Attr.td |  16 +-
 clang/include/clang/Basic/AttrDocs.td |  58 +++
 clang/include/clang/Sema/SemaSYCL.h   |   1 +
 clang/lib/AST/ASTContext.cpp  |  25 +++
 clang/lib/Sema/SemaDecl.cpp   |   4 +
 clang/lib/Sema/SemaDeclAttr.cpp   |   3 +
 clang/lib/Sema/SemaSYCL.cpp   |   9 ++
 clang/lib/Serialization/ASTReaderDecl.cpp |   9 ++
 .../ast-dump-sycl-kernel-entry-point.cpp  | 144 ++
 ...a-attribute-supported-attributes-list.test |   1 +
 .../sycl-kernel-entry-point-attr-grammar.cpp  | 137 +
 .../sycl-kernel-entry-point-attr-ignored.cpp  |  17 +++
 14 files changed, 480 insertions(+), 3 deletions(-)
 create mode 100644 clang/include/clang/AST/SYCLKernelInfo.h
 create mode 100644 clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-kernel-entry-point-attr-grammar.cpp
 create mode 100644 clang/test/SemaSYCL/sycl-kernel-entry-point-attr-ignored.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index b65a1f7dff5bc1..e68f0a4da57b16 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -23,6 +23,7 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RawCommentList.h"
+#include "clang/AST/SYCLKernelInfo.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PartialDiagnostic.h"
@@ -1222,6 +1223,11 @@ class ASTContext : public RefCountedBase {
   /// in device compilation.
   llvm::DenseSet CUDAImplicitHostDeviceFunUsedByDevice;
 
+  /// Map of SYCL kernels indexed by the unique type used to name the kernel.
+  /// Entries are not serialized but are recreated on deserialization of a
+  /// sycl_kernel_entry_point attributed function declaration.
+  llvm::DenseMap SYCLKernels;
+
   /// For capturing lambdas with an explicit object parameter whose type is
   /// derived from the lambda type, we need to perform derived-to-base
   /// conversion so we can access the captures; the cast paths for that
@@ -3301,6 +3307,12 @@ class ASTContext : public RefCountedBase {
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  GlobalDecl GD) const;
 
+  /// Generates and stores SYCL kernel metadata for the provided
+  /// SYCL kernel entry point function. The provided function must have
+  /// an attached sycl_kernel_entry_point attribute that specifies a unique
+  /// type for the name of a SYCL kernel.
+  void registerSYCLEntryPointFunction(FunctionDecl *FD);
+
   
//======//
   //Statistics
   
//======//
diff --git a/clang/include/clang/AST/SYCLKernelInfo.h 
b/clang/include/clang/AST/SYCLKernelInfo.h
new file mode 100644
index 00..79a83330f1d23b
--- /dev/null
+++ b/clang/include/clang/AST/SYCLKernelInfo.h
@@ -0,0 +1,47 @@
+//===--- SYCLKernelInfo.h --- Information about SYCL kernels 
--===//
+//
+// P

[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/111798

>From 259282836aa24e59b94dba0572faa2180520028d Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Thu, 10 Oct 2024 15:31:19 +0800
Subject: [PATCH] [Driver][AVR] Reject c/c++ compilation for avr1 devices

avr-gcc also rejects since these devices has no SRAM.

Fixes https://github.com/llvm/llvm-project/issues/96881
---
 clang/lib/Driver/ToolChains/AVR.cpp | 8 
 clang/test/Driver/avr-mmcu.c| 5 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index bb5c0e6db9978e..08e906ac9e8067 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices since they have no SRAM.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());
+  std::optional FamilyName = GetMCUFamilyName(CPU);
+  if (CPU == "avr1" || (FamilyName && *FamilyName == "avr1"))
+D.Diag(diag::err_drv_opt_unsupported_input_type)
+<< "-mmcu=" + CPU << "c/c++";
+
   // By default, use `.ctors` (not `.init_array`), as required by libgcc, which
   // runs constructors/destructors on AVR.
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
diff --git a/clang/test/Driver/avr-mmcu.c b/clang/test/Driver/avr-mmcu.c
index 6c13ab5b68d3b9..0edb05dad136ab 100644
--- a/clang/test/Driver/avr-mmcu.c
+++ b/clang/test/Driver/avr-mmcu.c
@@ -1,8 +1,7 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK0 %s
-// CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
-// CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
+// RUN: not %clang -### --target=avr -mmcu=attiny11 %s 2>&1 | FileCheck 
-check-prefix=CHECK0 %s
+// CHECK0: error: '-mmcu=attiny11' invalid for input of type c/c++
 
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"

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


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits

benshi001 wrote:

> Thanks for getting to this I had forgotten I raised that issue.
> 
> You should move your commit's message into the PR description, as the PR 
> description is what's used for the final commit when we merge this.

Thanks. I have update my PR description according to my commit message.

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits


@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());
+  std::optional FamilyName = GetMCUFamilyName(CPU);
+  if (CPU == "avr1" || (FamilyName && FamilyName->compare("avr1") == 0))
+D.Diag(diag::err_drv_opt_unsupported_input_type) << "avr1"
+ << "c/c++";

benshi001 wrote:

Since `-mmcu` is the only way to trigger this issue, I have updated my error 
message to `'-mmcu=attiny11' invalid for input of type c/c++`

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits


@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());
+  std::optional FamilyName = GetMCUFamilyName(CPU);
+  if (CPU == "avr1" || (FamilyName && FamilyName->compare("avr1") == 0))

benshi001 wrote:

Fixed. Thanks.

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits


@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices.

benshi001 wrote:

I have updated my comments to "Reject C/C++ compilation for avr1 devices since 
they have no SRAM."

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits


@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());

benshi001 wrote:

I think `const Driver &D = getDriver();` at line 404 is necessary, since I have 
to use  `D.Diag(..)`, it would not be better to call `getDriver()` twice.

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits

https://github.com/benshi001 edited 
https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/111798

>From c50c44044546fd9d67dab56b1f88b2e83557656f Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Thu, 10 Oct 2024 15:31:19 +0800
Subject: [PATCH] [clang][Driver][AVR] Reject c/c++ compilation for avr1
 devices

avr-gcc also rejects since these devices has no SRAM.

Fixes https://github.com/llvm/llvm-project/issues/96881
---
 clang/lib/Driver/ToolChains/AVR.cpp | 8 
 clang/test/Driver/avr-mmcu.c| 5 ++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index bb5c0e6db9978e..08e906ac9e8067 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -400,6 +400,14 @@ void AVRToolChain::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
 void AVRToolChain::addClangTargetOptions(
 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const {
+  // Reject C/C++ compilation for avr1 devices since they have no SRAM.
+  const Driver &D = getDriver();
+  std::string CPU = getCPUName(D, DriverArgs, getTriple());
+  std::optional FamilyName = GetMCUFamilyName(CPU);
+  if (CPU == "avr1" || (FamilyName && *FamilyName == "avr1"))
+D.Diag(diag::err_drv_opt_unsupported_input_type)
+<< "-mmcu=" + CPU << "c/c++";
+
   // By default, use `.ctors` (not `.init_array`), as required by libgcc, which
   // runs constructors/destructors on AVR.
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
diff --git a/clang/test/Driver/avr-mmcu.c b/clang/test/Driver/avr-mmcu.c
index 6c13ab5b68d3b9..0edb05dad136ab 100644
--- a/clang/test/Driver/avr-mmcu.c
+++ b/clang/test/Driver/avr-mmcu.c
@@ -1,8 +1,7 @@
 // A test for the propagation of the -mmcu option to -cc1 and -cc1as
 
-// RUN: %clang -### --target=avr -mmcu=attiny11 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK0 %s
-// CHECK0: "-cc1" {{.*}} "-target-cpu" "attiny11"
-// CHECK0: "-cc1as" {{.*}} "-target-cpu" "attiny11"
+// RUN: not %clang -### --target=avr -mmcu=attiny11 %s 2>&1 | FileCheck 
-check-prefix=CHECK0 %s
+// CHECK0: error: '-mmcu=attiny11' invalid for input of type c/c++
 
 // RUN: %clang -### --target=avr -mmcu=at90s2313 -save-temps %s 2>&1 | 
FileCheck -check-prefix=CHECK1 %s
 // CHECK1: "-cc1" {{.*}} "-target-cpu" "at90s2313"

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


[clang] [llvm] [CGData][ThinLTO] Global Outlining with Two-CodeGen Rounds (PR #90933)

2024-10-11 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64-aix` running 
on `aix-ppc64` while building `clang,llvm` at step 3 "clean-build-dir".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/64/builds/1190


Here is the relevant piece of the build log for the reference

```
Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 5 (build-unified-tree) failure: build (failure)
...
1386.006 [3967/10/1190] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ValueLatticeUtils.cpp.o
1388.863 [3966/10/1191] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TargetTransformInfo.cpp.o
1391.228 [3965/10/1192] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/UniformityAnalysis.cpp.o
1395.461 [3964/10/1193] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/StackSafetyAnalysis.cpp.o
1401.264 [3963/10/1194] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/TargetLibraryInfo.cpp.o
1402.935 [3962/10/1195] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/UpdateCompilerUsed.cpp.o
1403.156 [3961/10/1196] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/VectorUtils.cpp.o
1406.575 [3960/10/1197] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ValueTracking.cpp.o
1407.006 [3959/10/1198] Building CXX object 
lib/MC/CMakeFiles/LLVMMC.dir/DXContainerPSVInfo.cpp.o
1407.994 [3958/10/1199] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
FAILED: lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o 
/usr/local/clang-17.0.2/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_LARGE_FILE_API -D_XOPEN_SOURCE=700 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/lib/LTO 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/LTO
 -I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/include 
-I/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/include
 -mcmodel=large -fPIC -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions 
-funwind-tables -fno-rtti -UNDEBUG -MD -MT 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o -MF 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o.d -o 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o -c 
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/LTO/LTO.cpp
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/LTO/LTO.cpp:2087:25:
 error: moving a temporary object prevents copy elision 
[-Werror,-Wpessimizing-move]
 2087 |   AddStream, Cache, std::move(IR.getResult()), CombinedHash);
  | ^
/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/lib/LTO/LTO.cpp:2087:25:
 note: remove std::move call here
 2087 |   AddStream, Cache, std::move(IR.getResult()), CombinedHash);
  | ^~  ~
1 error generated.
1408.126 [3958/9/1200] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTOModule.cpp.o
1408.365 [3958/8/1201] Building CXX object 
lib/MC/CMakeFiles/LLVMMC.dir/ConstantPools.cpp.o
1408.815 [3958/7/1202] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTOCodeGenerator.cpp.o
1410.461 [3958/6/1203] Building CXX object 
lib/MC/CMakeFiles/LLVMMC.dir/GOFFObjectWriter.cpp.o
1410.509 [3958/5/1204] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/LTOBackend.cpp.o
1412.102 [3958/4/1205] Building CXX object 
lib/MC/CMakeFiles/LLVMMC.dir/MCAsmBackend.cpp.o
1412.132 [3958/3/1206] Building CXX object 
lib/MC/CMakeFiles/LLVMMC.dir/ELFObjectWriter.cpp.o
1422.635 [3958/2/1207] Building CXX object 
lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ScalarEvolution.cpp.o
1424.659 [3958/1/1208] Building CXX object 
lib/LTO/CMakeFiles/LLVMLTO.dir/ThinLTOCodeGenerator.cpp.o
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-project/pull/90933
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver][AVR] Reject c/c++ compilation for avr1 devices (PR #111798)

2024-10-11 Thread Ben Shi via cfe-commits

benshi001 wrote:

> ```
> �_bk;t=1728546187607�Failed Tests (1):
> �_bk;t=1728546187607�  Clang :: Driver/hip-partial-link.hip
> ```
> 
> And the CI test failure is this, the reporting is not great because we run 
> check- targets one after another. This test was already failing on main.
> 
> If it fails again download the logs and search for "Failed<2-3 spaces>" and 
> you'll see any results summaries where something failed. I plan to work on 
> combining the results so this isn't a problem in the future.

Thanks. I am also thinking the failure is not related to my clang-driver-AVR 
work.

https://github.com/llvm/llvm-project/pull/111798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (PR #87717)

2024-10-11 Thread Max Winkler via cfe-commits

MaxEW707 wrote:

I put a PR with a fix, https://github.com/llvm/llvm-project/pull/112066.

This should probably go into 19.1.2 but I am familiar with that process. 
If someone with more experience in the project can give guidance there that 
would be appreciated :).

https://github.com/llvm/llvm-project/pull/87717
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments without breaking internal structure (think Doxygen). (PR #96804)

2024-10-11 Thread Owen Pan via cfe-commits

https://github.com/owenca approved this pull request.


https://github.com/llvm/llvm-project/pull/96804
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-11 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 created 
https://github.com/llvm/llvm-project/pull/112066

Fixes https://github.com/llvm/llvm-project/pull/87717.

>From 52e2175eb672fa9a97f9c1480a3cfb727b7c3dce Mon Sep 17 00:00:00 2001
From: MaxEW707 
Date: Fri, 11 Oct 2024 19:01:59 -0700
Subject: [PATCH] Fix extra tokens inside intrin0.h preprocessor directive

---
 clang/lib/Headers/intrin0.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Headers/intrin0.h b/clang/lib/Headers/intrin0.h
index 866c8896617d22..6b01f3808652aa 100644
--- a/clang/lib/Headers/intrin0.h
+++ b/clang/lib/Headers/intrin0.h
@@ -44,7 +44,7 @@ unsigned char _InterlockedCompareExchange128_rel(__int64 
volatile *_Destination,
  __int64 *_ComparandResult);
 #endif
 
-#ifdef __x86_64__ && !defined(__arm64ec__)
+#if defined(__x86_64__) && !defined(__arm64ec__)
 unsigned __int64 _umul128(unsigned __int64, unsigned __int64,
   unsigned __int64 *);
 unsigned __int64 __shiftleft128(unsigned __int64 _LowPart,

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


[clang] [clang-format] Stop crashing when formatting Verilog (PR #112043)

2024-10-11 Thread Owen Pan via cfe-commits

https://github.com/owenca approved this pull request.


https://github.com/llvm/llvm-project/pull/112043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-11 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Max Winkler (MaxEW707)


Changes

Fixes https://github.com/llvm/llvm-project/pull/87717.

---
Full diff: https://github.com/llvm/llvm-project/pull/112066.diff


1 Files Affected:

- (modified) clang/lib/Headers/intrin0.h (+1-1) 


``diff
diff --git a/clang/lib/Headers/intrin0.h b/clang/lib/Headers/intrin0.h
index 866c8896617d22..6b01f3808652aa 100644
--- a/clang/lib/Headers/intrin0.h
+++ b/clang/lib/Headers/intrin0.h
@@ -44,7 +44,7 @@ unsigned char _InterlockedCompareExchange128_rel(__int64 
volatile *_Destination,
  __int64 *_ComparandResult);
 #endif
 
-#ifdef __x86_64__ && !defined(__arm64ec__)
+#if defined(__x86_64__) && !defined(__arm64ec__)
 unsigned __int64 _umul128(unsigned __int64, unsigned __int64,
   unsigned __int64 *);
 unsigned __int64 __shiftleft128(unsigned __int64 _LowPart,

``




https://github.com/llvm/llvm-project/pull/112066
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0fba838 - [clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments without breaking internal structure (think Doxygen). (#96804)

2024-10-11 Thread via cfe-commits

Author: Iuri Chaer
Date: 2024-10-11T19:14:09-07:00
New Revision: 0fba8381d2a71ff440fdf0ae30d59a0bf07fea75

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

LOG: [clang-format] Introduce "ReflowComments: IndentOnly" to re-indent 
comments without breaking internal structure (think Doxygen). (#96804)

* Convert `ReflowComments` from boolean into a new `enum` which can take
on the value `RCS_Never`, `RCS_IndentOnly`, or `RCS_Always`. The first
one is equivalent to the old `false`, the third one is `true`, and the
middle one means that multiline comments should only have their
indentation corrected, which is what Doxygen users will want.
* Preserve backward compatibility while parsing `ReflowComments`.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.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/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a9bfb4c4a0fcb2..8add0a53e5be13 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5406,22 +5406,46 @@ the configuration (without a prefix: ``Auto``).
 
 .. _ReflowComments:
 
-**ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8` :ref:`¶ 
`
-  If ``true``, clang-format will attempt to re-flow comments. That is it
-  will touch a comment and *reflow* long comments into new lines, trying to
-  obey the ``ColumnLimit``.
+**ReflowComments** (``ReflowCommentsStyle``) :versionbadge:`clang-format 3.8` 
:ref:`¶ `
+  Comment reformatting style.
 
-  .. code-block:: c++
+  Possible values:
+
+  * ``RCS_Never`` (in configuration: ``Never``)
+Leave comments untouched.
+
+.. code-block:: c++
+
+   // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty 
of information
+   /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information */
+   /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information
+* and a misaligned second line */
+
+  * ``RCS_IndentOnly`` (in configuration: ``IndentOnly``)
+Only apply indentation rules, moving comments left or right, without
+changing formatting inside the comments.
+
+.. code-block:: c++
+
+   // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty 
of information
+   /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information */
+   /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information
+* and a misaligned second line */
+
+  * ``RCS_Always`` (in configuration: ``Always``)
+Apply indentation rules and reflow long comments into new lines, trying
+to obey the ``ColumnLimit``.
+
+.. code-block:: c++
+
+   // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty 
of
+   // information
+   /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of
+* information */
+   /* third veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of
+* information and a misaligned second line */
 
- false:
- // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of 
information
- /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information */
 
- true:
- // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
- // information
- /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of
-  * information */
 
 .. _RemoveBracesLLVM:
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 69f02fb0910177..337e3fc10bf49d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -663,6 +663,8 @@ clang-format
 - Adds ``BreakBinaryOperations`` option.
 - Adds ``TemplateNames`` option.
 - Adds ``AlignFunctionDeclarations`` option to 
``AlignConsecutiveDeclarations``.
+- Adds ``IndentOnly`` suboption to ``ReflowComments`` to fix the indentation 
of multi-line comments
+  without touching their contents, renames ``false`` to ``Never``, and 
``true`` to ``Always``.
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 3d3e4330902a30..a0762b088b68ef 100644
--- a/clang/include/clang/Format/Format.h
+++ b/cla

[clang] [clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments without breaking internal structure (think Doxygen). (PR #96804)

2024-10-11 Thread Owen Pan via cfe-commits

https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/96804
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Introduce "ReflowComments: IndentOnly" to re-indent comments without breaking internal structure (think Doxygen). (PR #96804)

2024-10-11 Thread via cfe-commits

github-actions[bot] wrote:



@ichaer Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/96804
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang & libcxx] constexpr pointer tagging (DO NOT MERGE) (PR #111861)

2024-10-11 Thread Hana Dusíková via cfe-commits

https://github.com/hanickadot updated 
https://github.com/llvm/llvm-project/pull/111861

From e1c8d5e689fe8d3d0338eb64220aaf6371aed48a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dusi=CC=81kova=CC=81?= 
Date: Thu, 10 Oct 2024 21:05:55 +0200
Subject: [PATCH 1/3] [clang & libcxx] constexpr pointer tagging (not for
 merging, just for review)

---
 clang/include/clang/AST/APValue.h |   4 +
 clang/include/clang/Basic/Builtins.td |  37 ++
 .../include/clang/Basic/DiagnosticASTKinds.td |   6 +
 clang/lib/AST/APValue.cpp |  10 +
 clang/lib/AST/ExprConstant.cpp| 112 +
 clang/lib/CodeGen/CGBuiltin.cpp   | 102 
 clang/lib/CodeGen/CodeGenFunction.h   |   7 +
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__memory/tagged_ptr.h  | 447 ++
 libcxx/include/memory |   4 +
 libcxx/include/module.modulemap   |   1 +
 11 files changed, 731 insertions(+)
 create mode 100644 libcxx/include/__memory/tagged_ptr.h

diff --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 7869ee386689d7..278cf61dd56f89 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -198,6 +198,8 @@ class APValue {
   /// The QualType, if this is a DynamicAllocLValue.
   void *DynamicAllocType;
 };
+  public:
+uint64_t Metadata{0};
   };
 
   /// A FieldDecl or CXXRecordDecl, along with a flag indicating whether we
@@ -527,6 +529,8 @@ class APValue {
   }
 
   const LValueBase getLValueBase() const;
+  uint64_t getLValueMetadata() const;
+  uint64_t & getLValueMetadata();
   CharUnits &getLValueOffset();
   const CharUnits &getLValueOffset() const {
 return const_cast(this)->getLValueOffset();
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 9ebee81fcb0d3d..6231f1c8af2830 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4867,3 +4867,40 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> {
   let Attributes = [CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
+
+// support for pointer tagging
+// (ptr & mask) | (val & ~mask)
+def TagPointerMaskOr : Builtin {
+  let Spellings = ["__builtin_tag_pointer_mask_or"];
+  let Attributes = [Constexpr, NoThrow];
+  let Prototype = "void*(void*, size_t, size_t)";
+}
+
+// (ptr & mask) -> void *
+def TagPointerMask : Builtin {
+  let Spellings = ["__builtin_tag_pointer_mask"];
+  let Attributes = [Constexpr, NoThrow];
+  let Prototype = "void*(void*, size_t)";
+}
+
+// (ptr & mask) -> uintptr_t
+def TagPointerMaskAsInt : Builtin {
+  let Spellings = ["__builtin_tag_pointer_mask_as_int"];
+  let Attributes = [Constexpr, NoThrow];
+  let Prototype = "size_t(void*, size_t)";
+}
+
+// (ptr << shift) | (value & ~mask) -> void *
+// mask = (1 << shift) - 1
+def TagPointerShiftOr : Builtin {
+  let Spellings = ["__builtin_tag_pointer_shift_or"];
+  let Attributes = [Constexpr, NoThrow];
+  let Prototype = "void*(void*, size_t, size_t)";
+}
+
+// (ptr >> unshift) -> void *
+def TagPointerUnshift : Builtin {
+  let Spellings = ["__builtin_tag_pointer_unshift"];
+  let Attributes = [Constexpr, NoThrow];
+  let Prototype = "void*(void*, size_t)";
+}
diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 6a658cf14356f5..3d6b0cbebc7002 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -218,6 +218,12 @@ def note_constexpr_access_null : Note<
 def note_constexpr_access_past_end : Note<
   "%sub{access_kind}0 dereferenced one-past-the-end pointer "
   "is not allowed in a constant expression">;
+def note_constexpr_dereferencing_tagged_pointer: Note<
+  "dereferencing tagged pointer">;
+def note_constexpr_tagging_with_shift_zero: Note<
+  "you must shift pointer at least by one bit to store a tag">;
+def note_constexpr_tagging_with_empty_mask: Note<
+  "you must provide non-zero mask for pointer tagging">;
 def note_constexpr_access_unsized_array : Note<
   "%sub{access_kind}0 element of array without known bound "
   "is not allowed in a constant expression">;
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 4f5d14cbd59bbf..02ba5cf51d4176 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -975,6 +975,16 @@ const APValue::LValueBase APValue::getLValueBase() const {
   return ((const LV *)(const void *)&Data)->Base;
 }
 
+uint64_t APValue::getLValueMetadata() const {
+  assert(isLValue() && "Invalid accessor");
+  return ((const LV *)(const void *)&Data)->Base.Metadata;
+}
+
+uint64_t & APValue::getLValueMetadata() {
+  assert(isLValue() && "Invalid accessor");
+  return ((LV *)(void *)&Data)->Base.Metadata;
+}
+
 bool APValue::isLValueOnePastTheEnd() const {
   assert(isLValue() && "Invalid a

[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,compiler-rt` at step 6 
"build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/153/builds/11565


Here is the relevant piece of the build log for the reference

```
Step 6 (build-unified-tree) failure: build (failure)
...
11.487 [72/58/1366] Linking CXX shared library 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_minimal.so
11.500 [71/58/1367] Building CXX object 
compiler-rt/lib/nsan/CMakeFiles/RTNsan_dynamic.x86_64.dir/nsan_stats.cpp.o
11.500 [70/58/1368] Linking CXX static library 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.hwasan.a
11.504 [69/58/1369] Building CXX object 
compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan-x86_64.dir/tsan_rtl_access.cpp.o
11.522 [68/58/1370] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profiling_flags.cpp.o
11.523 [67/58/1371] Linking CXX static library 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.profile.a
11.541 [66/58/1372] Generating exported symbols for 
clang_rt.ubsan_minimal-x86_64
11.550 [65/58/1373] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXrayDSO.x86_64.dir/xray_dso_init.cpp.o
11.553 [64/58/1374] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_log_interface.cpp.o
11.562 [63/58/1375] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o
FAILED: compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o 
/build/buildbot/premerge-monolithic-linux/build/./bin/clang++ 
--target=x86_64-unknown-linux-gnu -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS 
-DXRAY_HAS_EXCEPTIONS=1 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/lib/xray/..
 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/lib/xray/../../include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported 
-fdiagnostics-color -ffunction-sections -fdata-sections -Wall 
-Wno-unused-parameter -O3 -DNDEBUG -m64 -fPIC -fno-builtin -fno-exceptions 
-fomit-frame-pointer -funwind-tables -fno-stack-protector 
-fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety 
-Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu 
-Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern 
-Wno-format -fno-rtti -std=c++17 -MD -MT 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o -MF 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o.d -o 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o -c 
/build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/lib/xray/xray_interface.cpp
/build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/lib/xray/xray_interface.cpp:16:10:
 fatal error: 'llvm/Support/ErrorHandling.h' file not found
   16 | #include "llvm/Support/ErrorHandling.h"
  |  ^~
1 error generated.
11.563 [63/57/1376] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_init.cpp.o
/build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/lib/xray/xray_init.cpp:213:27:
 warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 
'size_t' (aka 'unsigned long') [-Wsign-compare]
  213 |   if (ObjId <= 0 || ObjId >= __xray_num_objects()) {
  | ~ ^  
1 warning generated.
11.563 [63/56/1377] Building CXX object 
compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan-dynamic-x86_64.dir/tsan_rtl_report.cpp.o
11.572 [63/55/1378] Building CXX object 
compiler-rt/lib/nsan/CMakeFiles/RTNsan_dynamic.x86_64.dir/nsan.cpp.o
11.592 [63/54/1379] Building CXX object 
compiler-rt/lib/memprof/CMakeFiles/RTMemprof_dynamic.x86_64.dir/memprof_shadow_setup.cpp.o
11.612 [63/53/1380] Generating version list for clang_rt.hwasan-dynamic-x86_64
11.633 [63/52/1381] Generating exported symbols for clang_rt.hwasan-x86_64
11.648 [63/51/1382] Building CXX object 
compiler-rt/lib/memprof/CMakeFiles/RTMemprof_dynamic.x86_64.dir/memprof_descriptions.cpp.o
11.650 [63/50/1383] Building ASM object 
compiler-rt/lib/xray/CMakeFiles/RTXrayDSO.x86_64.dir/xray_trampoline_x86_64.S.o
11.675 [63/49/1384] Building CXX object 
compiler-rt/

[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

I cannot reproduce the fail of `Driver/hip-partial-link.hip`. Any idea about it?

https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while 
building `clang,compiler-rt` at step 5 "compile-openmp".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/140/builds/8563


Here is the relevant piece of the build log for the reference

```
Step 5 (compile-openmp) failure: build (failure)
...
4.749 [1061/34/644] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_init.cpp.o
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/compiler-rt/lib/xray/xray_init.cpp:213:27:
 warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 
'size_t' (aka 'unsigned long') [-Wsign-compare]
  213 |   if (ObjId <= 0 || ObjId >= __xray_num_objects()) {
  | ~ ^  
1 warning generated.
4.752 [1060/34/645] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXrayPROFILING.x86_64.dir/xray_profiling_flags.cpp.o
4.761 [1059/34/646] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_log_interface.cpp.o
4.762 [1058/34/647] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtFunctionsDlsym.cpp.o
4.763 [1057/34/648] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtFunctionsWindows.cpp.o
4.766 [1056/34/649] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o
FAILED: compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/./bin/clang++ 
--target=x86_64-unknown-linux-gnu -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS 
-DXRAY_HAS_EXCEPTIONS=1 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/compiler-rt/lib/xray/..
 
-I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/compiler-rt/lib/xray/../../include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported 
-fdiagnostics-color -ffunction-sections -fdata-sections -Wall 
-Wno-unused-parameter -O3 -DNDEBUG -m64 -fPIC -fno-builtin -fno-exceptions 
-fomit-frame-pointer -funwind-tables -fno-stack-protector 
-fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety 
-Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu 
-Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern 
-Wno-format -fno-rtti -std=c++17 -MD -MT 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o -MF 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o.d -o 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_interface.cpp.o -c 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/compiler-rt/lib/xray/xray_interface.cpp
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/compiler-rt/lib/xray/xray_interface.cpp:16:10:
 fatal error: 'llvm/Support/ErrorHandling.h' file not found
   16 | #include "llvm/Support/ErrorHandling.h"
  |  ^~
1 error generated.
4.772 [1056/33/650] Linking CXX static library 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/20/lib/x86_64-unknown-linux-gnu/libclang_rt.xray-dso.a
4.780 [1056/32/651] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersDarwin.cpp.o
4.787 [1056/31/652] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCounters.cpp.o
4.788 [1056/30/653] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTfuzzer.x86_64.dir/FuzzerExtraCountersWindows.cpp.o
4.791 [1056/29/654] Building CXX object 
compiler-rt/lib/nsan/CMakeFiles/RTNsan.x86_64.dir/nsan.cpp.o
4.889 [1056/28/655] Building CXX object 
compiler-rt/lib/nsan/CMakeFiles/RTNsan_dynamic.x86_64.dir/nsan_allocator.cpp.o
4.900 [1056/27/656] Building CXX object 
compiler-rt/lib/ctx_profile/CMakeFiles/clang_rt.ctx_profile-x86_64.dir/CtxInstrProfiling.cpp.o
4.945 [1056/26/657] Building CXX object 
compiler-rt/lib/nsan/CMakeFiles/RTNsan.x86_64.dir/nsan_allocator.cpp.o
4.983 [1056/25/658] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXrayBASIC.x86_64.dir/xray_basic_logging.cpp.o
4.986 [1056/24/659] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_buffer_queue.cpp.o
5.101 [1056/23/660] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.x86_64.dir/xray_utils.cpp.o
5.180 [1056/22/661] Building CXX object 
compiler-rt/lib/fuzzer/CMakeFiles/RTf

[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-10-11 Thread Timm Baeder via cfe-commits

tbaederr wrote:

> > Can you add a test that passes a non-float value and checks that it's 
> > rejected?
> 
> Do you mean something like this?
> 
> ```
> $ cat xx.c 
> #include 
> 
> float f(char *a, char *b) {
> return fminimum_num(a, b);
> }
> $ ./bin/clang -std=c23 -O2 -S -emit-llvm xx.c 
> xx.c:4:22: error: passing 'char *' to parameter of incompatible type 'double'
> 4 | return fminimum_num(a, b);
>   | ^
> /usr/include/x86_64-linux-gnu/bits/mathcalls.h:409:40: note: passing argument 
> to parameter '__x' here
>   409 | __MATHCALLX (fminimum_num,, (_Mdouble_ __x, _Mdouble_ __y), 
> (__const__));
>   |^
> 1 error generated.
> ```

Yes, but also with an integer please


https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-10-11 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-ppc64le-linux-test-suite` running on `ppc64le-clang-test-suite` while 
building `clang,compiler-rt` at step 5 "build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/95/builds/4912


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
1 warning generated.
0.996 [37/190/303] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_log_interface.cpp.o
1.001 [37/189/304] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizerNoHooks.powerpc64le.dir/sanitizer_stackdepot.cpp.o
1.007 [37/188/305] Building CXX object 
compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic.powerpc64le.dir/asan_stack.cpp.o
1.013 [37/187/306] Building C object 
compiler-rt/lib/profile/CMakeFiles/clang_rt.profile-powerpc64le.dir/GCDAProfiling.c.o
1.014 [37/186/307] Building CXX object 
compiler-rt/lib/stats/CMakeFiles/clang_rt.stats-powerpc64le.dir/stats.cpp.o
1.016 [37/185/308] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoHooks.powerpc64le.dir/sanitizer_libignore.cpp.o
1.030 [37/184/309] Building CXX object 
compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-powerpc64le.dir/string_utils.cpp.o
1.032 [37/183/310] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.powerpc64le.dir/sanitizer_printf.cpp.o
1.038 [37/182/311] Building CXX object 
compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_interface.cpp.o
FAILED: 
compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_interface.cpp.o 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/./bin/clang++
 --target=powerpc64le-unknown-linux-gnu -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS 
-DXRAY_HAS_EXCEPTIONS=1 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/lib/xray/..
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/lib/xray/../../include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type 
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override 
-Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported 
-fdiagnostics-color -ffunction-sections -fdata-sections -Wall 
-Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -m64 -fno-function-sections -fPIC 
-fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables 
-fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 
-gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions 
-Wno-format -fno-rtti -MD -MT 
compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_interface.cpp.o -MF 
compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_interface.cpp.o.d 
-o compiler-rt/lib/xray/CMakeFiles/RTXray.powerpc64le.dir/xray_interface.cpp.o 
-c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/lib/xray/xray_interface.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/lib/xray/xray_interface.cpp:16:10:
 fatal error: 'llvm/Support/ErrorHandling.h' file not found
   16 | #include "llvm/Support/ErrorHandling.h"
  |  ^~
1 error generated.
1.039 [37/181/312] Building CXX object 
compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan-powerpc64le.dir/tsan_mutexset.cpp.o
1.042 [37/180/313] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.powerpc64le.dir/sanitizer_flags.cpp.o
1.043 [37/179/314] Building CXX object 
compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic.powerpc64le.dir/asan_flags.cpp.o
1.044 [37/178/315] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizerNoHooks.powerpc64le.dir/sanitizer_symbolizer_report.cpp.o
1.049 [37/177/316] Building CXX object 
compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.powerpc64le.dir/sanitizer_symbolizer.cpp.o
1.050 [37/176/317] Building CXX object 
compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64le.dir/asan_activation.cpp.o
1.051 [37/175/318] Building CXX object 
compiler-rt/lib/scudo/standalone/CMakeFiles/clang_rt.scudo_standalone-dynamic-powerpc64le.dir/string_utils.cpp.o
1.054 [37/174/319] Building CXX object 
compiler-rt/lib/sanitizer_c

  1   2   3   4   5   6   >