[clang] [Driver][X86] Add -m[no-]apxf to m_x86_Features_Group (PR #140874)

2025-05-27 Thread Feng Zou via cfe-commits

fzou1 wrote:

> > Looks like this breaks tests on macOS: 
> > http://45.33.8.238/macm1/107398/step_6.txt
> > Please take a look and revert for now if it takes a while to fix.
> 
> Thank you. I've reproduced this issue on MacOS and updated PR #141486 to fix 
> it.

@nico / @rorth , The PR #141486 had been merged. Please have a check. Thanks.

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


[clang] [llvm] [clang][DebugInfo] Add symbol for debugger with VTable information. (PR #130255)

2025-05-27 Thread Carlos Alberto Enciso via cfe-commits

CarlosAlbertoEnciso wrote:

@labath @pogo59 @jmorse @Michael137 @tromey Is there any additional points 
about the current patch that you would like to address?

Thanks

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


[clang] [Clang] Fix a pack expansion bug in template argument deduction (PR #141547)

2025-05-27 Thread Younan Zhang via cfe-commits

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


[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 Thread Balázs Benics via cfe-commits

balazs-benics-sonarsource wrote:

> In the tests I felt that it'd be a bit hard to decipher the meaning of the 
> block identifiers like `B1` etc. -- but when I re-read the file I noticed 
> that you included the very nice helper function `dumpCFGAndEgraph` (IIUC) for 
> those who will need to debug broken cases in this test file 😄 Perhaps it 
> would be even nicer if you included a commented out call to that function 
> with "`// NOTE: Uncomment this if you want to decipher the meaning of 'B0', 
> 'B1', ...`" to make its existence and role more obvious.

Changed the debugging interface a bit, and added comments explaining it in 
f339eb1dc8216da013d5a92f01332b43e0a75790

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


[clang] f8d6316 - [Clang] Fix a pack expansion bug in template argument deduction (#141547)

2025-05-27 Thread via cfe-commits

Author: Younan Zhang
Date: 2025-05-27T15:10:24+08:00
New Revision: f8d63168b6b9928ffed6b068fb35fa26a70f996d

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

LOG: [Clang] Fix a pack expansion bug in template argument deduction (#141547)

I think the intent of df18ee96206 was to substitute only those non-packs
into a pack expansion type (e.g. `T` in `T::pack...`), so let's hold off
pack expansions explicitly, in case there are calls coming from a
substitution of pack expansion.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 780716b089e41..35ab1461e7b89 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -798,6 +798,7 @@ Bug Fixes to C++ Support
 - Fix instantiation of default-initialized variable template specialization. 
(#GH140632) (#GH140622)
 - Clang modules now allow a module and its user to 
diff er on TrivialAutoVarInit*
 - Fixed an access checking bug when initializing non-aggregates in default 
arguments (#GH62444), (#GH83608)
+- Fixed a pack substitution bug in deducing class template partial 
specializations. (#GH53609)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 217d57d67f067..75ae04b27d06a 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2946,6 +2946,7 @@ ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param,
   LocalInstantiationScope Scope(S);
   MultiLevelTemplateArgumentList Args(Template, CTAI.SugaredConverted,
   /*Final=*/true);
+  Sema::ArgPackSubstIndexRAII OnlySubstNonPackExpansion(S, std::nullopt);
 
   if (auto *NTTP = dyn_cast(Param)) {
 Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template,

diff  --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp 
b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp
index f0ab7b8ea7612..de6fa0c837e2a 100644
--- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp
@@ -54,3 +54,20 @@ namespace reversed_operator_substitution_order {
   float &s = no_adl::f(true);
 }
 #endif
+
+namespace GH53609 {
+
+template 
+struct a;
+
+template 
+struct b;
+
+template 
+struct b...> {};
+
+template  struct c: b...  {};
+
+c d;
+
+}



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


[clang] [clang][RISCV] Handle target features correctly in CheckBuiltinFunctionCall (PR #141548)

2025-05-27 Thread Pengcheng Wang via cfe-commits


@@ -0,0 +1,11 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zvknha %s -fsyntax-only 
-verify
+
+#include 
+
+// expected-no-diagnostics
+
+__attribute__((target("arch=+zvl128b")))
+void test_zvk_features(vuint32m1_t vd, vuint32m1_t vs2, vuint32m1_t vs1, 
size_t vl) {

wangpc-pp wrote:

What do we get if without this PR?

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


[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-05-27 Thread Daan De Meyer via cfe-commits

DaanDeMeyer wrote:

Ping? Would love to get this over the finish line

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


[clang-tools-extra] [clang-tidy][performance-unnecessary-value-param] Avoid in coroutines (PR #140912)

2025-05-27 Thread Dmitry Polukhin via cfe-commits

dmpolukhin wrote:

@HerrCai0907 @carlosgalvezp @PiotrZSL friendly ping, please take a look!

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


[clang] [llvm] [LoongArch] Add support for half-precision floating-point type (PR #141564)

2025-05-27 Thread via cfe-commits

Ami-zhang wrote:

> LLVM uses squash and merge. So please split it into 3 PRs if you do not want 
> to squash them.

Ok, I'll split this into 3 separate PRs.

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


[clang] [llvm] [RISCV] Add shlcofideleg extension (PR #141572)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Ying Chen (punkyc)


Changes

This is for `shlcofideleg` extension, that supports delegating LCOFI interrupts 
to VS-mode.

Spec: https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc

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


7 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 7b4f46cdb4443..e4f593fbd6df1 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -119,6 +119,7 @@
 // CHECK-NEXT: sha  1.0   'Sha' (Augmented Hypervisor)
 // CHECK-NEXT: shcounterenw 1.0   'Shcounterenw' (Support 
writeable hcounteren enable bit for any hpmcounter that is not read-only zero)
 // CHECK-NEXT: shgatpa  1.0   'Shgatpa' (SvNNx4 mode 
supported for all modes supported by satp, as well as Bare)
+// CHECK-NEXT: shlcofideleg 1.0   'Shlcofideleg' (Delegating 
LCOFI interrupts to VS-mode)
 // CHECK-NEXT: shtvala  1.0   'Shtvala' (htval provides 
all needed values)
 // CHECK-NEXT: shvsatpa 1.0   'Shvsatpa' (vsatp supports 
all modes supported by satp)
 // CHECK-NEXT: shvstvala1.0   'Shvstvala' (vstval provides 
all needed values)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index e3b456e0245f7..86085c21a95aa 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -24,6 +24,7 @@
 // CHECK-NOT: __riscv_sha {{.*$}}
 // CHECK-NOT: __riscv_shcounterenw {{.*$}}
 // CHECK-NOT: __riscv_shgatpa {{.*$}}
+// CHECK-NOT: __riscv_shlcofideleg {{.*$}}
 // CHECK-NOT: __riscv_shtvala {{.*$}}
 // CHECK-NOT: __riscv_shvsatpa {{.*$}}
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
@@ -370,6 +371,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHGATPA-EXT %s
 // CHECK-SHGATPA-EXT: __riscv_shgatpa 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// CHECK-SHLCOFIDELEG-EXT: __riscv_shlcofideleg 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32ishtvala -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHTVALA-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 9ac21052eb66c..7d0d0cc21a27d 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -123,6 +123,7 @@ on support follow.
  ``Sha``   Supported
  ``Shcounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shgatpa``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Shlcofideleg``  Supported
  ``Shtvala``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvsatpa``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 86576ed190d14..690068d05aaab 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -906,6 +906,10 @@ def FeatureStdExtShvsatpa
 : RISCVExtension<1, 0,
  "vsatp supports all modes supported by satp">;
 
+def FeatureStdExtShlcofideleg
+: RISCVExtension<1, 0,
+ "Delegating LCOFI Interrupts to VS-mode">;
+
 def FeatureStdExtSmaia
 : RISCVExtension<1, 0,
  "Advanced Interrupt Architecture Machine Level">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index 68b472936ecdf..ba8969b5a5382 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,6 +47,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+shcounterenw %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SHCOUNTERENW %s
 ; RUN: llc -mtriple=riscv32 -mattr=+shgatpa %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SHGATPA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+shvsatp

[clang] [llvm] [RISCV] Add shlcofideleg extension (PR #141572)

2025-05-27 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-risc-v

Author: Ying Chen (punkyc)


Changes

This is for `shlcofideleg` extension, that supports delegating LCOFI interrupts 
to VS-mode.

Spec: https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc

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


7 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 7b4f46cdb4443..e4f593fbd6df1 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -119,6 +119,7 @@
 // CHECK-NEXT: sha  1.0   'Sha' (Augmented Hypervisor)
 // CHECK-NEXT: shcounterenw 1.0   'Shcounterenw' (Support 
writeable hcounteren enable bit for any hpmcounter that is not read-only zero)
 // CHECK-NEXT: shgatpa  1.0   'Shgatpa' (SvNNx4 mode 
supported for all modes supported by satp, as well as Bare)
+// CHECK-NEXT: shlcofideleg 1.0   'Shlcofideleg' (Delegating 
LCOFI interrupts to VS-mode)
 // CHECK-NEXT: shtvala  1.0   'Shtvala' (htval provides 
all needed values)
 // CHECK-NEXT: shvsatpa 1.0   'Shvsatpa' (vsatp supports 
all modes supported by satp)
 // CHECK-NEXT: shvstvala1.0   'Shvstvala' (vstval provides 
all needed values)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index e3b456e0245f7..86085c21a95aa 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -24,6 +24,7 @@
 // CHECK-NOT: __riscv_sha {{.*$}}
 // CHECK-NOT: __riscv_shcounterenw {{.*$}}
 // CHECK-NOT: __riscv_shgatpa {{.*$}}
+// CHECK-NOT: __riscv_shlcofideleg {{.*$}}
 // CHECK-NOT: __riscv_shtvala {{.*$}}
 // CHECK-NOT: __riscv_shvsatpa {{.*$}}
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
@@ -370,6 +371,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHGATPA-EXT %s
 // CHECK-SHGATPA-EXT: __riscv_shgatpa 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// CHECK-SHLCOFIDELEG-EXT: __riscv_shlcofideleg 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32ishtvala -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHTVALA-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 9ac21052eb66c..7d0d0cc21a27d 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -123,6 +123,7 @@ on support follow.
  ``Sha``   Supported
  ``Shcounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shgatpa``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Shlcofideleg``  Supported
  ``Shtvala``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvsatpa``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 86576ed190d14..690068d05aaab 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -906,6 +906,10 @@ def FeatureStdExtShvsatpa
 : RISCVExtension<1, 0,
  "vsatp supports all modes supported by satp">;
 
+def FeatureStdExtShlcofideleg
+: RISCVExtension<1, 0,
+ "Delegating LCOFI Interrupts to VS-mode">;
+
 def FeatureStdExtSmaia
 : RISCVExtension<1, 0,
  "Advanced Interrupt Architecture Machine Level">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index 68b472936ecdf..ba8969b5a5382 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,6 +47,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+shcounterenw %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SHCOUNTERENW %s
 ; RUN: llc -mtriple=riscv32 -mattr=+shgatpa %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SHGATPA %s
 ; RUN: llc -mt

[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

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


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)
...
[   OK ] AddressSanitizer.AtoiAndFriendsOOBTest (2275 ms)
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (12 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (162 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (30 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (124 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (8 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (128 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (126 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN  ] AddressSanitizer.LongDoubleNegativeTest
[   OK ] AddressSanitizer.LongDoubleNegativeTest (0 ms)
[--] 19 tests from AddressSanitizer (28356 ms total)

[--] Global test environment tear-down
[==] 22 tests from 2 test suites ran. (28360 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 1 DISABLED TEST

Step 24 (run instrumented asan tests 
[aarch64/aosp_coral-userdebug/AOSP.MASTER]) failure: run instrumented asan 
tests [aarch64/aosp_coral-userdebug/AOSP.MASTER] (failure)
...
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (8 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (317 ms)
[ RUN  ] AddressSanitizer.ReallocTest
[   OK ] AddressSanitizer.ReallocTest (20 ms)
[ RUN  ] AddressSanitizer.WrongFreeTest
[   OK ] AddressSanitizer.WrongFreeTest (256 ms)
[ RUN  ] AddressSanitizer.LongJmpTest
[   OK ] AddressSanitizer.LongJmpTest (0 ms)
[ RUN  ] AddressSanitizer.ThreadStackReuseTest
[   OK ] AddressSanitizer.ThreadStackReuseTest (3 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.UseThenFreeThenUseTest
[   OK ] AddressSanitizer.UseThenFreeThenUseTest (318 ms)
[ RUN  ] AddressSanitizer.FileNameInGlobalReportTest
[   OK ] AddressSanitizer.FileNameInGlobalReportTest (303 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.MlockTest
[   OK ] AddressSanitizer.MlockTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] Addre

[clang] 94929b7 - [KeyInstr] Add triple to Clang tests

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-27T10:54:44+01:00
New Revision: 94929b725f415a8ab8de35194f3c2eec5192990f

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

LOG: [KeyInstr] Add triple to Clang tests

Fixes various downstream bot failures ocurring with different default targets
e.g., windows due to mangling assumptions baked into the tests.

Added: 


Modified: 
clang/test/DebugInfo/KeyInstructions/agg.c
clang/test/DebugInfo/KeyInstructions/assign-scalar.c
clang/test/DebugInfo/KeyInstructions/do.c
clang/test/DebugInfo/KeyInstructions/if.c
clang/test/DebugInfo/KeyInstructions/init-agg.c
clang/test/DebugInfo/KeyInstructions/init-member.cpp
clang/test/DebugInfo/KeyInstructions/init-scalar.c
clang/test/DebugInfo/KeyInstructions/init-static.cpp
clang/test/DebugInfo/KeyInstructions/while.c

Removed: 




diff  --git a/clang/test/DebugInfo/KeyInstructions/agg.c 
b/clang/test/DebugInfo/KeyInstructions/agg.c
index 06c9ebbb63369..e9d9da7f687c6 100644
--- a/clang/test/DebugInfo/KeyInstructions/agg.c
+++ b/clang/test/DebugInfo/KeyInstructions/agg.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
-// RUN: %clang_cc1 -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 typedef struct { int a, b, c; } Struct;

diff  --git a/clang/test/DebugInfo/KeyInstructions/assign-scalar.c 
b/clang/test/DebugInfo/KeyInstructions/assign-scalar.c
index 98d005b2e925c..afb0ed8ebdfd7 100644
--- a/clang/test/DebugInfo/KeyInstructions/assign-scalar.c
+++ b/clang/test/DebugInfo/KeyInstructions/assign-scalar.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
-// RUN: %clang_cc1 -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 unsigned long long g, h, i;

diff  --git a/clang/test/DebugInfo/KeyInstructions/do.c 
b/clang/test/DebugInfo/KeyInstructions/do.c
index f3b2bb465cae8..4f0d388f94047 100644
--- a/clang/test/DebugInfo/KeyInstructions/do.c
+++ b/clang/test/DebugInfo/KeyInstructions/do.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -gkey-instructions -x c++ -std=c++17 %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ 
-std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
-// RUN: %clang_cc1 -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o -  \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o -  \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 // Perennial question: should the `dec` be in its own source atom or not

diff  --git a/clang/test/DebugInfo/KeyInstructions/if.c 
b/clang/test/DebugInfo/KeyInstructions/if.c
index df7d10d6ee7b8..b16dec7b91c4f 100644
--- a/clang/test/DebugInfo/KeyInstructions/if.c
+++ b/clang/test/DebugInfo/KeyInstructions/if.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -gkey-instructions -x c++ -std=c++17 %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ 
-std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank --check-prefixes=CHECK,CHECK-CXX
 
-// RUN: %clang_cc1 -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 int g;

diff  --git a/clang/test/DebugInfo/KeyInstructions/init-agg.c 
b/clang/test/DebugInfo/KeyIns

[clang] [KeyInstr] Complex assignment atoms (PR #134638)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134638

>From fa1c06148d4f79e9464d92ab5c26d9a22c5bf41d Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 13:36:59 +0100
Subject: [PATCH 01/10] [KeyInstr] Complex assignment atoms

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGExprComplex.cpp   | 10 -
 .../test/DebugInfo/KeyInstructions/complex.c  | 40 +++
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/DebugInfo/KeyInstructions/complex.c

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index f556594f4a9ec..600f61f1b325f 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -461,8 +461,12 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy 
Val, LValue lvalue,
   Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.getType());
   Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.getType());
 
-  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
-  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  auto *R =
+  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(R, Val.first);
+  auto *I =
+  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(I, Val.second);
 }
 
 
@@ -1209,6 +1213,7 @@ LValue ComplexExprEmitter::
 EmitCompoundAssignLValue(const CompoundAssignOperator *E,
   ComplexPairTy (ComplexExprEmitter::*Func)(const BinOpInfo&),
  RValue &Val) {
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   TestAndClearIgnoreReal();
   TestAndClearIgnoreImag();
   QualType LHSTy = E->getLHS()->getType();
@@ -1356,6 +1361,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const 
BinaryOperator *E,
 }
 
 ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   ComplexPairTy Val;
   LValue LV = EmitBinAssignLValue(E, Val);
 
diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c 
b/clang/test/DebugInfo/KeyInstructions/complex.c
new file mode 100644
index 0..b97314e815bdc
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/complex.c
@@ -0,0 +1,40 @@
+
+// RUN: %clang -gkey-instructions -x c++ %s -gmlt -gcolumn-info -S -emit-llvm 
-o - -Wno-unused-variable \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// RUN: %clang -gkey-instructions -x c %s -gmlt -gcolumn-info -S -emit-llvm -o 
- -Wno-unused-variable \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+_Complex float ci;
+void test() {
+// CHECK: %ci.real = load float, ptr @ci{{.*}}, !dbg [[G1R2:!.*]]
+// CHECK: %ci.imag = load float, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G1R2]]
+// CHECK: store float %ci.real, ptr %lc.realp{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: store float %ci.imag, ptr %lc.imagp{{.*}}, !dbg [[G1R1]]
+  _Complex float lc = ci;
+
+// CHECK: %ci.real1 = load float, ptr @ci{{.*}}, !dbg [[G2R2:!.*]]
+// CHECK: %ci.imag2 = load float, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R2]]
+// CHECK: store float %ci.real1, ptr @ci{{.*}}, !dbg [[G2R1:!.*]]
+// CHECK: store float %ci.imag2, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R1]]
+  ci = ci;
+
+// CHECK: %add.r = fadd float %ci.real5, %ci.real3, !dbg [[G3R2:!.*]]
+// CHECK: %add.i = fadd float %ci.imag6, %ci.imag4, !dbg [[G3R2]]
+// CHECK: store float %add.r, ptr @ci{{.*}}, !dbg [[G3R1:!.*]]
+// CHECK: store float %add.i, ptr getelementptr inbounds nuw ({ float, float 
}, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G3R1]]
+  ci += ci;
+
+// CHECK: %add = fadd float %0, %1, !dbg [[G4R2:!.*]]
+// CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, 
ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G4R1:!.*]]
+  __imag ci = __imag ci + __imag ci;
+}
+
+// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atom

[clang] [KeyInstr] Complex assignment atoms (PR #134638)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134638

>From fa1c06148d4f79e9464d92ab5c26d9a22c5bf41d Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 13:36:59 +0100
Subject: [PATCH 1/9] [KeyInstr] Complex assignment atoms

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGExprComplex.cpp   | 10 -
 .../test/DebugInfo/KeyInstructions/complex.c  | 40 +++
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/DebugInfo/KeyInstructions/complex.c

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index f556594f4a9ec..600f61f1b325f 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -461,8 +461,12 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy 
Val, LValue lvalue,
   Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.getType());
   Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.getType());
 
-  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
-  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  auto *R =
+  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(R, Val.first);
+  auto *I =
+  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(I, Val.second);
 }
 
 
@@ -1209,6 +1213,7 @@ LValue ComplexExprEmitter::
 EmitCompoundAssignLValue(const CompoundAssignOperator *E,
   ComplexPairTy (ComplexExprEmitter::*Func)(const BinOpInfo&),
  RValue &Val) {
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   TestAndClearIgnoreReal();
   TestAndClearIgnoreImag();
   QualType LHSTy = E->getLHS()->getType();
@@ -1356,6 +1361,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const 
BinaryOperator *E,
 }
 
 ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   ComplexPairTy Val;
   LValue LV = EmitBinAssignLValue(E, Val);
 
diff --git a/clang/test/DebugInfo/KeyInstructions/complex.c 
b/clang/test/DebugInfo/KeyInstructions/complex.c
new file mode 100644
index 0..b97314e815bdc
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/complex.c
@@ -0,0 +1,40 @@
+
+// RUN: %clang -gkey-instructions -x c++ %s -gmlt -gcolumn-info -S -emit-llvm 
-o - -Wno-unused-variable \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// RUN: %clang -gkey-instructions -x c %s -gmlt -gcolumn-info -S -emit-llvm -o 
- -Wno-unused-variable \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+_Complex float ci;
+void test() {
+// CHECK: %ci.real = load float, ptr @ci{{.*}}, !dbg [[G1R2:!.*]]
+// CHECK: %ci.imag = load float, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G1R2]]
+// CHECK: store float %ci.real, ptr %lc.realp{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: store float %ci.imag, ptr %lc.imagp{{.*}}, !dbg [[G1R1]]
+  _Complex float lc = ci;
+
+// CHECK: %ci.real1 = load float, ptr @ci{{.*}}, !dbg [[G2R2:!.*]]
+// CHECK: %ci.imag2 = load float, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R2]]
+// CHECK: store float %ci.real1, ptr @ci{{.*}}, !dbg [[G2R1:!.*]]
+// CHECK: store float %ci.imag2, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G2R1]]
+  ci = ci;
+
+// CHECK: %add.r = fadd float %ci.real5, %ci.real3, !dbg [[G3R2:!.*]]
+// CHECK: %add.i = fadd float %ci.imag6, %ci.imag4, !dbg [[G3R2]]
+// CHECK: store float %add.r, ptr @ci{{.*}}, !dbg [[G3R1:!.*]]
+// CHECK: store float %add.i, ptr getelementptr inbounds nuw ({ float, float 
}, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G3R1]]
+  ci += ci;
+
+// CHECK: %add = fadd float %0, %1, !dbg [[G4R2:!.*]]
+// CHECK: store float %add, ptr getelementptr inbounds nuw ({ float, float }, 
ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G4R1:!.*]]
+  __imag ci = __imag ci + __imag ci;
+}
+
+// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGr

[clang-tools-extra] [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (PR #141092)

2025-05-27 Thread kadir çetinkaya via cfe-commits

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

thanks a lot!

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


[clang] 059885c - [KeyInstr] Complex assignment atoms (#134638)

2025-05-27 Thread via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-27T11:06:46+01:00
New Revision: 059885c703e9de601d868061a0c344837a81aaf4

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

LOG: [KeyInstr] Complex assignment atoms (#134638)

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

Added: 
clang/test/DebugInfo/KeyInstructions/complex.c

Modified: 
clang/lib/CodeGen/CGExprComplex.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index f556594f4a9ec..f8a946a76554a 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -364,15 +364,19 @@ class ComplexExprEmitter
 
   // Compound assignments.
   ComplexPairTy VisitBinAddAssign(const CompoundAssignOperator *E) {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
   }
   ComplexPairTy VisitBinSubAssign(const CompoundAssignOperator *E) {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
   }
   ComplexPairTy VisitBinMulAssign(const CompoundAssignOperator *E) {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
   }
   ComplexPairTy VisitBinDivAssign(const CompoundAssignOperator *E) {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
   }
 
@@ -461,8 +465,12 @@ void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy 
Val, LValue lvalue,
   Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.getType());
   Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.getType());
 
-  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
-  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  auto *R =
+  Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(R, Val.first);
+  auto *I =
+  Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
+  CGF.addInstToCurrentSourceAtom(I, Val.second);
 }
 
 
@@ -1357,6 +1365,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const 
BinaryOperator *E,
 
 ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
   ComplexPairTy Val;
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   LValue LV = EmitBinAssignLValue(E, Val);
 
   // The result of an assignment in C is the assigned r-value.
@@ -1532,6 +1541,7 @@ static CompoundFunc getComplexOp(BinaryOperatorKind Op) {
 
 LValue CodeGenFunction::
 EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) {
+  ApplyAtomGroup Grp(getDebugInfo());
   CompoundFunc Op = getComplexOp(E->getOpcode());
   RValue Val;
   return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
@@ -1540,6 +1550,8 @@ EmitComplexCompoundAssignmentLValue(const 
CompoundAssignOperator *E) {
 LValue CodeGenFunction::
 EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E,
 llvm::Value *&Result) {
+  // Key Instructions: Don't need to create an atom group here; one will 
already
+  // be active through scalar handling code.
   CompoundFunc Op = getComplexOp(E->getOpcode());
   RValue Val;
   LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);

diff  --git a/clang/test/DebugInfo/KeyInstructions/complex.c 
b/clang/test/DebugInfo/KeyInstructions/complex.c
new file mode 100644
index 0..9647d0e4009ee
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/complex.c
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank --check-prefixes=CHECK,CHECK-C
+
+_Complex float ci;
+float f;
+void test() {
+// CHECK: %ci.real = load float, ptr @ci{{.*}}, !dbg [[G1R2:!.*]]
+// CHECK: %ci.imag = load float, ptr getelementptr inbounds nuw ({ float, 
float }, ptr @ci, i32 0, i32 1){{.*}}, !dbg [[G1R2]]
+// CHECK: store float %ci.real, ptr %lc.realp{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: store float %ci.imag, ptr %lc.imagp{{.*}}, !dbg [[G1R1]]
+  _Complex flo

[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-05-27 Thread Anatoly Trosinenko via cfe-commits

https://github.com/atrosinenko created 
https://github.com/llvm/llvm-project/pull/141573

None

>From 93eca6d9b68619766b7897c41dcc318ef54be73d Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Mon, 26 May 2025 22:28:55 +0300
Subject: [PATCH] [AArch64][FMV] Enable PAuth and BTI hardening of resolver
 functions

---
 clang/lib/CodeGen/CodeGenModule.cpp   |  9 +++
 .../CodeGen/ptrauth-resolver-attributes.c | 25 +++
 2 files changed, 34 insertions(+)
 create mode 100644 clang/test/CodeGen/ptrauth-resolver-attributes.c

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 16e010adbeb5f..af8d4cc60de57 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4638,6 +4638,13 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   if (FD->isTargetMultiVersion() || FD->isTargetClonesMultiVersion())
 AddDeferredMultiVersionResolverToEmit(GD);
 
+  auto SetResolverAttrs = [&](llvm::Function &Resolver) {
+TargetInfo::BranchProtectionInfo BPI(getLangOpts());
+TargetCodeGenInfo::setBranchProtectionFnAttributes(BPI, Resolver);
+TargetCodeGenInfo::setPointerAuthFnAttributes(CodeGenOpts.PointerAuth,
+  Resolver);
+  };
+
   // For cpu_specific, don't create an ifunc yet because we don't know if the
   // cpu_dispatch will be emitted in this translation unit.
   if (ShouldReturnIFunc) {
@@ -4652,6 +4659,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   "", Resolver, &getModule());
 GIF->setName(ResolverName);
 SetCommonAttributes(FD, GIF);
+SetResolverAttrs(cast(*Resolver));
 if (ResolverGV)
   replaceDeclarationWith(ResolverGV, GIF);
 return GIF;
@@ -4662,6 +4670,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   assert(isa(Resolver) && !ResolverGV &&
  "Resolver should be created for the first time");
   SetCommonAttributes(FD, cast(Resolver));
+  SetResolverAttrs(cast(*Resolver));
   return Resolver;
 }
 
diff --git a/clang/test/CodeGen/ptrauth-resolver-attributes.c 
b/clang/test/CodeGen/ptrauth-resolver-attributes.c
new file mode 100644
index 0..af6a97fa52781
--- /dev/null
+++ b/clang/test/CodeGen/ptrauth-resolver-attributes.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+
+// Check that resolver functions generated by clang have the correct 
attributes.
+
+int __attribute__((target_clones("crc", "default"))) ftc(void) { return 0; }
+
+int __attribute__((target_version("crc"))) fmv(void) { return 0; }
+int __attribute__((target_version("default"))) fmv(void) { return 0; }
+
+// CHECK: define{{.*}} i32 @ftc._Mcrc() #0
+// CHECK: define{{.*}} ptr @ftc.resolver() #1
+// CHECK: define{{.*}} i32 @fmv._Mcrc() #0
+// CHECK: define{{.*}} i32 @fmv.default() #2
+// CHECK: define{{.*}} i32 @ftc.default() #2
+// CHECK: define{{.*}} ptr @fmv.resolver() #1
+
+// BTI-SIGNRA: attributes #0 = { {{.*}}"branch-target-enforcement" 
{{.*}}""sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #1 = { {{.*}}"branch-target-enforcement" 
{{.*}}""sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #2 = { {{.*}}"branch-target-enforcement" 
{{.*}}""sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// PAUTHTEST: attributes #0 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #1 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #2 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }

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


[clang] Fix tests of lookup table generator (PR #139463)

2025-05-27 Thread Robin Caloudis via cfe-commits

robincaloudis wrote:

@kadircet, can you merge this PR? I lack write access. Thank you.

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


[clang-tools-extra] [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (PR #141092)

2025-05-27 Thread via cfe-commits

https://github.com/FabianWolff updated 
https://github.com/llvm/llvm-project/pull/141092

>From 131d6c6aeb13ac89e79406eaa119e9ab021b5b5a Mon Sep 17 00:00:00 2001
From: Fabian Wolff 
Date: Tue, 27 May 2025 10:01:40 +
Subject: [PATCH] [clang-tidy] readability-redundant-smartptr-get: disable for
 smart pointers to arrays

---
 .../readability/RedundantSmartptrGetCheck.cpp | 38 ++--
 .../redundant-smartptr-get-msvc.cpp   | 44 +++
 .../readability/redundant-smartptr-get.cpp| 42 ++
 3 files changed, 111 insertions(+), 13 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index be52af77ae0a5..baa977750d101 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -49,29 +49,41 @@ internal::Matcher knownSmartptr() {
 
 void registerMatchersForGetArrowStart(MatchFinder *Finder,
   MatchFinder::MatchCallback *Callback) {
-  const auto QuacksLikeASmartptr = recordDecl(
-  recordDecl().bind("duck_typing"),
-  has(cxxMethodDecl(hasName("operator->"),
-returns(qualType(pointsTo(type().bind("op->Type")),
-  has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
-  type().bind("op*Type")));
+  const auto MatchesOpArrow =
+  allOf(hasName("operator->"),
+returns(qualType(pointsTo(type().bind("op->Type");
+  const auto MatchesOpStar =
+  allOf(hasName("operator*"),
+returns(qualType(references(type().bind("op*Type");
+  const auto HasRelevantOps =
+  allOf(anyOf(hasMethod(MatchesOpArrow),
+  
has(functionTemplateDecl(has(functionDecl(MatchesOpArrow),
+anyOf(hasMethod(MatchesOpStar),
+  
has(functionTemplateDecl(has(functionDecl(MatchesOpStar));
+
+  const auto QuacksLikeASmartptr =
+  cxxRecordDecl(cxxRecordDecl().bind("duck_typing"), HasRelevantOps);
 
   // Make sure we are not missing the known standard types.
-  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+  const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+  const auto SmartptrWithDeref =
+  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
-  Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
-hasObjectExpression(callToGet(Smartptr))),
- Callback);
+  Finder->addMatcher(
+  memberExpr(expr().bind("memberExpr"), isArrow(),
+ hasObjectExpression(callToGet(SmartptrWithDeref))),
+  Callback);
 
   // Catch '*ptr.get()' or '*ptr->get()'
   Finder->addMatcher(
-  unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(callToGet(Smartptr))),
+  unaryOperator(hasOperatorName("*"),
+hasUnaryOperand(callToGet(SmartptrWithDeref))),
   Callback);
 
   // Catch '!ptr.get()'
   const auto CallToGetAsBool = callToGet(
-  recordDecl(Smartptr, has(cxxConversionDecl(returns(booleanType());
+  recordDecl(SmartptrAny, has(cxxConversionDecl(returns(booleanType());
   Finder->addMatcher(
   unaryOperator(hasOperatorName("!"), hasUnaryOperand(CallToGetAsBool)),
   Callback);
@@ -84,7 +96,7 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
  Callback);
 
   Finder->addMatcher(cxxDependentScopeMemberExpr(hasObjectExpression(
- callExpr(has(callToGet(Smartptr))).bind("obj"))),
+ callExpr(has(callToGet(SmartptrAny),
  Callback);
 }
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
index bd8990a27b263..b360ccbadfa5f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
@@ -16,6 +16,14 @@ struct unique_ptr {
   explicit operator bool() const noexcept;
 };
 
+template 
+struct unique_ptr {
+  template 
+  T2* operator[](unsigned) const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
 template 
 struct shared_ptr {
   template 
@@ -26,6 +34,14 @@ struct shared_ptr {
   explicit operator bool() const noexcept;
 };
 
+template 
+struct shared_ptr {
+  template 
+  T2* operator[](unsigned) const;
+  T* get() const;
+  explicit operator bool() const noexcept;
+};
+
 }  // namespace std
 
 struct Bar {
@@ -92,3 +108,31 @@ void Positive() {
   // CHECK-MESSAGES: if (NULL == x.get());
   // CHECK-FIXES: if (NULL == x);
 }
+
+void te

[clang] [KeyInstr][Clang] Catch variable init atom (PR #134641)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134641

>From 7c86cc1b0b0bfaba4c304a31b5b0f2a1f391ad63 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 17:31:32 +0100
Subject: [PATCH 1/3] [KeyInstr][Clang] Catch variable init atom

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  1 +
 .../DebugInfo/KeyInstructions/try-catch.cpp   | 20 +++
 2 files changed, 21 insertions(+)
 create mode 100644 clang/test/DebugInfo/KeyInstructions/try-catch.cpp

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index faa07024a6052..1041ae84dbdf1 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -5055,6 +5055,7 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,
 
   // Emit the local.
   CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
+  ApplyAtomGroup Grp(CGF.getDebugInfo());
   InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), 
S->getBeginLoc());
   CGF.EmitAutoVarCleanups(var);
 }
diff --git a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp 
b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
new file mode 100644
index 0..3d1080aca2f07
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - -fexceptions \
+// RUN: | FileCheck %s
+
+void except() {
+  // FIXME(OCH): Should `store i32 32, ptr %exception` be key?
+  throw 32;
+}
+
+void attempt() {
+  try { except(); }
+// CHECK: catch:
+// CHECK: %4 = call ptr @__cxa_begin_catch(ptr %exn)
+// CHECK: %5 = load i32{{.*}}, !dbg [[G1R2:!.*]]
+// CHECK: store i32 %5, ptr %e{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: call void @__cxa_end_catch()
+  catch (int e) { }
+}
+
+// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)

>From 5d308ddf70afa9e7ec8382c0abada43f4296a486 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Wed, 21 May 2025 15:30:39 +0100
Subject: [PATCH 2/3] cc1

---
 clang/test/DebugInfo/KeyInstructions/try-catch.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp 
b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
index 3d1080aca2f07..d2b458f361e11 100644
--- a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -gkey-instructions %s -gmlt -S -emit-llvm -o - -fexceptions \
+// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only 
-emit-llvm -o - -fexceptions -fcxx-exceptions \
 // RUN: | FileCheck %s
 
 void except() {

>From a2b11b1914d80d0796747b6f1045719893e2194f Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Tue, 27 May 2025 11:11:22 +0100
Subject: [PATCH 3/3] braces + add triple to test

---
 clang/lib/CodeGen/ItaniumCXXABI.cpp| 7 +--
 clang/test/DebugInfo/KeyInstructions/try-catch.cpp | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 1041ae84dbdf1..5018a6b39b000 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -5055,8 +5055,11 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,
 
   // Emit the local.
   CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
-  ApplyAtomGroup Grp(CGF.getDebugInfo());
-  InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), 
S->getBeginLoc());
+  {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
+InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF),
+   S->getBeginLoc());
+  }
   CGF.EmitAutoVarCleanups(var);
 }
 
diff --git a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp 
b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
index d2b458f361e11..918eb4c97db9a 100644
--- a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
+++ b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only 
-emit-llvm -o - -fexceptions -fcxx-exceptions \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s 
-debug-info-kind=line-tables-only -emit-llvm -o - -fexceptions -fcxx-exceptions 

[clang] bf1d422 - [KeyInstr][Clang] Catch variable init atom (#134641)

2025-05-27 Thread via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-27T11:12:16+01:00
New Revision: bf1d4228f1660db694c29e2694414340897734f7

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

LOG: [KeyInstr][Clang] Catch variable init atom (#134641)

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

Added: 
clang/test/DebugInfo/KeyInstructions/try-catch.cpp

Modified: 
clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index faa07024a6052..5018a6b39b000 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -5055,7 +5055,11 @@ void ItaniumCXXABI::emitBeginCatch(CodeGenFunction &CGF,
 
   // Emit the local.
   CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
-  InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF), 
S->getBeginLoc());
+  {
+ApplyAtomGroup Grp(CGF.getDebugInfo());
+InitCatchParam(CGF, *CatchParam, var.getObjectAddress(CGF),
+   S->getBeginLoc());
+  }
   CGF.EmitAutoVarCleanups(var);
 }
 

diff  --git a/clang/test/DebugInfo/KeyInstructions/try-catch.cpp 
b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
new file mode 100644
index 0..918eb4c97db9a
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/try-catch.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s 
-debug-info-kind=line-tables-only -emit-llvm -o - -fexceptions -fcxx-exceptions 
\
+// RUN: | FileCheck %s
+
+void except() {
+  // FIXME(OCH): Should `store i32 32, ptr %exception` be key?
+  throw 32;
+}
+
+void attempt() {
+  try { except(); }
+// CHECK: catch:
+// CHECK: %4 = call ptr @__cxa_begin_catch(ptr %exn)
+// CHECK: %5 = load i32{{.*}}, !dbg [[G1R2:!.*]]
+// CHECK: store i32 %5, ptr %e{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: call void @__cxa_end_catch()
+  catch (int e) { }
+}
+
+// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)



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


[clang] [KeyInstr] Complex assignment atoms (PR #134638)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang-tools-extra] 47d5e94 - [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (#141092)

2025-05-27 Thread via cfe-commits

Author: FabianWolff
Date: 2025-05-27T12:06:08+02:00
New Revision: 47d5e94acb92ce4ec5040e95e167ba471d080244

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

LOG: [clang-tidy] readability-redundant-smartptr-get: disable for smart 
pointers to arrays (#141092)

Currently we generate an incorrect suggestion for shared/unique pointers
to arrays; for instance ([Godbolt](https://godbolt.org/z/Tens1reGP)):
```c++
#include 

void test_shared_ptr_to_array() {
  std::shared_ptr i;
  auto s = sizeof(*i.get());
}
```
```
:5:20: warning: redundant get() call on smart pointer 
[readability-redundant-smartptr-get]
5 |   auto s = sizeof(*i.get());
  |^~~
  |i
1 warning generated.
```
`sizeof(*i)` is incorrect, though, because the array specialization of
`std::shared/unique_ptr` does not have an `operator*()`. Therefore I
have disabled this check for smart pointers to arrays for now; future
work could, of course, improve on this by suggesting, say,
`sizeof(i[0])` in the above example.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index be52af77ae0a5..baa977750d101 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -49,29 +49,41 @@ internal::Matcher knownSmartptr() {
 
 void registerMatchersForGetArrowStart(MatchFinder *Finder,
   MatchFinder::MatchCallback *Callback) {
-  const auto QuacksLikeASmartptr = recordDecl(
-  recordDecl().bind("duck_typing"),
-  has(cxxMethodDecl(hasName("operator->"),
-returns(qualType(pointsTo(type().bind("op->Type")),
-  has(cxxMethodDecl(hasName("operator*"), returns(qualType(references(
-  type().bind("op*Type")));
+  const auto MatchesOpArrow =
+  allOf(hasName("operator->"),
+returns(qualType(pointsTo(type().bind("op->Type");
+  const auto MatchesOpStar =
+  allOf(hasName("operator*"),
+returns(qualType(references(type().bind("op*Type");
+  const auto HasRelevantOps =
+  allOf(anyOf(hasMethod(MatchesOpArrow),
+  
has(functionTemplateDecl(has(functionDecl(MatchesOpArrow),
+anyOf(hasMethod(MatchesOpStar),
+  
has(functionTemplateDecl(has(functionDecl(MatchesOpStar));
+
+  const auto QuacksLikeASmartptr =
+  cxxRecordDecl(cxxRecordDecl().bind("duck_typing"), HasRelevantOps);
 
   // Make sure we are not missing the known standard types.
-  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+  const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
+  const auto SmartptrWithDeref =
+  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
-  Finder->addMatcher(memberExpr(expr().bind("memberExpr"), isArrow(),
-hasObjectExpression(callToGet(Smartptr))),
- Callback);
+  Finder->addMatcher(
+  memberExpr(expr().bind("memberExpr"), isArrow(),
+ hasObjectExpression(callToGet(SmartptrWithDeref))),
+  Callback);
 
   // Catch '*ptr.get()' or '*ptr->get()'
   Finder->addMatcher(
-  unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(callToGet(Smartptr))),
+  unaryOperator(hasOperatorName("*"),
+hasUnaryOperand(callToGet(SmartptrWithDeref))),
   Callback);
 
   // Catch '!ptr.get()'
   const auto CallToGetAsBool = callToGet(
-  recordDecl(Smartptr, has(cxxConversionDecl(returns(booleanType());
+  recordDecl(SmartptrAny, has(cxxConversionDecl(returns(booleanType());
   Finder->addMatcher(
   unaryOperator(hasOperatorName("!"), hasUnaryOperand(CallToGetAsBool)),
   Callback);
@@ -84,7 +96,7 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
  Callback);
 
   Finder->addMatcher(cxxDependentScopeMemberExpr(hasObjectExpression(
- callExpr(has(callToGet(Smartptr))).bind("obj"))),
+ callExpr(has(callToGet(SmartptrAny),
  Callback);
 }
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
 
b/clang-tools-extra/test/clang-tidy/check

[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/141574

This commit deprecates the use of LLVM_ENABLE_PROJECTS in favour of 
LLVM_ENABLE_RUNTIMES.

Alternatively, using -DLLVM_RUNTIME_TARGETS= combined with 
-DRUNTIMES__LLVM_ENABLE_RUNTIMES=libclc also gets pretty far but fails 
due to zlib problems building the LLVM utility 'prepare_builtins'. I'm not sure 
what's going on there but I don't think it's required at this stage. More work 
would be required to support that option.

This does nothing to change how the host tools are found in order to be used to 
actually build the libclc libraries.

Fixes #124013.

>From f5278d261d203cea8889174c8b0a16c03d1cbad9 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Tue, 27 May 2025 11:11:14 +0100
Subject: [PATCH] [libclc] Support LLVM_ENABLE_RUNTIMES when building

This commit deprecates the use of LLVM_ENABLE_PROJECTS in favour of
LLVM_ENABLE_RUNTIMES.

Alternatively, using -DLLVM_RUNTIME_TARGETS= combined with
-DRUNTIMES__LLVM_ENABLE_RUNTIMES=libclc also gets pretty far but
fails due to zlib problems building the LLVM utility 'prepare_builtins'.
I'm not sure what's going on there but I don't think it's required at
this stage. More work would be required to support that option.

This does nothing to change how the host tools are found in order to be
used to actually build the libclc libraries.

Fixes #124013.
---
 libclc/CMakeLists.txt| 2 +-
 llvm/CMakeLists.txt  | 9 -
 llvm/runtimes/CMakeLists.txt | 2 +-
 runtimes/CMakeLists.txt  | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 0d9a21c6d63a9..657cab713f8d9 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -72,7 +72,7 @@ else()
   # Note that we check this later (for both build types) but we can provide a
   # more useful error message when built in-tree. We assume that LLVM tools are
   # always available so don't warn here.
-  if( NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
+  if( NOT LLVM_RUNTIMES_BUILD AND NOT clang IN_LIST LLVM_ENABLE_PROJECTS )
 message(FATAL_ERROR "Clang is not enabled, but is required to build libclc 
in-tree")
   endif()
 
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index ed44b16bf9aeb..b27ea78eb5e6c 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -136,7 +136,7 @@ endforeach()
 # As we migrate runtimes to using the bootstrapping build, the set of default 
runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt")
+set(LLVM_SUPPORTED_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt;libclc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" 
(${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
@@ -200,6 +200,13 @@ if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
   endif ()
 endif ()
 
+if ("libclc" IN_LIST LLVM_ENABLE_PROJECTS)
+  message(WARNING "Using LLVM_ENABLE_PROJECTS=libclc is deprecated now, and 
will "
+"become a fatal error in the LLVM 21 release.  Please use "
+"-DLLVM_ENABLE_RUNTIMES=libclc or see the instructions at "
+"https://libclc.llvm.org/ for building the runtimes.")
+endif()
+
 # Set a shorthand option to enable the GPU build of the 'libc' project.
 option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
 if(LIBC_GPU_BUILD)
diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index cabadfc9184f8..9f86650ec58d1 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -193,7 +193,7 @@ endif()
 
 function(_get_runtime_name name out_var)
   string(FIND ${name} "lib" idx)
-  if(idx EQUAL 0 AND NOT ${name} STREQUAL "libc")
+  if(idx EQUAL 0 AND NOT (${name} STREQUAL "libc" OR ${name} STREQUAL 
"libclc"))
 string(SUBSTRING ${name} 3 -1 name)
   endif()
   set(${out_var} ${name} PARENT_SCOPE)
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 7f1e2ae065d6c..c62a6c7e8d2b3 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0
 
 # We order libraries to mirror roughly how they are layered, except that 
compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
+set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload;libclc")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc;flang-rt")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" 
(${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM

[clang] [llvm] [LoongArch] Add support for half-precision floating-point type (PR #141564)

2025-05-27 Thread via cfe-commits

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


[clang] [llvm] [RISCV] Add shlcofideleg extension (PR #141572)

2025-05-27 Thread Ying Chen via cfe-commits

https://github.com/punkyc created 
https://github.com/llvm/llvm-project/pull/141572

This is for `shlcofideleg` extension, that supports delegating LCOFI interrupts 
to VS-mode.

Spec: https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc

>From 385ae3040ae39d62702c430e2d0b79b80b30e36b Mon Sep 17 00:00:00 2001
From: punkyc 
Date: Tue, 27 May 2025 17:21:12 +0800
Subject: [PATCH] [RISCV] Add shlcofideleg extension

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 7b4f46cdb4443..e4f593fbd6df1 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -119,6 +119,7 @@
 // CHECK-NEXT: sha  1.0   'Sha' (Augmented Hypervisor)
 // CHECK-NEXT: shcounterenw 1.0   'Shcounterenw' (Support 
writeable hcounteren enable bit for any hpmcounter that is not read-only zero)
 // CHECK-NEXT: shgatpa  1.0   'Shgatpa' (SvNNx4 mode 
supported for all modes supported by satp, as well as Bare)
+// CHECK-NEXT: shlcofideleg 1.0   'Shlcofideleg' (Delegating 
LCOFI interrupts to VS-mode)
 // CHECK-NEXT: shtvala  1.0   'Shtvala' (htval provides 
all needed values)
 // CHECK-NEXT: shvsatpa 1.0   'Shvsatpa' (vsatp supports 
all modes supported by satp)
 // CHECK-NEXT: shvstvala1.0   'Shvstvala' (vstval provides 
all needed values)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index e3b456e0245f7..86085c21a95aa 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -24,6 +24,7 @@
 // CHECK-NOT: __riscv_sha {{.*$}}
 // CHECK-NOT: __riscv_shcounterenw {{.*$}}
 // CHECK-NOT: __riscv_shgatpa {{.*$}}
+// CHECK-NOT: __riscv_shlcofideleg {{.*$}}
 // CHECK-NOT: __riscv_shtvala {{.*$}}
 // CHECK-NOT: __riscv_shvsatpa {{.*$}}
 // CHECK-NOT: __riscv_shvstvala {{.*$}}
@@ -370,6 +371,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHGATPA-EXT %s
 // CHECK-SHGATPA-EXT: __riscv_shgatpa 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64ishlcofideleg -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SHLCOFIDELEG-EXT %s
+// CHECK-SHLCOFIDELEG-EXT: __riscv_shlcofideleg 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32ishtvala -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SHTVALA-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 9ac21052eb66c..7d0d0cc21a27d 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -123,6 +123,7 @@ on support follow.
  ``Sha``   Supported
  ``Shcounterenw``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shgatpa``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Shlcofideleg``  Supported
  ``Shtvala``   Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvsatpa``  Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Shvstvala`` Assembly Support (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 86576ed190d14..690068d05aaab 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -906,6 +906,10 @@ def FeatureStdExtShvsatpa
 : RISCVExtension<1, 0,
  "vsatp supports all modes supported by satp">;
 
+def FeatureStdExtShlcofideleg
+: RISCVExtension<1, 0,
+ "Delegating LCOFI Interrupts to VS-mode">;
+
 def FeatureStdExtSmaia
 : RISCVExtension<1, 0,
  "Advanced Interrupt Architecture Machine Level">;
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index 68b472936ecdf..ba8969b5a5382 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -47,6 +47,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+shcounterenw %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SHCOUNTERENW %s
 ; RUN: llc -mtriple=riscv32 -

[clang-tools-extra] [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (PR #141092)

2025-05-27 Thread kadir çetinkaya via cfe-commits

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


[clang] [clang] Introduce elementwise clz/ctz builtins (PR #131995)

2025-05-27 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

ping, thanks.

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


[clang] [KeyInstr][Clang] Switch stmt atom (PR #134643)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134643

>From 71a5f65a7ecbd0b1ba3b5e45f0b03fa34484f85a Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 18:43:56 +0100
Subject: [PATCH 1/3] [KeyInstr][Clang] Switch stmt atom

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGStmt.cpp  |  2 +
 clang/test/DebugInfo/KeyInstructions/switch.c | 51 +++
 2 files changed, 53 insertions(+)
 create mode 100644 clang/test/DebugInfo/KeyInstructions/switch.c

diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 3b701116e5e4b..31d64a5a788ee 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2293,6 +2293,8 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) 
{
   // failure.
   llvm::BasicBlock *DefaultBlock = createBasicBlock("sw.default");
   SwitchInsn = Builder.CreateSwitch(CondV, DefaultBlock);
+  addInstToNewSourceAtom(SwitchInsn, CondV);
+
   if (HLSLControlFlowAttr != HLSLControlFlowHintAttr::SpellingNotCalculated) {
 llvm::MDBuilder MDHelper(CGM.getLLVMContext());
 llvm::ConstantInt *BranchHintConstant =
diff --git a/clang/test/DebugInfo/KeyInstructions/switch.c 
b/clang/test/DebugInfo/KeyInstructions/switch.c
new file mode 100644
index 0..cff6b834106e9
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/switch.c
@@ -0,0 +1,51 @@
+// RUN: %clang -gkey-instructions -x c++ -std=c++17 %s -gmlt -S -emit-llvm -o 
- \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank --check-prefixes=CHECK,CHECK-CXX
+
+// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o -  \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+int g;
+void a(int A, int B) {
+// CHECK: entry:
+// The load gets associated with the branch rather than the store.
+// FIXME: Is that the best thing to do?
+// CHECK: %0 = load i32, ptr %A.addr{{.*}}, !dbg [[G2R2:!.*]]
+// CHECK: store i32 %0, ptr @g{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: switch i32 %0, label %{{.*}} [
+// CHECK:   i32 0, label %sw.bb
+// CHECK:   i32 1, label %sw.bb1
+// CHECK: ], !dbg [[G2R1:!.*]]
+switch ((g = A)) {
+case 0: break;
+case 1: {
+// CHECK: sw.bb1:
+// CHECK: %1 = load i32, ptr %B.addr{{.*}}, !dbg [[G3R2:!.*]]
+// CHECK: switch i32 %1, label %{{.*}} [
+// CHECK:   i32 0, label %sw.bb2
+// CHECK: ], !dbg [[G3R1:!.*]]
+switch ((B)) {
+case 0: {
+// Test that assignments in constant-folded switches don't go missing.
+// CHECK-CXX: sw.bb2:
+// CHECK-CXX: store i32 1, ptr %C{{.*}}, !dbg [[G4R1:!.*]]
+#ifdef __cplusplus
+switch (const int C = 1; C) {
+case 0: break;
+case 1: break;
+default: break;
+}
+#endif
+} break;
+default: break;
+}
+} break;
+default: break;
+}
+}
+
+// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
+// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)

>From 21266abfda12a5dcb61d1409cd8e7e0e0213b6f3 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Wed, 21 May 2025 15:39:37 +0100
Subject: [PATCH 2/3] cc1

---
 clang/test/DebugInfo/KeyInstructions/switch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/DebugInfo/KeyInstructions/switch.c 
b/clang/test/DebugInfo/KeyInstructions/switch.c
index cff6b834106e9..dbfc4a44d271c 100644
--- a/clang/test/DebugInfo/KeyInstructions/switch.c
+++ b/clang/test/DebugInfo/KeyInstructions/switch.c
@@ -1,7 +1,7 @@
-// RUN: %clang -gkey-instructions -x c++ -std=c++17 %s -gmlt -S -emit-llvm -o 
- \
+// RUN: %clang_cc1 -gkey-instructions -x c++ -std=c++17 %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank --check-prefixes=CHECK,CHECK-CXX
 
-// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o -  \
+// RUN: %clang_cc1 -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 

[clang] dd8eb1e - [KeyInstr][Clang] Switch stmt atom (#134643)

2025-05-27 Thread via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-27T11:26:40+01:00
New Revision: dd8eb1e6737a612be204c59949ff3611c300e25a

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

LOG: [KeyInstr][Clang] Switch stmt atom (#134643)

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

Added: 
clang/test/DebugInfo/KeyInstructions/switch.c

Modified: 
clang/lib/CodeGen/CGStmt.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 3b701116e5e4b..31d64a5a788ee 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2293,6 +2293,8 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) 
{
   // failure.
   llvm::BasicBlock *DefaultBlock = createBasicBlock("sw.default");
   SwitchInsn = Builder.CreateSwitch(CondV, DefaultBlock);
+  addInstToNewSourceAtom(SwitchInsn, CondV);
+
   if (HLSLControlFlowAttr != HLSLControlFlowHintAttr::SpellingNotCalculated) {
 llvm::MDBuilder MDHelper(CGM.getLLVMContext());
 llvm::ConstantInt *BranchHintConstant =

diff  --git a/clang/test/DebugInfo/KeyInstructions/switch.c 
b/clang/test/DebugInfo/KeyInstructions/switch.c
new file mode 100644
index 0..5142f204ff587
--- /dev/null
+++ b/clang/test/DebugInfo/KeyInstructions/switch.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ 
-std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank --check-prefixes=CHECK,CHECK-CXX
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+int g;
+void a(int A, int B) {
+// CHECK: entry:
+// The load gets associated with the branch rather than the store.
+// TODO: Associating it with the store may be a better choice.
+// CHECK: %0 = load i32, ptr %A.addr{{.*}}, !dbg [[G2R2:!.*]]
+// CHECK: store i32 %0, ptr @g{{.*}}, !dbg [[G1R1:!.*]]
+// CHECK: switch i32 %0, label %{{.*}} [
+// CHECK:   i32 0, label %sw.bb
+// CHECK:   i32 1, label %sw.bb1
+// CHECK: ], !dbg [[G2R1:!.*]]
+switch ((g = A)) {
+case 0: break;
+case 1: {
+// CHECK: sw.bb1:
+// CHECK: %1 = load i32, ptr %B.addr{{.*}}, !dbg [[G3R2:!.*]]
+// CHECK: switch i32 %1, label %{{.*}} [
+// CHECK:   i32 0, label %sw.bb2
+// CHECK: ], !dbg [[G3R1:!.*]]
+switch ((B)) {
+case 0: {
+// Test that assignments in constant-folded switches don't go missing.
+// CHECK-CXX: sw.bb2:
+// CHECK-CXX: store i32 1, ptr %C{{.*}}, !dbg [[G4R1:!.*]]
+#ifdef __cplusplus
+switch (const int C = 1; C) {
+case 0: break;
+case 1: break;
+default: break;
+}
+#endif
+} break;
+default: break;
+}
+} break;
+default: break;
+}
+}
+
+// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
+// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
+// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
+// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)



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


[clang] [KeyInstr][Clang] Switch stmt atom (PR #134643)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang] [lld] [llvm] Integrated Distributed ThinLTO (DTLTO): Design Overview (PR #126654)

2025-05-27 Thread via cfe-commits

bd1976bris wrote:

Thanks to everyone for the review effort on DTLTO — I’ve now merged the LLVM 
portion of the changes (#127749).

I’m currently on PTO this week, but once I’m back, I’ll post the Clang and LLD 
patches for review. In the meantime, if anyone wants to try out DTLTO on a 
stable branch, I’ve backported the changes to LLVM 19 here: 
https://github.com/bd1976bris/llvm-project/commits/dtlto_llvm19.

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


[clang] [CIR] Upstream global initialization for ComplexType (PR #141369)

2025-05-27 Thread Henrich Lauko via cfe-commits


@@ -385,6 +385,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
 break;
   }
 
+  case Type::Complex: {
+const ComplexType *ct = cast(ty);
+mlir::Type elementTy = convertType(ct->getElementType());

xlauko wrote:

Oh sorry thought this was `cir::ComplexType`, then this should be `const auto 
*ct = cast(ty);` not `mlir` cast

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


[clang] [KeyInstr][Clang] Assign vector element atom (PR #134649)

2025-05-27 Thread Stephen Tozer via cfe-commits

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


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


[clang] [Clang] add fix-it hints for unknown attributes (PR #141305)

2025-05-27 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -Wunknown-attributes -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wunknown-attributes -fsyntax-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+[[gmu::deprected]] // expected-warning {{unknown attribute 'gmu::deprected' 
ignored; did you mean 'gnu::deprecated'?}}
+int f1(void) {
+  return 0;
+}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:17}:"gnu::deprecated"
+
+[[gmu::deprecated]] // expected-warning {{unknown attribute 'gmu::deprecated' 
ignored; did you mean 'gnu::deprecated'?}}
+int f2(void) {
+  return 0;
+}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:18}:"gnu::deprecated"
+
+[[gnu::deprected]] // expected-warning {{unknown attribute 'gnu::deprected' 
ignored; did you mean 'gnu::deprecated'?}}
+int f3(void) {
+  return 0;
+}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:17}:"gnu::deprecated"
+
+[[deprected]] // expected-warning {{unknown attribute 'deprected' ignored; did 
you mean 'deprecated'?}}
+int f4(void) {
+  return 0;
+}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:12}:"deprecated"
+
+[[using gnu : deprected]] // expected-warning {{unknown attribute 
'gnu::deprected' ignored; did you mean 'gnu::deprecated'?}}
+int f5(void) {
+  return 0;
+}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:9-[[@LINE-4]]:24}:"gnu::deprecated"

AaronBallman wrote:

I think this shows a bug with the patch because this seems to be replacing 
`[[using gnu: deprected]]` with `[[gnu::deprecated]]`. While this is 1:1 in 
this example, consider something like: `[[using gnu: deprected, noreturn]]` 
where there are multiple attributes all sharing the same prefix.

I think `using` should be handled in a separate patch; for this PR, I'd 
recommend not attempting to fix this situation. But we may not have that 
information in Sema, so that may be more involved.

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


[clang] [Clang] add fix-it hints for unknown attributes (PR #141305)

2025-05-27 Thread Aaron Ballman via cfe-commits


@@ -7867,15 +7867,16 @@ void Sema::checkUnusedDeclAttributes(Declarator &D) {
 
 void Sema::DiagnoseUnknownAttribute(const ParsedAttr &AL) {
   std::string NormalizedFullName = '\'' + AL.getNormalizedFullName() + '\'';
+  SourceRange NR = AL.getNormalizedRange();
+  SourceLocation Loc = NR.getBegin();
+
   if (auto CorrectedFullName =
   AL.getCorrectedFullName(Context.getTargetInfo(), getLangOpts())) {
-Diag(AL.getNormalizedRange().getBegin(),
- diag::warn_unknown_attribute_ignored_suggestion)
-<< NormalizedFullName << *CorrectedFullName << AL.getNormalizedRange();
+Diag(Loc, diag::warn_unknown_attribute_ignored_suggestion)
+<< NormalizedFullName << *CorrectedFullName
+<< FixItHint::CreateReplacement(NR, *CorrectedFullName) << NR;
   } else {
-Diag(AL.getNormalizedRange().getBegin(),
- diag::warn_unknown_attribute_ignored)
-<< NormalizedFullName << AL.getNormalizedRange();
+Diag(Loc, diag::warn_unknown_attribute_ignored) << NormalizedFullName << 
NR;

AaronBallman wrote:

There are more places where we emit a `warn_unknown_attribute_ignored` 
diagnostic; should any of those be handled as well? For example, 
target-specific attributes which are typos, etc.

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


[clang] [KeyInstr][Clang] Bitfield atom (PR #134648)

2025-05-27 Thread Stephen Tozer via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only 
-emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+

SLTozer wrote:

Maybe a small comment to the effect of, "Test for storing to a bitfield member, 
as this has distinct codegen to other variable/member stores"? Entirely 
optional since this may already be contextually obvious.

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


[clang] [HIP] disable sanitizer for `__hip_cuid` (PR #141581)

2025-05-27 Thread Yaxun Liu via cfe-commits

https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/141581

Global variable `__hip_cuid_*` is for identifying purpose and does not need 
sanitization, therefore disable it for sanitizers.

>From 503ee3dd5144b4cc2dd83488b2194900605217fd Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" 
Date: Tue, 27 May 2025 00:38:24 -0400
Subject: [PATCH] [HIP] disable sanitizer for __hip_cuid

Global variable __hip_cuid_* is for identifying purpose
and does not need sanitization, therefore disable it
for sanitizers.
---
 clang/lib/CodeGen/CodeGenModule.cpp| 1 +
 clang/test/CodeGenCUDA/nosanitize-cuid.hip | 6 ++
 2 files changed, 7 insertions(+)
 create mode 100644 clang/test/CodeGenCUDA/nosanitize-cuid.hip

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 16e010adbeb5f..039507bc03510 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -971,6 +971,7 @@ void CodeGenModule::Release() {
 getModule(), Int8Ty, false, llvm::GlobalValue::ExternalLinkage,
 llvm::Constant::getNullValue(Int8Ty),
 "__hip_cuid_" + getContext().getCUIDHash());
+getSanitizerMetadata()->disableSanitizerForGlobal(GV);
 addCompilerUsedGlobal(GV);
   }
   emitLLVMUsed();
diff --git a/clang/test/CodeGenCUDA/nosanitize-cuid.hip 
b/clang/test/CodeGenCUDA/nosanitize-cuid.hip
new file mode 100644
index 0..4af83c91ac883
--- /dev/null
+++ b/clang/test/CodeGenCUDA/nosanitize-cuid.hip
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fsanitize=address 
-fcuda-is-device \
+// RUN:-emit-llvm -cuid=abcd -o - %s | FileCheck  %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: @__hip_cuid_{{.*}} = {{.*}} no_sanitize_address

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


[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-27 Thread Fraser Cormack via cfe-commits

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


[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)

2025-05-27 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

Ping.

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


[clang] [llvm] [UBSan] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-27 Thread Qinkun Bao via cfe-commits


@@ -56,10 +56,20 @@ void SanitizerSpecialCaseList::createSanitizerSections() {
 bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
  StringRef Query,
  StringRef Category) const {
-  for (auto &S : SanitizerSections)
-if ((S.Mask & Mask) &&
-SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
-  return true;
+  return inSectionBlame(Mask, Prefix, Query, Category);
+}
 
-  return false;
+unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
+  StringRef Prefix,
+  StringRef Query,
+  StringRef Category) const {
+  for (auto &S : SanitizerSections) {

qinkunbao wrote:

Good catch.  Thanks for the finding.
New tests: 
[6be9bfd](https://github.com/llvm/llvm-project/pull/140529/commits/6be9bfd1a21c1ef936279b4e207a9e49300bb16c)

Fix: 
[f582891](https://github.com/llvm/llvm-project/pull/140529/commits/f582891bd77b4ad1f9829350bbb96153831dc89a)

The Windows CI check should be irrelavant to this PR 
https://github.com/llvm/llvm-project/commit/de93f7ed0d615060735ad15e720f2497ed1d2468



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


[clang] [KeyInstr][Clang] For range stmt atoms (PR #134647)

2025-05-27 Thread Stephen Tozer via cfe-commits


@@ -1448,7 +1448,14 @@ CodeGenFunction::EmitCXXForRangeStmt(const 
CXXForRangeStmt &S,
   if (!Weights && CGM.getCodeGenOpts().OptimizationLevel)
 BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
 BoolCondVal, Stmt::getLikelihood(S.getBody()));
-  Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+  auto *I = Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+  // Key Instructions: Emit the condition and branch as separate atoms to
+  // match existing loop stepping behaviour. FIXME: We could have the branch as
+  // the backup location for the condition, which would probably be a better
+  // experience.
+  if (auto *I = dyn_cast(BoolCondVal))
+addInstToNewSourceAtom(I, nullptr);

SLTozer wrote:

Not a big fan of the shadowing here, it seems like it'd make things harder to 
parse at a glance?

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


[clang-tools-extra] [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (PR #141092)

2025-05-27 Thread Baranov Victor via cfe-commits

vbvictor wrote:

@kadircet, I think we generally shouldn't merge code that doesn't pass 
`clang-format` build (if non-compliant changes are so small). In the future I 
plan to make whole _clang-tidy_ directory `clang-format`-complaint so that 
people can have "format on save: file" in their editors when developing 
_clang-tidy_.

Also, an entry in ReleaseNotes.rst about this change is missing. (Did not see 
it at first look, sorry)
I'd highly appreciate a new PR with entry in release notes and fixed formatting.

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


[clang] b56b4e0 - Fix tests of lookup table generator (#139463)

2025-05-27 Thread via cfe-commits

Author: Robin Caloudis
Date: 2025-05-27T13:45:11+02:00
New Revision: b56b4e02b5424d5f180c068c1ba93a9c6da0470d

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

LOG: Fix tests of lookup table generator (#139463)

## Why
In
https://github.com/llvm/llvm-project/pull/113612/files#diff-ada12e18f3e902b41b6989b46455c4e32656276e59907026e2464cf57d10d583,
the parameter `qual_name` was introduced. However, the tests have not
been adopted accordingly and hence cannot be executed.

## What
Fix the execution of tests by providing the missing argument.

Added: 


Modified: 
clang/tools/include-mapping/test.py

Removed: 




diff  --git a/clang/tools/include-mapping/test.py 
b/clang/tools/include-mapping/test.py
index eef328381f2bb..81803855dac8f 100755
--- a/clang/tools/include-mapping/test.py
+++ b/clang/tools/include-mapping/test.py
@@ -52,7 +52,7 @@ def testParseSymbolPage_SingleHeader(self):
   
 
 """
-self.assertEqual(_ParseSymbolPage(html, "foo"), set([""]))
+self.assertEqual(_ParseSymbolPage(html, "foo", "foo"), 
set([""]))
 
 def testParseSymbolPage_MulHeaders(self):
 #  Defined in header 
@@ -92,7 +92,9 @@ def testParseSymbolPage_MulHeaders(self):
   
 
 """
-self.assertEqual(_ParseSymbolPage(html, "foo"), set(["", 
""]))
+self.assertEqual(
+_ParseSymbolPage(html, "foo", "foo"), set(["", 
""])
+)
 
 def testParseSymbolPage_MulHeadersInSameDiv(self):
 # Multile  blocks in a Div.
@@ -118,7 +120,7 @@ def testParseSymbolPage_MulHeadersInSameDiv(self):
 
 """
 self.assertEqual(
-_ParseSymbolPage(html, "foo"), set(["", ""])
+_ParseSymbolPage(html, "foo", "foo"), set(["", 
""])
 )
 
 def testParseSymbolPage_MulSymbolsInSameTd(self):
@@ -142,8 +144,10 @@ def testParseSymbolPage_MulSymbolsInSameTd(self):
 
 
 """
-self.assertEqual(_ParseSymbolPage(html, "int8_t"), set([""]))
-self.assertEqual(_ParseSymbolPage(html, "int16_t"), set([""]))
+self.assertEqual(_ParseSymbolPage(html, "int8_t", "int8_t"), 
set([""]))
+self.assertEqual(
+_ParseSymbolPage(html, "int16_t", "int16_t"), set([""])
+)
 
 
 if __name__ == "__main__":



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


[clang] Fix tests of lookup table generator (PR #139463)

2025-05-27 Thread kadir çetinkaya via cfe-commits

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


[clang] Fix tests of lookup table generator (PR #139463)

2025-05-27 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 87442 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 
FAIL: LLVM :: 
ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s (52910 of 
87442)
 TEST 'LLVM :: 
ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-mc
 -filetype=obj -triple=x86_64-windows-msvc 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s
 -o 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp
 # RUN: at line 1
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-mc
 -filetype=obj -triple=x86_64-windows-msvc 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s
 -o 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp
not 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-jitlink
 -noexec 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp
 2>&1 | 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s
 # RUN: at line 2
+ not 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-jitlink
 -noexec 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s

--


Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--
60.59s: Clang :: Driver/fsanitize.c
42.13s: Clang :: Preprocessor/riscv-target-features.c
38.87s: Clang :: Driver/arm-cortex-cpus-2.c
38.13s: Clang :: Driver/arm-cortex-cpus-1.c
3

[clang-tools-extra] [clang-tidy] Add check for assignment or comparision operators' operand in `readability-math-missing-parentheses` (PR #141345)

2025-05-27 Thread via cfe-commits

flovent wrote:

Rebased and changed PR description link to resolved issue.

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


[clang] [KeyInstr][Clang] Bitfield atom (PR #134648)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix formatting and add release notes entry (PR #141584)

2025-05-27 Thread Baranov Victor via cfe-commits


@@ -114,6 +114,9 @@ Improvements to clang-tidy
 - Fixed bug in :program:`run_clang_tidy.py` where the program would not
   correctly display the checks enabled by the top-level `.clang-tidy` file.
 
+- Fixed some false positives in the ``readability-redundant-smartptr-get``

vbvictor wrote:

Please, place this in "Changes in existing checks" category (line 157).
Follow existing style there and put in alphabetical order (by check name)

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


[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)

2025-05-27 Thread Garvit Gupta via cfe-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/121829

>From 63eaf99ffe04d8c66bf11ec3bad6b04b83de3c96 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Fri, 13 Dec 2024 05:31:56 -0800
Subject: [PATCH] [Driver] Teach Barmetal toolchain about GCC installation

This patch introduces the baretmetal toolchain object about GCC Installation.
Currently, if `--gcc-installation` ot `--gcc-install-dir` options are passed on
commandline, then sysroot will be formed from there if paths will be valid.
Otherwise, it will be fallback to as it already existed in the Baremetal
toolchaibn object. Moreover, support for adding include paths for libstd
C++ library is added as well.

Additionally, the restriction to always use integrated assembler is removed
because with valid gcc installation, gnu assembler can be invoked as well.

This patch currently adds and modifies arm related test only. The riscv specific
test will be added in the last PR when driver code related to calling of
RISCVToolchain object will be removed. Currently in this PR, there is no way to
test riscv target.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ibaeb569cf7e2cee03c022aa9ecd1abe29d5c30d4
---
 clang/docs/Toolchain.rst  |   5 +
 .../clang/Basic/DiagnosticDriverKinds.td  |   3 +
 clang/lib/Driver/ToolChains/BareMetal.cpp | 206 +-
 clang/lib/Driver/ToolChains/BareMetal.h   |  14 +-
 .../aarch64-none-elf/include/c++/8.2.1/.keep  |   0
 .../aarch64-none-elf/lib/.keep|   0
 .../aarch64-none-elf/lib/crt0.o   |   0
 .../bin/aarch64-none-elf-ld   |   1 +
 .../lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o |   0
 .../lib/gcc/aarch64-none-elf/8.2.1/crtend.o   |   0
 .../aarch64-none-elf/lib/crt0.o   |   0
 .../aarch64-none-elf/lib/crtbegin.o   |   0
 .../aarch64-none-elf/lib/crtend.o |   0
 .../bin/aarch64-none-elf-ld   |   1 +
 .../armv6m-none-eabi/include/c++/8.2.1/.keep  |   0
 .../armv6m-none-eabi/lib/.keep|   0
 .../armv6m-none-eabi/lib/crt0.o   |   0
 .../bin/armv6m-none-eabi-ld   |   1 +
 .../lib/gcc/armv6m-none-eabi/8.2.1/crtbegin.o |   0
 .../lib/gcc/armv6m-none-eabi/8.2.1/crtend.o   |   0
 .../armv6m-none-eabi/lib/crt0.o   |   0
 .../armv6m-none-eabi/lib/crtbegin.o   |   0
 .../armv6m-none-eabi/lib/crtend.o |   0
 .../bin/armv6m-none-eabi-ld   |   1 +
 clang/test/Driver/aarch64-gnutools.c  |   4 +
 clang/test/Driver/aarch64-toolchain-extra.c   |  28 +++
 clang/test/Driver/aarch64-toolchain.c |  61 ++
 clang/test/Driver/arm-gnutools.c  |   6 +
 clang/test/Driver/arm-toolchain-extra.c   |  29 +++
 clang/test/Driver/arm-toolchain.c |  62 ++
 clang/test/Driver/baremetal.cpp   |  16 ++
 clang/test/Driver/check-no-multlib-warning.c  |  10 +
 32 files changed, 386 insertions(+), 62 deletions(-)
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/.keep
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/.keep
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o
 create mode 100755 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/bin/aarch64-none-elf-ld
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crt0.o
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtend.o
 create mode 100755 
clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/bin/aarch64-none-elf-ld
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1/.keep
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/.keep
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/crt0.o
 create mode 100755 
clang/test/Driver/Inputs/basic_arm_gcc_tree/bin/armv6m-none-eabi-ld
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crt0.o
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtend.o
 create mode 100755 
clang

[clang] 8b9448e - [KeyInstr][Clang] Assign vector element atom (#134649)

2025-05-27 Thread via cfe-commits

Author: Orlando Cazalet-Hyams
Date: 2025-05-27T13:35:14+01:00
New Revision: 8b9448edc6f39ba9d5eaac3d1e9275ffecc65798

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

LOG: [KeyInstr][Clang] Assign vector element atom (#134649)

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

RFC:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/test/DebugInfo/KeyInstructions/agg.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b82f4e9945777..ea23455bb9a5e 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2507,8 +2507,9 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, 
LValue Dst,
 Vec = Builder.CreateBitCast(Vec, IRStoreTy);
   }
 
-  Builder.CreateStore(Vec, Dst.getVectorAddress(),
-  Dst.isVolatileQualified());
+  auto *I = Builder.CreateStore(Vec, Dst.getVectorAddress(),
+Dst.isVolatileQualified());
+  addInstToCurrentSourceAtom(I, Vec);
   return;
 }
 

diff  --git a/clang/test/DebugInfo/KeyInstructions/agg.c 
b/clang/test/DebugInfo/KeyInstructions/agg.c
index e9d9da7f687c6..5cb3a553b6752 100644
--- a/clang/test/DebugInfo/KeyInstructions/agg.c
+++ b/clang/test/DebugInfo/KeyInstructions/agg.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
+__attribute__((ext_vector_type(1))) char c;
 typedef struct { int a, b, c; } Struct;
 void fun(Struct a) {
 // CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
@@ -11,7 +12,14 @@ void fun(Struct a) {
 
 // CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G2R1:!.*]]
   b = a;
+
+// CHECK: %2 = load <1 x i8>, ptr @c
+// CHECK: %vecins = insertelement <1 x i8> %2, i8 0, i32 0, !dbg [[G3R2:!.*]]
+// CHECK: store <1 x i8> %vecins, ptr @c{{.*}}, !dbg [[G3R1:!.*]]
+  c[0] = 0;
 }
 
 // CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
 // CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)



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


[clang] [KeyInstr][Clang] Assign vector element atom (PR #134649)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang] [KeyInstr][Clang] Assign matrix element atom (PR #134650)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134650

>From 1a7848740a2b708724d057cd881a3e4db42e96e3 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 22:05:32 +0100
Subject: [PATCH 1/2] [KeyInstr][Clang] Assign matrix element atom

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGExpr.cpp   | 5 +++--
 clang/test/DebugInfo/KeyInstructions/agg.c | 9 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ea23455bb9a5e..bae28b45afaa3 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2531,8 +2531,9 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, 
LValue Dst,
   llvm::Instruction *Load = Builder.CreateLoad(Dst.getMatrixAddress());
   llvm::Value *Vec =
   Builder.CreateInsertElement(Load, Src.getScalarVal(), Idx, "matins");
-  Builder.CreateStore(Vec, Dst.getMatrixAddress(),
-  Dst.isVolatileQualified());
+  auto *I = Builder.CreateStore(Vec, Dst.getMatrixAddress(),
+Dst.isVolatileQualified());
+  addInstToCurrentSourceAtom(I, Vec);
   return;
 }
 
diff --git a/clang/test/DebugInfo/KeyInstructions/agg.c 
b/clang/test/DebugInfo/KeyInstructions/agg.c
index 5cb3a553b6752..6451d44fafc19 100644
--- a/clang/test/DebugInfo/KeyInstructions/agg.c
+++ b/clang/test/DebugInfo/KeyInstructions/agg.c
@@ -5,6 +5,8 @@
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 __attribute__((ext_vector_type(1))) char c;
+typedef float m5x5 __attribute__((matrix_type(5, 5)));
+m5x5 m;
 typedef struct { int a, b, c; } Struct;
 void fun(Struct a) {
 // CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
@@ -17,9 +19,16 @@ void fun(Struct a) {
 // CHECK: %vecins = insertelement <1 x i8> %2, i8 0, i32 0, !dbg [[G3R2:!.*]]
 // CHECK: store <1 x i8> %vecins, ptr @c{{.*}}, !dbg [[G3R1:!.*]]
   c[0] = 0;
+
+// CHECK: %3 = load <25 x float>, ptr @m, align 4
+// CHECK: %matins = insertelement <25 x float> %3, float 0.00e+00, i64 0, 
!dbg [[G4R2:!.*]]
+// CHECK: store <25 x float> %matins, ptr @m{{.*}}, !dbg [[G4R1:!.*]]
+  m[0][0] = 0;
 }
 
 // CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
 // CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
 // CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
 // CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
+// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
+// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)

>From 2cbfe629d899cb45a56708e2560528bd3f496ef6 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Wed, 21 May 2025 16:00:41 +0100
Subject: [PATCH 2/2] cc1

---
 clang/test/DebugInfo/KeyInstructions/agg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/DebugInfo/KeyInstructions/agg.c 
b/clang/test/DebugInfo/KeyInstructions/agg.c
index 6451d44fafc19..33b3a0141a0f1 100644
--- a/clang/test/DebugInfo/KeyInstructions/agg.c
+++ b/clang/test/DebugInfo/KeyInstructions/agg.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s 
-debug-info-kind=line-tables-only -emit-llvm -o - -fenable-matrix \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - -fenable-matrix \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
 __attribute__((ext_vector_type(1))) char c;

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


[clang] [Sema] built-in args type checking using hasSameUnqualifiedType (PR #141485)

2025-05-27 Thread via cfe-commits

https://github.com/cor3ntin commented:

This change needs a release note.
Please add an entry to `clang/docs/ReleaseNotes.rst` in the section the most 
adapted to the change, and referencing any Github issue this change fixes. 
Thanks!

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


[clang] [Sema] built-in args type checking using hasSameUnqualifiedType (PR #141485)

2025-05-27 Thread via cfe-commits


@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// expected-no-diagnostics
+
+// This example uncovered a bug in Sema::BuiltinVectorMath, where we should be
+// using ASTContext::hasSameUnqualifiedType().
+
+typedef float vec3 __attribute__((ext_vector_type(3)));
+
+typedef struct {
+  vec3 b;
+} struc;
+
+vec3 foo(vec3 a,const struc* hi) {
+  vec3 b = __builtin_elementwise_max((vec3)(0.0f), a);
+  return __builtin_elementwise_pow(b, hi->b.yyy);
+}

cor3ntin wrote:

Can you move that to test/Sema/builtins-elementwise-math.c, leaving a comment 
referencing the github issue?

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


[clang] [KeyInstr][Clang] Assign matrix element atom (PR #134650)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang] [KeyInstr][Clang] Assign matrix element atom (PR #134650)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

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


[clang] [compiler-rt] [lldb] [LLDB] [NFC] - Remove duplicate #include headers from the files of lldb dir & few other files (PR #141478)

2025-05-27 Thread Pavel Labath via cfe-commits

https://github.com/labath commented:

This PR also contains clang and compiler-rt changes. You'll have better luck 
finding someone to approve your PR if you split it along subproject boundaries.

Also, what's up with the extra blank line after the first header you are adding 
everywhere? I don't think we have that as a convention.

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


[clang] [HIP] disable sanitizer for `__hip_cuid` (PR #141581)

2025-05-27 Thread Matt Arsenault via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] readability-redundant-smartptr-get: disable for smart pointers to arrays (PR #141092)

2025-05-27 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-msvc.cpp
 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index baa977750..9774d93ff 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -66,8 +66,8 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
 
   // Make sure we are not missing the known standard types.
   const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
-  const auto SmartptrWithDeref =
-  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
+  const auto SmartptrWithDeref = anyOf(
+  cxxRecordDecl(knownSmartptr(), HasRelevantOps), QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(

``




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


[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-27 Thread Joseph Huber via cfe-commits

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

The changes make sense for just adding it, but does it actually work? The CMake 
I've seen in `libclc` does multiple compilations and some with 
`--target=amdgcn` for example, which is a little different from how the 
runtimes builds handle it.

Do you have an example of how to actually build this stuff?

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


[libclc] [llvm] [libclc] Support LLVM_ENABLE_RUNTIMES when building (PR #141574)

2025-05-27 Thread Joseph Huber via cfe-commits


@@ -35,7 +35,7 @@ list(INSERT CMAKE_MODULE_PATH 0
 
 # We order libraries to mirror roughly how they are layered, except that 
compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload")
+set(LLVM_DEFAULT_RUNTIMES 
"libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;offload;libclc")

jhuber6 wrote:

FYI, this is the order they build in, so if anything depends on `libclc` it 
should be placed after.

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


[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-05-27 Thread via cfe-commits

BukeBeyond wrote:

This commit breaks a critical optimization for us.  We have a project that 
compiles most of the C++26 language features to Vulkan SPIRV.  One optimization 
we rely on is the elimination of global variables.  Generating a second stub 
copy of the kernel breaks this optimization.

While we disabled the code generation from this commit, a better and more 
general solution may be to introduce a Clang flag like -fno-opencl-kernel-stub. 
 This may allow other ambitious projects like ours to pursue modern C++ on 
Vulkan.  We will soon open-source our project, which we envision will also 
benefit the AMD community.


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


[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)

2025-05-27 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez updated 
https://github.com/llvm/llvm-project/pull/137665

From f416b07520e73c7feec72378d970305e85295ad8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Mon, 28 Apr 2025 17:05:46 +0200
Subject: [PATCH 1/6] Pre-commit test: [Preprocessor] Do not expand macros if
 the input is already preprocessed

---
 clang/test/Preprocessor/preprocess-cpp-output.c | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 clang/test/Preprocessor/preprocess-cpp-output.c

diff --git a/clang/test/Preprocessor/preprocess-cpp-output.c 
b/clang/test/Preprocessor/preprocess-cpp-output.c
new file mode 100644
index 0..59ff057e9b871
--- /dev/null
+++ b/clang/test/Preprocessor/preprocess-cpp-output.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E -x c %s | FileCheck %s --check-prefixes=EXPANDED
+// RUN: %clang_cc1 -E -x cpp-output %s | FileCheck %s --check-prefixes=EXPANDED
+
+// EXPANDED: void __attribute__((__attribute__((always_inline foo()
+
+#define always_inline __attribute__((always_inline))
+void __attribute__((always_inline)) foo() {
+return 4;
+}

From 21fc4802b6147dd4c21cc7163f1a2fe8595f28c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Tue, 13 May 2025 15:03:46 +0200
Subject: [PATCH 2/6] [Modules] initializers.cpp test fix

The module contents should not contain preprocessor directives. The
contents should be already preprocessed.

Duplicate the modules instead to propose 2 versions: one with the
namespace ns and one without.
---
 clang/test/Modules/initializers.cpp | 59 +++--
 1 file changed, 55 insertions(+), 4 deletions(-)

diff --git a/clang/test/Modules/initializers.cpp 
b/clang/test/Modules/initializers.cpp
index dcd9b08ec6f7a..e1f826fbc09f3 100644
--- a/clang/test/Modules/initializers.cpp
+++ b/clang/test/Modules/initializers.cpp
@@ -48,6 +48,7 @@
 // instantiation for v in one of the two headers, because we will only
 // parse one of the two get() functions.
 
+#ifdef NS
 #pragma clang module build m
 module m {
   module a {
@@ -60,9 +61,7 @@ module m {
 #pragma clang module begin m.a
 inline int non_trivial() { return 3; }
 
-#ifdef NS
 namespace ns {
-#endif
 
 int a = non_trivial();
 inline int b = non_trivial();
@@ -102,12 +101,64 @@ inline void use(bool b, ...) {
   X::e, X::f, X::g, X::h);
 }
 
-#ifdef NS
 }
-#endif
 
 #pragma clang module end
 #pragma clang module endbuild
+#else
+#pragma clang module build m
+module m {
+  module a {
+header "foo.h" { size 123 mtime 456789 }
+  }
+  module b {}
+}
+
+#pragma clang module contents
+#pragma clang module begin m.a
+inline int non_trivial() { return 3; }
+
+int a = non_trivial();
+inline int b = non_trivial();
+thread_local int c = non_trivial();
+inline thread_local int d = non_trivial();
+
+template int e = non_trivial();
+template inline int f = non_trivial();
+template thread_local int g = non_trivial();
+template inline thread_local int h = non_trivial();
+
+inline int unused = 123; // should not be emitted
+
+template struct X {
+  static int a;
+  static inline int b = non_trivial();
+  static thread_local int c;
+  static inline thread_local int d = non_trivial();
+
+  template static int e;
+  template static inline int f = non_trivial();
+  template static thread_local int g;
+  template static inline thread_local int h = non_trivial();
+
+  static inline int unused = 123; // should not be emitted
+};
+
+template int X::a = non_trivial();
+template thread_local int X::c = non_trivial();
+template template int X::e = non_trivial();
+template template thread_local int X::g = 
non_trivial();
+
+inline void use(bool b, ...) {
+  if (b) return;
+  use(true, e, f, g, h,
+  X::a, X::b, X::c, X::d,
+  X::e, X::f, X::g, X::h);
+}
+
+#pragma clang module end
+#pragma clang module endbuild
+#endif
 
 #if IMPORT == 1
 // Import the module and the m.a submodule; runs the ordered initializers and

From 2492698a0ecdefbc25bf3be399f053e697eb6df9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20Martinez=20Caama=C3=B1o?= 
Date: Tue, 22 Apr 2025 18:40:37 +0200
Subject: [PATCH 3/6] [Preprocessor] Do not expand macros if the input is
 already preprocessed

---
 clang/include/clang/Lex/Preprocessor.h  | 5 +
 clang/lib/Frontend/InitPreprocessor.cpp | 7 +++
 clang/test/Preprocessor/preprocess-cpp-output.c | 3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index f2dfd3a349b8b..63774e48a468b 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1831,6 +1831,11 @@ class Preprocessor {
 MacroExpansionInDirectivesOverride = true;
   }
 
+  void SetDisableMacroExpansion() {
+DisableMacroExpansion = true;
+MacroExpansionInDirectivesOverride = false;
+  }
+
   /// Peeks ahead N tokens and returns that token without co

[clang] [Sema] built-in args type checking using hasSameUnqualifiedType (PR #141485)

2025-05-27 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix formatting and add release notes entry (PR #141584)

2025-05-27 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor requested changes to this pull request.


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


[clang] [KeyInstr][Clang] For range stmt atoms (PR #134647)

2025-05-27 Thread Stephen Tozer via cfe-commits

https://github.com/SLTozer commented:

Broadly LGTM, just a few style comments.

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


[clang] [KeyInstr][Clang] For range stmt atoms (PR #134647)

2025-05-27 Thread Stephen Tozer via cfe-commits


@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only 
-emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// Perennial quesiton: should the inc be its own source atom or not
+// (currently it is).
+
+// FIXME: See do.c and while.c regarding cmp and cond br groups.
+
+// The stores in the setup (stores to __RANGE1, __BEGIN1, __END1) are all
+// marked as Key. Unclear whether that's desirable. Keep for now as that's
+// least risky.

SLTozer wrote:

For posterity, maybe explain what "risky" means in this context?

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


[clang] [KeyInstr][Clang] For range stmt atoms (PR #134647)

2025-05-27 Thread Stephen Tozer via cfe-commits


@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -gkey-instructions %s -debug-info-kind=line-tables-only 
-emit-llvm -o - \
+// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
+
+// Perennial quesiton: should the inc be its own source atom or not

SLTozer wrote:

```suggestion
// Perennial question: should the inc be its own source atom or not
```

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


[clang] [clang-format] Stop moving lambda to new line only to indent it more. (PR #141576)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (rmarker)


Changes

Hanging indents are minimised for lambdas by pushing them onto a new line. 
However, it could still do this even if it would cause even more hanging 
indents than it otherwise would.

The handling has been expanded to check for this case and avoid moving the 
lambda to a new line.

Fix #141575 

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


2 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+21-4) 
- (modified) clang/unittests/Format/FormatTest.cpp (+14) 


``diff
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 4e4e48f90a89f..c6c21c4a5ffcd 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -325,13 +325,30 @@ bool ContinuationIndenter::canBreak(const LineState 
&State) {
   if (Current.isMemberAccess() && CurrentState.ContainsUnwrappedBuilder)
 return false;
 
-  // Don't create a 'hanging' indent if there are multiple blocks in a single
-  // statement and we are aligning lambda blocks to their signatures.
-  if (Previous.is(tok::l_brace) && State.Stack.size() > 1 &&
+  // Force a lambda onto a new line so that we don't create a 'hanging' indent
+  // if there are multiple blocks in a single statement and we are aligning
+  // lambda blocks to their signatures.
+  if (Previous.is(tok::l_brace) && State.Stack.size() > 2 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined &&
   State.Stack[State.Stack.size() - 2].HasMultipleNestedBlocks &&
   Style.LambdaBodyIndentation == FormatStyle::LBI_Signature) {
-return false;
+if (!Style.isCpp())
+  return false;
+
+// Make sure to push lambdas to a new line when they are an argument with
+// other arguments preceding them.
+if (State.Stack[State.Stack.size() - 2].StartOfFunctionCall > 0)
+  return false;
+
+// Only force a new line if it is not just going to create a worse hanging
+// indent. Otherwise, based on the ContinuationIndentWidth, we could end up
+// more indented than we would've been. To avoid odd looking breaks, make
+// sure we save at least IndentWidth.
+if (State.Stack[State.Stack.size() - 3].Indent +
+Style.ContinuationIndentWidth + Style.IndentWidth <
+State.Stack[State.Stack.size() - 2].Indent) {
+  return false;
+}
   }
 
   // Don't break after very short return types (e.g. "void") as that is often
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index c0633ba3c29b3..e55d82ca82c8b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23814,6 +23814,20 @@ TEST_F(FormatTest, FormatsLambdas) {
"}",
LLVMWithBeforeLambdaBody);
 
+  // Make sure we don't put the lambda on a new line when it would be indented
+  // more than where it would be otherwise.
+  verifyFormat("if ([]()\n"
+   "{\n"
+   "  return true;\n"
+   "}()) {\n"
+   "}",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("fun([]()\n"
+   "{\n"
+   "  return 17;\n"
+   "});",
+   LLVMWithBeforeLambdaBody);
+
   LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
   FormatStyle::ShortLambdaStyle::SLS_Empty;
   verifyFormat("FctWithOneNestedLambdaInline_SLS_Empty(\n"

``




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


[clang] [clang-format] Stop moving lambda to new line only to indent it more. (PR #141576)

2025-05-27 Thread via cfe-commits

https://github.com/rmarker created 
https://github.com/llvm/llvm-project/pull/141576

Hanging indents are minimised for lambdas by pushing them onto a new line. 
However, it could still do this even if it would cause even more hanging 
indents than it otherwise would.

The handling has been expanded to check for this case and avoid moving the 
lambda to a new line.

Fix #141575 

>From a727440759fc1b6219ad5e20ad89cc48acc6279b Mon Sep 17 00:00:00 2001
From: rmarker 
Date: Tue, 27 May 2025 19:54:00 +0930
Subject: [PATCH] [clang-format] Stop moving lambda to new line only to indent
 it more.

Hanging indents are minimised for lambdas by pushing them onto a new
line. However, it could still do this even if it would cause even more
hanging indents than it otherwise would.

The handling has been expanded to check for this case and avoid moving
the lambda to a new line.
---
 clang/lib/Format/ContinuationIndenter.cpp | 25 +++
 clang/unittests/Format/FormatTest.cpp | 14 +
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 4e4e48f90a89f..c6c21c4a5ffcd 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -325,13 +325,30 @@ bool ContinuationIndenter::canBreak(const LineState 
&State) {
   if (Current.isMemberAccess() && CurrentState.ContainsUnwrappedBuilder)
 return false;
 
-  // Don't create a 'hanging' indent if there are multiple blocks in a single
-  // statement and we are aligning lambda blocks to their signatures.
-  if (Previous.is(tok::l_brace) && State.Stack.size() > 1 &&
+  // Force a lambda onto a new line so that we don't create a 'hanging' indent
+  // if there are multiple blocks in a single statement and we are aligning
+  // lambda blocks to their signatures.
+  if (Previous.is(tok::l_brace) && State.Stack.size() > 2 &&
   State.Stack[State.Stack.size() - 2].NestedBlockInlined &&
   State.Stack[State.Stack.size() - 2].HasMultipleNestedBlocks &&
   Style.LambdaBodyIndentation == FormatStyle::LBI_Signature) {
-return false;
+if (!Style.isCpp())
+  return false;
+
+// Make sure to push lambdas to a new line when they are an argument with
+// other arguments preceding them.
+if (State.Stack[State.Stack.size() - 2].StartOfFunctionCall > 0)
+  return false;
+
+// Only force a new line if it is not just going to create a worse hanging
+// indent. Otherwise, based on the ContinuationIndentWidth, we could end up
+// more indented than we would've been. To avoid odd looking breaks, make
+// sure we save at least IndentWidth.
+if (State.Stack[State.Stack.size() - 3].Indent +
+Style.ContinuationIndentWidth + Style.IndentWidth <
+State.Stack[State.Stack.size() - 2].Indent) {
+  return false;
+}
   }
 
   // Don't break after very short return types (e.g. "void") as that is often
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index c0633ba3c29b3..e55d82ca82c8b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23814,6 +23814,20 @@ TEST_F(FormatTest, FormatsLambdas) {
"}",
LLVMWithBeforeLambdaBody);
 
+  // Make sure we don't put the lambda on a new line when it would be indented
+  // more than where it would be otherwise.
+  verifyFormat("if ([]()\n"
+   "{\n"
+   "  return true;\n"
+   "}()) {\n"
+   "}",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("fun([]()\n"
+   "{\n"
+   "  return 17;\n"
+   "});",
+   LLVMWithBeforeLambdaBody);
+
   LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
   FormatStyle::ShortLambdaStyle::SLS_Empty;
   verifyFormat("FctWithOneNestedLambdaInline_SLS_Empty(\n"

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


[clang] [llvm] [UBSan] Implement src:*=sanitize for UBSan (PR #140529)

2025-05-27 Thread Qinkun Bao via cfe-commits

https://github.com/qinkunbao updated 
https://github.com/llvm/llvm-project/pull/140529

>From b83755d2aa0c5417ab8f359aa842449213437a7a Mon Sep 17 00:00:00 2001
From: Qinkun Bao 
Date: Mon, 19 May 2025 11:14:01 +
Subject: [PATCH 01/16] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?=
 =?UTF-8?q?initial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 .../clang/Basic/SanitizerSpecialCaseList.h|  7 +++-
 clang/lib/Basic/NoSanitizeList.cpp|  7 
 clang/lib/Basic/SanitizerSpecialCaseList.cpp  | 16 
 .../ubsan-src-ignorelist-category.test| 37 +++
 4 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/ubsan-src-ignorelist-category.test

diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h 
b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index d024b7dfc2e85..25d518e7128cf 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -43,13 +43,18 @@ class SanitizerSpecialCaseList : public 
llvm::SpecialCaseList {
   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
  StringRef Category = StringRef()) const;
 
+  // Query ignorelisted entries if any bit in Mask matches the entry's section.
+  // Return 0 if not found. If found, return the line number (starts with 1).
+  unsigned inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef 
Query,
+  StringRef Category = StringRef()) const;
+
 protected:
   // Initialize SanitizerSections.
   void createSanitizerSections();
 
   struct SanitizerSection {
 SanitizerSection(SanitizerMask SM, SectionEntries &E)
-: Mask(SM), Entries(E){};
+: Mask(SM), Entries(E) {};
 
 SanitizerMask Mask;
 SectionEntries &Entries;
diff --git a/clang/lib/Basic/NoSanitizeList.cpp 
b/clang/lib/Basic/NoSanitizeList.cpp
index e7e63c1f419e6..811480f914ec5 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -44,6 +44,13 @@ bool NoSanitizeList::containsFunction(SanitizerMask Mask,
 
 bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
   StringRef Category) const {
+  unsigned nosanline = SSCL->inSectionBlame(Mask, "src", FileName, Category);
+  unsigned sanline = SSCL->inSectionBlame(Mask, "src", FileName, "sanitize");
+  // If we have two cases such as `src:a.cpp=sanitize` and `src:a.cpp`, the
+  // current entry override the previous entry.
+  if (nosanline > 0 && sanline > 0) {
+return nosanline > sanline;
+  }
   return SSCL->inSection(Mask, "src", FileName, Category);
 }
 
diff --git a/clang/lib/Basic/SanitizerSpecialCaseList.cpp 
b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
index 2dbf04c6ede97..7da36f3801453 100644
--- a/clang/lib/Basic/SanitizerSpecialCaseList.cpp
+++ b/clang/lib/Basic/SanitizerSpecialCaseList.cpp
@@ -63,3 +63,19 @@ bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, 
StringRef Prefix,
 
   return false;
 }
+
+unsigned SanitizerSpecialCaseList::inSectionBlame(SanitizerMask Mask,
+  StringRef Prefix,
+  StringRef Query,
+  StringRef Category) const {
+  for (auto &S : SanitizerSections) {
+if (S.Mask & Mask) {
+  unsigned lineNum =
+  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category);
+  if (lineNum > 0) {
+return lineNum;
+  }
+}
+  }
+  return 0;
+}
diff --git a/clang/test/CodeGen/ubsan-src-ignorelist-category.test 
b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
new file mode 100644
index 0..e0efd65df8652
--- /dev/null
+++ b/clang/test/CodeGen/ubsan-src-ignorelist-category.test
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck 
%s -check-prefix=CHECK-ALLOWLIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck 
%s -check-prefix=CHECK-IGNORELIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict1 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE1
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow 
-fsanitize-ignorelist=%t/src.ignorelist.contradict2 -emit-llvm %t/test1.c -o - 
| FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE2
+
+
+// Verify ubsan only emits checks for files in the allowlist
+
+//--- src.ignorelist
+src:*
+src:*/test1.c=sanitize
+
+//--- src.ignorelist.contradict1
+src:*

[clang] [KeyInstr][Clang] For range stmt atoms (PR #134647)

2025-05-27 Thread Stephen Tozer via cfe-commits

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


[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-05-27 Thread Anatoly Trosinenko via cfe-commits

https://github.com/atrosinenko updated 
https://github.com/llvm/llvm-project/pull/141573

>From c5a7fea9925c9d4aebf948c9e3d7f0af47893fb7 Mon Sep 17 00:00:00 2001
From: Anatoly Trosinenko 
Date: Mon, 26 May 2025 22:28:55 +0300
Subject: [PATCH] [AArch64][FMV] Enable PAuth and BTI hardening of resolver
 functions

---
 clang/lib/CodeGen/CodeGenModule.cpp   |  9 +++
 .../CodeGen/ptrauth-resolver-attributes.c | 25 +++
 2 files changed, 34 insertions(+)
 create mode 100644 clang/test/CodeGen/ptrauth-resolver-attributes.c

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 16e010adbeb5f..af8d4cc60de57 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4638,6 +4638,13 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   if (FD->isTargetMultiVersion() || FD->isTargetClonesMultiVersion())
 AddDeferredMultiVersionResolverToEmit(GD);
 
+  auto SetResolverAttrs = [&](llvm::Function &Resolver) {
+TargetInfo::BranchProtectionInfo BPI(getLangOpts());
+TargetCodeGenInfo::setBranchProtectionFnAttributes(BPI, Resolver);
+TargetCodeGenInfo::setPointerAuthFnAttributes(CodeGenOpts.PointerAuth,
+  Resolver);
+  };
+
   // For cpu_specific, don't create an ifunc yet because we don't know if the
   // cpu_dispatch will be emitted in this translation unit.
   if (ShouldReturnIFunc) {
@@ -4652,6 +4659,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   "", Resolver, &getModule());
 GIF->setName(ResolverName);
 SetCommonAttributes(FD, GIF);
+SetResolverAttrs(cast(*Resolver));
 if (ResolverGV)
   replaceDeclarationWith(ResolverGV, GIF);
 return GIF;
@@ -4662,6 +4670,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   assert(isa(Resolver) && !ResolverGV &&
  "Resolver should be created for the first time");
   SetCommonAttributes(FD, cast(Resolver));
+  SetResolverAttrs(cast(*Resolver));
   return Resolver;
 }
 
diff --git a/clang/test/CodeGen/ptrauth-resolver-attributes.c 
b/clang/test/CodeGen/ptrauth-resolver-attributes.c
new file mode 100644
index 0..8bdedd2c549be
--- /dev/null
+++ b/clang/test/CodeGen/ptrauth-resolver-attributes.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+
+// Check that resolver functions generated by clang have the correct 
attributes.
+
+int __attribute__((target_clones("crc", "default"))) ftc(void) { return 0; }
+
+int __attribute__((target_version("crc"))) fmv(void) { return 0; }
+int __attribute__((target_version("default"))) fmv(void) { return 0; }
+
+// CHECK: define{{.*}} i32 @ftc._Mcrc() #0
+// CHECK: define{{.*}} ptr @ftc.resolver() #1
+// CHECK: define{{.*}} i32 @fmv._Mcrc() #0
+// CHECK: define{{.*}} i32 @fmv.default() #2
+// CHECK: define{{.*}} i32 @ftc.default() #2
+// CHECK: define{{.*}} ptr @fmv.resolver() #1
+
+// BTI-SIGNRA: attributes #0 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #1 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #2 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// PAUTHTEST: attributes #0 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #1 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #2 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }

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


[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-05-27 Thread Anatoly Trosinenko via cfe-commits

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


[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Anatoly Trosinenko (atrosinenko)


Changes



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


2 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+9) 
- (added) clang/test/CodeGen/ptrauth-resolver-attributes.c (+25) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 16e010adbeb5f..af8d4cc60de57 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4638,6 +4638,13 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   if (FD->isTargetMultiVersion() || FD->isTargetClonesMultiVersion())
 AddDeferredMultiVersionResolverToEmit(GD);
 
+  auto SetResolverAttrs = [&](llvm::Function &Resolver) {
+TargetInfo::BranchProtectionInfo BPI(getLangOpts());
+TargetCodeGenInfo::setBranchProtectionFnAttributes(BPI, Resolver);
+TargetCodeGenInfo::setPointerAuthFnAttributes(CodeGenOpts.PointerAuth,
+  Resolver);
+  };
+
   // For cpu_specific, don't create an ifunc yet because we don't know if the
   // cpu_dispatch will be emitted in this translation unit.
   if (ShouldReturnIFunc) {
@@ -4652,6 +4659,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   "", Resolver, &getModule());
 GIF->setName(ResolverName);
 SetCommonAttributes(FD, GIF);
+SetResolverAttrs(cast(*Resolver));
 if (ResolverGV)
   replaceDeclarationWith(ResolverGV, GIF);
 return GIF;
@@ -4662,6 +4670,7 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   assert(isa(Resolver) && !ResolverGV &&
  "Resolver should be created for the first time");
   SetCommonAttributes(FD, cast(Resolver));
+  SetResolverAttrs(cast(*Resolver));
   return Resolver;
 }
 
diff --git a/clang/test/CodeGen/ptrauth-resolver-attributes.c 
b/clang/test/CodeGen/ptrauth-resolver-attributes.c
new file mode 100644
index 0..8bdedd2c549be
--- /dev/null
+++ b/clang/test/CodeGen/ptrauth-resolver-attributes.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -mbranch-target-enforce 
-msign-return-address=all  -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,BTI-SIGNRA %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+// RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -fptrauth-returns 
-fptrauth-auth-traps -emit-llvm %s -o - | FileCheck 
--check-prefixes=CHECK,PAUTHTEST %s
+
+// Check that resolver functions generated by clang have the correct 
attributes.
+
+int __attribute__((target_clones("crc", "default"))) ftc(void) { return 0; }
+
+int __attribute__((target_version("crc"))) fmv(void) { return 0; }
+int __attribute__((target_version("default"))) fmv(void) { return 0; }
+
+// CHECK: define{{.*}} i32 @ftc._Mcrc() #0
+// CHECK: define{{.*}} ptr @ftc.resolver() #1
+// CHECK: define{{.*}} i32 @fmv._Mcrc() #0
+// CHECK: define{{.*}} i32 @fmv.default() #2
+// CHECK: define{{.*}} i32 @ftc.default() #2
+// CHECK: define{{.*}} ptr @fmv.resolver() #1
+
+// BTI-SIGNRA: attributes #0 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #1 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// BTI-SIGNRA: attributes #2 = { {{.*}}"branch-target-enforcement" 
{{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"{{.*}} }
+// PAUTHTEST: attributes #0 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #1 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }
+// PAUTHTEST: attributes #2 = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" 
"ptrauth-returns"{{.*}} }

``




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


[clang] [CodeGen] Add TBAA struct path info for array members (PR #137719)

2025-05-27 Thread Bruno De Fraine via cfe-commits

https://github.com/brunodf-snps updated 
https://github.com/llvm/llvm-project/pull/137719

>From d63c8fe4fcc8e89933bf3c1cc176941b0b9094fa Mon Sep 17 00:00:00 2001
From: Bruno De Fraine 
Date: Mon, 28 Apr 2025 14:12:00 +0200
Subject: [PATCH 1/6] [clang][CodeGen] Make tbaa-array test more robust

Avoid unintentional matches against extra load/stores in the unoptimized
LLVM IR.
---
 clang/test/CodeGen/tbaa-array.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/test/CodeGen/tbaa-array.cpp 
b/clang/test/CodeGen/tbaa-array.cpp
index 4a6576e2eeb7f..ce34e7d586e3e 100644
--- a/clang/test/CodeGen/tbaa-array.cpp
+++ b/clang/test/CodeGen/tbaa-array.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
+// RUN: %clang_cc1 -triple x86_64-linux -O1 %s \
 // RUN: -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \
+// RUN: %clang_cc1 -triple x86_64-linux -O1 %s \
 // RUN: -new-struct-path-tbaa -emit-llvm -o - | \
 // RUN: FileCheck -check-prefix=CHECK-NEW %s
 //
@@ -45,7 +45,6 @@ int bar3(C *c, int j) {
 // CHECK-NEW-DAG: [[TYPE_char:!.*]] = !{{{.*}}, i64 1, !"omnipotent char"}
 // CHECK-NEW-DAG: [[TYPE_int:!.*]] = !{[[TYPE_char]], i64 4, !"int"}
 // CHECK-NEW-DAG: [[TAG_int]] = !{[[TYPE_int]], [[TYPE_int]], i64 0, i64 4}
-// CHECK-NEW-DAG: [[TYPE_pointer:!.*]] = !{[[TYPE_char]], i64 8, !"any 
pointer"}
 // CHECK-NEW-DAG: [[TYPE_A:!.*]] = !{[[TYPE_char]], i64 4, !"_ZTS1A", 
[[TYPE_int]], i64 0, i64 4}
 // CHECK-NEW-DAG: [[TAG_A_i]] = !{[[TYPE_A]], [[TYPE_int]], i64 0, i64 4}
 // CHECK-NEW-DAG: [[TYPE_C:!.*]] = !{[[TYPE_char]], i64 16, !"_ZTS1C", 
[[TYPE_int]], i64 0, i64 4, [[TYPE_int]], i64 4, i64 12}

>From bba5ee5ed17af062f91604d3185d733df944df67 Mon Sep 17 00:00:00 2001
From: Bruno De Fraine 
Date: Tue, 29 Apr 2025 00:07:02 +0200
Subject: [PATCH 2/6] [CodeGen] Add TBAA struct path info for array members

This enables the LLVM optimizer to view accesses to distinct struct
members as independent, also for array members. For example, the
following two stores no longer alias:

struct S { int a[10]; int b; };
void test(S *p, int i) {
  p->a[i] = ...;
  p->b = ...;
}

Array members were already added to TBAA struct type nodes in commit
57493e2. Here, we extend a path tag for an array subscript expression.
---
 clang/lib/CodeGen/CGExpr.cpp  | 27 ++-
 clang/test/CodeGen/tbaa-array.cpp | 21 +++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bba7d1e805f3f..c95a54fcebba9 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4503,7 +4503,32 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const 
ArraySubscriptExpr *E,
 E->getType(), !getLangOpts().PointerOverflowDefined, SignedIndices,
 E->getExprLoc(), &arrayType, E->getBase());
 EltBaseInfo = ArrayLV.getBaseInfo();
-EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
+if (!CGM.getCodeGenOpts().NewStructPathTBAA) {
+  // Since CodeGenTBAA::getTypeInfoHelper only handles array types for
+  // new struct path TBAA, we must a use a plain access.
+  EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
+} else if (ArrayLV.getTBAAInfo().isMayAlias()) {
+  EltTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
+} else if (ArrayLV.getTBAAInfo().isIncomplete()) {
+  EltTBAAInfo = CGM.getTBAAAccessInfo(E->getType());
+} else {
+  // Extend struct path from base lvalue, similar to EmitLValueForField.
+  // If no base type has been assigned for the array access, then try to
+  // generate one.
+  EltTBAAInfo = ArrayLV.getTBAAInfo();
+  if (!EltTBAAInfo.BaseType) {
+EltTBAAInfo.BaseType = CGM.getTBAABaseTypeInfo(ArrayLV.getType());
+assert(!EltTBAAInfo.Offset &&
+   "Nonzero offset for an access with no base type!");
+  }
+  // The index into the array is a runtime value. We use the same struct
+  // path for all array elements (that of the element at index 0). So we
+  // set the access type and size, but do not have to adjust
+  // EltTBAAInfo.Offset.
+  EltTBAAInfo.AccessType = CGM.getTBAATypeInfo(E->getType());
+  EltTBAAInfo.Size =
+  getContext().getTypeSizeInChars(E->getType()).getQuantity();
+}
   } else {
 // The base must be a pointer; emit it with an estimate of its alignment.
 Addr = EmitPointerWithAlignment(E->getBase(), &EltBaseInfo, &EltTBAAInfo);
diff --git a/clang/test/CodeGen/tbaa-array.cpp 
b/clang/test/CodeGen/tbaa-array.cpp
index ce34e7d586e3e..7cda1dd8d5bf7 100644
--- a/clang/test/CodeGen/tbaa-array.cpp
+++ b/clang/test/CodeGen/tbaa-array.cpp
@@ -10,6 +10,8 @@
 struct A { int i; };
 struct B { A a[1]; };
 struct C { int i; int x[3]; };
+struct D { int n; int arr[]; }; // flexible array memb

[clang] [KeyInstr][Clang] Bitfield atom (PR #134648)

2025-05-27 Thread Stephen Tozer via cfe-commits

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


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


[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 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` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'lit :: timeout-hang.py' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 13
not env -u FILECHECK_OPTS 
"/home/llvm/llvm-external-buildbots/workers/env/bin/python3.11" 
/home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/utils/lit/lit.py
 -j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt  --timeout=1 
--param external=0 | 
"/home/llvm/llvm-external-buildbots/workers/env/bin/python3.11" 
/home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/build/utils/lit/tests/timeout-hang.py
 1
# executed command: not env -u FILECHECK_OPTS 
/home/llvm/llvm-external-buildbots/workers/env/bin/python3.11 
/home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/utils/lit/lit.py
 -j1 --order=lexical Inputs/timeout-hang/run-nonexistent.txt --timeout=1 
--param external=0
# .---command stderr
# | lit.py: 
/home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 1 seconds was requested on the command line. Forcing 
timeout to be 1 seconds.
# `-
# executed command: 
/home/llvm/llvm-external-buildbots/workers/env/bin/python3.11 
/home/llvm/llvm-external-buildbots/workers/aix-ppc64/clang-ppc64-aix/build/utils/lit/tests/timeout-hang.py
 1
# .---command stdout
# | Testing took as long or longer than timeout
# `-
# error: command failed with exit status: 1

--




```



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


[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat commented:

@steakhal Thanks for the updates, I'm completely satisfied with them.

I don't see any connection between this commit and the buildbot failures 
:thinking: ... they are probably unrelated.

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


[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 Thread Balázs Benics via cfe-commits

balazs-benics-sonarsource wrote:

> @steakhal Thanks for the updates, I'm completely satisfied with them.
> 
> I don't see any connection between this commit and the buildbot failures 🤔 
> ... they are probably unrelated.

About 90% of the time they are unrelated. I don't usually put a confirmation to 
these messages.

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


[clang-tools-extra] [clang-tidy] Fix formatting and add release notes entry (PR #141584)

2025-05-27 Thread via cfe-commits

https://github.com/FabianWolff created 
https://github.com/llvm/llvm-project/pull/141584

Follow-up to #141092.

>From eccc89a78d2da840279d584d0b6580269b7fb3fc Mon Sep 17 00:00:00 2001
From: Fabian Wolff 
Date: Tue, 27 May 2025 12:13:32 +
Subject: [PATCH 1/2] Run `clang-format`

---
 .../clang-tidy/readability/RedundantSmartptrGetCheck.cpp  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index baa977750d101..9774d93ff36fd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -66,8 +66,8 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
 
   // Make sure we are not missing the known standard types.
   const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
-  const auto SmartptrWithDeref =
-  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
+  const auto SmartptrWithDeref = anyOf(
+  cxxRecordDecl(knownSmartptr(), HasRelevantOps), QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(

>From f81178ec1022213fdcab91baf348e689b2b4647d Mon Sep 17 00:00:00 2001
From: Fabian Wolff 
Date: Tue, 27 May 2025 12:13:32 +
Subject: [PATCH 2/2] Document change in the release notes

---
 clang-tools-extra/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index d6f2d2b37624e..bc9f4a4a11bcc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -114,6 +114,9 @@ Improvements to clang-tidy
 - Fixed bug in :program:`run_clang_tidy.py` where the program would not
   correctly display the checks enabled by the top-level `.clang-tidy` file.
 
+- Fixed some false positives in the ``readability-redundant-smartptr-get``
+  check involving smart pointers to arrays.
+
 New checks
 ^^
 

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


[clang] [C2y] Correctly handle incomplete types in generic selections (PR #141596)

2025-05-27 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman created 
https://github.com/llvm/llvm-project/pull/141596

We were emitting a non-error diagnostic but claiming we emitted an error, which 
caused some obvious follow-on problems.

Fixes #141549

>From a3509b043c9b36decdb3e891ac4e808c3d907827 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Tue, 27 May 2025 09:10:46 -0400
Subject: [PATCH] [C2y] Correctly handle incomplete types in generic selections

We were emitting a non-error diagnostic but claiming we emitted an
error, which caused some obvious follow-on problems.

Fixes #141549
---
 clang/lib/Sema/SemaExpr.cpp  |  8 ---
 clang/test/C/C2y/n3409.c | 29 
 clang/test/SemaCXX/generic-selection.cpp |  2 +-
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 11dddac536d32..5aa33939a7817 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1874,9 +1874,11 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
 if (D != 0) {
   Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
-<< Types[i]->getTypeLoc().getSourceRange()
-<< Types[i]->getType();
-  TypeErrorFound = true;
+  << Types[i]->getTypeLoc().getSourceRange() << 
Types[i]->getType();
+  if (getDiagnostics().getDiagnosticLevel(
+  D, Types[i]->getTypeLoc().getBeginLoc()) >=
+  DiagnosticsEngine::Error)
+TypeErrorFound = true;
 }
 
 // C11 6.5.1.1p2 "No two generic associations in the same generic
diff --git a/clang/test/C/C2y/n3409.c b/clang/test/C/C2y/n3409.c
index 01be716132b11..a0b8e2f28ee40 100644
--- a/clang/test/C/C2y/n3409.c
+++ b/clang/test/C/C2y/n3409.c
@@ -1,7 +1,6 @@
-// RUN: %clang_cc1 -verify -std=c2y -pedantic %s
-// RUN: %clang_cc1 -verify=pre-c2y -std=c2y -Wpre-c2y-compat %s
-// RUN: %clang_cc1 -verify=ext -std=c23 -pedantic %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -verify -std=c2y -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=expected,pre-c2y -std=c2y -Wpre-c2y-compat 
-Wno-unused %s
+// RUN: %clang_cc1 -verify=expected,ext -std=c23 -pedantic -Wno-unused %s
 
 /* WG14 N3409: Clang 21
  * Slay Some Earthly Demons X
@@ -34,3 +33,25 @@ void foo() {
   // C23 and earlier.
   return x; // ext-warning {{void function 'foo' should not return void 
expression}}
 }
+
+
+// Ensure we behave correctly with incomplete types. See GH141549.
+static_assert(
+  _Generic(
+void,/* ext-warning {{passing a type argument as the first operand to 
'_Generic' is a C2y extension}}
+pre-c2y-warning {{passing a type argument as the first operand 
to '_Generic' is incompatible with C standards before C2y}}
+  */
+void : 1,
+default : 0
+  )
+);
+
+static_assert(
+  _Generic( // expected-error {{static assertion failed}}
+12,
+void : 1, /* ext-warning {{incomplete type 'void' in a '_Generic' 
association is a C2y extension}}
+ pre-c2y-warning {{use of incomplete type 'void' in a 
'_Generic' association is incompatible with C standards before C2y}}
+   */
+default : 0
+  )
+);
diff --git a/clang/test/SemaCXX/generic-selection.cpp 
b/clang/test/SemaCXX/generic-selection.cpp
index aa4a4c435adec..ed9d2b7d44be3 100644
--- a/clang/test/SemaCXX/generic-selection.cpp
+++ b/clang/test/SemaCXX/generic-selection.cpp
@@ -81,7 +81,7 @@ void func(struct S s) {
   // is an elaborated type specifier followed by the association's value and
   // it should work the same as in C.
   (void)_Generic(s, struct S : 1);
-  (void)_Generic(s, struct T : 1);
+  (void)_Generic(s, struct T : 1); // expected-error {{controlling expression 
type 'struct S' not compatible with any generic association type}}
 
   // The rest of these cases test that we still produce a reasonable diagnostic
   // when referencing an unknown type or trying to define a type in other ways.

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


[clang] [KeyIntsr][Clang] Builtins alloca auto-init atom (PR #134651)

2025-05-27 Thread Stephen Tozer via cfe-commits

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


[clang] [KeyInstr][Clang] Assign vector element atom (PR #134649)

2025-05-27 Thread Orlando Cazalet-Hyams via cfe-commits

https://github.com/OCHyams updated 
https://github.com/llvm/llvm-project/pull/134649

>From d5bf606509f4f4fcb30e0cb1ea2fe0b51e5a5b5c Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams 
Date: Thu, 3 Apr 2025 21:56:37 +0100
Subject: [PATCH] [KeyInstr][Clang] Assign vector element atom

This patch is part of a stack that teaches Clang to generate Key Instructions
metadata for C and C++.

The Key Instructions project is introduced, including a "quick summary" section
at the top which adds context for this PR, here:
https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668

The feature is only functional in LLVM if LLVM is built with CMake flag
LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed.

The Clang-side work is demoed here:
https://github.com/llvm/llvm-project/pull/130943
---
 clang/lib/CodeGen/CGExpr.cpp   | 5 +++--
 clang/test/DebugInfo/KeyInstructions/agg.c | 8 
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 76db2a9c5..dbeccfc2b9f6d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2507,8 +2507,9 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, 
LValue Dst,
 Vec = Builder.CreateBitCast(Vec, IRStoreTy);
   }
 
-  Builder.CreateStore(Vec, Dst.getVectorAddress(),
-  Dst.isVolatileQualified());
+  auto *I = Builder.CreateStore(Vec, Dst.getVectorAddress(),
+Dst.isVolatileQualified());
+  addInstToCurrentSourceAtom(I, Vec);
   return;
 }
 
diff --git a/clang/test/DebugInfo/KeyInstructions/agg.c 
b/clang/test/DebugInfo/KeyInstructions/agg.c
index e9d9da7f687c6..5cb3a553b6752 100644
--- a/clang/test/DebugInfo/KeyInstructions/agg.c
+++ b/clang/test/DebugInfo/KeyInstructions/agg.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s 
-debug-info-kind=line-tables-only -emit-llvm -o - \
 // RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not 
atomRank
 
+__attribute__((ext_vector_type(1))) char c;
 typedef struct { int a, b, c; } Struct;
 void fun(Struct a) {
 // CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
@@ -11,7 +12,14 @@ void fun(Struct a) {
 
 // CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G2R1:!.*]]
   b = a;
+
+// CHECK: %2 = load <1 x i8>, ptr @c
+// CHECK: %vecins = insertelement <1 x i8> %2, i8 0, i32 0, !dbg [[G3R2:!.*]]
+// CHECK: store <1 x i8> %vecins, ptr @c{{.*}}, !dbg [[G3R1:!.*]]
+  c[0] = 0;
 }
 
 // CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
 // CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
+// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
+// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)

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


[clang] [C2y] Correctly handle incomplete types in generic selections (PR #141596)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Aaron Ballman (AaronBallman)


Changes

We were emitting a non-error diagnostic but claiming we emitted an error, which 
caused some obvious follow-on problems.

Fixes #141549

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


3 Files Affected:

- (modified) clang/lib/Sema/SemaExpr.cpp (+5-3) 
- (modified) clang/test/C/C2y/n3409.c (+25-4) 
- (modified) clang/test/SemaCXX/generic-selection.cpp (+1-1) 


``diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 11dddac536d32..5aa33939a7817 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1874,9 +1874,11 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
 if (D != 0) {
   Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
-<< Types[i]->getTypeLoc().getSourceRange()
-<< Types[i]->getType();
-  TypeErrorFound = true;
+  << Types[i]->getTypeLoc().getSourceRange() << 
Types[i]->getType();
+  if (getDiagnostics().getDiagnosticLevel(
+  D, Types[i]->getTypeLoc().getBeginLoc()) >=
+  DiagnosticsEngine::Error)
+TypeErrorFound = true;
 }
 
 // C11 6.5.1.1p2 "No two generic associations in the same generic
diff --git a/clang/test/C/C2y/n3409.c b/clang/test/C/C2y/n3409.c
index 01be716132b11..a0b8e2f28ee40 100644
--- a/clang/test/C/C2y/n3409.c
+++ b/clang/test/C/C2y/n3409.c
@@ -1,7 +1,6 @@
-// RUN: %clang_cc1 -verify -std=c2y -pedantic %s
-// RUN: %clang_cc1 -verify=pre-c2y -std=c2y -Wpre-c2y-compat %s
-// RUN: %clang_cc1 -verify=ext -std=c23 -pedantic %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -verify -std=c2y -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=expected,pre-c2y -std=c2y -Wpre-c2y-compat 
-Wno-unused %s
+// RUN: %clang_cc1 -verify=expected,ext -std=c23 -pedantic -Wno-unused %s
 
 /* WG14 N3409: Clang 21
  * Slay Some Earthly Demons X
@@ -34,3 +33,25 @@ void foo() {
   // C23 and earlier.
   return x; // ext-warning {{void function 'foo' should not return void 
expression}}
 }
+
+
+// Ensure we behave correctly with incomplete types. See GH141549.
+static_assert(
+  _Generic(
+void,/* ext-warning {{passing a type argument as the first operand to 
'_Generic' is a C2y extension}}
+pre-c2y-warning {{passing a type argument as the first operand 
to '_Generic' is incompatible with C standards before C2y}}
+  */
+void : 1,
+default : 0
+  )
+);
+
+static_assert(
+  _Generic( // expected-error {{static assertion failed}}
+12,
+void : 1, /* ext-warning {{incomplete type 'void' in a '_Generic' 
association is a C2y extension}}
+ pre-c2y-warning {{use of incomplete type 'void' in a 
'_Generic' association is incompatible with C standards before C2y}}
+   */
+default : 0
+  )
+);
diff --git a/clang/test/SemaCXX/generic-selection.cpp 
b/clang/test/SemaCXX/generic-selection.cpp
index aa4a4c435adec..ed9d2b7d44be3 100644
--- a/clang/test/SemaCXX/generic-selection.cpp
+++ b/clang/test/SemaCXX/generic-selection.cpp
@@ -81,7 +81,7 @@ void func(struct S s) {
   // is an elaborated type specifier followed by the association's value and
   // it should work the same as in C.
   (void)_Generic(s, struct S : 1);
-  (void)_Generic(s, struct T : 1);
+  (void)_Generic(s, struct T : 1); // expected-error {{controlling expression 
type 'struct S' not compatible with any generic association type}}
 
   // The rest of these cases test that we still produce a reasonable diagnostic
   // when referencing an unknown type or trying to define a type in other ways.

``




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


[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-05-27 Thread via cfe-commits

BukeBeyond wrote:

> Doesn't OpenCL have an extension system? You could make an extension to 
> disable this feature instead of putting it in the compiler I'd think. I'm not 
> sure how SPIR-V works, but normally we differentiate between globals needed 
> for the user and internal globals by their visibility. Hidden visibility 
> variables are internalized at link time / not emitted while others can be 
> read by the user while loading the GPU blob, so they must stay.

You are right!
`#pragma OPENCL EXTENSION __cl_clang_kernel_stub : disable`
would be the better place for this switch, though it may be more difficult to 
implement than an experimental Clang flag.  It is possible the stub generation 
here or the global variable optimization may improve in the future, when the 
stub feature can be safely enabled for all cases.

Kernels have exclusive access to private (register) and local (core memory) 
objects, but we need to give access to these states from other functions and 
methods without explicit wiring.  Imagine a print() function that needs to be 
wired at every use, and the state passed everywhere would make for very 
ineloquent code!  

We lifted some artificial limits in Clang and OpenCL to allow a global pointer 
to a private object inside the kernel.  The optimization passes in LLVM do an 
excellent job eliminating everything, Methods, Lambdas to a flat stream of code 
in the kernel body.  All the struct definitions are also eliminated, which 
otherwise Clspv cannot handle.

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


[clang-tools-extra] [clang-tidy] Fix formatting and add release notes entry (PR #141584)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (FabianWolff)


Changes

Follow-up to #141092.

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


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (+2-2) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+3) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index baa977750d101..9774d93ff36fd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -66,8 +66,8 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
 
   // Make sure we are not missing the known standard types.
   const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
-  const auto SmartptrWithDeref =
-  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
+  const auto SmartptrWithDeref = anyOf(
+  cxxRecordDecl(knownSmartptr(), HasRelevantOps), QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index d6f2d2b37624e..bc9f4a4a11bcc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -114,6 +114,9 @@ Improvements to clang-tidy
 - Fixed bug in :program:`run_clang_tidy.py` where the program would not
   correctly display the checks enabled by the top-level `.clang-tidy` file.
 
+- Fixed some false positives in the ``readability-redundant-smartptr-get``
+  check involving smart pointers to arrays.
+
 New checks
 ^^
 

``




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


[clang-tools-extra] [clang-tidy] Add check for assignment or comparision operators' operand in `readability-math-missing-parentheses` (PR #141345)

2025-05-27 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix formatting and add release notes entry (PR #141584)

2025-05-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (FabianWolff)


Changes

Follow-up to #141092.

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


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (+2-2) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+3) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index baa977750d101..9774d93ff36fd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -66,8 +66,8 @@ void registerMatchersForGetArrowStart(MatchFinder *Finder,
 
   // Make sure we are not missing the known standard types.
   const auto SmartptrAny = anyOf(knownSmartptr(), QuacksLikeASmartptr);
-  const auto SmartptrWithDeref =
-  anyOf(cxxRecordDecl(knownSmartptr(), HasRelevantOps), 
QuacksLikeASmartptr);
+  const auto SmartptrWithDeref = anyOf(
+  cxxRecordDecl(knownSmartptr(), HasRelevantOps), QuacksLikeASmartptr);
 
   // Catch 'ptr.get()->Foo()'
   Finder->addMatcher(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index d6f2d2b37624e..bc9f4a4a11bcc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -114,6 +114,9 @@ Improvements to clang-tidy
 - Fixed bug in :program:`run_clang_tidy.py` where the program would not
   correctly display the checks enabled by the top-level `.clang-tidy` file.
 
+- Fixed some false positives in the ``readability-redundant-smartptr-get``
+  check involving smart pointers to arrays.
+
 New checks
 ^^
 

``




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


[clang] [llvm] [clang][RISCV][Zicfilp] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2025-05-27 Thread Ming-Yi Lai via cfe-commits

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


[clang] [Driver][X86] Add -m[no-]apxf to m_x86_Features_Group (PR #140874)

2025-05-27 Thread Rainer Orth via cfe-commits

rorth wrote:

The Solaris/amd64 bot is green again, thanks.

I'd tried to reproduce the failure locally yesterday, but weirdly couldn't: no 
idea what's the difference between the bot and
my local builds.

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


[clang] [clang][RISCV] Handle target features correctly in CheckBuiltinFunctionCall (PR #141548)

2025-05-27 Thread Brandon Wu via cfe-commits


@@ -0,0 +1,11 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zvknha %s -fsyntax-only 
-verify
+
+#include 
+
+// expected-no-diagnostics
+
+__attribute__((target("arch=+zvl128b")))
+void test_zvk_features(vuint32m1_t vd, vuint32m1_t vs2, vuint32m1_t vs1, 
size_t vl) {

4vtomat wrote:

We'll have following error: `RISC-V type 'vuint32m1_t' (aka '__rvv_uint32m1_t') 
requires the 'zvl128b' extension`
That's the extra check for vector crypto extensions

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


[clang] 104f5d1 - [analyzer] Introduce the check::BlockEntrance checker callback (#140924)

2025-05-27 Thread via cfe-commits

Author: Balázs Benics
Date: 2025-05-27T10:11:12+02:00
New Revision: 104f5d1ff84613542442b71bcb59e19c5ed17b89

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

LOG: [analyzer] Introduce the check::BlockEntrance checker callback (#140924)

Tranersing the CFG blocks of a function is a fundamental operation. Many
C++ constructs can create splits in the control-flow, such as `if`,
`for`, and similar control structures or ternary expressions, gnu
conditionals, gotos, switches and possibly more.

Checkers should be able to get notifications about entering or leaving a
CFG block of interest.

Note that in the ExplodedGraph there is always a BlockEntrance
ProgramPoint right after the BlockEdge ProgramPoint. I considered naming
this callback check::BlockEdge, but then that may leave the observer of
the graph puzzled to see BlockEdge points followed more BlockEdge nodes
describing the same CFG transition. This confusion could also apply to
Bug Report Visitors too.

Because of this, I decided to hook BlockEntrance ProgramPoints instead.
The same confusion applies here, but I find this still a better place
TBH. There would only appear only one BlockEntrance ProgramPoint in the
graph if no checkers modify the state or emit a bug report. Otherwise
they modify some GDM (aka. State) thus create a new ExplodedNode with
the same BlockEntrance ProgramPoint in the graph.

CPP-6484

Added: 
clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/Checker.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h 
b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index acd83602aeec4..c6866cb561551 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -221,6 +221,22 @@ class Bind {
   }
 };
 
+class BlockEntrance {
+  template 
+  static void _checkBlockEntrance(void *Checker,
+  const clang::BlockEntrance &Entrance,
+  CheckerContext &C) {
+((const CHECKER *)Checker)->checkBlockEntrance(Entrance, C);
+  }
+
+public:
+  template 
+  static void _register(CHECKER *checker, CheckerManager &mgr) {
+mgr._registerForBlockEntrance(CheckerManager::CheckBlockEntranceFunc(
+checker, _checkBlockEntrance));
+  }
+};
+
 class EndAnalysis {
   template 
   static void _checkEndAnalysis(void *checker, ExplodedGraph &G,
@@ -536,6 +552,8 @@ class CheckerBase : public CheckerFrontend, public 
CheckerBackend {
 template 
 class Checker : public CheckerBase, public CHECKs... {
 public:
+  using BlockEntrance = clang::BlockEntrance;
+
   template 
   static void _register(CHECKER *Chk, CheckerManager &Mgr) {
 (CHECKs::_register(Chk, Mgr), ...);
@@ -565,6 +583,8 @@ class Checker : public CheckerBase, public CHECKs... {
 template 
 class CheckerFamily : public CheckerBackend, public CHECKs... {
 public:
+  using BlockEntrance = clang::BlockEntrance;
+
   template 
   static void _register(CHECKER *Chk, CheckerManager &Mgr) {
 (CHECKs::_register(Chk, Mgr), ...);

diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 58f59f7ab049f..c8e6f1265a3db 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -344,6 +344,12 @@ class CheckerManager {
   const Stmt *S, ExprEngine &Eng,
   const ProgramPoint &PP);
 
+  /// Run checkers after taking a control flow edge.
+  void runCheckersForBlockEntrance(ExplodedNodeSet &Dst,
+   const ExplodedNodeSet &Src,
+   const BlockEntrance &Entrance,
+   ExprEngine &Eng) const;
+
   /// Run checkers for end of analysis.
   void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR,
  ExprEngine &Eng);
@@ -496,6 +502,9 @@ class CheckerManager {
   using CheckBindFunc =
   CheckerFn;
 
+  using CheckBlockEntranceFunc =
+  CheckerFn;
+
   using CheckEndAnalysisFunc =
   CheckerFn;
 
@@ -557,6 +566,8 @@ class CheckerManager {
 
   void _registerForBind(CheckBindFunc checkfn);
 
+ 

[clang] [clang][RISCV] Handle target features correctly in CheckBuiltinFunctionCall (PR #141548)

2025-05-27 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp approved this pull request.

LGTM.

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


[clang] [analyzer] Introduce the check::BlockEntrance checker callback (PR #140924)

2025-05-27 Thread Balázs Benics via cfe-commits

https://github.com/balazs-benics-sonarsource closed 
https://github.com/llvm/llvm-project/pull/140924
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce elementwise clz/ctz builtins (PR #131995)

2025-05-27 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck updated 
https://github.com/llvm/llvm-project/pull/131995

>From 8f445e8db9378779d822388060ee3be15f360751 Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 3 Feb 2025 16:54:17 +
Subject: [PATCH 1/4] [clang] Introduce elementwise clz/ctz builtins

These builtins are modeled on the clzg/ctzg builtins, which accept an
optional second argument. This second argument is returned if the first
argument is 0.
---
 clang/docs/LanguageExtensions.rst |  8 ++
 clang/include/clang/Basic/Builtins.td | 12 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 18 ++--
 clang/lib/Sema/SemaChecking.cpp   | 13 +++
 .../test/CodeGen/builtins-elementwise-math.c  | 96 +++
 clang/test/Sema/builtins-elementwise-math.c   | 44 +
 6 files changed, 185 insertions(+), 6 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index a40dd4d1a1673..383c6c2e039b5 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -847,6 +847,14 @@ of different sizes and signs is forbidden in binary and 
ternary builtins.
 semantics, see `LangRef
 
`_
 for the comparison.
+ T __builtin_elementwise_clz(T x[, T y])return the number of leading 0 
bits in the first argument. If  integer types
+the first argument is 0 and an 
optional second argument is provided,
+the second argument is 
returned. If the first argument is 0 but only
+one argument is provided, the 
behaviour is undefined.
+ T __builtin_elementwise_ctz(T x[, T y])return the number of trailing 
0 bits in the first argument. If integer types
+the first argument is 0 and an 
optional second argument is provided,
+the second argument is 
returned. If the first argument is 0 but only
+one argument is provided, the 
behaviour is undefined.
 == 
== 
=
 
 
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index e43b87fb3c131..53d24ef00a5e6 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -1496,6 +1496,18 @@ def ElementwiseSubSat : Builtin {
   let Prototype = "void(...)";
 }
 
+def ElementwiseClz : Builtin {
+  let Spellings = ["__builtin_elementwise_clz"];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
+  let Prototype = "void(...)";
+}
+
+def ElementwiseCtz : Builtin {
+  let Spellings = ["__builtin_elementwise_ctz"];
+  let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
+  let Prototype = "void(...)";
+}
+
 def ReduceMax : Builtin {
   let Spellings = ["__builtin_reduce_max"];
   let Attributes = [NoThrow, Const, CustomTypeChecking, Constexpr];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 89b321090f2d8..b33ef3a42c14b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3298,9 +3298,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_ctz:
   case Builtin::BI__builtin_ctzl:
   case Builtin::BI__builtin_ctzll:
-  case Builtin::BI__builtin_ctzg: {
-bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_ctzg &&
-   E->getNumArgs() > 1;
+  case Builtin::BI__builtin_ctzg:
+  case Builtin::BI__builtin_elementwise_ctz: {
+bool HasFallback =
+(BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_ctzg ||
+ BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_elementwise_ctz) &&
+E->getNumArgs() > 1;
 
 Value *ArgValue =
 HasFallback ? EmitScalarExpr(E->getArg(0))
@@ -3330,9 +,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_clz:
   case Builtin::BI__builtin_clzl:
   case Builtin::BI__builtin_clzll:
-  case Builtin::BI__builtin_clzg: {
-bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_clzg &&
-   E->getNumArgs() > 1;
+  case Builtin::BI__builtin_clzg:
+  case Builtin::BI__builtin_elementwise_clz: {
+bool HasFallback =
+(BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_clzg ||
+ BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_elementwise_clz) &&
+E->getNumArgs() > 1;
 
 Value *ArgValue =
 HasFallback ? Em

[clang] [llvm] [ARM, AArch64] Don't put BTI at asm goto branch targets (PR #141562)

2025-05-27 Thread Simon Tatham via cfe-commits

https://github.com/statham-arm created 
https://github.com/llvm/llvm-project/pull/141562

In 'asm goto' statements ('callbr' in LLVM IR), you can specify one or more 
labels / basic blocks in the containing function which the assembly code might 
jump to. If you're also compiling with branch target enforcement via BTI, then 
previously listing a basic block as a possible jump destination of an asm goto 
would cause a BTI instruction to be placed at the start of the block, in case 
the assembly code used an _indirect_ branch instruction (i.e. to a destination 
address read from a register) to jump to that location. Now it doesn't do that 
any more: branches to destination labels from the assembly code are assumed to 
be direct branches (to a relative offset encoded in the instruction), which 
don't require a BTI at their destination.

This change was proposed in https://discourse.llvm.org/t/85845 and there seemed 
to be no disagreement. The rationale is:

1. it brings clang's handling of asm goto in Arm and AArch64 in line with 
gcc's, which didn't generate BTIs at the target labels in the first place.

2. it improves performance in the Linux kernel, which uses a lot of 'asm goto' 
in which the assembly language just contains a NOP, and the label's address is 
saved elsewhere to let the kernel self-modify at run time to swap between the 
original NOP and a direct branch to the label. This allows hot code paths to be 
instrumented for debugging, at only the cost of a NOP when the instrumentation 
is turned off, instead of the larger cost of an indirect branch. In this 
situation a BTI is unnecessary (if the branch happens it's direct), and since 
the code paths are hot, also a noticeable performance hit.

Implementation:

`SelectionDAGBuilder::visitCallBr` is the place where 'asm goto' target labels 
are handled. It calls `setIsInlineAsmBrIndirectTarget()` on each target 
`MachineBasicBlock`. Previously it also called `setMachineBlockAddressTaken()`, 
which made `hasAddressTaken()` return true, which caused a BTI to be added in 
the Arm backends.

Now `visitCallBr` doesn't call `setMachineBlockAddressTaken()` any more on asm 
goto targets, but `hasAddressTaken()` also checks the flag set by 
`setIsInlineAsmBrIndirectTarget()`. So call sites that were using 
`hasAddressTaken()` don't need to be modified. But the Arm backends don't call 
`hasAddressTaken()` any more: instead they test two more specific query 
functions that cover all the reasons `hasAddressTaken()` might have returned 
true _except_ being an asm goto target.

Testing:

The new test `AArch64/callbr-asm-label-bti.ll` is testing the actual change, 
where it expects not to see a `bti` instruction after `[[LABEL]]`. The rest of 
the test changes are all churn, due to the flags on basic blocks changing. 
Actual output code hasn't changed in any of the existing tests, only comments 
and diagnostics.

Further work:

`RISCVIndirectBranchTracking.cpp` and `X86IndirectBranchTracking.cpp` also call 
`hasAddressTaken()` in a way that might benefit from using the same more 
specific check I've put in `ARMBranchTargets.cpp` and 
`AArch64BranchTargets.cpp`. But I'm not sure of that, so in this commit I've 
only changed the Arm backends, and left those alone.

>From 1be326ffb4350f2818068da1aa4bde2adae41d70 Mon Sep 17 00:00:00 2001
From: Simon Tatham 
Date: Wed, 14 May 2025 17:02:21 +0100
Subject: [PATCH] [ARM,AArch64] Don't put BTI at asm goto branch targets

In 'asm goto' statements ('callbr' in LLVM IR), you can specify one or
more labels / basic blocks in the containing function which the
assembly code might jump to. If you're also compiling with branch
target enforcement via BTI, then previously listing a basic block as a
possible jump destination of an asm goto would cause a BTI instruction
to be placed at the start of the block, in case the assembly code used
an _indirect_ branch instruction (i.e. to a destination address read
from a register) to jump to that location. Now it doesn't do that any
more: branches to destination labels from the assembly code are
assumed to be direct branches (to a relative offset encoded in the
instruction), which don't require a BTI at their destination.

This change was proposed in https://discourse.llvm.org/t/85845 and
there seemed to be no disagreement. The rationale is:

1. it brings clang's handling of asm goto in Arm and AArch64 in line
with gcc's, which didn't generate BTIs at the target labels in the
first place.

2. it improves performance in the Linux kernel, which uses a lot of
'asm goto' in which the assembly language just contains a NOP, and the
label's address is saved elsewhere to let the kernel self-modify at
run time to swap between the original NOP and a direct branch to the
label. This allows hot code paths to be instrumented for debugging, at
only the cost of a NOP when the instrumentation is turned off, instead
of the larger cost of an indirect branch. In this situation a BTI is
unnecessary (if the bra

[clang] [llvm] [ARM, AArch64] Don't put BTI at asm goto branch targets (PR #141562)

2025-05-27 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-powerpc

@llvm/pr-subscribers-backend-aarch64

Author: Simon Tatham (statham-arm)


Changes

In 'asm goto' statements ('callbr' in LLVM IR), you can specify one or more 
labels / basic blocks in the containing function which the assembly code might 
jump to. If you're also compiling with branch target enforcement via BTI, then 
previously listing a basic block as a possible jump destination of an asm goto 
would cause a BTI instruction to be placed at the start of the block, in case 
the assembly code used an _indirect_ branch instruction (i.e. to a destination 
address read from a register) to jump to that location. Now it doesn't do that 
any more: branches to destination labels from the assembly code are assumed to 
be direct branches (to a relative offset encoded in the instruction), which 
don't require a BTI at their destination.

This change was proposed in https://discourse.llvm.org/t/85845 and there seemed 
to be no disagreement. The rationale is:

1. it brings clang's handling of asm goto in Arm and AArch64 in line with 
gcc's, which didn't generate BTIs at the target labels in the first place.

2. it improves performance in the Linux kernel, which uses a lot of 'asm goto' 
in which the assembly language just contains a NOP, and the label's address is 
saved elsewhere to let the kernel self-modify at run time to swap between the 
original NOP and a direct branch to the label. This allows hot code paths to be 
instrumented for debugging, at only the cost of a NOP when the instrumentation 
is turned off, instead of the larger cost of an indirect branch. In this 
situation a BTI is unnecessary (if the branch happens it's direct), and since 
the code paths are hot, also a noticeable performance hit.

Implementation:

`SelectionDAGBuilder::visitCallBr` is the place where 'asm goto' target labels 
are handled. It calls `setIsInlineAsmBrIndirectTarget()` on each target 
`MachineBasicBlock`. Previously it also called `setMachineBlockAddressTaken()`, 
which made `hasAddressTaken()` return true, which caused a BTI to be added in 
the Arm backends.

Now `visitCallBr` doesn't call `setMachineBlockAddressTaken()` any more on asm 
goto targets, but `hasAddressTaken()` also checks the flag set by 
`setIsInlineAsmBrIndirectTarget()`. So call sites that were using 
`hasAddressTaken()` don't need to be modified. But the Arm backends don't call 
`hasAddressTaken()` any more: instead they test two more specific query 
functions that cover all the reasons `hasAddressTaken()` might have returned 
true _except_ being an asm goto target.

Testing:

The new test `AArch64/callbr-asm-label-bti.ll` is testing the actual change, 
where it expects not to see a `bti` instruction after `[[LABEL]]`. The rest of 
the test changes are all churn, due to the flags on basic blocks changing. 
Actual output code hasn't changed in any of the existing tests, only comments 
and diagnostics.

Further work:

`RISCVIndirectBranchTracking.cpp` and `X86IndirectBranchTracking.cpp` also call 
`hasAddressTaken()` in a way that might benefit from using the same more 
specific check I've put in `ARMBranchTargets.cpp` and 
`AArch64BranchTargets.cpp`. But I'm not sure of that, so in this commit I've 
only changed the Arm backends, and left those alone.

---

Patch is 70.55 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/141562.diff


28 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+11) 
- (modified) llvm/docs/LangRef.rst (+8) 
- (modified) llvm/include/llvm/CodeGen/MachineBasicBlock.h (+16-1) 
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+2) 
- (modified) llvm/lib/CodeGen/BasicBlockPathCloning.cpp (+9-2) 
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+4-1) 
- (modified) llvm/lib/Target/AArch64/AArch64BranchTargets.cpp (+2-1) 
- (modified) llvm/lib/Target/ARM/ARMBranchTargets.cpp (+2-1) 
- (added) llvm/test/CodeGen/AArch64/callbr-asm-label-bti.ll (+40) 
- (modified) llvm/test/CodeGen/AArch64/callbr-asm-label.ll (+3-3) 
- (modified) llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll 
(+15-15) 
- (modified) llvm/test/CodeGen/PowerPC/callbr-asm-outputs-indirect-isel.ll 
(+1-1) 
- (modified) llvm/test/CodeGen/PowerPC/ppc64-inlineasm-clobber.ll (+4-4) 
- (modified) llvm/test/CodeGen/RISCV/inline-asm-mem-constraint.ll (+60-60) 
- (modified) llvm/test/CodeGen/X86/basic-block-sections-cloning-invalid.ll 
(+1-1) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-blockplacement.ll (+1-1) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-branch-folding.ll (+1-1) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-destinations.ll (+2-2) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-label-addr.ll (+1-1) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll 
(+3-3) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll (+11-11) 
- (modified) llvm/test/CodeGen/X86/callbr-asm-outputs-p

  1   2   3   4   5   >