[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)

2024-12-09 Thread Haohai Wen via cfe-commits

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

LGTM for -Xlinker.

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


[clang] [lld] [lldb] [llvm] Rework the `Option` library to reduce dynamic relocations (PR #119198)

2024-12-09 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-binary-utilities
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-clang

Author: Chandler Carruth (chandlerc)


Changes

Apologies for the large change, I looked for ways to break this up and all of 
the ones I saw added real complexity. This change focuses on the option's 
prefixed names and the array of prefixes. These are present in every option and 
the dominant source of dynamic relocations for PIE or PIC users of LLVM and 
Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which 
has a huge number of options.

This PR addresses this by building a string table and a prefixes table that can 
be referenced with indices rather than pointers that require dynamic 
relocations. This removes almost 7k dynmaic relocations from the `clang` 
binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For 
busy-boxing use cases where many different option tables are linked into the 
same binary, the savings add up a bit more.

The string table is a straightforward mechanism, but the prefixes required some 
subtlety. They are encoded in a Pascal-string fashion with a size followed by a 
sequence of offsets. This works relatively well for the small realistic 
prefixes arrays in use.

Lots of code has to change in order to land this though: both all the option 
library code has to be updated to use the string table and prefixes table, and 
all the users of the options library have to be updated to correctly 
instantiate the objects.

Note, I've successfully built and tested `check-{llvm,clang,lld}` with this 
change, but had to make edits beyond that. I've ended up needing to modify LLDB 
to reflect these changes, but have not been able to build and test it fully. 
The relevant binaries build, but `check-lldb` currently hits unrelated errors 
for me blocking any progress in checking those changes.

---

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


51 Files Affected:

- (modified) clang/lib/Driver/DriverOptions.cpp (+11-12) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+43-20) 
- (modified) clang/tools/clang-installapi/Options.cpp (+12-30) 
- (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+8-6) 
- (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+8-6) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+8-6) 
- (modified) clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp (+8-6) 
- (modified) lld/COFF/DriverUtils.cpp (+8-6) 
- (modified) lld/ELF/DriverUtils.cpp (+8-6) 
- (modified) lld/MachO/DriverUtils.cpp (+8-6) 
- (modified) lld/MinGW/Driver.cpp (+9-7) 
- (modified) lld/wasm/Driver.cpp (+8-7) 
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+6-2) 
- (modified) lldb/tools/driver/Driver.cpp (+8-6) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+9-6) 
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+8-6) 
- (modified) llvm/include/llvm/Option/OptTable.h (+100-44) 
- (modified) llvm/include/llvm/Option/Option.h (+8-6) 
- (modified) llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp (+11-13) 
- (modified) llvm/lib/Option/OptTable.cpp (+91-64) 
- (modified) llvm/lib/Option/Option.cpp (+6-3) 
- (modified) llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp (+9-6) 
- (modified) llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp (+9-6) 
- (modified) llvm/tools/dsymutil/dsymutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-cgdata/llvm-cgdata.cpp (+8-6) 
- (modified) llvm/tools/llvm-cvtres/llvm-cvtres.cpp (+9-6) 
- (modified) llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp (+8-6) 
- (modified) llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp (+8-6) 
- (modified) llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp (+8-6) 
- (modified) llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-dwp/llvm-dwp.cpp (+8-6) 
- (modified) llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-ifs/llvm-ifs.cpp (+8-6) 
- (modified) llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp (+8-6) 
- (modified) llvm/tools/llvm-lipo/llvm-lipo.cpp (+9-6) 
- (modified) llvm/tools/llvm-ml/llvm-ml.cpp (+9-6) 
- (modified) llvm/tools/llvm-mt/llvm-mt.cpp (+9-6) 
- (modified) llvm/tools/llvm-nm/llvm-nm.cpp (+8-6) 
- (modified) llvm/tools/llvm-objcopy/ObjcopyOptions.cpp (+35-24) 
- (modified) llvm/tools/llvm-objdump/llvm-objdump.cpp (+22-17) 
- (modified) llvm/tools/llvm-rc/llvm-rc.cpp (+20-12) 
- (modified) llvm/tools/llvm-readobj/llvm-readobj.cpp (+8-6) 
- (modified) llvm/tools/llvm-readtapi/llvm-readtapi.cpp (+8-6) 
- (modified) llvm/tools/llvm-size/llvm-size.cpp (+10-6) 
- (modified) llvm/tools/llvm-strings/llvm-strings.cpp (+8-6) 
- (modified) llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp (+8-6) 
- (modified) llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp (+8-6) 
- (modified) llvm/tools/sancov/sancov.cpp (+8-6) 
- (modified) llvm/unittests/Option/OptionMarshall

[clang] [lld] [lldb] [llvm] Rework the `Option` library to reduce dynamic relocations (PR #119198)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Chandler Carruth (chandlerc)


Changes

Apologies for the large change, I looked for ways to break this up and all of 
the ones I saw added real complexity. This change focuses on the option's 
prefixed names and the array of prefixes. These are present in every option and 
the dominant source of dynamic relocations for PIE or PIC users of LLVM and 
Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which 
has a huge number of options.

This PR addresses this by building a string table and a prefixes table that can 
be referenced with indices rather than pointers that require dynamic 
relocations. This removes almost 7k dynmaic relocations from the `clang` 
binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For 
busy-boxing use cases where many different option tables are linked into the 
same binary, the savings add up a bit more.

The string table is a straightforward mechanism, but the prefixes required some 
subtlety. They are encoded in a Pascal-string fashion with a size followed by a 
sequence of offsets. This works relatively well for the small realistic 
prefixes arrays in use.

Lots of code has to change in order to land this though: both all the option 
library code has to be updated to use the string table and prefixes table, and 
all the users of the options library have to be updated to correctly 
instantiate the objects.

Note, I've successfully built and tested `check-{llvm,clang,lld}` with this 
change, but had to make edits beyond that. I've ended up needing to modify LLDB 
to reflect these changes, but have not been able to build and test it fully. 
The relevant binaries build, but `check-lldb` currently hits unrelated errors 
for me blocking any progress in checking those changes.

---

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


51 Files Affected:

- (modified) clang/lib/Driver/DriverOptions.cpp (+11-12) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+43-20) 
- (modified) clang/tools/clang-installapi/Options.cpp (+12-30) 
- (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+8-6) 
- (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+8-6) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+8-6) 
- (modified) clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp (+8-6) 
- (modified) lld/COFF/DriverUtils.cpp (+8-6) 
- (modified) lld/ELF/DriverUtils.cpp (+8-6) 
- (modified) lld/MachO/DriverUtils.cpp (+8-6) 
- (modified) lld/MinGW/Driver.cpp (+9-7) 
- (modified) lld/wasm/Driver.cpp (+8-7) 
- (modified) lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (+6-2) 
- (modified) lldb/tools/driver/Driver.cpp (+8-6) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+9-6) 
- (modified) lldb/tools/lldb-server/lldb-gdbserver.cpp (+8-6) 
- (modified) llvm/include/llvm/Option/OptTable.h (+100-44) 
- (modified) llvm/include/llvm/Option/Option.h (+8-6) 
- (modified) llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp (+11-13) 
- (modified) llvm/lib/Option/OptTable.cpp (+91-64) 
- (modified) llvm/lib/Option/Option.cpp (+6-3) 
- (modified) llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp (+9-6) 
- (modified) llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp (+9-6) 
- (modified) llvm/tools/dsymutil/dsymutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-cgdata/llvm-cgdata.cpp (+8-6) 
- (modified) llvm/tools/llvm-cvtres/llvm-cvtres.cpp (+9-6) 
- (modified) llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp (+8-6) 
- (modified) llvm/tools/llvm-debuginfod-find/llvm-debuginfod-find.cpp (+8-6) 
- (modified) llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp (+8-6) 
- (modified) llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-dwp/llvm-dwp.cpp (+8-6) 
- (modified) llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp (+8-6) 
- (modified) llvm/tools/llvm-ifs/llvm-ifs.cpp (+8-6) 
- (modified) llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp (+8-6) 
- (modified) llvm/tools/llvm-lipo/llvm-lipo.cpp (+9-6) 
- (modified) llvm/tools/llvm-ml/llvm-ml.cpp (+9-6) 
- (modified) llvm/tools/llvm-mt/llvm-mt.cpp (+9-6) 
- (modified) llvm/tools/llvm-nm/llvm-nm.cpp (+8-6) 
- (modified) llvm/tools/llvm-objcopy/ObjcopyOptions.cpp (+35-24) 
- (modified) llvm/tools/llvm-objdump/llvm-objdump.cpp (+22-17) 
- (modified) llvm/tools/llvm-rc/llvm-rc.cpp (+20-12) 
- (modified) llvm/tools/llvm-readobj/llvm-readobj.cpp (+8-6) 
- (modified) llvm/tools/llvm-readtapi/llvm-readtapi.cpp (+8-6) 
- (modified) llvm/tools/llvm-size/llvm-size.cpp (+10-6) 
- (modified) llvm/tools/llvm-strings/llvm-strings.cpp (+8-6) 
- (modified) llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp (+8-6) 
- (modified) llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp (+8-6) 
- (modified) llvm/tools/sancov/sancov.cpp (+8-6) 
- (modified) llvm/unittests/Option/OptionMarshallingTest.cpp (+16-8) 
- (modified) llvm/unittests/Option/Optio

[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)

2024-12-09 Thread Haohai Wen via cfe-commits

HaohaiWen wrote:

@MaskRay, may need to merge 
https://github.com/llvm/llvm-project/blob/main/clang/test/Driver/fprofile-sample-use.c
 to clang/test/Driver/unknown-arg-drivermodes.test

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


[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 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 f9d6d46a8edfac7421a4b010eb216f793669bef1 
85f1d54459125568bfbe2088827040c3b05a7804 --extensions cpp -- 
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index f7a6807a14..a9faba0d84 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -1907,8 +1907,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   // Write out the diagnostic groups.
   for (const Record *G : DiagGroups) {
 bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup);
-auto &GroupInfo =
-DiagsInGroup[G->getValueAsString("GroupName")];
+auto &GroupInfo = DiagsInGroup[G->getValueAsString("GroupName")];
 bool IsSynonym = GroupInfo.DiagsInGroup.empty() &&
  GroupInfo.SubGroups.size() == 1;
 

``




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


[clang] 99f6ca9 - [AArch64] Implement intrinsics for SME FP8 FMOPA (#118115)

2024-12-09 Thread via cfe-commits

Author: SpencerAbson
Date: 2024-12-09T11:13:08Z
New Revision: 99f6ca9b7bb7d794db9ac8ff519b4e60766f6a4b

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

LOG: [AArch64] Implement intrinsics for SME FP8 FMOPA (#118115)

This patch implements the following intrinsics:

8-bit floating-point sum of outer products and accumulate.
``` c
  // Only if __ARM_FEATURE_SME_F8F16 != 0
void svmopa_za16[_mf8]_m_fpm(uint64_t tile, svbool_t pn, svbool_t pm,
 svmfloat8_t zn, svmfloat8_t zm, fpm_t fpm)
 __arm_streaming __arm_inout("za");

  // Only if __ARM_FEATURE_SME_F8F32 != 0
void svmopa_za32[_mf8]_m_fpm(uint64_t tile, svbool_t pn, svbool_t pm,
 svmfloat8_t zn, svmfloat8_t zm, fpm_t fpm)
 __arm_streaming __arm_inout("za");
```

In accordance with: https://github.com/ARM-software/acle/pull/323/

Co-authored-by: Momchil Velikov momchil.veli...@arm.com
Co-authored-by: Marian Lukac marian.lu...@arm.com

Added: 
clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_fmopa.c
clang/test/Sema/aarch64-fp8-intrinsics/acle_sme2_fp8_imm.c
clang/test/Sema/aarch64-fp8-intrinsics/acle_sme2_fp8_mopa.c
llvm/test/CodeGen/AArch64/sme2-fp8-intrinsics-fmopa.ll

Modified: 
clang/include/clang/Basic/arm_sme.td
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
llvm/lib/Target/AArch64/SMEInstrFormats.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 0f689e82bdb742..71b2c7cdd04f93 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -824,4 +824,14 @@ let SMETargetGuard = "sme-lutv2" in {
   def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
 }
 
+let SMETargetGuard = "sme-f8f32" in {
+  def SVMOPA_FP8_ZA32 : Inst<"svmopa_za32[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za32",
+ [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_3>]>;
+}
+
+let SMETargetGuard = "sme-f8f16" in {
+  def SVMOPA_FP8_ZA16 : Inst<"svmopa_za16[_mf8]_m_fpm", "viPPdd>", "m", 
MergeNone, "aarch64_sme_fp8_fmopa_za16",
+ [IsStreaming, IsInOutZA, SetsFPMR, 
IsOverloadNone], [ImmCheck<0, ImmCheck0_1>]>;
+}
+
 } // let SVETargetGuard = InvalidMode

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 41c632ead6aa3c..c2e983eebebc10 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10201,6 +10201,8 @@ CodeGenFunction::getSVEType(const SVETypeFlags 
&TypeFlags) {
   case SVETypeFlags::EltTyInt64:
 return llvm::ScalableVectorType::get(Builder.getInt64Ty(), 2);
 
+  case SVETypeFlags::EltTyMFloat8:
+return llvm::ScalableVectorType::get(Builder.getInt8Ty(), 16);
   case SVETypeFlags::EltTyFloat16:
 return llvm::ScalableVectorType::get(Builder.getHalfTy(), 8);
   case SVETypeFlags::EltTyBFloat16:
@@ -11255,6 +11257,10 @@ Value 
*CodeGenFunction::EmitAArch64SMEBuiltinExpr(unsigned BuiltinID,
BuiltinID == SME::BI__builtin_sme_svstr_za)
 return EmitSMELdrStr(TypeFlags, Ops, Builtin->LLVMIntrinsic);
 
+  // Emit set FPMR for intrinsics that require it
+  if (TypeFlags.setsFPMR())
+Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_set_fpmr),
+   Ops.pop_back_val());
   // Handle builtins which require their multi-vector operands to be swapped
   swapCommutativeSMEOperands(BuiltinID, Ops);
 

diff  --git a/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_fmopa.c 
b/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_fmopa.c
new file mode 100644
index 00..95d6383ab30efe
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sme2_fp8_fmopa.c
@@ -0,0 +1,55 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme-f8f16 -target-feature +sme-f8f32 -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme-f8f16 -target-feature +sme-f8f32 -disable-O0-optnone 
-Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -passes=mem2reg,tailcallelim | 
FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-ta

[clang] [llvm] [AArch64] Implement intrinsics for SME FP8 FMOPA (PR #118115)

2024-12-09 Thread via cfe-commits

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


[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-arm64-windows-msvc` 
running on `linaro-armv8-windows-msvc-04` while building `clang` at step 5 
"ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang-Unit :: 
DirectoryWatcher/./DirectoryWatcherTests.exe/5/8' FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\unittests\DirectoryWatcher\.\DirectoryWatcherTests.exe-Clang-Unit-4944-5-8.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=8 GTEST_SHARD_INDEX=5 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\unittests\DirectoryWatcher\.\DirectoryWatcherTests.exe
--

Script:
--
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\unittests\DirectoryWatcher\.\DirectoryWatcherTests.exe
 --gtest_filter=DirectoryWatcherTest.DeleteWatchedDir
--
C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp(259):
 error: Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == 
std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp(262):
 error: Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true


C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:259
Value of: WaitForExpectedStateResult.wait_for(EventualResultTimeout) == 
std::future_status::ready
  Actual: false
Expected: true
The expected result state wasn't reached before the time-out.

C:/Users/tcwg/llvm-worker/clang-arm64-windows-msvc/llvm/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp:262
Value of: TestConsumer.result().has_value()
  Actual: false
Expected: true






```



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


[clang] [llvm] Add processor aliases back to -print-supported-cpus and -mcpu=help (PR #118581)

2024-12-09 Thread Jonathan Thackray via cfe-commits

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

LGTM

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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread Timm Baeder via cfe-commits

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


[clang] 00b50c9 - [clang][bytecode] Handle __builtin_wcslen (#119187)

2024-12-09 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-12-09T12:34:25+01:00
New Revision: 00b50c917bf5e5abaded4f314b767b086069d1ee

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

LOG: [clang][bytecode] Handle __builtin_wcslen (#119187)

Handle different char widths in builtin_strlen.

Added: 


Modified: 
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 24b630d0455e14..2469648d68edb1 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -243,7 +243,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
   unsigned ID = Func->getBuiltinID();
   const Pointer &StrPtr = getParam(Frame, 0);
 
-  if (ID == Builtin::BIstrlen)
+  if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
   if (!CheckArray(S, OpPC, StrPtr))
@@ -256,6 +256,12 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
+
+  if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
+const ASTContext &AC = S.getASTContext();
+assert(ElemSize == AC.getTypeSizeInChars(AC.getWCharType()).getQuantity());
+  }
 
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
@@ -264,7 +270,20 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;
+switch (ElemSize) {
+case 1:
+  Val = ElemPtr.deref();
+  break;
+case 2:
+  Val = ElemPtr.deref();
+  break;
+case 4:
+  Val = ElemPtr.deref();
+  break;
+default:
+  llvm_unreachable("Unsupported char size");
+}
 if (Val == 0)
   break;
   }
@@ -1859,6 +1878,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strlen:
   case Builtin::BIstrlen:
+  case Builtin::BI__builtin_wcslen:
+  case Builtin::BIwcslen:
 if (!interp__builtin_strlen(S, OpPC, Frame, F, Call))
   return false;
 break;

diff  --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e2121a54e15768..4c21496d3972c9 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -15,6 +15,10 @@
 #error "huh?"
 #endif
 
+extern "C" {
+  typedef decltype(sizeof(int)) size_t;
+  extern size_t wcslen(const wchar_t *p);
+}
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
   constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
   constexpr int bad = __builtin_strlen(d); // both-error {{constant 
expression}} \
// both-note {{one-past-the-end}}
+
+  constexpr int wn = __builtin_wcslen(L"hello");
+  static_assert(wn == 5);
+  constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
+   // both-note {{non-constexpr function 
'wcslen' cannot be used in a constant expression}}
+
+  int arr[3]; // both-note {{here}}
+  int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
 }
 
 namespace nan {



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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits

RIscRIpt wrote:

> allow [[msvc::constexpr]] usage outside the std namespace

By the way, to be precisely correct, these changes actually allow usage of 
"placement new" in `[[msvc::constexpr]]` context outside of the std namespace.



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


[clang] [lld] [lldb] [llvm] Rework the `Option` library to reduce dynamic relocations (PR #119198)

2024-12-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> The relevant binaries build, but check-lldb currently hits unrelated errors 
> for me blocking any progress in checking those changes.

`ninja check-lldb` passes on AArch64 Linux, and given the changes, it's 
unlikely to fail on other platforms.

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


[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-09 Thread Alex Voicu via cfe-commits


@@ -105,6 +105,11 @@ void AMDGPUABIInfo::computeInfo(CGFunctionInfo &FI) const {
   if (!getCXXABI().classifyReturnType(FI))
 FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
 
+  // srets / indirect returns are unconditionally in the alloca AS.
+  if (FI.getReturnInfo().isIndirect())
+FI.getReturnInfo().setIndirectAddrSpace(
+getDataLayout().getAllocaAddrSpace());

AlexVlx wrote:

@rjmccall are you OK with the current solution (@arsenm  appears to be)?

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


[clang] [lld] [lldb] [llvm] Rework the `Option` library to reduce dynamic relocations (PR #119198)

2024-12-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

If you look for:
```
FAILED: 
tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CompileCommands.cpp.o
 
```
In the build log that's the failure reason.

All of the tests that reported JSON passed, that's why you have green test 
reports but failed builds. I will see what I can do about that.

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/119153

>From f19ea82bbe5c00af6a6e261f989c9a89ef4c78ca Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 9 Dec 2024 01:46:46 +0200
Subject: [PATCH 1/2] [Clang] allow [[msvc::constexpr]] usage outside the std
 namespace

---
 clang/docs/ReleaseNotes.rst |  2 ++
 clang/lib/AST/ExprConstant.cpp  |  4 +++-
 clang/test/AST/ms-constexpr-new.cpp | 13 +
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/ms-constexpr-new.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3f58e64cf0ccbc..71666e26146e92 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -525,6 +525,8 @@ Attribute Changes in Clang
 
 - The ``target_version`` attribute is now only supported for AArch64 and 
RISC-V architectures.
 
+- Clang now permits ``[[msvc::constexpr]]`` usage outside of the std 
namespace. (#GH74924)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6b5b95aee35522..9dbb350be59091 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10172,7 +10172,9 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const 
CXXNewExpr *E) {
   return false;
 IsNothrow = true;
   } else if (OperatorNew->isReservedGlobalPlacementOperator()) {
-if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26) {
+if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26 ||
+(Info.CurrentCall->CanEvalMSConstexpr &&
+ OperatorNew->hasAttr())) {
   if (!EvaluatePointer(E->getPlacementArg(0), Result, Info))
 return false;
   if (Result.Designator.Invalid)
diff --git a/clang/test/AST/ms-constexpr-new.cpp 
b/clang/test/AST/ms-constexpr-new.cpp
new file mode 100644
index 00..4b534cf0207644
--- /dev/null
+++ b/clang/test/AST/ms-constexpr-new.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -ast-dump %s | FileCheck %s
+
+// CHECK: used operator new
+// CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} 
+[[nodiscard]] [[msvc::constexpr]] inline void* __cdecl operator 
new(decltype(sizeof(void*)), void* p) noexcept { return p; }
+
+// CHECK: used constexpr construct_at
+// CHECK: AttributedStmt 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} 
+constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new 
(p) int(v); }
+constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 
42; }
+static_assert(check_construct_at());

>From 6ec3ea6ec803efddb095ac5b30d6c82ce2fb86a0 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 9 Dec 2024 13:48:23 +0200
Subject: [PATCH 2/2] add tests to cover unsupported cases

---
 clang/test/SemaCXX/ms-constexpr-new.cpp | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/test/SemaCXX/ms-constexpr-new.cpp 
b/clang/test/SemaCXX/ms-constexpr-new.cpp
index 30567740b2ecbb..096014be803e77 100644
--- a/clang/test/SemaCXX/ms-constexpr-new.cpp
+++ b/clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -12,5 +12,12 @@ namespace std {
   }
 }
 
-constexpr bool check_construct_at() { int x; return *std::construct_at(&x, 42) 
== 42; }
-static_assert(check_construct_at());
+constexpr bool check_std_construct_at() { int x; return *std::construct_at(&x, 
42) == 42; }
+static_assert(check_std_construct_at());
+
+constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new 
(p) int(v); } // unsupported-error {{constexpr function never produces a 
constant expression}} \
+   
 // unsupported-warning {{unknown attribute 'constexpr' ignored}} \
+   
 // unsupported-note 2{{this placement new expression is not 
supported in constant expressions before C++2c}}
+constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 
42; }  // unsupported-note {{in call to 'construct_at(&x, 42)'}}
+static_assert(check_construct_at());   
 // unsupported-error {{static assertion expression is not an 
integral constant expression}}\
+   
 // unsupported-note {{in call to 'check_construct_at()'}}

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


[clang] [analyzer] Handle [[assume(cond)]] as __builtin_assume(cond) (PR #116462)

2024-12-09 Thread Vinay Deshmukh via cfe-commits

https://github.com/vinay-deshmukh updated 
https://github.com/llvm/llvm-project/pull/116462

>From daddb9e13db6ca8373dc7298d17aa36a03014aeb Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <32487576+vinay-deshm...@users.noreply.github.com>
Date: Fri, 15 Nov 2024 07:37:17 -0500
Subject: [PATCH 1/9] [analyzer] Handle `[[assume(cond)]]` as
 `__builtin_assume(cond)`

Resolves #100762
---
 .../Core/PathSensitive/ExprEngine.h   |  4 ++
 clang/lib/Analysis/CFG.cpp| 43 +++
 clang/lib/StaticAnalyzer/Core/ExprEngine.cpp  |  8 +++-
 .../lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | 27 
 clang/test/Analysis/out-of-bounds-new.cpp | 16 +++
 5 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index 8c7493e27fcaa6..078a1d840d0516 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -498,6 +498,10 @@ class ExprEngine {
   void VisitInitListExpr(const InitListExpr *E, ExplodedNode *Pred,
  ExplodedNodeSet &Dst);
 
+  /// VisitAttributedStmt - Transfer function logic for AttributedStmt
+  void VisitAttributedStmt(const AttributedStmt *A, ExplodedNode *Pred,
+   ExplodedNodeSet &Dst);
+
   /// VisitLogicalExpr - Transfer function logic for '&&', '||'
   void VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
 ExplodedNodeSet &Dst);
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index f678ac6f2ff36a..fab10f51cf5cfc 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -456,6 +456,36 @@ reverse_children::reverse_children(Stmt *S) {
 IE->getNumInits());
   return;
 }
+case Stmt::AttributedStmtClass: {
+  AttributedStmt *attrStmt = cast(S);
+  assert(attrStmt);
+
+  {
+// for an attributed stmt, the "children()" returns only the NullStmt
+// (;) but semantically the "children" are supposed to be the
+// expressions _within_ i.e. the two square brackets i.e. [[ HERE ]]
+// so we add the subexpressions first, _then_ add the "children"
+
+for (const Attr *attr : attrStmt->getAttrs()) {
+
+  // i.e. one `assume()`
+  CXXAssumeAttr const *assumeAttr = 
llvm::dyn_cast(attr);
+  if (!assumeAttr) {
+continue;
+  }
+  // Only handles [[ assume() ]] right now
+  Expr *assumption = assumeAttr->getAssumption();
+  childrenBuf.push_back(assumption);
+}
+
+// children() for an AttributedStmt is NullStmt(;)
+llvm::append_range(childrenBuf, attrStmt->children());
+
+// This needs to be done *after* childrenBuf has been populated.
+children = childrenBuf;
+  }
+  return;
+}
 default:
   break;
   }
@@ -2475,6 +2505,14 @@ static bool isFallthroughStatement(const AttributedStmt 
*A) {
   return isFallthrough;
 }
 
+static bool isCXXAssumeAttr(const AttributedStmt *A) {
+  bool hasAssumeAttr = hasSpecificAttr(A->getAttrs());
+
+  assert((!hasAssumeAttr || isa(A->getSubStmt())) &&
+ "expected [[assume]] not to have children");
+  return hasAssumeAttr;
+}
+
 CFGBlock *CFGBuilder::VisitAttributedStmt(AttributedStmt *A,
   AddStmtChoice asc) {
   // AttributedStmts for [[likely]] can have arbitrary statements as children,
@@ -2490,6 +2528,11 @@ CFGBlock *CFGBuilder::VisitAttributedStmt(AttributedStmt 
*A,
 appendStmt(Block, A);
   }
 
+  if (isCXXAssumeAttr(A) && asc.alwaysAdd(*this, A)) {
+autoCreateBlock();
+appendStmt(Block, A);
+  }
+
   return VisitChildren(A);
 }
 
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 22eab9f66418d4..cbc83f1dbda145 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1946,7 +1946,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 // to be explicitly evaluated.
 case Stmt::PredefinedExprClass:
 case Stmt::AddrLabelExprClass:
-case Stmt::AttributedStmtClass:
 case Stmt::IntegerLiteralClass:
 case Stmt::FixedPointLiteralClass:
 case Stmt::CharacterLiteralClass:
@@ -1977,6 +1976,13 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
   break;
 }
 
+case Stmt::AttributedStmtClass: {
+  Bldr.takeNodes(Pred);
+  VisitAttributedStmt(cast(S), Pred, Dst);
+  Bldr.addNodes(Dst);
+  break;
+}
+
 case Stmt::CXXDefaultArgExprClass:
 case Stmt::CXXDefaultInitExprClass: {
   Bldr.takeNodes(Pred);
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index f

[clang] [Clang] allow usage of placement new operator in [[msvc::constexpr]] context outside of the std namespace (PR #119153)

2024-12-09 Thread Oleksandr T. via cfe-commits

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


[clang] [Clang] allow usage of placement new operator in [[msvc::constexpr]] context outside of the std namespace (PR #119153)

2024-12-09 Thread Oleksandr T. via cfe-commits




a-tarasyuk wrote:

@RIscRIpt I've added tests.

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


[clang] [Clang] allow usage of placement new operator in [[msvc::constexpr]] context outside of the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits

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

LGTM

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


[clang] [clang] Fix cast for injected types in case name lookup for dependent bases (PR #119024)

2024-12-09 Thread Vladislav Belov via cfe-commits

vbe-sc wrote:

@glandium, this is the fix for your example. Please, feel free to contact if 
you have any more troubles with this patch 

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


[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-12-09 Thread Fraser Cormack via cfe-commits


@@ -0,0 +1,21 @@
+#ifndef __CLC_INTEGER_CLC_CLZ_H__
+#define __CLC_INTEGER_CLC_CLZ_H__
+
+#if defined(CLC_CLSPV) || defined(CLC_SPIRV)
+// clspv and spir-v targets provide their own OpenCL-compatible clz
+#define __clc_clz clz

frasercrmck wrote:

> > In this context of this PR, what are you proposing? That no such 
> > redirections should take place, or just that ones that map to intrinsics 
> > specifically should not be redirected?
> 
> I mean __clc_ functions should not be implemented by directly calling the 
> opencl public name, that's backwards. Targets should be implementing __clc 
> override implementations, not directly providing their own opencl public 
> entrypoints. It sounds like that's the end goal, not sure how this step gets 
> you there though. I won't hold this up if it's in service of reaching that end

Yep, I think we agree on the direction of this aspect of libclc. Regardless, 
this is how it's currently done for the SPIR-V targets. I would prefer if 
SPIR-V targets built a fully complete OpenCL library, and that they would 
selectively link which OpenCL builtins they want from libclc and which they 
want to override or optimize themselves.

Personally, I'm hesitant to make too many changes that affect the downstream 
SPIR-V targets at the same time as refactoring the library in such an intrusive 
way. This macro header redirection is a convenient way of keeping things the 
same for them, whilst clearing away the noise that might obscure real codegen 
issues.

As mentioned above, it sounds like we can improve the SPIR-V situation for most 
`__clc` functions. In general I'd prefer to loop back to that sort of thing 
once the refactoring is complete. Then we can test (and commit, revert, 
whatever) those changes in isolation. We're not backing ourselves into a corner 
with the macro redirections.

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


[clang] [llvm] [AArch64] Implement FP8 SVE Intrinsics for narrowing conversions (PR #118124)

2024-12-09 Thread Momchil Velikov via cfe-commits


@@ -10753,10 +10758,45 @@ class sve2_fp8_down_cvt_single opc, string 
mnemonic,
   let Inst{5} = 0b0;
   let Inst{4-0} = Zd;
   let Uses = [FPMR, FPCR];
+
+  let mayLoad  = 1;
+  let mayStore = 0;
 }
 
-multiclass sve2_fp8_down_cvt_single opc, string mnemonic, 
RegisterOperand src> {
+multiclass sve2_fp8_down_cvt_single opc, string mnemonic, 
RegisterOperand src,
+ValueType ty, SDPatternOperator op> {
   def NAME : sve2_fp8_down_cvt_single;
+
+  def : Pat<(nxv16i8 (op ty:$Zn1, ty:$Zn2)),
+(!cast(NAME) (REG_SEQUENCE ZPR2Mul2, $Zn1, zsub0, 
$Zn2, zsub1))>;
+}
+
+class sve2_fp8_down_cvt_single_top opc, string mnemonic, 
RegisterOperand src_ty>

momchil-velikov wrote:

It's not like the encodings are going to change so we are worried about extra 
maintenance burden due to duplication.

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


[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

The s390x failure is just an unstable test that occasionally fails - that 
woudn't be a reason to revert.  Cannot say about the arm64-windows failure.

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


[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

2024-12-09 Thread Aaron Ballman via cfe-commits


@@ -2742,3 +2742,275 @@
 // RISCV64-LINUX: #define __unix__ 1
 // RISCV64-LINUX: #define linux 1
 // RISCV64-LINUX: #define unix 1
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=xtensa  
< /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=XTENSA %s
+// XTENSA: #define _ILP32 1
+// XTENSA: #define __ATOMIC_ACQUIRE 2
+// XTENSA: #define __ATOMIC_ACQ_REL 4
+// XTENSA: #define __ATOMIC_CONSUME 1
+// XTENSA: #define __ATOMIC_RELAXED 0
+// XTENSA: #define __ATOMIC_RELEASE 3
+// XTENSA: #define __ATOMIC_SEQ_CST 5
+// XTENSA: #define __BIGGEST_ALIGNMENT__ 4
+// XTENSA: #define __BITINT_MAXWIDTH__ 128
+// XTENSA: #define __BOOL_WIDTH__ 1
+// XTENSA: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// XTENSA: #define __CHAR16_TYPE__ unsigned short
+// XTENSA: #define __CHAR32_TYPE__ unsigned int
+// XTENSA: #define __CHAR_BIT__ 8
+// XTENSA: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_INT_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 1
+// XTENSA: #define __CLANG_ATOMIC_LONG_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
+// XTENSA: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
+// XTENSA: #define __CONSTANT_CFSTRINGS__ 1
+// XTENSA: #define __DBL_DECIMAL_DIG__ 17
+// XTENSA: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// XTENSA: #define __DBL_DIG__ 15
+// XTENSA: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// XTENSA: #define __DBL_HAS_DENORM__ 1
+// XTENSA: #define __DBL_HAS_INFINITY__ 1
+// XTENSA: #define __DBL_HAS_QUIET_NAN__ 1
+// XTENSA: #define __DBL_MANT_DIG__ 53
+// XTENSA: #define __DBL_MAX_10_EXP__ 308
+// XTENSA: #define __DBL_MAX_EXP__ 1024
+// XTENSA: #define __DBL_MAX__ 1.7976931348623157e+308
+// XTENSA: #define __DBL_MIN_10_EXP__ (-307)
+// XTENSA: #define __DBL_MIN_EXP__ (-1021)
+// XTENSA: #define __DBL_MIN__ 2.2250738585072014e-308
+// XTENSA: #define __DBL_NORM_MAX__ 1.7976931348623157e+308
+// XTENSA: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
+// XTENSA: #define __ELF__ 1
+// XTENSA: #define __FINITE_MATH_ONLY__ 0
+// XTENSA: #define __FLT_DECIMAL_DIG__ 9
+// XTENSA: #define __FLT_DENORM_MIN__ 1.40129846e-45F
+// XTENSA: #define __FLT_DIG__ 6
+// XTENSA: #define __FLT_EPSILON__ 1.19209290e-7F
+// XTENSA: #define __FLT_HAS_DENORM__ 1
+// XTENSA: #define __FLT_HAS_INFINITY__ 1
+// XTENSA: #define __FLT_HAS_QUIET_NAN__ 1
+// XTENSA: #define __FLT_MANT_DIG__ 24
+// XTENSA: #define __FLT_MAX_10_EXP__ 38
+// XTENSA: #define __FLT_MAX_EXP__ 128
+// XTENSA: #define __FLT_MAX__ 3.40282347e+38F
+// XTENSA: #define __FLT_MIN_10_EXP__ (-37)
+// XTENSA: #define __FLT_MIN_EXP__ (-125)
+// XTENSA: #define __FLT_MIN__ 1.17549435e-38F
+// XTENSA: #define __FLT_NORM_MAX__ 3.40282347e+38F
+// XTENSA: #define __FLT_RADIX__ 2
+// XTENSA: #define __FPCLASS_NEGINF 0x0004
+// XTENSA: #define __FPCLASS_NEGNORMAL 0x0008
+// XTENSA: #define __FPCLASS_NEGSUBNORMAL 0x0010
+// XTENSA: #define __FPCLASS_NEGZERO 0x0020
+// XTENSA: #define __FPCLASS_POSINF 0x0200
+// XTENSA: #define __FPCLASS_POSNORMAL 0x0100
+// XTENSA: #define __FPCLASS_POSSUBNORMAL 0x0080
+// XTENSA: #define __FPCLASS_POSZERO 0x0040
+// XTENSA: #define __FPCLASS_QNAN 0x0002
+// XTENSA: #define __FPCLASS_SNAN 0x0001
+// XTENSA: #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_INT_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// XTENSA: #define __GCC_ATOMIC_LONG_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
+// XTENSA: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
+// XTENSA: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// XTENSA: #define __GCC_CONSTRUCTIVE_SIZE 64
+// XTENSA: #define __GCC_DESTRUCTIVE_SIZE 64
+// XTENSA: #define __GNUC_MINOR__ {{.*}}
+// XTENSA: #define __GNUC_PATCHLEVEL__ {{.*}}
+// XTENSA: #define __GNUC_STDC_INLINE__ 1
+// XTENSA: #define __GNUC__ {{.*}}
+// XTENSA: #define __GXX_ABI_VERSION {{.*}}
+// XTENSA: #define __ILP32__ 1
+// XTENSA: #define __INT16_C_SUFFIX__ 
+// XTENSA: #define __INT16_MAX__ 32767
+// XTENSA: #define __INT16_TYPE__ short
+// XTENSA: #define __INT32_C_SUFFIX__ 
+// XTENSA: #define __INT32_MAX__ 2147483647
+// XTENSA: #define __INT32_TYPE__ int
+// XTENSA: #define __INT64_C_SUFFIX__ LL
+// XTENSA: #define __INT64_MAX__ 9223372036854775807LL
+// XTENSA: #define __INT64_TYPE__ long long int
+// XTENSA: #define __INT8_C_SUFFIX__ 
+// XTENSA: #define __INT8_MAX__ 127
+// XTENSA: #define __INT8_TYPE__ signed char
+// XTENSA: #define __INTMAX_C_SUFFIX__ LL
+// XTENSA: #define __INTMAX_MAX__ 9223372036854775807L

[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

The arm64-windows failures are from `DirectoryWatcherTest` that seems 
exceedingly unlikely to be related.

I think the only real failures here are the originally discussed ones on the 
one windows build bot. All the other windows bots seems to be OK here.

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


[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

2024-12-09 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

I don't know that we need reaffirmation; the target is already in the backend, 
so unless there's a call to remove the target, I think Clang's fine to expose 
it.

That said, if there are signs that the target is only sporadically maintained, 
reaffirming that's not the case would be a good thing, so I think Eli's 
question is still a good one to get an answer for.

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


[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

2024-12-09 Thread Aaron Ballman via cfe-commits


@@ -9727,6 +9727,51 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const 
ASTContext *Context) {
   return Context->buildImplicitTypedef(VaListTagArrayType, 
"__builtin_va_list");
 }
 
+static TypedefDecl *
+CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context) {
+  // typedef struct __va_list_tag {
+  RecordDecl *VaListTagDecl;
+
+  VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
+  VaListTagDecl->startDefinition();
+
+  const size_t NumFields = 3;

AaronBallman wrote:

```suggestion
  constexpr size_t NumFields = 3;
```

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


[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

2024-12-09 Thread Aaron Ballman via cfe-commits

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


[clang] [llvm] [AArch64] Implement FP8 SVE Intrinsics for narrowing conversions (PR #118124)

2024-12-09 Thread Momchil Velikov via cfe-commits


@@ -0,0 +1,101 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1-triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -target-feature +fp8 -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +fp8 -disable-O0-optnone -Werror -Wall 
-emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s 
-check-prefix=CHECK-CXX
+
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS-triple 
aarch64-none-linux-gnu -target-feature +sme -target-feature +sme2 
-target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt 
-S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++ -triple 
aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2 
-target-feature +fp8 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt 
-S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CHECK-CXX
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2 -target-feature +fp8 -S -disable-O0-optnone -Werror -Wall 
-o /dev/null %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-target-feature +sme2 -target-feature +fp8 -S -disable-O0-optnone -Werror -Wall 
-o /dev/null %s
+
+// REQUIRES: aarch64-registered-target
+
+#ifdef __ARM_FEATURE_SME
+#include 
+#else
+#include 
+#endif
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3) A1##A2##A3
+#endif
+
+#ifdef __ARM_FEATURE_SME
+#define STREAMING __arm_streaming
+#else
+#define STREAMING
+#endif
+
+// CHECK-LABEL: define dso_local  @test_svcvtn_f8_bf16(
+// CHECK-SAME:  [[ZN_ZM_COERCE0:%.*]],  [[ZN_ZM_COERCE1:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.set.fpmr(i64 [[FPM]])
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fp8.cvtn.nxv8bf16( [[ZN_ZM_COERCE0]], 
 [[ZN_ZM_COERCE1]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CHECK-CXX-LABEL: define dso_local  
@_Z19test_svcvtn_f8_bf1614svbfloat16x2_tm(
+// CHECK-CXX-SAME:  [[ZN_ZM_COERCE0:%.*]],  [[ZN_ZM_COERCE1:%.*]], i64 noundef [[FPM:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void @llvm.aarch64.set.fpmr(i64 [[FPM]])
+// CHECK-CXX-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fp8.cvtn.nxv8bf16( [[ZN_ZM_COERCE0]], 
 [[ZN_ZM_COERCE1]])
+// CHECK-CXX-NEXT:ret  [[TMP0]]
+//
+svmfloat8_t test_svcvtn_f8_bf16(svbfloat16x2_t zn_zm, fpm_t fpm) STREAMING {
+  return SVE_ACLE_FUNC(svcvtn_mf8,_bf16_x2,_fpm)(zn_zm, fpm);

momchil-velikov wrote:

It's completely irrelevant what is the variable name here. I've probably named 
it like this because the value is passed in two registers. Neither of `zn_zm`, 
`zn1_zn2`, `u_v`, `a`, 'x', `wt`, etc is better or worse than another.

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


[clang] [llvm] [RISCV] Add stack clash protection (PR #117612)

2024-12-09 Thread Raphael Moreira Zinsly via cfe-commits


@@ -0,0 +1,208 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+m,+v -O2 < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64I

rzinsly wrote:

@lenary hi, is there anything else I should change?

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


[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Dan Gohman (sunfishcode)


Changes

Clang [defaults to aligning `__int128_t` to 16 bytes], while LLVM `datalayout` 
strings [default to aligning `i128` to 8 bytes]. Wasm is currently using the 
defaults for both, so it's inconsistent. Fix this by adding `-i128:128` to 
Wasm's `datalayout` string so that it aligns `i128` to 16 bytes too.

This is similar to llvm/llvm-project@dbad963 for SPARC.

This fixes rust-lang/rust#133991; see that issue for further discussion.

[defaults to aligning `__int128_t` to 16 bytes]: 
https://github.com/llvm/llvm-project/blob/f8b4182f076f8fe55f9d5f617b5a25008a77b22f/clang/lib/Basic/TargetInfo.cpp#L77
[default to aligning `i128` to 8 bytes]: 
https://llvm.org/docs/LangRef.html#langref-datalayout

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


6 Files Affected:

- (modified) clang/lib/Basic/Targets/WebAssembly.h (+10-8) 
- (modified) clang/test/CodeGen/target-data.c (+2-2) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+4-4) 
- (added) llvm/test/CodeGen/WebAssembly/data-align.ll (+26) 
- (modified) llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp (+12) 


``diff
diff --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 1cae72e58e08ba..6ce2bb00e5f2a6 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -183,11 +183,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
@@ -207,11 +208,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index cb89fad941c832..de3091777bc8ce 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index e73538da282e99..8c0ca62a13e7bd 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5559,7 +5559,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
 return Res;
   }
 
-  if (T.isSPARC() || (T.isMIPS64() && !DL.contains("m:m"))) {
+  if (T.isSPARC() || (T.isMIPS64() && !DL.contains("m:m")) || T.isWasm()) {
 // Mips64 with o32 ABI did not add "-i128:128".
 // Add "-i128:128"
 std::string I64 = "-i64:64";
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 8ec72d5c47833a..9c95d730480f91 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -118,13 +118,13 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine(
   T,
   TT.isArch64Bit()
   ? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
-   "f128:64-n32:64-S128-ni:1:10:20"
+

[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)

2024-12-09 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-backend-webassembly

Author: Dan Gohman (sunfishcode)


Changes

Clang [defaults to aligning `__int128_t` to 16 bytes], while LLVM `datalayout` 
strings [default to aligning `i128` to 8 bytes]. Wasm is currently using the 
defaults for both, so it's inconsistent. Fix this by adding `-i128:128` to 
Wasm's `datalayout` string so that it aligns `i128` to 16 bytes too.

This is similar to llvm/llvm-project@dbad963 for SPARC.

This fixes rust-lang/rust#133991; see that issue for further discussion.

[defaults to aligning `__int128_t` to 16 bytes]: 
https://github.com/llvm/llvm-project/blob/f8b4182f076f8fe55f9d5f617b5a25008a77b22f/clang/lib/Basic/TargetInfo.cpp#L77
[default to aligning `i128` to 8 bytes]: 
https://llvm.org/docs/LangRef.html#langref-datalayout

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


6 Files Affected:

- (modified) clang/lib/Basic/Targets/WebAssembly.h (+10-8) 
- (modified) clang/test/CodeGen/target-data.c (+2-2) 
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+1-1) 
- (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+4-4) 
- (added) llvm/test/CodeGen/WebAssembly/data-align.ll (+26) 
- (modified) llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp (+12) 


``diff
diff --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 1cae72e58e08ba..6ce2bb00e5f2a6 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -183,11 +183,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
@@ -207,11 +208,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index cb89fad941c832..de3091777bc8ce 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index e73538da282e99..8c0ca62a13e7bd 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5559,7 +5559,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
 return Res;
   }
 
-  if (T.isSPARC() || (T.isMIPS64() && !DL.contains("m:m"))) {
+  if (T.isSPARC() || (T.isMIPS64() && !DL.contains("m:m")) || T.isWasm()) {
 // Mips64 with o32 ABI did not add "-i128:128".
 // Add "-i128:128"
 std::string I64 = "-i64:64";
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 8ec72d5c47833a..9c95d730480f91 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -118,13 +118,13 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine(
   T,
   TT.isArch64Bit()
   ? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
-   "f1

[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)

2024-12-09 Thread Dan Gohman via cfe-commits

https://github.com/sunfishcode created 
https://github.com/llvm/llvm-project/pull/119204

Clang [defaults to aligning `__int128_t` to 16 bytes], while LLVM `datalayout` 
strings [default to aligning `i128` to 8 bytes]. Wasm is currently using the 
defaults for both, so it's inconsistent. Fix this by adding `-i128:128` to 
Wasm's `datalayout` string so that it aligns `i128` to 16 bytes too.

This is similar to llvm/llvm-project@dbad963 for SPARC.

This fixes rust-lang/rust#133991; see that issue for further discussion.

[defaults to aligning `__int128_t` to 16 bytes]: 
https://github.com/llvm/llvm-project/blob/f8b4182f076f8fe55f9d5f617b5a25008a77b22f/clang/lib/Basic/TargetInfo.cpp#L77
[default to aligning `i128` to 8 bytes]: 
https://llvm.org/docs/LangRef.html#langref-datalayout

>From 13589931fd478fbd058686548bd66f501195128a Mon Sep 17 00:00:00 2001
From: Dan Gohman 
Date: Mon, 9 Dec 2024 04:30:33 -0800
Subject: [PATCH] [WebAssembly] Add `-i128:128` to the `datalayout` string.

Clang [defaults to aligning `__int128_t` to 16 bytes], while LLVM
`datalayout` strings [default to aligning `i128` to 8 bytes]. Wasm is
currently using the defaults for both, so it's inconsistent. Fix this
by adding `-i128:128` to Wasm's `datalayout` string so that it aligns
`i128` to 16 bytes too.

This is similar to llvm/llvm-project@dbad963 for SPARC.

This fixes rust-lang/rust#133991; see that issue for further discussion.

[defaults to aligning `__int128_t` to 16 bytes]: 
https://github.com/llvm/llvm-project/blob/f8b4182f076f8fe55f9d5f617b5a25008a77b22f/clang/lib/Basic/TargetInfo.cpp#L77
[default to aligning `i128` to 8 bytes]: 
https://llvm.org/docs/LangRef.html#langref-datalayout
---
 clang/lib/Basic/Targets/WebAssembly.h | 18 +++--
 clang/test/CodeGen/target-data.c  |  4 +--
 llvm/lib/IR/AutoUpgrade.cpp   |  2 +-
 .../WebAssembly/WebAssemblyTargetMachine.cpp  |  8 +++---
 llvm/test/CodeGen/WebAssembly/data-align.ll   | 26 +++
 .../Bitcode/DataLayoutUpgradeTest.cpp | 12 +
 6 files changed, 55 insertions(+), 15 deletions(-)
 create mode 100644 llvm/test/CodeGen/WebAssembly/data-align.ll

diff --git a/clang/lib/Basic/Targets/WebAssembly.h 
b/clang/lib/Basic/Targets/WebAssembly.h
index 1cae72e58e08ba..6ce2bb00e5f2a6 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/lib/Basic/Targets/WebAssembly.h
@@ -183,11 +183,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
const TargetOptions &Opts)
   : WebAssemblyTargetInfo(T, Opts) {
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
@@ -207,11 +208,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo
 PtrDiffType = SignedLong;
 IntPtrType = SignedLong;
 if (T.isOSEmscripten())
-  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-"
-  "S128-ni:1:10:20");
-else
   resetDataLayout(
-  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20");
+  "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-"
+  "S128-ni:1:10:20");
+else
+  resetDataLayout("e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-"
+  "S128-ni:1:10:20");
   }
 
 protected:
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index cb89fad941c832..de3091777bc8ce 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -108,11 +108,11 @@
 
 // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32
-// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY32: target datalayout = 
"e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64
-// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
+// WEBASSEMBLY64: target datalayout = 
"e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
 
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=LANAI
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index e73538da282e99..8c0ca62a13e7bd 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5559,7 +5559,7 @@ std::string llvm::U

[clang] [llvm] [WebAssembly] Add `-i128:128` to the `datalayout` string. (PR #119204)

2024-12-09 Thread Dan Gohman via cfe-commits

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


[clang] [clang-tools-extra] [lld] [lldb] [llvm] Rework the `Option` library to reduce dynamic relocations (PR #119198)

2024-12-09 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

> If you look for:
> 
> ```
> FAILED: 
> �[0mtools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CompileCommands.cpp.o
>  
> ```
> 
> In the build log that's the failure reason.

NP, and thanks. Sorry I missed that set of tests. Pushed a fix that makes 
`check-clang-tools` clean.

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


[clang] [llvm] [AArch64] Implement FP8 SVE Intrinsics for narrowing conversions (PR #118124)

2024-12-09 Thread Momchil Velikov via cfe-commits


@@ -0,0 +1,33 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -verify -emit-llvm %s

momchil-velikov wrote:

This feature is needed by `svcreate2` and `svundef_bf16`. What problems does it 
create as to need fixing?

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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread Timm Baeder via cfe-commits


@@ -256,15 +256,28 @@ static bool interp__builtin_strlen(InterpState &S, 
CodePtr OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
-
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
 const Pointer &ElemPtr = StrPtr.atIndex(I);
 
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;

tbaederr wrote:

Done

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


[clang-tools-extra] [clang-tidy] Filter out googletest TUs in bugprone-unchecked-optional-access (PR #115051)

2024-12-09 Thread Yitzhak Mandelbaum via cfe-commits

ymand wrote:

> I am still confused why your team did not just disable this rule for test 
> folder? It is normal cases that source code and test code have different 
> quality metrics.

Our codebase doesn't use test folders. We have no foolproof way of 
distinguishing code from test based on the file system.

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


[clang] [C++20][Modules] Load function body from the module that gives canonical decl (PR #111992)

2024-12-09 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

We have some testing results in and it's causing a large-scale breakage. I 
**think** it's all coming from 2 root causes, but it's hard to know for sure 
because there are many thousands of broken targets.

The two problems I see are:
- invalid `no matching constructor for initialization of` errors for some 
particular type,
- a crash during template instantiations for some other particular type.

And a few things that seem minor at first glance, but would also need some 
checking.
- some errors due to too long recursive template instantiations that we didn't 
see before (probably correct and coming from instantiating those bodies that 
were previously skipped?)
- some compilation timeouts (probably just a flake or a slight increase that we 
should mitigate on our end).

And there may be some long tail that's not visible because these issues take 
all of my attention.
I will try to get the reproducers for each of those. Or would it make sense to 
wait until you finish the review and do that for the new version?

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


[clang] [clang][bytecode] Handle __builtin_strncmp (PR #119208)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+18-2) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+9) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2469648d68edb1..f3cb3f52578e08 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -197,9 +197,19 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr 
OpPC,
   const Pointer &A = getParam(Frame, 0);
   const Pointer &B = getParam(Frame, 1);
 
-  if (ID == Builtin::BIstrcmp)
+  if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
+  uint64_t Limit = ~static_cast(0);
+  if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp)
+Limit = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)))
+.getZExtValue();
+
+  if (Limit == 0) {
+pushInteger(S, 0, Call->getType());
+return true;
+  }
+
   if (!CheckLive(S, OpPC, A, AK_Read) || !CheckLive(S, OpPC, B, AK_Read))
 return false;
 
@@ -212,7 +222,11 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr 
OpPC,
   unsigned IndexA = A.getIndex();
   unsigned IndexB = B.getIndex();
   int32_t Result = 0;
-  for (;; ++IndexA, ++IndexB) {
+  uint64_t Steps = 0;
+  for (;; ++IndexA, ++IndexB, ++Steps) {
+
+if (Steps >= Limit)
+  break;
 const Pointer &PA = A.atIndex(IndexA);
 const Pointer &PB = B.atIndex(IndexB);
 if (!CheckRange(S, OpPC, PA, AK_Read) ||
@@ -1873,6 +1887,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strcmp:
   case Builtin::BIstrcmp:
+  case Builtin::BI__builtin_strncmp:
+  case Builtin::BIstrncmp:
 if (!interp__builtin_strcmp(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 4c21496d3972c9..bd453d6d342d3f 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -51,6 +51,15 @@ namespace strcmp {
 return __builtin_strcmp(buffer, "mutable") == 0;
   }
   static_assert(char_memchr_mutable(), "");
+
+  static_assert(__builtin_strncmp("abaa", "abba", 5) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 4) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 3) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 2) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 1) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 0) == 0);
+  static_assert(__builtin_strncmp(0, 0, 0) == 0);
+  static_assert(__builtin_strncmp("abab\0banana", "abab\0canada", 100) == 0);
 }
 
 /// Copied from constant-expression-cxx11.cpp

``




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


[clang] [llvm] [AArch64] Implement intrinsics for SME FP8 FMLAL/FMLALL (single) (PR #118869)

2024-12-09 Thread via cfe-commits

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


[clang] [nfc][clang-offload-bundler] Don't leak on exit(1) (PR #119178)

2024-12-09 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread via cfe-commits

zmodem wrote:

> Not sure what to do debug this... @zmodem maybe has some idea?

Sorry, I don't have a lot to add. Things look good on my end so far (local 
builds and https://lab.llvm.org/buildbot/#/builders/63 + 
https://lab.llvm.org/buildbot/#/builders/107).

Besides the particular MSVC version on the failing bot, it's also using ccache. 
Perhaps that could be related somehow?

@dyung would it be possible to extract 
`tools\clang\lib\Basic\CMakeFiles\obj.clangBasic.dir\Builtins.cpp.obj` from one 
of the failing builds?

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


[clang] 411df3b - [clang-format] Make command lines of dump_format_[style|help].py consistent

2024-12-09 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2024-12-09T00:56:24-08:00
New Revision: 411df3bb4941318a02a59b4cd7a898d4f9b788a3

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

LOG: [clang-format] Make command lines of dump_format_[style|help].py consistent

Added: 


Modified: 
clang/docs/tools/dump_format_style.py
clang/test/Format/docs_updated.test

Removed: 




diff  --git a/clang/docs/tools/dump_format_style.py 
b/clang/docs/tools/dump_format_style.py
index c98f2bdcb4f2f0..f00f3ee8b20e87 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -3,6 +3,7 @@
 # documentation in ../ClangFormatStyleOptions.rst automatically.
 # Run from the directory in which this file is located to update the docs.
 
+import argparse
 import inspect
 import os
 import re
@@ -474,6 +475,10 @@ class State:
 return options
 
 
+p = argparse.ArgumentParser()
+p.add_argument("-o", "--output", help="path of output file")
+args = p.parse_args()
+
 with open(FORMAT_STYLE_FILE) as f:
 opts = OptionsReader(f).read_options()
 with open(INCLUDE_STYLE_FILE) as f:
@@ -487,6 +492,5 @@ class State:
 
 contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
 
-output_file_path = sys.argv[1] if len(sys.argv) == 2 else DOC_FILE
-with open(output_file_path, "wb") as output:
+with open(args.output if args.output else DOC_FILE, "wb") as output:
 output.write(contents.encode())

diff  --git a/clang/test/Format/docs_updated.test 
b/clang/test/Format/docs_updated.test
index 56ca4d13eb375c..17066650a12677 100644
--- a/clang/test/Format/docs_updated.test
+++ b/clang/test/Format/docs_updated.test
@@ -1,4 +1,4 @@
-// RUN: %python %S/../../docs/tools/dump_format_style.py %t.style
+// RUN: %python %S/../../docs/tools/dump_format_style.py -o %t.style
 // RUN: 
diff  %t.style %S/../../docs/ClangFormatStyleOptions.rst
 
 // RUN: %python %S/../../docs/tools/dump_format_help.py -o %t.help



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


[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-s390x-linux` running 
on `systemz-1` while building `clang` at step 5 "ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'libFuzzer-s390x-default-Linux :: 
fuzzer-timeout.test' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/./bin/clang
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/lib/fuzzer 
 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/lib/fuzzer 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
RUN: at line 2: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/./bin/clang
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/lib/fuzzer 
 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/lib/fuzzer 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp
 -o 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
RUN: at line 3: not  
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 2>&1 | FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=TimeoutTest
+ not 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1
+ FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=TimeoutTest
RUN: at line 12: not  
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/hi.txt
 2>&1 | FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=SingleInputTimeoutTest
+ not 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/hi.txt
+ FileCheck 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test
 --check-prefix=SingleInputTimeoutTest
RUN: at line 16: 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 -timeout_exitcode=0
+ 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
 -timeout=1 -timeout_exitcode=0
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2585351529
INFO: Loaded 1 modules   (13 inline 8-bit counters): 13 [0x2aa27850e70, 
0x2aa27850e7d), 
INFO: Loaded 1 PC tables (

[clang] [flang] [clang][driver] When -fveclib=ArmPL flag is in use, always link against libamath (PR #116432)

2024-12-09 Thread Paul Osmialowski via cfe-commits


@@ -490,6 +490,35 @@ void tools::AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
 else
   A.renderAsInput(Args, CmdArgs);
   }
+  if (const Arg *A = Args.getLastArg(options::OPT_fveclib)) {
+const llvm::Triple &Triple = TC.getTriple();
+StringRef V = A->getValue();
+if (V == "ArmPL" && (Triple.isOSLinux() || Triple.isOSDarwin())) {
+  // To support -fveclib=ArmPL we need to link against libamath.
+  // Some of the libamath functions depend on libm, at the same time,
+  // libamath exports its own implementation of some of the libm
+  // functions. Since here we are interested only in the subset of
+  // libamath functions that is covered by the veclib mappings,
+  // we need to do the following:
+  //
+  // 1. On Linux, link only when actually needed.
+  //
+  // 2. Prefer libm functions over libamath.
+  //
+  // 3. Link against libm to resolve libamath dependencies.
+  //
+  if (Triple.isOSLinux()) {
+CmdArgs.push_back(Args.MakeArgString("--push-state"));
+CmdArgs.push_back(Args.MakeArgString("--as-needed"));
+  }
+  CmdArgs.push_back(Args.MakeArgString("-lm"));

pawosm-arm wrote:

@MaskRay is this response sufficient?

https://github.com/llvm/llvm-project/pull/116432
___
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 crash in modernize-use-designated-initializers check (PR #113688)

2024-12-09 Thread Remi Mommsen via cfe-commits

mommsen wrote:

Will this fix be added to an upcoming patch release for 19.1? We suffer from 
this issue using version 19.1.5.

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


[clang] [clang] Fix cast for injected types in case name lookup for dependent bases (PR #119024)

2024-12-09 Thread via cfe-commits

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


[clang] 01710aa - [clang] Fix cast for injected types in case name lookup for dependent bases (#119024)

2024-12-09 Thread via cfe-commits

Author: Vladislav Belov
Date: 2024-12-09T10:28:26+01:00
New Revision: 01710aa345f2fb26e2312dd1c62bd0044fc75bed

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

LOG: [clang] Fix cast for injected types in case name lookup for dependent 
bases (#119024)

An assertion failure occurs in Clang when attempting to compile such an
example:

```c++
template  struct MozPromise {
  class Private;

private:
  int mMagic4 = 42;
};

template 
struct MozPromise::Private : 
MozPromise {
  void SetTaskPriority() { mMagic4 ; }
};
```

Output:
```
clang: llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) 
llvm::cast(const From&) [with To = clang::RecordType; From = clang::QualType]: 
Assertion `isa(Val) && "cast() argument of incompatible type!"' failed.
```

The reason is in the incorrect way of casting types when searching for
names in base classes

```c++
return 
Specifier->getType()->castAs()->getDecl()->getCanonicalDecl() == 
BaseRecord;
```

It loses injected types for template class names. 

This patch provides fix for such cases

Added: 


Modified: 
clang/lib/AST/CXXInheritance.cpp
clang/test/CXX/drs/cwg5xx.cpp

Removed: 




diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index 10b8d524ff8978..ee5775837d5355 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -368,8 +368,8 @@ bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier 
*Specifier,
   const CXXRecordDecl *BaseRecord) {
   assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
  "User data for FindBaseClass is not canonical!");
-  return Specifier->getType()->castAs()->getDecl()
-->getCanonicalDecl() == BaseRecord;
+  return cast(Specifier->getType()->getAsRecordDecl())
+ ->getCanonicalDecl() == BaseRecord;
 }
 
 bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
@@ -378,8 +378,8 @@ bool CXXRecordDecl::FindVirtualBaseClass(const 
CXXBaseSpecifier *Specifier,
   assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
  "User data for FindBaseClass is not canonical!");
   return Specifier->isVirtual() &&
- Specifier->getType()->castAs()->getDecl()
-->getCanonicalDecl() == BaseRecord;
+ cast(Specifier->getType()->getAsRecordDecl())
+ ->getCanonicalDecl() == BaseRecord;
 }
 
 static bool isOrdinaryMember(const NamedDecl *ND) {
@@ -692,7 +692,7 @@ AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext 
&Context,
"Cannot get indirect primary bases for class with dependent 
bases.");
 
 const CXXRecordDecl *BaseDecl =
-  cast(I.getType()->castAs()->getDecl());
+cast(I.getType()->getAsRecordDecl());
 
 // Only bases with virtual bases participate in computing the
 // indirect primary virtual base classes.
@@ -714,7 +714,7 @@ 
CXXRecordDecl::getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const {
"Cannot get indirect primary bases for class with dependent 
bases.");
 
 const CXXRecordDecl *BaseDecl =
-  cast(I.getType()->castAs()->getDecl());
+cast(I.getType()->getAsRecordDecl());
 
 // Only bases with virtual bases participate in computing the
 // indirect primary virtual base classes.

diff  --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp
index 567a42b2bc7917..9219a4c857b12b 100644
--- a/clang/test/CXX/drs/cwg5xx.cpp
+++ b/clang/test/CXX/drs/cwg5xx.cpp
@@ -1209,6 +1209,11 @@ namespace cwg591 { // cwg591: 20
 };
   };
 
+  template  struct M {
+class P;
+int M;
+  };
+
   template struct A::B::C : A {
 M m;
   };
@@ -1224,6 +1229,10 @@ namespace cwg591 { // cwg591: 20
 M m;
   };
 
+  template class M::P : M {
+int foo() { (void) M; }
+  };
+
   template struct A::B::D : A {
 M m;
 // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}



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


[libclc] [llvm] [polly] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

2024-12-09 Thread Tobias Grosser via cfe-commits

tobiasgrosser wrote:

Sure, this works for me. Thank you @Meinersbur for all your work here. I am 
happy to help out if this is useful.

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


[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-12-09 Thread via cfe-commits

qt-tatiana wrote:

Hi all,
Sorry for silly question, but what is next? 
if I already have 2 approvals, should I squash all fix-ups and merge?  (Btw, I 
don't have write permisions, not sure if I can land anything by myself)

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits




RIscRIpt wrote:

Instead of adding this new test, could you please modify behavior of existing 
test: 
[`clang/test/SemaCXX/ms-constexpr-new.cpp`](https://github.com/llvm/llvm-project/pull/71300/files#diff-b0e33c7c54dd10b988b2badcc60be091e69ff3aeaf86c95cb2bb9bec14ac376f).



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


[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)

2024-12-09 Thread Mészáros Gergely via cfe-commits

Maetveis wrote:

@HaohaiWen can you review and approve if it looks good now for clang-cl? I'll 
try pinging discord and waiting a little bit for HLSL people before merging.

Gentle ping @bob80905. 

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits

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


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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread Timm Baeder via cfe-commits

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

>From d5c3e403c6cc30c897e7b8ada981a0d311ea187c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 8 Dec 2024 19:12:54 +0100
Subject: [PATCH] [clang][bytecode] Handle __builtin_wcslen

Handle different char widths in builtin_strlen.
---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 25 +--
 clang/test/AST/ByteCode/builtin-functions.cpp | 12 +
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 24b630d0455e14..2469648d68edb1 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -243,7 +243,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
   unsigned ID = Func->getBuiltinID();
   const Pointer &StrPtr = getParam(Frame, 0);
 
-  if (ID == Builtin::BIstrlen)
+  if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
   if (!CheckArray(S, OpPC, StrPtr))
@@ -256,6 +256,12 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
+
+  if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
+const ASTContext &AC = S.getASTContext();
+assert(ElemSize == AC.getTypeSizeInChars(AC.getWCharType()).getQuantity());
+  }
 
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
@@ -264,7 +270,20 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;
+switch (ElemSize) {
+case 1:
+  Val = ElemPtr.deref();
+  break;
+case 2:
+  Val = ElemPtr.deref();
+  break;
+case 4:
+  Val = ElemPtr.deref();
+  break;
+default:
+  llvm_unreachable("Unsupported char size");
+}
 if (Val == 0)
   break;
   }
@@ -1859,6 +1878,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strlen:
   case Builtin::BIstrlen:
+  case Builtin::BI__builtin_wcslen:
+  case Builtin::BIwcslen:
 if (!interp__builtin_strlen(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e2121a54e15768..4c21496d3972c9 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -15,6 +15,10 @@
 #error "huh?"
 #endif
 
+extern "C" {
+  typedef decltype(sizeof(int)) size_t;
+  extern size_t wcslen(const wchar_t *p);
+}
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
   constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
   constexpr int bad = __builtin_strlen(d); // both-error {{constant 
expression}} \
// both-note {{one-past-the-end}}
+
+  constexpr int wn = __builtin_wcslen(L"hello");
+  static_assert(wn == 5);
+  constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
+   // both-note {{non-constexpr function 
'wcslen' cannot be used in a constant expression}}
+
+  int arr[3]; // both-note {{here}}
+  int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
 }
 
 namespace nan {

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits




RIscRIpt wrote:

I don't think so.

Ah, I forgot I previously added `clang/test/AST/ms-constexpr.cpp`, so having 
your new `ms-constexpr-new.cpp` makes sense (sorry for confusion).

But I still would like to see a test in 
`clang/test/SemaCXX/ms-constexpr-new.cpp` that placement new can be called 
outside of `std` namespace (in non c++26 mode) when used in 
`[[msvc::constexpr]]` context.

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Oleksandr T. via cfe-commits




a-tarasyuk wrote:

Thanks for the review., would adding an AST dump at the Sema level be 
considered appropriate?

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


[clang] [llvm] [AArch64] Add intrinsics for SME FP8 FDOT LANE instructions (PR #118492)

2024-12-09 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/118492

>From 609cf3fbdb28c155f4b8c787c1e2cb791c8a292f Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Fri, 29 Nov 2024 11:27:03 +
Subject: [PATCH 1/8] [AArch64] Add intrinsics for SME FP8 FDOT LANE
 instructions

Co-authored-by: Momchil Velikov 
Co-authored-by: Marian Lukac 
Co-authored-by: Caroline Concatto 
---
 clang/include/clang/Basic/arm_sme.td  |   5 +
 clang/include/clang/Basic/arm_sve_sme_incl.td |   1 +
 clang/lib/CodeGen/CGBuiltin.cpp   |   6 +
 .../sme2-intrinsics/acle_sme2_fp8_fdot.c  |  57 +++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  22 +++
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   4 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td| 141 ++
 .../AArch64/sme2-intrinsics-fp8-fdot.ll   |  32 
 8 files changed, 266 insertions(+), 2 deletions(-)
 create mode 100644 
clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_fp8_fdot.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-fp8-fdot.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 0f689e82bdb742..87ed68c03430cd 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -740,6 +740,11 @@ let SMETargetGuard = "sme2" in {
   def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", 
"cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, 
IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
 }
 
+// FDOT
+let SMETargetGuard = "sme2,sme-f8f16" in {
+  def SVDOT_LANE_FP8_ZA16_VG1x2 : Inst<"svdot_lane_za16[_mf8]_vg1x2_fpm", 
"vm2di>", "m", MergeNone, "aarch64_sme_fp8_fdot_lane_za16_vg1x2", [IsStreaming, 
IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
+  def SVDOT_LANE_FP8_ZA16_VG1x4 : Inst<"svdot_lane_za16[_mf8]_vg1x4_fpm", 
"vm4di>", "m", MergeNone, "aarch64_sme_fp8_fdot_lane_za16_vg1x4", [IsStreaming, 
IsInOutZA, SetsFPMR, IsOverloadNone], [ImmCheck<3, ImmCheck0_7>]>;
+}
 

 // SME2p1 - FMOPA, FMOPS (non-widening)
 let SMETargetGuard = "sme-b16b16" in {
diff --git a/clang/include/clang/Basic/arm_sve_sme_incl.td 
b/clang/include/clang/Basic/arm_sve_sme_incl.td
index de10be7bdce0db..e7cc40db7dca6c 100644
--- a/clang/include/clang/Basic/arm_sve_sme_incl.td
+++ b/clang/include/clang/Basic/arm_sve_sme_incl.td
@@ -52,6 +52,7 @@ include "arm_immcheck_incl.td"
 // h: half-float
 // d: double
 // b: bfloat
+// m: mfloat8
 
 // Typespec modifiers
 // --
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7588f8427cdd38..7de5e8bcd439d7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10183,6 +10183,8 @@ CodeGenFunction::getSVEType(const SVETypeFlags 
&TypeFlags) {
   case SVETypeFlags::EltTyInt64:
 return llvm::ScalableVectorType::get(Builder.getInt64Ty(), 2);
 
+ case SVETypeFlags::EltTyMFloat8:
+return llvm::ScalableVectorType::get(Builder.getInt8Ty(), 16);
   case SVETypeFlags::EltTyFloat16:
 return llvm::ScalableVectorType::get(Builder.getHalfTy(), 8);
   case SVETypeFlags::EltTyBFloat16:
@@ -11234,6 +11236,10 @@ Value 
*CodeGenFunction::EmitAArch64SMEBuiltinExpr(unsigned BuiltinID,
BuiltinID == SME::BI__builtin_sme_svstr_za)
 return EmitSMELdrStr(TypeFlags, Ops, Builtin->LLVMIntrinsic);
 
+  // Emit set FPMR for intrinsics that require it
+  if (TypeFlags.setsFPMR())
+Builder.CreateCall(CGM.getIntrinsic(Intrinsic::aarch64_set_fpmr),
+   Ops.pop_back_val());
   // Handle builtins which require their multi-vector operands to be swapped
   swapCommutativeSMEOperands(BuiltinID, Ops);
 
diff --git a/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_fp8_fdot.c 
b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_fp8_fdot.c
new file mode 100644
index 00..999b1940df80c4
--- /dev/null
+++ b/clang/test/CodeGen/AArch64/sme2-intrinsics/acle_sme2_fp8_fdot.c
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// REQUIRES: aarch64-registered-target
+#include 
+
+// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-f8f16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - %s | opt -S -passes mem2reg,instcombine,tailcallelim | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-f8f16 -disable-O0-optnone -Werror 
-Wall -emit-llvm -o - -x c++ %s | opt -S -passes 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature +sme-f8f16 
-disable-O0-optnone -We

[clang] [flang] [Flang][LoongArch] Enable clang command-line options in flang. (PR #118244)

2024-12-09 Thread via cfe-commits

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


[clang] 669f704 - [Flang][LoongArch] Enable clang command-line options in flang. (#118244)

2024-12-09 Thread via cfe-commits

Author: Zhaoxin Yang
Date: 2024-12-09T19:59:39+08:00
New Revision: 669f704d0dc833fc3cd844a8d8c1e0ed34d43a5b

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

LOG: [Flang][LoongArch] Enable clang command-line options in flang. (#118244)

Mainly including the following LoongArch specific options: -m[no-]lsx,
-m[no-]lasx, -msimd=, -m[no-]frecipe, -m[no-]lam-bh, -m[no-]lamcas,
-m[no-]ld-seq-sa, -m[no-]div32,
-m[no-]annotate-tablejump

Added: 
flang/test/Driver/options-loongarch.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a89a4e8f8ec985..bd5e35c677b44e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -240,7 +240,8 @@ def m_riscv_Features_Group : OptionGroup<"">,
 def m_ve_Features_Group : OptionGroup<"">,
   Group, DocName<"VE">;
 def m_loongarch_Features_Group : OptionGroup<"">,
- Group, DocName<"LoongArch">;
+ Group, DocName<"LoongArch">,
+ Visibility<[ClangOption, CLOption, 
FlangOption]>;
 
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 72c0787d7df993..9186647b09c886 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -213,6 +213,14 @@ void Flang::AddLoongArch64TargetArgs(const ArgList &Args,
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-mabi" << V;
 }
   }
+
+  if (const Arg *A = Args.getLastArg(options::OPT_mannotate_tablejump,
+ options::OPT_mno_annotate_tablejump)) {
+if (A->getOption().matches(options::OPT_mannotate_tablejump)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-loongarch-annotate-tablejump");
+}
+  }
 }
 
 void Flang::AddPPCTargetArgs(const ArgList &Args,

diff  --git a/flang/test/Driver/options-loongarch.f90 
b/flang/test/Driver/options-loongarch.f90
new file mode 100644
index 00..717bf6385b06d7
--- /dev/null
+++ b/flang/test/Driver/options-loongarch.f90
@@ -0,0 +1,43 @@
+!! This test tests options from clang, which are also supported by flang in 
LoongArch.
+
+! RUN: %flang -c --target=loongarch64-unknown-linux -mlsx %s -### 2>&1 | 
FileCheck --check-prefixes=LSX,NOLASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-lsx %s -### 2>&1 | 
FileCheck --check-prefixes=NOLSX,NOLASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mlasx %s -### 2>&1 | 
FileCheck --check-prefixes=LSX,LASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-lasx %s -### 2>&1 | 
FileCheck --check-prefixes=LSX,NOLASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -msimd=none %s -### 2>&1 | 
FileCheck --check-prefixes=NOLSX,NOLASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -msimd=lsx %s -### 2>&1 | 
FileCheck --check-prefixes=LSX,NOLASX %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -msimd=lasx %s -### 2>&1 | 
FileCheck --check-prefixes=LSX,LASX %s
+! RUN: not %flang -c --target=loongarch64-unknown-linux -msimd=supper %s -### 
2>&1 | FileCheck --check-prefix=MSIMD-INVALID %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mfrecipe %s -### 2>&1 | 
FileCheck --check-prefix=FRECIPE %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-frecipe %s -### 2>&1 
| FileCheck --check-prefix=NOFRECIPE %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mlam-bh %s -### 2>&1 | 
FileCheck --check-prefix=LAMBH %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-lam-bh %s -### 2>&1 | 
FileCheck --check-prefix=NOLAMBH %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mlamcas %s -### 2>&1 | 
FileCheck --check-prefix=LAMCAS %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-lamcas %s -### 2>&1 | 
FileCheck --check-prefix=NOLAMCAS %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mld-seq-sa %s -### 2>&1 | 
FileCheck --check-prefix=LD-SEQ-SA %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-ld-seq-sa %s -### 
2>&1 | FileCheck --check-prefix=NOLD-SEQ-SA %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mdiv32 %s -### 2>&1 | 
FileCheck --check-prefix=DIV32 %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-div32 %s -### 2>&1 | 
FileCheck --check-prefix=NODIV32 %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mannotate-tablejump %s 
-### 2>&1 | FileCheck --check-prefix=ANOTATE %s
+! RUN: %flang -c --target=loongarch64-unknown-linux -mno-annotate-tablejump %s 
-### 2>&

[clang] [Clang] allow usage of placement new operator in [[msvc::constexpr]] context outside of the std namespace (PR #119153)

2024-12-09 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/119153

>From f19ea82bbe5c00af6a6e261f989c9a89ef4c78ca Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 9 Dec 2024 01:46:46 +0200
Subject: [PATCH 1/3] [Clang] allow [[msvc::constexpr]] usage outside the std
 namespace

---
 clang/docs/ReleaseNotes.rst |  2 ++
 clang/lib/AST/ExprConstant.cpp  |  4 +++-
 clang/test/AST/ms-constexpr-new.cpp | 13 +
 3 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/ms-constexpr-new.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3f58e64cf0ccbc..71666e26146e92 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -525,6 +525,8 @@ Attribute Changes in Clang
 
 - The ``target_version`` attribute is now only supported for AArch64 and 
RISC-V architectures.
 
+- Clang now permits ``[[msvc::constexpr]]`` usage outside of the std 
namespace. (#GH74924)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6b5b95aee35522..9dbb350be59091 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10172,7 +10172,9 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const 
CXXNewExpr *E) {
   return false;
 IsNothrow = true;
   } else if (OperatorNew->isReservedGlobalPlacementOperator()) {
-if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26) {
+if (Info.CurrentCall->isStdFunction() || Info.getLangOpts().CPlusPlus26 ||
+(Info.CurrentCall->CanEvalMSConstexpr &&
+ OperatorNew->hasAttr())) {
   if (!EvaluatePointer(E->getPlacementArg(0), Result, Info))
 return false;
   if (Result.Designator.Invalid)
diff --git a/clang/test/AST/ms-constexpr-new.cpp 
b/clang/test/AST/ms-constexpr-new.cpp
new file mode 100644
index 00..4b534cf0207644
--- /dev/null
+++ b/clang/test/AST/ms-constexpr-new.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 
-std=c++20 -ast-dump %s | FileCheck %s
+
+// CHECK: used operator new
+// CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} 
+[[nodiscard]] [[msvc::constexpr]] inline void* __cdecl operator 
new(decltype(sizeof(void*)), void* p) noexcept { return p; }
+
+// CHECK: used constexpr construct_at
+// CHECK: AttributedStmt 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} 
+constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new 
(p) int(v); }
+constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 
42; }
+static_assert(check_construct_at());

>From 6ec3ea6ec803efddb095ac5b30d6c82ce2fb86a0 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 9 Dec 2024 13:48:23 +0200
Subject: [PATCH 2/3] add tests to cover unsupported cases

---
 clang/test/SemaCXX/ms-constexpr-new.cpp | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/clang/test/SemaCXX/ms-constexpr-new.cpp 
b/clang/test/SemaCXX/ms-constexpr-new.cpp
index 30567740b2ecbb..096014be803e77 100644
--- a/clang/test/SemaCXX/ms-constexpr-new.cpp
+++ b/clang/test/SemaCXX/ms-constexpr-new.cpp
@@ -12,5 +12,12 @@ namespace std {
   }
 }
 
-constexpr bool check_construct_at() { int x; return *std::construct_at(&x, 42) 
== 42; }
-static_assert(check_construct_at());
+constexpr bool check_std_construct_at() { int x; return *std::construct_at(&x, 
42) == 42; }
+static_assert(check_std_construct_at());
+
+constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new 
(p) int(v); } // unsupported-error {{constexpr function never produces a 
constant expression}} \
+   
 // unsupported-warning {{unknown attribute 'constexpr' ignored}} \
+   
 // unsupported-note 2{{this placement new expression is not 
supported in constant expressions before C++2c}}
+constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 
42; }  // unsupported-note {{in call to 'construct_at(&x, 42)'}}
+static_assert(check_construct_at());   
 // unsupported-error {{static assertion expression is not an 
integral constant expression}}\
+   
 // unsupported-note {{in call to 'check_construct_at()'}}

>From a4f4d1322430a6b5fe2e2baa77c25603af10478a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 9 Dec 2024 13:54:26 +0200
Subject: [PATCH 3/3] update release notes

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

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 71666e26146e92..8

[clang-tools-extra] [clangd] Handle DeducedTemplateSpecializationType in HeuristicResolver (PR #119107)

2024-12-09 Thread Haojian Wu via cfe-commits

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


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


[clang] [nfc][clang-offload-bundler] Don't leak on exit(1) (PR #119178)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)


Changes

`exit(1)` Don't calls C++ destructors, however calls
`at_exit()` handlers, including lsan.

Usually lsan can see pointers of local allocations
on stack or in registers, but those can be
discarded by noreturn `exit` call.

Fixes leak triggered by f7685af4a5bd188e6d548967d818d8569f10a70d.


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


1 Files Affected:

- (modified) clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp (+47-47) 


``diff
diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 0189fe5d56ab2a..14c584064e311c 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -196,13 +196,14 @@ int main(int argc, const char **argv) {
 
   auto reportError = [argv](Error E) {
 logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
-exit(1);
+return 1;
   };
 
   auto doWork = [&](std::function Work) {
 if (llvm::Error Err = Work()) {
-  reportError(std::move(Err));
+  return reportError(std::move(Err));
 }
+return 0;
   };
 
   auto warningOS = [argv]() -> raw_ostream & {
@@ -223,14 +224,14 @@ int main(int argc, const char **argv) {
   if (!Objcopy)
 Objcopy = sys::findProgramByName("llvm-objcopy");
   if (!Objcopy)
-reportError(createStringError(Objcopy.getError(),
- "unable to find 'llvm-objcopy' in path"));
+return reportError(createStringError(
+Objcopy.getError(), "unable to find 'llvm-objcopy' in path"));
   else
 BundlerConfig.ObjcopyPath = *Objcopy;
 
   if (InputFileNames.getNumOccurrences() != 0 &&
   InputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
-reportError(createStringError(
+return reportError(createStringError(
 errc::invalid_argument,
 "-inputs and -input cannot be used together, use only -input 
instead"));
   }
@@ -246,9 +247,9 @@ int main(int argc, const char **argv) {
 
   if (OutputFileNames.getNumOccurrences() != 0 &&
   OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
-reportError(createStringError(errc::invalid_argument,
-  "-outputs and -output cannot be used "
-  "together, use only -output instead"));
+return reportError(createStringError(errc::invalid_argument,
+ "-outputs and -output cannot be used "
+ "together, use only -output 
instead"));
   }
 
   if (OutputFileNamesDeprecatedOpt.size()) {
@@ -262,77 +263,77 @@ int main(int argc, const char **argv) {
 
   if (ListBundleIDs) {
 if (Unbundle) {
-  reportError(
+  return reportError(
   createStringError(errc::invalid_argument,
 "-unbundle and -list cannot be used together"));
 }
 if (InputFileNames.size() != 1) {
-  reportError(createStringError(errc::invalid_argument,
-"only one input file supported for 
-list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "only one input file supported for -list"));
 }
 if (OutputFileNames.size()) {
-  reportError(createStringError(errc::invalid_argument,
-"-outputs option is invalid for -list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-outputs option is invalid for -list"));
 }
 if (TargetNames.size()) {
-  reportError(createStringError(errc::invalid_argument,
-"-targets option is invalid for -list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-targets option is invalid for -list"));
 }
 
-doWork([&]() { return OffloadBundler::ListBundleIDsInFile(
-  InputFileNames.front(),
-  BundlerConfig); });
-return 0;
+return doWork([&]() {
+  return OffloadBundler::ListBundleIDsInFile(InputFileNames.front(),
+ BundlerConfig);
+});
   }
 
   if (BundlerConfig.CheckInputArchive) {
 if (!Unbundle) {
-  reportError(createStringError(errc::invalid_argument,
-"-check-input-archive cannot be used while 
"
-"bundling"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-check-input-archive cannot be used while "
+  "bundling"));
 }
 if (Unbundle && BundlerConfig.FilesType != "a") {
-  reportError(createStringError(errc::invalid_argument,
-"-check-input-archive can only be used for 
"
-"unbundling archives (-

[clang] [nfc][clang-offload-bundler] Don't leak on exit(1) (PR #119178)

2024-12-09 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/119178

`exit(1)` Don't calls C++ destructors, however calls
`at_exit()` handlers, including lsan.

Usually lsan can see pointers of local allocations
on stack or in registers, but those can be
discarded by noreturn `exit` call.

Fixes leak triggered by f7685af4a5bd188e6d548967d818d8569f10a70d.


>From 1412ada1c9cba2497c2e420d9ab9967772427bc5 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Mon, 9 Dec 2024 00:03:21 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../ClangOffloadBundler.cpp   | 94 +--
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 0189fe5d56ab2a..14c584064e311c 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -196,13 +196,14 @@ int main(int argc, const char **argv) {
 
   auto reportError = [argv](Error E) {
 logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
-exit(1);
+return 1;
   };
 
   auto doWork = [&](std::function Work) {
 if (llvm::Error Err = Work()) {
-  reportError(std::move(Err));
+  return reportError(std::move(Err));
 }
+return 0;
   };
 
   auto warningOS = [argv]() -> raw_ostream & {
@@ -223,14 +224,14 @@ int main(int argc, const char **argv) {
   if (!Objcopy)
 Objcopy = sys::findProgramByName("llvm-objcopy");
   if (!Objcopy)
-reportError(createStringError(Objcopy.getError(),
- "unable to find 'llvm-objcopy' in path"));
+return reportError(createStringError(
+Objcopy.getError(), "unable to find 'llvm-objcopy' in path"));
   else
 BundlerConfig.ObjcopyPath = *Objcopy;
 
   if (InputFileNames.getNumOccurrences() != 0 &&
   InputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
-reportError(createStringError(
+return reportError(createStringError(
 errc::invalid_argument,
 "-inputs and -input cannot be used together, use only -input 
instead"));
   }
@@ -246,9 +247,9 @@ int main(int argc, const char **argv) {
 
   if (OutputFileNames.getNumOccurrences() != 0 &&
   OutputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
-reportError(createStringError(errc::invalid_argument,
-  "-outputs and -output cannot be used "
-  "together, use only -output instead"));
+return reportError(createStringError(errc::invalid_argument,
+ "-outputs and -output cannot be used "
+ "together, use only -output 
instead"));
   }
 
   if (OutputFileNamesDeprecatedOpt.size()) {
@@ -262,77 +263,77 @@ int main(int argc, const char **argv) {
 
   if (ListBundleIDs) {
 if (Unbundle) {
-  reportError(
+  return reportError(
   createStringError(errc::invalid_argument,
 "-unbundle and -list cannot be used together"));
 }
 if (InputFileNames.size() != 1) {
-  reportError(createStringError(errc::invalid_argument,
-"only one input file supported for 
-list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "only one input file supported for -list"));
 }
 if (OutputFileNames.size()) {
-  reportError(createStringError(errc::invalid_argument,
-"-outputs option is invalid for -list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-outputs option is invalid for -list"));
 }
 if (TargetNames.size()) {
-  reportError(createStringError(errc::invalid_argument,
-"-targets option is invalid for -list"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-targets option is invalid for -list"));
 }
 
-doWork([&]() { return OffloadBundler::ListBundleIDsInFile(
-  InputFileNames.front(),
-  BundlerConfig); });
-return 0;
+return doWork([&]() {
+  return OffloadBundler::ListBundleIDsInFile(InputFileNames.front(),
+ BundlerConfig);
+});
   }
 
   if (BundlerConfig.CheckInputArchive) {
 if (!Unbundle) {
-  reportError(createStringError(errc::invalid_argument,
-"-check-input-archive cannot be used while 
"
-"bundling"));
+  return reportError(createStringError(
+  errc::invalid_argument, "-check-input-archive cannot be used while "
+   

[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)

2024-12-09 Thread Mészáros Gergely via cfe-commits

https://github.com/Maetveis updated 
https://github.com/llvm/llvm-project/pull/118640

From c2efb475c557dd4ad1018e261a9659b1c4f16b83 Mon Sep 17 00:00:00 2001
From: Gergely Meszaros 
Date: Wed, 4 Dec 2024 05:44:19 -0800
Subject: [PATCH 1/3] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc
 by mistake

When these options were enabled for flang the visibility was also
extended to clang-cl and dxc. I believe this was due to a misunderstanding
of the default value for `Visibility`.
---
 clang/include/clang/Driver/Options.td | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4bc0b97ea68f2f..aa705f95ca399a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1055,11 +1055,11 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
 def offload_link : Flag<["--"], "offload-link">, Group,
   HelpText<"Use the new offloading linker to perform the link job.">;
 def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
   Group;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Pass  to the offload linkers or the ones identified by 
-">,
   MetaVarName<" ">, Group;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, 
Group,
@@ -1175,7 +1175,7 @@ def compatibility__version : JoinedOrSeparate<["-"], 
"compatibility_version">;
 def config : Joined<["--"], "config=">, Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, 
MetaVarName<"">,
   HelpText<"Specify configuration file">;
-def : Separate<["--"], "config">, Visibility<[ClangOption, CLOption, 
DXCOption, FlangOption]>, Alias;
+def : Separate<["--"], "config">, Visibility<[ClangOption, FlangOption]>, 
Alias;
 def no_default_config : Flag<["--"], "no-default-config">,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CLOption, DXCOption, 
FlangOption]>,
   HelpText<"Disable loading default configuration files">;
@@ -1989,7 +1989,7 @@ def : Flag<["-"], "fno-diagnostics-color">, 
Group,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias;
 def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, 
Group,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Values<"auto,always,never">,
   HelpText<"When to use colors in diagnostics">;
 def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group,
@@ -2015,10 +2015,10 @@ argument are escaped with backslashes. This format 
differs from the format of
 the equivalent section produced by GCC with the -frecord-gcc-switches flag.
 This option is currently only supported on ELF targets.}]>,
   Group,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
   Group,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def : Flag<["-"], "frecord-gcc-switches">, Alias;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias;
 def fcommon : Flag<["-"], "fcommon">, Group,
@@ -5643,7 +5643,7 @@ def gpulibc : Flag<["-"], "gpulibc">, 
Visibility<[ClangOption, CC1Option, FlangO
   HelpText<"Link the LLVM C Library for GPUs">;
 def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option, 
FlangOption, FC1Option]>;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">,
-  Visibility<[ClangOption, FlangOption, CLOption, DXCOption]>;
+  Visibility<[ClangOption, FlangOption]>;
 def nodriverkitlib : Flag<["-"], "nodriverkitlib">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
@@ -5665,10 +5665,10 @@ def nostdincxx : Flag<["-"], "nostdinc++">, 
Visibility<[ClangOption, CC1Option]>
   HelpText<"Disable standard #include directories for the C++ standard 
library">,
   MarshallingInfoNegativeFlag>;
 def nostdlib : Flag<["-"], "nostdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group;
 def stdlib : Flag<["-"], "stdlib">,
-  Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption]>,
   Group;
 def nostdlibxx : Flag<["-"], "nostdlib++">;
 def object : Flag<["-"], "object">;
@@ -5782,7 +5782,7 @@ def resource_dir_EQ : Joined<["-"], "resource-dir=">, 
Flags<[NoXarchOption]>,
   Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   Alias;
 def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group,
-  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
+  Visibility<[

[clang] [nfc][clang-offload-bundler] Don't leak on exit(1) (PR #119178)

2024-12-09 Thread Vitaly Buka via cfe-commits

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


[clang-tools-extra] [clangd] Do not show `aParam` parameter hint for argument spelled `param` (PR #119162)

2024-12-09 Thread Haojian Wu via cfe-commits

https://github.com/hokein commented:

I have mixed feelings about this. The change is small, but it seems tied to a 
particular coding style, and the implementation appears to be "optimized" 
specifically for that style, which isn’t we do generally.

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


[clang] [clang-cl][flang][dxc] Fix opts exposed to clang-cl/dxc by mistake (PR #118640)

2024-12-09 Thread Mészáros Gergely via cfe-commits

Maetveis wrote:

> Can we keep this flag for CL in this PR and open an issue to discuss whether 
> it should be disabled for CL?

Sure, see latest commit and https://github.com/llvm/llvm-project/issues/119179.

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


[clang] [LoongArch] Add FreeBSD targets (PR #119191)

2024-12-09 Thread via cfe-commits

https://github.com/hitmoon created 
https://github.com/llvm/llvm-project/pull/119191

Add support for freebsd on loongarch

>From f56241d879e8da925c31d6605092cce5c4d8c8c9 Mon Sep 17 00:00:00 2001
From: xiaoqiang zhao 
Date: Mon, 9 Dec 2024 14:26:37 +0800
Subject: [PATCH] [LoongArch] Add FreeBSD targets

Co-authored-by: yu shan wei 
Signed-off-by: xiaoqiang zhao 
---
 clang/lib/Basic/Targets.cpp |  6 ++
 clang/lib/Basic/Targets/OSTargets.h |  3 +++
 clang/lib/Driver/ToolChains/FreeBSD.cpp | 14 ++
 clang/test/Driver/freebsd.c |  9 +
 4 files changed, 32 insertions(+)

diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 0021d33c45d7c9..98d151cfe4312f 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -726,6 +726,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Linux:
 return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::FreeBSD:
+return 
std::make_unique>(Triple,
+  
Opts);
 default:
 return std::make_unique(Triple, Opts);
 }
@@ -734,6 +737,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Linux:
 return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::FreeBSD:
+return 
std::make_unique>(Triple,
+  
Opts);
 default:
 return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 75f53e96ce28f6..a39d8526e958f3 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -231,6 +231,9 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::riscv32:
 case llvm::Triple::riscv64:
   break;
+case llvm::Triple::loongarch32:
+case llvm::Triple::loongarch64:
+  break;
 }
   }
 };
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 3d744bc087f467..be44fc4fe1a84d 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -213,6 +213,14 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-m");
 CmdArgs.push_back("elf64lriscv");
 break;
+  case llvm::Triple::loongarch32:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32loongarch");
+break;
+  case llvm::Triple::loongarch64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64loongarch");
+break;
   default:
 break;
   }
@@ -223,6 +231,12 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("--no-relax");
   }
 
+  if (Triple.isLoongArch64()) {
+CmdArgs.push_back("-X");
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_G)) {
 if (ToolChain.getTriple().isMIPS()) {
   StringRef v = A->getValue();
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index 10fe155fee8744..c99beade607343 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -77,6 +77,15 @@
 // RUN:   | FileCheck --check-prefix=CHECK-RV64I-LD %s
 // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
 //
+// Check that LOONGARCH passes the correct linker emulation.
+//
+// RUN: %clang --target=loongarch32-freebsd -### %s %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONG32-LD %s
+// CHECK-LOONG32-LD: ld{{.*}}" {{.*}} "-m" "elf32loongarch"
+// RUN: %clang --target=loongarch64-freebsd -### %s %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONG64-LD %s
+// CHECK-LOONG64-LD: ld{{.*}}" {{.*}} "-m" "elf64loongarch"
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang --target=x86_64-pc-freebsd10.0 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \

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


[clang] [llvm] [clang] Implement pragma clang section on COFF targets (PR #112714)

2024-12-09 Thread David Spickett via cfe-commits

DavidSpickett wrote:

My comments have been addressed.

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


[clang] [llvm] [clang] Implement pragma clang section on COFF targets (PR #112714)

2024-12-09 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 026af9e972469c878e51f1215659b7264da0136d 
e01f6fb36734b214e23cbbe66818b3269d21a591 --extensions cpp,c -- 
clang/test/Sema/pragma-clang-section.c 
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 28875f91ae..eb71436f38 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -781,7 +781,8 @@ getGlobalObjectInfo(const GlobalObject *GO, const 
TargetMachine &TM) {
   return {Group, IsComdat, Flags};
 }
 
-static StringRef handlePragmaClangSection(const GlobalObject *GO, SectionKind 
Kind) {
+static StringRef handlePragmaClangSection(const GlobalObject *GO,
+  SectionKind Kind) {
   // Check if '#pragma clang section' name is applicable.
   // Note that pragma directive overrides -ffunction-section, -fdata-section
   // and so section name is exactly as user specified and not uniqued.
@@ -801,10 +802,12 @@ static StringRef handlePragmaClangSection(const 
GlobalObject *GO, SectionKind Ki
   return GO->getSection();
 }
 
-static MCSection *selectExplicitSectionGlobal(
-const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM,
-MCContext &Ctx, Mangler &Mang, unsigned &NextUniqueID,
-bool Retain, bool ForceUnique) {
+static MCSection *selectExplicitSectionGlobal(const GlobalObject *GO,
+  SectionKind Kind,
+  const TargetMachine &TM,
+  MCContext &Ctx, Mangler &Mang,
+  unsigned &NextUniqueID,
+  bool Retain, bool ForceUnique) {
   StringRef SectionName = handlePragmaClangSection(GO, Kind);
 
   // Infer section flags from the section name if we can.

``




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


[clang] [Serialization] Migrate away from PointerUnion::{is,get} (NFC) (PR #118948)

2024-12-09 Thread Younan Zhang via cfe-commits

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

Thanks

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


[clang] [LoongArch] Add FreeBSD targets (PR #119191)

2024-12-09 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [LoongArch] Add FreeBSD targets (PR #119191)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (hitmoon)


Changes

Add support for freebsd on loongarch

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


4 Files Affected:

- (modified) clang/lib/Basic/Targets.cpp (+6) 
- (modified) clang/lib/Basic/Targets/OSTargets.h (+3) 
- (modified) clang/lib/Driver/ToolChains/FreeBSD.cpp (+14) 
- (modified) clang/test/Driver/freebsd.c (+9) 


``diff
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 0021d33c45d7c9..98d151cfe4312f 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -726,6 +726,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Linux:
 return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::FreeBSD:
+return 
std::make_unique>(Triple,
+  
Opts);
 default:
 return std::make_unique(Triple, Opts);
 }
@@ -734,6 +737,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Linux:
 return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::FreeBSD:
+return 
std::make_unique>(Triple,
+  
Opts);
 default:
 return std::make_unique(Triple, Opts);
 }
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 75f53e96ce28f6..a39d8526e958f3 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -231,6 +231,9 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::riscv32:
 case llvm::Triple::riscv64:
   break;
+case llvm::Triple::loongarch32:
+case llvm::Triple::loongarch64:
+  break;
 }
   }
 };
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp 
b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 3d744bc087f467..be44fc4fe1a84d 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -213,6 +213,14 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-m");
 CmdArgs.push_back("elf64lriscv");
 break;
+  case llvm::Triple::loongarch32:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf32loongarch");
+break;
+  case llvm::Triple::loongarch64:
+CmdArgs.push_back("-m");
+CmdArgs.push_back("elf64loongarch");
+break;
   default:
 break;
   }
@@ -223,6 +231,12 @@ void freebsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("--no-relax");
   }
 
+  if (Triple.isLoongArch64()) {
+CmdArgs.push_back("-X");
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_G)) {
 if (ToolChain.getTriple().isMIPS()) {
   StringRef v = A->getValue();
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index 10fe155fee8744..c99beade607343 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -77,6 +77,15 @@
 // RUN:   | FileCheck --check-prefix=CHECK-RV64I-LD %s
 // CHECK-RV64I-LD: ld{{.*}}" {{.*}} "-m" "elf64lriscv"
 //
+// Check that LOONGARCH passes the correct linker emulation.
+//
+// RUN: %clang --target=loongarch32-freebsd -### %s %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONG32-LD %s
+// CHECK-LOONG32-LD: ld{{.*}}" {{.*}} "-m" "elf32loongarch"
+// RUN: %clang --target=loongarch64-freebsd -### %s %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LOONG64-LD %s
+// CHECK-LOONG64-LD: ld{{.*}}" {{.*}} "-m" "elf64loongarch"
+//
 // Check that the new linker flags are passed to FreeBSD
 // RUN: %clang --target=x86_64-pc-freebsd10.0 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \

``




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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread via cfe-commits

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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread via cfe-commits


@@ -256,15 +256,28 @@ static bool interp__builtin_strlen(InterpState &S, 
CodePtr OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
-
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
 const Pointer &ElemPtr = StrPtr.atIndex(I);
 
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;

cor3ntin wrote:

Should we assert that if `ID == Builtin::BIwcslen` ElemSize is the size of 
wchar_t?

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


[clang] Fix a bug with the hasAncestor AST matcher when a node has several parents without pointer identity (PR #118511)

2024-12-09 Thread Loïc Joly via cfe-commits

loic-joly-sonarsource wrote:

Hi there. I do not have commit access, but this PR had one approval. Could 
someone with commit access merge it?

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


[clang] 6d759f8 - [Clang] Deleting an incomplete enum type is not an error (#119077)

2024-12-09 Thread via cfe-commits

Author: cor3ntin
Date: 2024-12-09T10:20:16+01:00
New Revision: 6d759f83eb779cfdec02c1fe33344f3215bbdab1

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

LOG: [Clang] Deleting an incomplete enum type is not an error (#119077)

The changes introduced in #97733 accidentally prevented to delete an
incomplete enum
(the validity of which has been confirmed by CWG2925

Fixes #99278

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/new-delete.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 95007f357b766f..7d846f1d447d16 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -799,6 +799,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure caused by mangled names with invalid identifiers. 
(#GH112205)
 - Fixed an incorrect lambda scope of generic lambdas that caused Clang to 
crash when computing potential lambda
   captures at the end of a full expression. (#GH115931)
+- Clang no longer rejects deleting a pointer of incomplete enumeration type. 
(#GH99278)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index f58c0fa21e8380..caea13b192ad57 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3747,7 +3747,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool 
UseGlobal,
 } else if (!Pointee->isDependentType()) {
   // FIXME: This can result in errors if the definition was imported from a
   // module but is hidden.
-  if (!RequireCompleteType(StartLoc, Pointee,
+  if (Pointee->isEnumeralType() ||
+  !RequireCompleteType(StartLoc, Pointee,
LangOpts.CPlusPlus26
? diag::err_delete_incomplete
: diag::warn_delete_incomplete,

diff  --git a/clang/test/SemaCXX/new-delete.cpp 
b/clang/test/SemaCXX/new-delete.cpp
index 595bdc689d694b..fb4810ad673ad2 100644
--- a/clang/test/SemaCXX/new-delete.cpp
+++ b/clang/test/SemaCXX/new-delete.cpp
@@ -540,6 +540,22 @@ namespace PR10504 {
   void f(A *x) { delete x; } // expected-warning {{delete called on 
'PR10504::A' that is abstract but has non-virtual destructor}}
 }
 
+#if __cplusplus >= 201103L
+enum GH99278_1 {
+zero = decltype(delete static_cast(nullptr), 0){}
+// expected-warning@-1 {{expression with side effects has no effect in an 
unevaluated context}}
+};
+template 
+struct GH99278_2 {
+  union b {};
+  struct c {
+c() { delete d; }
+b *d;
+  } f;
+};
+GH99278_2 e;
+#endif
+
 struct PlacementArg {};
 inline void *operator new[](size_t, const PlacementArg &) throw () {
   return 0;



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


[clang] [Clang] Deleting an incomplete enum type is not an error (PR #119077)

2024-12-09 Thread via cfe-commits

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread via cfe-commits

https://github.com/cor3ntin commented:

LGTM

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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread Timm Baeder via cfe-commits

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

Handle different char widths in builtin_strlen.

>From 1048d45d72c8b44211e245228e97b83b36b1c1b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 8 Dec 2024 19:12:54 +0100
Subject: [PATCH] [clang][bytecode] Handle __builtin_wcslen

Handle different char widths in builtin_strlen.
---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 21 ---
 clang/test/AST/ByteCode/builtin-functions.cpp | 12 +++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 24b630d0455e14..df5b4fcb3f0fbb 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -243,7 +243,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
   unsigned ID = Func->getBuiltinID();
   const Pointer &StrPtr = getParam(Frame, 0);
 
-  if (ID == Builtin::BIstrlen)
+  if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
   if (!CheckArray(S, OpPC, StrPtr))
@@ -256,7 +256,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
-
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
 const Pointer &ElemPtr = StrPtr.atIndex(I);
@@ -264,7 +264,20 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;
+switch (ElemSize) {
+case 1:
+  Val = ElemPtr.deref();
+  break;
+case 2:
+  Val = ElemPtr.deref();
+  break;
+case 4:
+  Val = ElemPtr.deref();
+  break;
+default:
+  llvm_unreachable("Unsupported char size");
+}
 if (Val == 0)
   break;
   }
@@ -1859,6 +1872,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strlen:
   case Builtin::BIstrlen:
+  case Builtin::BI__builtin_wcslen:
+  case Builtin::BIwcslen:
 if (!interp__builtin_strlen(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e2121a54e15768..4c21496d3972c9 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -15,6 +15,10 @@
 #error "huh?"
 #endif
 
+extern "C" {
+  typedef decltype(sizeof(int)) size_t;
+  extern size_t wcslen(const wchar_t *p);
+}
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
   constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
   constexpr int bad = __builtin_strlen(d); // both-error {{constant 
expression}} \
// both-note {{one-past-the-end}}
+
+  constexpr int wn = __builtin_wcslen(L"hello");
+  static_assert(wn == 5);
+  constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
+   // both-note {{non-constexpr function 
'wcslen' cannot be used in a constant expression}}
+
+  int arr[3]; // both-note {{here}}
+  int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
 }
 
 namespace nan {

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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Handle different char widths in builtin_strlen.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+18-3) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+12) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 24b630d0455e14..df5b4fcb3f0fbb 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -243,7 +243,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
   unsigned ID = Func->getBuiltinID();
   const Pointer &StrPtr = getParam(Frame, 0);
 
-  if (ID == Builtin::BIstrlen)
+  if (ID == Builtin::BIstrlen || ID == Builtin::BIwcslen)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
   if (!CheckArray(S, OpPC, StrPtr))
@@ -256,7 +256,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 return false;
 
   assert(StrPtr.getFieldDesc()->isPrimitiveArray());
-
+  unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
   size_t Len = 0;
   for (size_t I = StrPtr.getIndex();; ++I, ++Len) {
 const Pointer &ElemPtr = StrPtr.atIndex(I);
@@ -264,7 +264,20 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
 if (!CheckRange(S, OpPC, ElemPtr, AK_Read))
   return false;
 
-uint8_t Val = ElemPtr.deref();
+uint32_t Val;
+switch (ElemSize) {
+case 1:
+  Val = ElemPtr.deref();
+  break;
+case 2:
+  Val = ElemPtr.deref();
+  break;
+case 4:
+  Val = ElemPtr.deref();
+  break;
+default:
+  llvm_unreachable("Unsupported char size");
+}
 if (Val == 0)
   break;
   }
@@ -1859,6 +1872,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strlen:
   case Builtin::BIstrlen:
+  case Builtin::BI__builtin_wcslen:
+  case Builtin::BIwcslen:
 if (!interp__builtin_strlen(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index e2121a54e15768..4c21496d3972c9 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -15,6 +15,10 @@
 #error "huh?"
 #endif
 
+extern "C" {
+  typedef decltype(sizeof(int)) size_t;
+  extern size_t wcslen(const wchar_t *p);
+}
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -93,6 +97,14 @@ constexpr const char *a = "foo\0quux";
   constexpr char d[] = { 'f', 'o', 'o' }; // no nul terminator.
   constexpr int bad = __builtin_strlen(d); // both-error {{constant 
expression}} \
// both-note {{one-past-the-end}}
+
+  constexpr int wn = __builtin_wcslen(L"hello");
+  static_assert(wn == 5);
+  constexpr int wm = wcslen(L"hello"); // both-error {{constant expression}} \
+   // both-note {{non-constexpr function 
'wcslen' cannot be used in a constant expression}}
+
+  int arr[3]; // both-note {{here}}
+  int wk = arr[wcslen(L"hello")]; // both-warning {{array index 5}}
 }
 
 namespace nan {

``




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


[clang] [clang][bytecode] Handle __builtin_wcslen (PR #119187)

2024-12-09 Thread via cfe-commits

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

LGTM modulo comment

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


[clang] Switch builtin strings to use string tables (PR #118734)

2024-12-09 Thread Chandler Carruth via cfe-commits

chandlerc wrote:

(FYI, I'm about to drop offline -- Hans, if you think it makes sense to revert 
temporarily, please feel free to do so. I don't have a good sense of whether 
the fallout here is enough to warrant that.)

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


[clang] [Clang] allow [[msvc::constexpr]] usage outside the std namespace (PR #119153)

2024-12-09 Thread Richard Dzenis via cfe-commits

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


[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits

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


[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

`DiagsInGroup` is a `map`, we store a dangling 
string_view in the key.

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


1 Files Affected:

- (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+1-1) 


``diff
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 6a4a64a0813063..f7a6807a142490 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -1908,7 +1908,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   for (const Record *G : DiagGroups) {
 bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup);
 auto &GroupInfo =
-DiagsInGroup[std::string(G->getValueAsString("GroupName"))];
+DiagsInGroup[G->getValueAsString("GroupName")];
 bool IsSynonym = GroupInfo.DiagsInGroup.empty() &&
  GroupInfo.SubGroups.size() == 1;
 

``




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


[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/119197

`DiagsInGroup` is a `map`, we store a dangling string_view in 
the key.

>From 85f1d54459125568bfbe2088827040c3b05a7804 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Mon, 9 Dec 2024 11:48:59 +0100
Subject: [PATCH] [clang] Fix a dangling reference in
 clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

`DiagsInGroup` is a `map`, we store a dangling
string_view in the key.
---
 clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp 
b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 6a4a64a0813063..f7a6807a142490 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -1908,7 +1908,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   for (const Record *G : DiagGroups) {
 bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup);
 auto &GroupInfo =
-DiagsInGroup[std::string(G->getValueAsString("GroupName"))];
+DiagsInGroup[G->getValueAsString("GroupName")];
 bool IsSynonym = GroupInfo.DiagsInGroup.empty() &&
  GroupInfo.SubGroups.size() == 1;
 

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


[clang] [clang][bytecode] Reject memcpy sizes with element size remainder (PR #119209)

2024-12-09 Thread Timm Baeder via cfe-commits

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

None

>From 0778f47716355e0916727c0bdb098e1f61b99bd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 9 Dec 2024 14:23:51 +0100
Subject: [PATCH] [clang][bytecode] Reject memcpy sizes with element size
 remainder

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 15 +++
 clang/test/AST/ByteCode/builtin-functions.cpp | 10 ++
 2 files changed, 25 insertions(+)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2469648d68edb1..bd284e3ddd2cb5 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1846,6 +1846,21 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
 return false;
   }
 
+  QualType ElemType;
+  if (SrcPtr.getFieldDesc()->isArray())
+ElemType = SrcPtr.getFieldDesc()->getElemQualType();
+  else
+ElemType = SrcPtr.getType();
+
+  unsigned ElemSize =
+  S.getASTContext().getTypeSizeInChars(ElemType).getQuantity();
+  if (Size.urem(ElemSize) != 0) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_memcpy_unsupported)
+<< Move << /*IsWchar=*/false << 0 << ElemType << Size << ElemSize;
+return false;
+  }
+
   // As a last resort, reject dummy pointers.
   if (DestPtr.isDummy() || SrcPtr.isDummy())
 return false;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 4c21496d3972c9..1e0132b8d9bb75 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1188,4 +1188,14 @@ namespace BuiltinMemcpy {
 return b;
   }
   static_assert(simpleMove() == 12);
+
+  constexpr int memcpyTypeRem() { // ref-error {{never produces a constant 
expression}}
+int a = 12;
+int b = 0;
+__builtin_memmove(&b, &a, 1); // both-note {{'memmove' not supported: size 
to copy (1) is not a multiple of size of element type 'int'}} \
+  // ref-note {{not supported}}
+return b;
+  }
+  static_assert(memcpyTypeRem() == 12); // both-error {{not an integral 
constant expression}} \
+// both-note {{in call to}}
 }

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


[clang] 4f08fa1 - [clang] Fix -Wunused-variable in InterpBuiltin.cpp (NFC)

2024-12-09 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2024-12-09T21:23:08+08:00
New Revision: 4f08fa1a77b7357b4f1455b386ab8ca835e92558

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

LOG: [clang] Fix -Wunused-variable in InterpBuiltin.cpp (NFC)

/llvm-project/clang/lib/AST/ByteCode/InterpBuiltin.cpp:262:23:
error: unused variable 'AC' [-Werror,-Wunused-variable]
const ASTContext &AC = S.getASTContext();
  ^
1 error generated.

Added: 


Modified: 
clang/lib/AST/ByteCode/InterpBuiltin.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2469648d68edb1..f816373c4d3dcc 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -259,7 +259,7 @@ static bool interp__builtin_strlen(InterpState &S, CodePtr 
OpPC,
   unsigned ElemSize = StrPtr.getFieldDesc()->getElemSize();
 
   if (ID == Builtin::BI__builtin_wcslen || ID == Builtin::BIwcslen) {
-const ASTContext &AC = S.getASTContext();
+[[maybe_unused]] const ASTContext &AC = S.getASTContext();
 assert(ElemSize == AC.getTypeSizeInChars(AC.getWCharType()).getQuantity());
   }
 



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


[clang] [clang][bytecode] Handle __builtin_strncmp (PR #119208)

2024-12-09 Thread Timm Baeder via cfe-commits

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

None

>From 9dea6213fc6590b24278dbf8b65e23e97a0810f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 9 Dec 2024 14:13:00 +0100
Subject: [PATCH] [clang][bytecode] Handle __builtin_strncmp

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp  | 20 +--
 clang/test/AST/ByteCode/builtin-functions.cpp |  9 +
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2469648d68edb1..f3cb3f52578e08 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -197,9 +197,19 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr 
OpPC,
   const Pointer &A = getParam(Frame, 0);
   const Pointer &B = getParam(Frame, 1);
 
-  if (ID == Builtin::BIstrcmp)
+  if (ID == Builtin::BIstrcmp || ID == Builtin::BIstrncmp)
 diagnoseNonConstexprBuiltin(S, OpPC, ID);
 
+  uint64_t Limit = ~static_cast(0);
+  if (ID == Builtin::BIstrncmp || ID == Builtin::BI__builtin_strncmp)
+Limit = peekToAPSInt(S.Stk, *S.getContext().classify(Call->getArg(2)))
+.getZExtValue();
+
+  if (Limit == 0) {
+pushInteger(S, 0, Call->getType());
+return true;
+  }
+
   if (!CheckLive(S, OpPC, A, AK_Read) || !CheckLive(S, OpPC, B, AK_Read))
 return false;
 
@@ -212,7 +222,11 @@ static bool interp__builtin_strcmp(InterpState &S, CodePtr 
OpPC,
   unsigned IndexA = A.getIndex();
   unsigned IndexB = B.getIndex();
   int32_t Result = 0;
-  for (;; ++IndexA, ++IndexB) {
+  uint64_t Steps = 0;
+  for (;; ++IndexA, ++IndexB, ++Steps) {
+
+if (Steps >= Limit)
+  break;
 const Pointer &PA = A.atIndex(IndexA);
 const Pointer &PB = B.atIndex(IndexB);
 if (!CheckRange(S, OpPC, PA, AK_Read) ||
@@ -1873,6 +1887,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F,
 break;
   case Builtin::BI__builtin_strcmp:
   case Builtin::BIstrcmp:
+  case Builtin::BI__builtin_strncmp:
+  case Builtin::BIstrncmp:
 if (!interp__builtin_strcmp(S, OpPC, Frame, F, Call))
   return false;
 break;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 4c21496d3972c9..bd453d6d342d3f 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -51,6 +51,15 @@ namespace strcmp {
 return __builtin_strcmp(buffer, "mutable") == 0;
   }
   static_assert(char_memchr_mutable(), "");
+
+  static_assert(__builtin_strncmp("abaa", "abba", 5) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 4) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 3) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 2) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 1) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 0) == 0);
+  static_assert(__builtin_strncmp(0, 0, 0) == 0);
+  static_assert(__builtin_strncmp("abab\0banana", "abab\0canada", 100) == 0);
 }
 
 /// Copied from constant-expression-cxx11.cpp

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


[clang] [clang][bytecode] Reject memcpy sizes with element size remainder (PR #119209)

2024-12-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+15) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+10) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2469648d68edb1..bd284e3ddd2cb5 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1846,6 +1846,21 @@ static bool interp__builtin_memcpy(InterpState &S, 
CodePtr OpPC,
 return false;
   }
 
+  QualType ElemType;
+  if (SrcPtr.getFieldDesc()->isArray())
+ElemType = SrcPtr.getFieldDesc()->getElemQualType();
+  else
+ElemType = SrcPtr.getType();
+
+  unsigned ElemSize =
+  S.getASTContext().getTypeSizeInChars(ElemType).getQuantity();
+  if (Size.urem(ElemSize) != 0) {
+S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_memcpy_unsupported)
+<< Move << /*IsWchar=*/false << 0 << ElemType << Size << ElemSize;
+return false;
+  }
+
   // As a last resort, reject dummy pointers.
   if (DestPtr.isDummy() || SrcPtr.isDummy())
 return false;
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 4c21496d3972c9..1e0132b8d9bb75 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1188,4 +1188,14 @@ namespace BuiltinMemcpy {
 return b;
   }
   static_assert(simpleMove() == 12);
+
+  constexpr int memcpyTypeRem() { // ref-error {{never produces a constant 
expression}}
+int a = 12;
+int b = 0;
+__builtin_memmove(&b, &a, 1); // both-note {{'memmove' not supported: size 
to copy (1) is not a multiple of size of element type 'int'}} \
+  // ref-note {{not supported}}
+return b;
+  }
+  static_assert(memcpyTypeRem() == 12); // both-error {{not an integral 
constant expression}} \
+// both-note {{in call to}}
 }

``




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


[clang] [llvm] Add processor aliases back to -print-supported-cpus and -mcpu=help (PR #118581)

2024-12-09 Thread Tomas Matheson via cfe-commits

https://github.com/tmatheson-arm approved this pull request.

I'm surprised how complicated this was to do, but LGTM.

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


[clang] Fix lld link issue for OHOS (PR #118192)

2024-12-09 Thread Peng Huang via cfe-commits

phuang wrote:

> LGTM

Could you please help merge the PR? I don't see how to do it from my side. 
Thanks.

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


[clang] [clang][bytecode] Handle __builtin_strncmp (PR #119208)

2024-12-09 Thread via cfe-commits

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

LGTM

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


[libclc] [llvm] [polly] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

2024-12-09 Thread Michael Kruse via cfe-commits

Meinersbur wrote:

@tobiasgrosser and me already had talked about this at an LLVM conference. I 
didn't push the maintainer change yet because I am myself somewhat slow with 
reviews, but I think it makes sense.

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


[clang] [clang] Fix a dangling reference in clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (PR #119197)

2024-12-09 Thread Ilya Biryukov via cfe-commits


@@ -1908,7 +1908,7 @@ void clang::EmitClangDiagDocs(const RecordKeeper 
&Records, raw_ostream &OS) {
   for (const Record *G : DiagGroups) {
 bool IsRemarkGroup = isRemarkGroup(G, DiagsInGroup);
 auto &GroupInfo =
-DiagsInGroup[std::string(G->getValueAsString("GroupName"))];

ilya-biryukov wrote:

Maybe replace with `llvm::StringMap` to get better performance and avoid these 
problems for good?
I would be surprised if the `StringRef` in the map is critical for performance 
and I am 99% certain that `StringMap` will likely win over `std::maphttps://github.com/llvm/llvm-project/pull/119197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] [llvm] [llvm] Move sub-project lead maintainers into their own Maintainers.md files (PR #118309)

2024-12-09 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/118309

>From 64bfb1cd1bb7aa9e1597c0212dba7067c9f75d9f Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 2 Dec 2024 15:22:50 +
Subject: [PATCH] [libclc] Add Maintainers.md for libclc

---
 libclc/Maintainers.md | 10 ++
 llvm/Maintainers.md   |  8 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 libclc/Maintainers.md

diff --git a/libclc/Maintainers.md b/libclc/Maintainers.md
new file mode 100644
index 00..314b139b81aaff
--- /dev/null
+++ b/libclc/Maintainers.md
@@ -0,0 +1,10 @@
+# libclc Maintainers
+
+This file is a list of the
+[maintainers](https://llvm.org/docs/DeveloperPolicy.html#maintainers) for
+libclc.
+
+# Lead maintainer
+
+Tom Stellard \
+tstel...@redhat.com (email), [tstellar](https://github.com/tstellar) (GitHub)
\ No newline at end of file
diff --git a/llvm/Maintainers.md b/llvm/Maintainers.md
index 313afa21180fd4..27b69ef98da1f6 100644
--- a/llvm/Maintainers.md
+++ b/llvm/Maintainers.md
@@ -422,7 +422,6 @@ gkistan...@gmail.com (email), 
[gkistanova](https://github.com/gkistanova) (GitHu
 ### Other subprojects
 
 Some subprojects maintain their own list of per-component maintainers.
-Others only have a lead maintainer listed here.
 
 [Bolt 
maintainers](https://github.com/llvm/llvm-project/blob/main/bolt/Maintainers.txt)
 
@@ -436,6 +435,8 @@ Others only have a lead maintainer listed here.
 
 [libc++ 
maintainers](https://github.com/llvm/llvm-project/blob/main/libcxx/Maintainers.md)
 
+[libclc 
maintainers](https://github.com/llvm/llvm-project/blob/main/libclc/Maintainers.md)
+
 [LLD 
maintainers](https://github.com/llvm/llvm-project/blob/main/lld/Maintainers.md)
 
 [LLDB 
maintainers](https://github.com/llvm/llvm-project/blob/main/lldb/Maintainers.rst)
@@ -444,11 +445,6 @@ Others only have a lead maintainer listed here.
 
 [Polly 
maintainers](https://github.com/llvm/llvm-project/blob/main/polly/Maintainers.md)
 
- libclc
-
-Tom Stellard \
-tstel...@redhat.com (email), [tstellar](https://github.com/tstellar) (GitHub)
-
 ## Inactive Maintainers
 
 The following people have graciously spent time performing maintainer

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


[clang] [Clang] Fix handling of immediate escalation for inherited constructors (PR #112860)

2024-12-09 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 54c6a592a078d0a2d484f8a64ac0f1ed47f79e35 
ca10f9df93b987c6684cd2d211e6262258f3b2ae --extensions cpp,h -- 
clang/include/clang/Sema/Sema.h clang/lib/AST/Decl.cpp 
clang/lib/AST/TextNodeDumper.cpp 
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 11a8ec5b56..9e153c8bca 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3285,10 +3285,9 @@ bool FunctionDecl::isImmediateEscalating() const {
 return true;
 
   if (auto *CD = dyn_cast(this);
-  CD && CD->isInheritingConstructor() && CD->getInheritedConstructor()
-.getConstructor()
-->isImmediateEscalating())
-  return true;
+  CD && CD->isInheritingConstructor() &&
+  CD->getInheritedConstructor().getConstructor()->isImmediateEscalating())
+return true;
 
   // - a function that results from the instantiation of a templated entity
   // defined with the constexpr specifier.
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 9055a103bb..34c2de2d71 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -306,8 +306,8 @@ void TextNodeDumper::Visit(const Decl *D) {
   OS << " constexpr";
 if (FD->isConsteval())
   OS << " consteval";
-//else if (FD->isImmediateFunction())
-//  OS << " immediate";
+// else if (FD->isImmediateFunction())
+//   OS << " immediate";
 if (FD->isMultiVersion())
   OS << " multiversion";
   }

``




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


  1   2   3   4   5   >