[clang] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)
@@ -871,13 +871,81 @@ struct FormatStyle { /// void f() { bar(); } /// \endcode SFS_All, +/// Configure merge behavior using AllowShortFunctionsOnASingleLineOptions +SFS_Custom, }; /// Dependent on the value, ``int f() { return 0; }`` can be put on a /// single line. /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; + /// Precise control over merging short functions + /// \code + /// # Should be declared this way: + /// AllowShortFunctionsOnASingleLine: Custom + /// AllowShortFunctionsOnASingleLineOptions: + /// Empty: false + /// Inline: true + /// All: false + /// \endcode + struct ShortFunctionMergeFlags { +/// Only merge empty functions. +/// \code +/// void f() {} +/// void f2() { +/// bar2(); +/// } +/// \endcode +bool Empty; +/// Only merge functions defined inside a class. +/// \code +/// class Foo { +/// void f() { foo(); } +/// }; +/// void f() { +/// foo(); +/// } +/// void f() {} +/// \endcode +bool Inline; +/// Merge all functions fitting on a single line. +/// \code +/// class Foo { +/// void f() { foo(); } +/// }; +/// void f() { bar(); } +/// \endcode +bool All; owenca wrote: ```suggestion bool Other; ``` Below is the equivalence table based on my understanding: | `enum` | `Custom` | | --- | --- | | `SFS_None` | everything set to `false` | | `SFS_InlineOnly` | only `Inline` set to `true` | | `SFS_Empty` | only `Empty` set to `true` | | `SFS_Inline` | both `Inline` and `Empty` set to `true` | | `SFS_All` | everything set to `true` | https://github.com/llvm/llvm-project/pull/134337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)
@@ -871,13 +871,81 @@ struct FormatStyle { /// void f() { bar(); } /// \endcode SFS_All, +/// Configure merge behavior using AllowShortFunctionsOnASingleLineOptions +SFS_Custom, }; /// Dependent on the value, ``int f() { return 0; }`` can be put on a /// single line. /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; + /// Precise control over merging short functions + /// \code + /// # Should be declared this way: + /// AllowShortFunctionsOnASingleLine: Custom + /// AllowShortFunctionsOnASingleLineOptions: + /// Empty: false + /// Inline: true + /// All: false + /// \endcode + struct ShortFunctionMergeFlags { +/// Only merge empty functions. +/// \code +/// void f() {} +/// void f2() { +/// bar2(); +/// } +/// \endcode +bool Empty; +/// Only merge functions defined inside a class. +/// \code +/// class Foo { +/// void f() { foo(); } owenca wrote: ```suggestion /// void f() { foo(); } /// void g() {} ``` https://github.com/llvm/llvm-project/pull/134337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86][AVX10.2] Replace nepbh with bf16 to match with others, NFCI (PR #134240)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-aarch64-sve-vla` running on `linaro-g3-04` while building `clang` at step 7 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/17/builds/7014 Here is the relevant piece of the build log for the reference ``` Step 7 (ninja check 1) failure: stage 1 checked (failure) ... llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/ld64.lld llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/wasm-ld llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/runtimes/runtimes-bins/compiler-rt/test/interception/Unit' contained no tests llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/discovery.py:276: warning: input '/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit' contained no tests llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/ld.lld llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/lld-link llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/ld64.lld llvm-lit: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/bin/wasm-ld -- Testing: 97642 tests, 64 workers -- UNRESOLVED: Flang :: Driver/slp-vectorize.ll (1 of 97642) TEST 'Flang :: Driver/slp-vectorize.ll' FAILED Test has no 'RUN:' line PASS: libFuzzer-aarch64-default-Linux :: deep-recursion.test (2 of 97642) PASS: Clang :: Analysis/PR24184.cpp (3 of 97642) PASS: Clangd :: protocol.test (4 of 97642) PASS: libFuzzer-aarch64-default-Linux :: value-profile-mem.test (5 of 97642) PASS: Clang :: CodeGenCXX/dllimport-members.cpp (6 of 97642) PASS: Clang :: CodeGen/X86/mmx-builtins.c (7 of 97642) PASS: LLVM :: CodeGen/X86/vector-interleaved-load-i8-stride-8.ll (8 of 97642) PASS: Clang :: OpenMP/target_teams_codegen_registration.cpp (9 of 97642) PASS: Clang :: OpenMP/target_parallel_codegen_registration.cpp (10 of 97642) PASS: Clang :: Driver/x86-target-features.c (11 of 97642) PASS: Clang :: CodeGen/X86/avx2-builtins.c (12 of 97642) PASS: LLVM :: CodeGen/ARM/build-attributes.ll (13 of 97642) PASS: ThreadSanitizer-aarch64 :: lots_of_threads.c (14 of 97642) PASS: Clang :: Analysis/runtime-regression.c (15 of 97642) PASS: Clang :: Headers/arm-neon-header.c (16 of 97642) PASS: ThreadSanitizer-aarch64 :: signal_thread.cpp (17 of 97642) PASS: libFuzzer-aarch64-default-Linux :: large.test (18 of 97642) PASS: libFuzzer-aarch64-default-Linux :: swap-cmp.test (19 of 97642) PASS: libFuzzer-aarch64-default-Linux :: msan.test (20 of 97642) PASS: Clang :: Driver/linux-ld.c (21 of 97642) PASS: Clang :: CodeGen/X86/rot-intrinsics.c (22 of 97642) PASS: Clang :: OpenMP/target_teams_distribute_simd_codegen_registration.cpp (23 of 97642) PASS: Clang :: CodeGen/X86/sse2-builtins.c (24 of 97642) PASS: Clang :: CodeGen/X86/avx-builtins.c (25 of 97642) PASS: SanitizerCommon-ubsan-aarch64-Linux :: Linux/signal_segv_handler.cpp (26 of 97642) PASS: Clang :: Preprocessor/predefined-arch-macros.c (27 of 97642) PASS: HWAddressSanitizer-aarch64 :: TestCases/Linux/create-thread-stress.cpp (28 of 97642) PASS: SanitizerCommon-tsan-aarch64-Linux :: Linux/signal_segv_handler.cpp (29 of 97642) PASS: ThreadSanitizer-aarch64 :: deadlock_detector_stress_test.cpp (30 of 97642) PASS: Clang :: Analysis/a_flaky_crash.cpp (31 of 97642) PASS: SanitizerCommon-lsan-aarch64-Linux :: Linux/signal_segv_handler.cpp (32 of 97642) PASS: SanitizerCommon-asan-aarch64-Linux :: Linux/signal_segv_handler.cpp (33 of 97642) PASS: Clang :: Driver/clang_f_opts.c (34 of 97642) PASS: Clang :: OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp (35 of 97642) PASS: Clang :: Preprocessor/aarch64-target-features.c (36 of 97642) PASS: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir (37 of 97642) ``` https://github.com/llvm/llvm-project/pull/134240 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
bassiounix wrote: How do I do the last one, the target support part? https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)
ilya-biryukov wrote: Friendly ping @AaronBallman to take a look. And also add @usx95 to get another pair of eyes and faster review in case Aaron is busy. https://github.com/llvm/llvm-project/pull/132387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Arm] Add more -mtp=cp15 tests (PR #134098)
@@ -1,93 +1,93 @@ -// Test of the AArch32 values of -mtp=, checking that each one maps to -// the right target features. - -// RUN: %clang --target=armv7-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s -// ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=tpidruro -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s -// RUN: %clang --target=armv7-linux -mtp=tpidrurw -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-TPIDRURW %s -// ARMv7_THREAD_POINTER-TPIDRURW: "-target-feature" "+read-tp-tpidrurw" -// RUN: %clang --target=armv7-linux -mtp=tpidrprw -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-TPIDRPRW %s -// ARMv7_THREAD_POINTER-TPIDRPRW: "-target-feature" "+read-tp-tpidrprw" - -// RUN: %clang --target=armv6k-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER-HARD %s -// ARM_THREAD_POINTER-HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6k-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER_AUTO %s -// ARM_THREAD_POINTER_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=thumbv6k-apple-darwin -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_NO_AUTO %s -// THUMBv6_THREAD_POINTER_NO_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=thumbv6k-apple-darwin -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_NO_HARD %s -// THUMBv6_THREAD_POINTER_NO_HARD: unsupported option '-mtp=' for target 'thumbv6k-apple-darwin' - -// RUN: not %clang --target=thumbv6t2-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER_NO_HARD %s -// ARM_THREAD_POINTER_NO_HARD: hardware TLS register is not supported for the armv6t2 sub-architecture - -// RUN: %clang --target=armv5t-linux -mtp=cp15 -x assembler -### %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv5_THREAD_POINTER_ASSEMBLER %s -// ARMv5_THREAD_POINTER_ASSEMBLER-NOT: hardware TLS register is not supported for the armv5 sub-architecture - -// RUN: not %clang --target=armv6-linux -mthumb -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_UNSUPP %s -// RUN: not %clang --target=thumbv6-linux -mthumb -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_UNSUPP %s -// THUMBv6_THREAD_POINTER_UNSUPP: hardware TLS register is not supported for the thumbv6 sub-architecture - -// RUN: %clang --target=armv7-linux -mtp=soft -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_SOFT %s -// ARMv7_THREAD_POINTER_SOFT-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s -// ARMv7_THREAD_POINTER_NON: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_Auto %s -// ARMv7_THREAD_POINTER_Auto: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_HARD %s -// ARMv7_THREAD_POINTER_HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7m-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7m_THREAD_POINTER_Auto %s -// ARMv7m_THREAD_POINTER_Auto-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=armv7m-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7m_THREAD_POINTER_HARD %s -// ARMv7m_THREAD_POINTER_HARD: hardware TLS register is not supported for the thumbv7m sub-architecture - -// RUN: %clang --target=armv5t-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv5t_THREAD_POINTER_Auto %s -// ARMv5t_THREAD_POINTER_Auto-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6k-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6k_THREAD_POINTER_Auto %s -// ARMv6k_THREAD_POINTER_Auto: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=armv6t2-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6t2_THREAD_POINTER_HARD %s -// ARMv6t2_THREAD_POINTER_HARD: hardware TLS register is not supported for the armv6t2 sub-architecture - -// RUN: %clang --target=armv6t2-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMV6t2_THREAD_POINTER_AUTO %s -// ARMV6t2_THREAD_POINTER_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6kz-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6kz_THREAD_POINTER_HARD %s -// ARMv6kz_THREAD_POINTER_HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target
[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)
carlosgalvezp wrote: In general, I don't fully understand the scope of this patch. Surely, there's thousands of things that could be improved in the codebase. Which of those belong to this patch? Reviewers can always point out things that could be improved ad infinitum, leading to a patch with lots of unrelated changes. When do we decide that we are done? https://github.com/llvm/llvm-project/pull/134138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
https://github.com/Lukacma updated https://github.com/llvm/llvm-project/pull/128019 >From c331c4c260b6432b6ae96723f78c16b189e9297a Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Thu, 20 Feb 2025 15:35:45 + Subject: [PATCH] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics This patch adds fp8 variants to existing intrinsics, whose operation doesn't depend on arguments being a specific type. --- clang/include/clang/Basic/arm_neon.td | 74 +- clang/lib/AST/Type.cpp|5 + clang/lib/CodeGen/CGCall.cpp |9 + clang/lib/CodeGen/TargetBuiltins/ARM.cpp | 20 + clang/lib/Sema/SemaInit.cpp |2 + .../fp8-intrinsics/acle_neon_fp8_untyped.c| 1114 + 6 files changed, 1220 insertions(+), 4 deletions(-) create mode 100644 clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_untyped.c diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index ab0051efe5159..90f0e90e4a7f8 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -2090,17 +2090,17 @@ let ArchGuard = "defined(__aarch64__) || defined(__arm64ec__)", TargetGuard = "r // Lookup table read with 2-bit/4-bit indices let ArchGuard = "defined(__aarch64__)", TargetGuard = "lut" in { - def VLUTI2_B: SInst<"vluti2_lane", "Q.(qU)I", "cUcPcQcQUcQPc", + def VLUTI2_B: SInst<"vluti2_lane", "Q.(qU)I", "cUcPcmQcQUcQPcQm", [ImmCheck<2, ImmCheck0_1>]>; - def VLUTI2_B_Q : SInst<"vluti2_laneq", "Q.(QU)I", "cUcPcQcQUcQPc", + def VLUTI2_B_Q : SInst<"vluti2_laneq", "Q.(QU)I", "cUcPcmQcQUcQPcQm", [ImmCheck<2, ImmCheck0_3>]>; def VLUTI2_H: SInst<"vluti2_lane", "Q.(]>; def VLUTI2_H_Q : SInst<"vluti2_laneq", "Q.(]>; - def VLUTI4_B: SInst<"vluti4_lane", "..(qU)I", "QcQUcQPc", + def VLUTI4_B: SInst<"vluti4_lane", "..(qU)I", "QcQUcQPcQm", [ImmCheck<2, ImmCheck0_0>]>; - def VLUTI4_B_Q : SInst<"vluti4_laneq", "..UI", "QcQUcQPc", + def VLUTI4_B_Q : SInst<"vluti4_laneq", "..UI", "QcQUcQPcQm", [ImmCheck<2, ImmCheck0_1>]>; def VLUTI4_H_X2 : SInst<"vluti4_lane_x2", ".2(]>; @@ -2194,4 +2194,70 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = "fp8,neon" in { // fscale def FSCALE_V128 : WInst<"vscale", "..(.S)", "QdQfQh">; def FSCALE_V64 : WInst<"vscale", "(.q)(.q)(.qS)", "fh">; +} + +//FP8 versions of untyped intrinsics +let ArchGuard = "defined(__aarch64__)" in { + def VGET_LANE_MF8 : IInst<"vget_lane", "1.I", "mQm", [ImmCheck<1, ImmCheckLaneIndex, 0>]>; + def SPLAT_MF8 : WInst<"splat_lane", ".(!q)I", "mQm", [ImmCheck<1, ImmCheckLaneIndex, 0>]>; + def SPLATQ_MF8 : WInst<"splat_laneq", ".(!Q)I", "mQm", [ImmCheck<1, ImmCheckLaneIndex, 0>]>; + def VSET_LANE_MF8 : IInst<"vset_lane", ".1.I", "mQm", [ImmCheck<2, ImmCheckLaneIndex, 1>]>; + def VCREATE_MF8 : NoTestOpInst<"vcreate", ".(IU>)", "m", OP_CAST> { let BigEndianSafe = 1; } + let InstName = "vmov" in { +def VDUP_N_MF8 : WOpInst<"vdup_n", ".1", "mQm", OP_DUP>; +def VMOV_N_MF8 : WOpInst<"vmov_n", ".1", "mQm", OP_DUP>; + } + let InstName = "" in +def VDUP_LANE_MF8: WOpInst<"vdup_lane", ".qI", "mQm", OP_DUP_LN>; + def VCOMBINE_MF8 : NoTestOpInst<"vcombine", "Q..", "m", OP_CONC>; + let InstName = "vmov" in { +def VGET_HIGH_MF8 : NoTestOpInst<"vget_high", ".Q", "m", OP_HI>; +def VGET_LOW_MF8 : NoTestOpInst<"vget_low", ".Q", "m", OP_LO>; + } + let InstName = "vtbl" in { +def VTBL1_MF8 : WInst<"vtbl1", "..p", "m">; +def VTBL2_MF8 : WInst<"vtbl2", ".2p", "m">; +def VTBL3_MF8 : WInst<"vtbl3", ".3p", "m">; +def VTBL4_MF8 : WInst<"vtbl4", ".4p", "m">; + } + let InstName = "vtbx" in { +def VTBX1_MF8 : WInst<"vtbx1", "...p", "m">; +def VTBX2_MF8 : WInst<"vtbx2", "..2p", "m">; +def VTBX3_MF8 : WInst<"vtbx3", "..3p", "m">; +def VTBX4_MF8 : WInst<"vtbx4", "..4p", "m">; + } + def VEXT_MF8 : WInst<"vext", "...I", "mQm", [ImmCheck<2, ImmCheckLaneIndex, 0>]>; + def VREV64_MF8 : WOpInst<"vrev64", "..", "mQm", OP_REV64>; + def VREV32_MF8 : WOpInst<"vrev32", "..", "mQm", OP_REV32>; + def VREV16_MF8 : WOpInst<"vrev16", "..", "mQm", OP_REV16>; + let isHiddenLInst = 1 in + def VBSL_MF8 : SInst<"vbsl", ".U..", "mQm">; + def VTRN_MF8 : WInst<"vtrn", "2..", "mQm">; + def VZIP_MF8 : WInst<"vzip", "2..", "mQm">; + def VUZP_MF8 : WInst<"vuzp", "2..", "mQm">; + def COPY_LANE_MF8 : IOpInst<"vcopy_lane", "..I.I", "m", OP_COPY_LN>; + def COPYQ_LANE_MF8 : IOpInst<"vcopy_lane", "..IqI", "Qm", OP_COPY_LN>; + def COPY_LANEQ_MF8 : IOpInst<"vcopy_laneq", "..IQI", "m", OP_COPY_LN>; + def COPYQ_LANEQ_MF8 : IOpInst<"vcopy_laneq", "..I.I", "Qm", OP_COPY_LN>; + def VDUP_LANE2_MF8 : WOpInst<"vdup_laneq", ".QI", "mQm", OP_DUP_LN>; + def VTRN1_MF8 : SOpInst<"vtrn1", "...", "mQm", OP_TRN1>; + def VZIP1_MF8 : SOpInst<"vzip1", "...", "mQ
[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)
@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext &Context, llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false); LowerValue.setBit(PrecisionBits); LowerValue.setSignBit(); -return {LowerValue, UpperValue}; +return {std::move(LowerValue), UpperValue}; carlosgalvezp wrote: What tool did you use to get that error message? I do not see the point of this change, please revert. We must not blindly do what tools tell us, we must critically think if they make sense or not. https://github.com/llvm/llvm-project/pull/134138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
overmighty wrote: You could have multiple `// RUN:` lines with different targets and macro definitions. For example: ```cpp // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple x86_64 -DSUPPORTED %s // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple armv7 %s // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple armv7 -target-feature +bf16 -DSUPPORTED %s ``` Then you can guard the test cases with `#ifdef SUPPORTED`/`#ifndef SUPPORTED`. Also, the test will currently fail if testing a Clang build with a default target triple that doesn't support bfloat16. https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
@@ -978,6 +979,24 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': // FP Suffix for "__bf16" +case 'B': + if (!Target.hasBFloat16Type()) +break; + if (!isFPConstant) +break; // Error for integer constant. + if (HasSize) +break; + HasSize = true; + + if ((Target.hasBFloat16Type()) && s + 3 < ThisTokEnd && overmighty wrote: We already have `if (!Target.hasBFloat16Type()) break;` above. ```suggestion ``` https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)
https://github.com/carlosgalvezp approved this pull request. https://github.com/llvm/llvm-project/pull/134138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
@@ -2878,7 +2878,7 @@ class CXXDestructorDecl : public CXXMethodDecl { static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID); void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg); - void setOperatorArrayDelete(FunctionDecl *OD, Expr *ThisArg); + void setOperatorArrayDelete(FunctionDecl *OD); Fznamznon wrote: Should I do that in a separate commit? https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
AaronBallman wrote: > > LGTM but do we need a release note? > > No, it is a fix for a regression caused by a patch committed a couple of days > ago. Excellent, thank you for confirming! LG as-is https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
https://github.com/AaronBallman approved this pull request. LGTM but do we need a release note? https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
@@ -2878,7 +2878,7 @@ class CXXDestructorDecl : public CXXMethodDecl { static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID); void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg); - void setOperatorArrayDelete(FunctionDecl *OD, Expr *ThisArg); + void setOperatorArrayDelete(FunctionDecl *OD); AaronBallman wrote: This looks like unrelated changes, but the changes themselves are correct. https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)
https://github.com/zahiraam closed https://github.com/llvm/llvm-project/pull/134138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AArch64] Remove strict checks from init-aarch64.c (PR #134338)
SpencerAbson wrote: Agree with @arsenm. If you'd rather not `XFAIL` (or equivalent) this file in your downstream CI, perhaps you could have it autogenerated. A colleague of mine once wrote a script to do something similar https://github.com/llvm/llvm-project/pull/97829#issuecomment-2213535663, maybe you could repeat this for `-E -dM`. https://github.com/llvm/llvm-project/pull/134338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][doc]: Merge the contents of identical entries. (PR #134089)
YLChenZ wrote: > Oh yeah, that is not a good outcome. :-) I think Undocumented is a special > case. For this patch, I would not merge if the category is Undocumented. @AaronBallman Oh, I forgot the other merged entry that is slightly smaller compared to `Undocumented` like this:   Similarly, it doesn't look very pretty. https://github.com/llvm/llvm-project/pull/134089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 547d054 - [clang-tidy][NFC][doc] improve "options" sections of `misc-`, `cppcore-` and other checks (#133694)
Author: Baranov Victor Date: 2025-04-04T14:21:48+02:00 New Revision: 547d054ef13c2ca5ec42f7061d8ba941c05605d9 URL: https://github.com/llvm/llvm-project/commit/547d054ef13c2ca5ec42f7061d8ba941c05605d9 DIFF: https://github.com/llvm/llvm-project/commit/547d054ef13c2ca5ec42f7061d8ba941c05605d9.diff LOG: [clang-tidy][NFC][doc] improve "options" sections of `misc-`, `cppcore-` and other checks (#133694) Improved "options" sections of various checks: 1. Added Options keyword to be a delimiter between "body" and "options" parts of docs 2. Added default values where were absent. 3. Changed double-tick to single-tick in default values. - Co-authored-by: EugeneZelenko Added: Modified: clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-bounds-constant-array-index.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-type-member-init.rst clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst clang-tools-extra/docs/clang-tidy/checks/misc/include-cleaner.rst clang-tools-extra/docs/clang-tidy/checks/misc/non-private-member-variables-in-classes.rst clang-tools-extra/docs/clang-tidy/checks/readability/container-data-pointer.rst clang-tools-extra/docs/clang-tidy/checks/readability/container-size-empty.rst clang-tools-extra/docs/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.rst clang-tools-extra/docs/clang-tidy/checks/readability/redundant-inline-specifier.rst clang-tools-extra/docs/clang-tidy/checks/readability/redundant-smartptr-get.rst Removed: diff --git a/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst b/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst index 93112ee2bea64..31cc72b0579c4 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/android/comparison-in-temp-failure-retry.rst @@ -41,3 +41,4 @@ Options .. option:: RetryMacros A comma-separated list of the names of retry macros to be checked. + Default is `TEMP_FAILURE_RETRY`. diff --git a/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst b/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst index 1e0e34efe0a58..99e550aef0e7a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/cert/msc51-cpp.rst @@ -37,4 +37,4 @@ Options .. option:: DisallowedSeedTypes A comma-separated list of the type names which are disallowed. - Default values are ``time_t``, ``std::time_t``. + Default value is `time_t,std::time_t`. diff --git a/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst b/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst index 4e46ba1edc34f..337be787d962b 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/concurrency/mt-unsafe.rst @@ -32,6 +32,9 @@ Examples: sleep(1); // implementation may use SIGALRM +Options +--- + .. option:: FunctionSet Specifies which functions in libc should be considered thread-safe, diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst index 237520aa6690a..e3a162078a3b8 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-malloc.rst @@ -35,14 +35,14 @@ Options .. option:: Allocations Semicolon-separated list of fully qualified names of memory allocation functions. - Defaults to ``::malloc;::calloc``. + Defaults to `::malloc;::calloc`. .. option:: Deallocations Semicolon-separated list of fully qualified names of memory allocation functions. - Defaults to ``::free``. + Defaults to `::free`. .. option:: Reallocations Semicolon-separated list of fully qualified names of memory allocation functions. - Defaults to ``::realloc``. + Defaults to `::realloc`. diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst index 3c91d09dda1f2..4fc49f8bd6eee 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/owning-memory.rst +++ b/clang-tools-extra/docs/clang-tidy/ch
[clang-tools-extra] [clang-tidy][NFC][doc] improve "options" sections of `misc-`, `cppcore-` and other checks (PR #133694)
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/133694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][doc]: Merge the contents of identical entries. (PR #134089)
AaronBallman wrote: > > Oh yeah, that is not a good outcome. :-) I think Undocumented is a special > > case. For this patch, I would not merge if the category is Undocumented. > > @AaronBallman Oh, I forgot the other merged entry that is slightly smaller > compared to `Undocumented` like this: > >  > >  > > Similarly, it doesn't look very pretty. > > Oh yeah, that is not a good outcome. :-) I think Undocumented is a special > > case. For this patch, I would not merge if the category is Undocumented. > > @AaronBallman Oh, I forgot the other merged entry that is slightly smaller > compared to `Undocumented` like this: > >  > >  > > Similarly, it doesn't look very pretty. CC @erichkeane for opinions, but I think this is... ugly-but-reasonable. Ideally, I'd like to see those split off (cf in one group, ns in another, etc) with different documentation given that these are presumably doing different things. But as it stands, I think this is better than repeating the same information 15 times. https://github.com/llvm/llvm-project/pull/134089 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)
https://github.com/skatrak approved this pull request. Thanks, LGTM! https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
@@ -2878,7 +2878,7 @@ class CXXDestructorDecl : public CXXMethodDecl { static CXXDestructorDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID); void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg); - void setOperatorArrayDelete(FunctionDecl *OD, Expr *ThisArg); + void setOperatorArrayDelete(FunctionDecl *OD); AaronBallman wrote: No, I think it's related enough as a drive-by it's fine. https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
Fznamznon wrote: > LGTM but do we need a release note? No, it is a regression caused by a patch committed a couple of days ago. https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Arm] Add more -mtp=cp15 tests (PR #134098)
@@ -1,93 +1,93 @@ -// Test of the AArch32 values of -mtp=, checking that each one maps to -// the right target features. - -// RUN: %clang --target=armv7-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s -// ARMv7_THREAD_POINTER-HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=tpidruro -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-HARD %s -// RUN: %clang --target=armv7-linux -mtp=tpidrurw -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-TPIDRURW %s -// ARMv7_THREAD_POINTER-TPIDRURW: "-target-feature" "+read-tp-tpidrurw" -// RUN: %clang --target=armv7-linux -mtp=tpidrprw -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER-TPIDRPRW %s -// ARMv7_THREAD_POINTER-TPIDRPRW: "-target-feature" "+read-tp-tpidrprw" - -// RUN: %clang --target=armv6k-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER-HARD %s -// ARM_THREAD_POINTER-HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6k-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER_AUTO %s -// ARM_THREAD_POINTER_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=thumbv6k-apple-darwin -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_NO_AUTO %s -// THUMBv6_THREAD_POINTER_NO_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=thumbv6k-apple-darwin -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_NO_HARD %s -// THUMBv6_THREAD_POINTER_NO_HARD: unsupported option '-mtp=' for target 'thumbv6k-apple-darwin' - -// RUN: not %clang --target=thumbv6t2-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARM_THREAD_POINTER_NO_HARD %s -// ARM_THREAD_POINTER_NO_HARD: hardware TLS register is not supported for the armv6t2 sub-architecture - -// RUN: %clang --target=armv5t-linux -mtp=cp15 -x assembler -### %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv5_THREAD_POINTER_ASSEMBLER %s -// ARMv5_THREAD_POINTER_ASSEMBLER-NOT: hardware TLS register is not supported for the armv5 sub-architecture - -// RUN: not %clang --target=armv6-linux -mthumb -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_UNSUPP %s -// RUN: not %clang --target=thumbv6-linux -mthumb -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=THUMBv6_THREAD_POINTER_UNSUPP %s -// THUMBv6_THREAD_POINTER_UNSUPP: hardware TLS register is not supported for the thumbv6 sub-architecture - -// RUN: %clang --target=armv7-linux -mtp=soft -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_SOFT %s -// ARMv7_THREAD_POINTER_SOFT-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s -// ARMv7_THREAD_POINTER_NON: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_Auto %s -// ARMv7_THREAD_POINTER_Auto: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_HARD %s -// ARMv7_THREAD_POINTER_HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv7m-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7m_THREAD_POINTER_Auto %s -// ARMv7m_THREAD_POINTER_Auto-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=armv7m-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv7m_THREAD_POINTER_HARD %s -// ARMv7m_THREAD_POINTER_HARD: hardware TLS register is not supported for the thumbv7m sub-architecture - -// RUN: %clang --target=armv5t-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv5t_THREAD_POINTER_Auto %s -// ARMv5t_THREAD_POINTER_Auto-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6k-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6k_THREAD_POINTER_Auto %s -// ARMv6k_THREAD_POINTER_Auto: "-target-feature" "+read-tp-tpidruro" - -// RUN: not %clang --target=armv6t2-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6t2_THREAD_POINTER_HARD %s -// ARMv6t2_THREAD_POINTER_HARD: hardware TLS register is not supported for the armv6t2 sub-architecture - -// RUN: %clang --target=armv6t2-linux -mtp=auto -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMV6t2_THREAD_POINTER_AUTO %s -// ARMV6t2_THREAD_POINTER_AUTO-NOT: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target=armv6kz-linux -mtp=cp15 -### -S %s 2>&1 | \ -// RUN: FileCheck -check-prefix=ARMv6kz_THREAD_POINTER_HARD %s -// ARMv6kz_THREAD_POINTER_HARD: "-target-feature" "+read-tp-tpidruro" - -// RUN: %clang --target
[clang] d02786e - [Sema] Handle AttributedType in template deduction with derived-to-base conversions (#134361)
Author: Ilya Biryukov Date: 2025-04-04T14:23:55+02:00 New Revision: d02786e7785ffa8c0aae4d89e9f6391bb4645500 URL: https://github.com/llvm/llvm-project/commit/d02786e7785ffa8c0aae4d89e9f6391bb4645500 DIFF: https://github.com/llvm/llvm-project/commit/d02786e7785ffa8c0aae4d89e9f6391bb4645500.diff LOG: [Sema] Handle AttributedType in template deduction with derived-to-base conversions (#134361) Fix #134356. We accidentally skipped checking derived-to-base conversions because deduction did not strip sugar in the relevant code. This caused deduction failures when a parameter type had an attribute. Added: clang/test/Sema/nullability-and-template-deduction.cpp Modified: clang/lib/Sema/SemaTemplateDeduction.cpp Removed: diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index ab6e18aee7206..170b9f05002b1 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4447,7 +4447,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( // transformed A can be a pointer to a derived class pointed to by // the deduced A. if (isSimpleTemplateIdType(ParamType) || - (isa(ParamType) && + (ParamType->getAs() && isSimpleTemplateIdType( ParamType->castAs()->getPointeeType( TDF |= TDF_DerivedClass; diff --git a/clang/test/Sema/nullability-and-template-deduction.cpp b/clang/test/Sema/nullability-and-template-deduction.cpp new file mode 100644 index 0..3ea6d38d26b69 --- /dev/null +++ b/clang/test/Sema/nullability-and-template-deduction.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify +// expected-no-diagnostics + +template struct Base {}; +template struct Derived : Base {}; + +template void foo(Base *_Nonnull); + +template void bar(Base *); + + +void test() { +Derived d; +foo(&d); +bar(&d); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler (PR #134366)
https://github.com/DavidSpickett commented: I see that this would be breaking for code unintentionally relying on the features being omitted, but it makes sense to fix it nevertheless. I would have expected us to add the features all along. What does gcc/binutils do in this scenario? I don't think it would change the decision here, but curious anyway. https://github.com/llvm/llvm-project/pull/134366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler (PR #134366)
@@ -38,6 +38,9 @@ Potentially Breaking Changes - Fix missing diagnostics for uses of declarations when performing typename access, such as when performing member access on a '[[deprecated]]' type alias. (#GH58547) +- For ARM targets, when using cc1as, the features included in the selected CPU or + Arch's FPU are now loaded and utilized. If you wish not to use a specific feature, + this will need appending to the command line used. DavidSpickett wrote: "Arch's" -> "Architecture's" > this will need appending to the command line used. "this" seems to refer to "specific feature" but what you'd want to append is the option to disable that feature. Perhaps instead: "If you wish not to use a specific feature, an option to disable it will need appending to the command line used." And we assume folks know, or can find out, that "+no..." is probably what they want. https://github.com/llvm/llvm-project/pull/134366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)
dtcxzyw wrote: > Usually we'd want to also insert `-fsanitize=pointer-overflow` > instrumentation in places where we respect `-fwrapv-pointer`. I'm not > entirely sure whether we want to do this here, as it will probably blow up > the amount of inserted instrumentation for little benefit... A struct GEP is unlikely to overflow. But a null check should be useful. https://github.com/llvm/llvm-project/pull/134269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM][Clang] Make `+nosimd` functional for AArch32 Targets (PR #130623)
@@ -0,0 +1,31 @@ +// Ensures that when targeting an ARM target with an Asm file, clang +// collects the features from the FPU. This is critical in the +// activation of NEON for supported targets. The Cortex-R52 will be +// used and tested for VFP and NEON Support + +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | count 0 mstorsjo wrote: This requires a `// REQUIRES: arm-registered-target` (like `armv8.1.m.main.s` has), as this actually does try to compile the code. Actually compiling code in Clang driver tests would ideally not be done (we should ideally only inspect the generated command lines), but we do seem to have some precedent for it already in `armv8.1.m.main.s`, and especially for the implicit behaviours that aren't necessarily visible in the command line, I guess there's no other good alternative. So I guess this kind of test is fine, but add the `REQUIRES` line. https://github.com/llvm/llvm-project/pull/130623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/11] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/11] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler (PR #134366)
mstorsjo wrote: This is a smaller, self-isolated change split out from #130623 - in order to fix a regression from 8fa0f0efce5fb81eb422e6d7eec74c66dafef4a3 as noted by @anemet in https://github.com/llvm/llvm-project/pull/122095#discussion_r2027399582; in a form that hopefully can be considered for backporting to 20.x. https://github.com/llvm/llvm-project/pull/134366 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler (PR #134366)
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/134366 Previously, FPU features were not collected when forming a list of features for the Assembler. This fixes a regression from 8fa0f0efce5fb81eb422e6d7eec74c66dafef4a3, which caused VFPv4 to be unavailable if assembling for an armv7s-apple-darwin target. From 6d04e18124344a81a699db618e401e707411d020 Mon Sep 17 00:00:00 2001 From: Jack Styles Date: Fri, 7 Mar 2025 15:49:00 + Subject: [PATCH] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, FPU features were not collected when forming a list of features for the Assembler. This fixes a regression from 8fa0f0efce5fb81eb422e6d7eec74c66dafef4a3, which caused VFPv4 to be unavailable if assembling for an armv7s-apple-darwin target. Co-authored-by: Martin Storsjö --- clang/docs/ReleaseNotes.rst | 4 ++ clang/lib/Driver/ToolChains/Arch/ARM.cpp | 17 clang/test/Driver/arm-fpu-selection.s| 32 +++ clang/test/Driver/armv7-default-neon.s | 8 clang/test/Driver/armv7s-default-vfpv4.s | 6 +++ clang/test/Driver/armv8.1m.main.s| 51 6 files changed, 92 insertions(+), 26 deletions(-) create mode 100644 clang/test/Driver/arm-fpu-selection.s create mode 100644 clang/test/Driver/armv7-default-neon.s create mode 100644 clang/test/Driver/armv7s-default-vfpv4.s diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c4e82678949ff..2267f0d06e834 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -38,6 +38,9 @@ Potentially Breaking Changes - Fix missing diagnostics for uses of declarations when performing typename access, such as when performing member access on a '[[deprecated]]' type alias. (#GH58547) +- For ARM targets, when using cc1as, the features included in the selected CPU or + Arch's FPU are now loaded and utilized. If you wish not to use a specific feature, + this will need appending to the command line used. C/C++ Language Potentially Breaking Changes --- @@ -440,6 +443,7 @@ X86 Support Arm and AArch64 Support ^^^ +- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Arch. Android Support ^^^ diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index e50cb3836f2c9..ff0e52aa285b1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -679,20 +679,17 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : ArchArgFPUKind; (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } else { -bool Generic = true; -if (!ForAS) { - std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); - if (CPU != "generic") -Generic = false; - llvm::ARM::ArchKind ArchKind = - arm::getLLVMArchKindForARM(CPU, ArchName, Triple); - FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind); - (void)llvm::ARM::getFPUFeatures(FPUKind, Features); -} +std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); +bool Generic = CPU == "generic"; if (Generic && (Triple.isOSWindows() || Triple.isOSDarwin()) && getARMSubArchVersionNumber(Triple) >= 7) { FPUKind = llvm::ARM::parseFPU("neon"); (void)llvm::ARM::getFPUFeatures(FPUKind, Features); +} else { + llvm::ARM::ArchKind ArchKind = + arm::getLLVMArchKindForARM(CPU, ArchName, Triple); + FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind); + (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } } diff --git a/clang/test/Driver/arm-fpu-selection.s b/clang/test/Driver/arm-fpu-selection.s new file mode 100644 index 0..c40e0f5b25852 --- /dev/null +++ b/clang/test/Driver/arm-fpu-selection.s @@ -0,0 +1,32 @@ +// REQUIRES: arm-registered-target +// Ensures that when targeting an ARM target with an Asm file, clang +// collects the features from the FPU. This is critical in the +// activation of NEON for supported targets. The Cortex-R52 will be +// used and tested for VFP and NEON Support + +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | count 0 +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null -### 2>&1 | FileCheck --check-prefix=CHECK-TARGET-FEATURES %s + +// Check that NEON and VFPV5 have been activated when using Cortex-R52 when using cc1as +// CHECK-TARGET-FEATURES: "-target-feature" "+vfp2sp" +// CHECK-TARGET-FEATURES: "-target-feature" "+vfp3" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8d16" +// CHECK-TARGET-FEATURES: "-target-feature" "+
[clang] [Clang] [ARM] Ensure FPU Features are collected when using the Clang Assembler (PR #134366)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Martin Storsjö (mstorsjo) Changes Previously, FPU features were not collected when forming a list of features for the Assembler. This fixes a regression from 8fa0f0efce5fb81eb422e6d7eec74c66dafef4a3, which caused VFPv4 to be unavailable if assembling for an armv7s-apple-darwin target. --- Full diff: https://github.com/llvm/llvm-project/pull/134366.diff 6 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+4) - (modified) clang/lib/Driver/ToolChains/Arch/ARM.cpp (+7-10) - (added) clang/test/Driver/arm-fpu-selection.s (+32) - (added) clang/test/Driver/armv7-default-neon.s (+8) - (added) clang/test/Driver/armv7s-default-vfpv4.s (+6) - (modified) clang/test/Driver/armv8.1m.main.s (+35-16) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c4e82678949ff..2267f0d06e834 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -38,6 +38,9 @@ Potentially Breaking Changes - Fix missing diagnostics for uses of declarations when performing typename access, such as when performing member access on a '[[deprecated]]' type alias. (#GH58547) +- For ARM targets, when using cc1as, the features included in the selected CPU or + Arch's FPU are now loaded and utilized. If you wish not to use a specific feature, + this will need appending to the command line used. C/C++ Language Potentially Breaking Changes --- @@ -440,6 +443,7 @@ X86 Support Arm and AArch64 Support ^^^ +- For ARM targets, cc1as now considers the FPU's features for the selected CPU or Arch. Android Support ^^^ diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index e50cb3836f2c9..ff0e52aa285b1 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -679,20 +679,17 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : ArchArgFPUKind; (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } else { -bool Generic = true; -if (!ForAS) { - std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); - if (CPU != "generic") -Generic = false; - llvm::ARM::ArchKind ArchKind = - arm::getLLVMArchKindForARM(CPU, ArchName, Triple); - FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind); - (void)llvm::ARM::getFPUFeatures(FPUKind, Features); -} +std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); +bool Generic = CPU == "generic"; if (Generic && (Triple.isOSWindows() || Triple.isOSDarwin()) && getARMSubArchVersionNumber(Triple) >= 7) { FPUKind = llvm::ARM::parseFPU("neon"); (void)llvm::ARM::getFPUFeatures(FPUKind, Features); +} else { + llvm::ARM::ArchKind ArchKind = + arm::getLLVMArchKindForARM(CPU, ArchName, Triple); + FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind); + (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } } diff --git a/clang/test/Driver/arm-fpu-selection.s b/clang/test/Driver/arm-fpu-selection.s new file mode 100644 index 0..c40e0f5b25852 --- /dev/null +++ b/clang/test/Driver/arm-fpu-selection.s @@ -0,0 +1,32 @@ +// REQUIRES: arm-registered-target +// Ensures that when targeting an ARM target with an Asm file, clang +// collects the features from the FPU. This is critical in the +// activation of NEON for supported targets. The Cortex-R52 will be +// used and tested for VFP and NEON Support + +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | count 0 +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null -### 2>&1 | FileCheck --check-prefix=CHECK-TARGET-FEATURES %s + +// Check that NEON and VFPV5 have been activated when using Cortex-R52 when using cc1as +// CHECK-TARGET-FEATURES: "-target-feature" "+vfp2sp" +// CHECK-TARGET-FEATURES: "-target-feature" "+vfp3" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8d16" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8d16sp" +// CHECK-TARGET-FEATURES: "-target-feature" "+fp-armv8sp" +// CHECK-TARGET-FEATURES: "-target-feature" "+neon" + + vadd.f32 s0, s1, s2 + vadd.f64 d0, d1, d2 + vcvt.u32.f32 s0, s0, #1 + vcvt.u32.f64 d0, d0, #1 + vcvtb.f32.f16 s0, s1 + vcvtb.f64.f16 d0, s1 + vfma.f32 s0, s1, s2 + vfma.f64 d0, d1, d2 + vcvta.u32.f32 s0, s1 + vcvta.u32.f64 s0, d1 + vadd.f32 q0, q1, q2 + vcvt.f32.f16 q0, d1 + vfma.f32 q0, q1, q2 + vcvta.u32.f32 q0, q1 diff --git a/clang/test/Driver/armv7-default-neon.s b/clang/test/Driver/armv7-default-neon.s new file mode 100644 index 0..1b72cd65590bf --- /dev/null +++ b/clang/test/Driver/armv7-default-neon.s @@ -0,0 +1,8 @@ +// Ensure that we can assemble NEON by just
[clang] [llvm] [AARCH64] Add FEAT_SSVE_FEXPA and fix unsupported features list (PR #134368)
https://github.com/Lukacma created https://github.com/llvm/llvm-project/pull/134368 This patch adds new feature introduced in [2025-03 release](https://developer.arm.com/documentation/ddi0602/2025-03/SVE-Instructions/FEXPA--Floating-point-exponential-accelerator-) and changes feature requirements for fexpa instructions and intrinsics. Additionally it fixes unsupported features list by moving fearures dependent on sme2p1 to correct location. >From c1d652f7bb3f6ff272eca6dabc762b9504d7126a Mon Sep 17 00:00:00 2001 From: Marian Lukac Date: Fri, 4 Apr 2025 11:18:23 + Subject: [PATCH] [AARCH64] Add support for FEAT_SSVE_FEXPA extension and update fix unsopported features list --- clang/include/clang/Basic/arm_sve.td | 6 -- .../CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c | 14 +++--- .../Driver/print-supported-extensions-aarch64.c| 1 + llvm/lib/Target/AArch64/AArch64.td | 5 ++--- llvm/lib/Target/AArch64/AArch64Features.td | 4 +++- llvm/lib/Target/AArch64/AArch64InstrInfo.td| 4 llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td | 2 +- llvm/test/CodeGen/AArch64/sve-intrinsics-fexpa.ll | 2 +- llvm/test/MC/AArch64/SVE/fexpa.s | 8 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 35263541b67ae..f09f40ce9202e 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -836,9 +836,11 @@ defm SVRINTP : SInstZPZ<"svrintp", "hfd", "aarch64_sve_frintp">; defm SVRINTX : SInstZPZ<"svrintx", "hfd", "aarch64_sve_frintx">; defm SVRINTZ : SInstZPZ<"svrintz", "hfd", "aarch64_sve_frintz">; defm SVSQRT : SInstZPZ<"svsqrt", "hfd", "aarch64_sve_fsqrt">; - +def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x", [VerifyRuntimeMode]>{ + let SVETargetGuard = "sve"; + let SMETargetGuard = "sme2,ssve-fexpa"; +} let SVETargetGuard = "sve", SMETargetGuard = InvalidMode in { -def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x">; def SVTMAD : SInst<"svtmad[_{d}]", "dddi", "hfd", MergeNone, "aarch64_sve_ftmad_x", [], [ImmCheck<2, ImmCheck0_7>]>; def SVTSMUL : SInst<"svtsmul[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftsmul_x">; def SVTSSEL : SInst<"svtssel[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftssel_x">; diff --git a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c index 52b6822a833f7..8c34017b7750b 100644 --- a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c +++ b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c @@ -1,10 +1,12 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -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 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -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 -triple aarch64 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s #include #ifdef SVE_OVERLOADED_FORMS @@ -14,6 +16,12 @@ #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 #endif +#ifdef __ARM_FEATURE_SME +#define STREAMING __arm_streaming +#else +#define STREAMING +#endif + // CHECK-LABEL: @test_svexpa_f16( // CHECK-NEXT: entry: // CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) @@ -24,7 +32,7 @@ // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svfloat16_t test_svexpa_f16(svuint16_t op) +svfloat16_t test_svexpa_f16(svuint16_t op) STREAMING { return SVE_ACLE_FUNC(svexpa,_f16,,)(op); } @@ -39,7 +47,7 @@ svfloat16_t test_svexpa_f16(svuint16_t op) // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv4f32( [[OP:%.*]]) // CP
[clang] [llvm] [AARCH64] Add FEAT_SSVE_FEXPA and fix unsupported features list (PR #134368)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: None (Lukacma) Changes This patch adds new feature introduced in [2025-03 release](https://developer.arm.com/documentation/ddi0602/2025-03/SVE-Instructions/FEXPA--Floating-point-exponential-accelerator-) and changes feature requirements for fexpa instructions and intrinsics. Additionally it fixes unsupported features list by moving fearures dependent on sme2p1 to correct location. --- Full diff: https://github.com/llvm/llvm-project/pull/134368.diff 9 Files Affected: - (modified) clang/include/clang/Basic/arm_sve.td (+4-2) - (modified) clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c (+11-3) - (modified) clang/test/Driver/print-supported-extensions-aarch64.c (+1) - (modified) llvm/lib/Target/AArch64/AArch64.td (+2-3) - (modified) llvm/lib/Target/AArch64/AArch64Features.td (+3-1) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+4) - (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (+1-1) - (modified) llvm/test/CodeGen/AArch64/sve-intrinsics-fexpa.ll (+1-1) - (modified) llvm/test/MC/AArch64/SVE/fexpa.s (+4-4) ``diff diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 35263541b67ae..f09f40ce9202e 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -836,9 +836,11 @@ defm SVRINTP : SInstZPZ<"svrintp", "hfd", "aarch64_sve_frintp">; defm SVRINTX : SInstZPZ<"svrintx", "hfd", "aarch64_sve_frintx">; defm SVRINTZ : SInstZPZ<"svrintz", "hfd", "aarch64_sve_frintz">; defm SVSQRT : SInstZPZ<"svsqrt", "hfd", "aarch64_sve_fsqrt">; - +def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x", [VerifyRuntimeMode]>{ + let SVETargetGuard = "sve"; + let SMETargetGuard = "sme2,ssve-fexpa"; +} let SVETargetGuard = "sve", SMETargetGuard = InvalidMode in { -def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x">; def SVTMAD : SInst<"svtmad[_{d}]", "dddi", "hfd", MergeNone, "aarch64_sve_ftmad_x", [], [ImmCheck<2, ImmCheck0_7>]>; def SVTSMUL : SInst<"svtsmul[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftsmul_x">; def SVTSSEL : SInst<"svtssel[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftssel_x">; diff --git a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c index 52b6822a833f7..8c34017b7750b 100644 --- a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c +++ b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c @@ -1,10 +1,12 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -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 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -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 -triple aarch64 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s #include #ifdef SVE_OVERLOADED_FORMS @@ -14,6 +16,12 @@ #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 #endif +#ifdef __ARM_FEATURE_SME +#define STREAMING __arm_streaming +#else +#define STREAMING +#endif + // CHECK-LABEL: @test_svexpa_f16( // CHECK-NEXT: entry: // CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) @@ -24,7 +32,7 @@ // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svfloat16_t test_svexpa_f16(svuint16_t op) +svfloat16_t test_svexpa_f16(svuint16_t op) STREAMING { return SVE_ACLE_FUNC(svexpa,_f16,,)(op); } @@ -39,7 +47,7 @@ svfloat16_t test_svexpa_f16(svuint16_t op) // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv4f32( [[OP:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svfloat32_t test_svexpa_f32(svuint32_t op) +svfloat32_t test_svexpa_f32(svuint32_t op) STREAMING { return SVE_ACLE_FUNC(svexpa,_f
[clang] [llvm] [AARCH64] Add FEAT_SSVE_FEXPA and fix unsupported features list (PR #134368)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: None (Lukacma) Changes This patch adds new feature introduced in [2025-03 release](https://developer.arm.com/documentation/ddi0602/2025-03/SVE-Instructions/FEXPA--Floating-point-exponential-accelerator-) and changes feature requirements for fexpa instructions and intrinsics. Additionally it fixes unsupported features list by moving fearures dependent on sme2p1 to correct location. --- Full diff: https://github.com/llvm/llvm-project/pull/134368.diff 9 Files Affected: - (modified) clang/include/clang/Basic/arm_sve.td (+4-2) - (modified) clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c (+11-3) - (modified) clang/test/Driver/print-supported-extensions-aarch64.c (+1) - (modified) llvm/lib/Target/AArch64/AArch64.td (+2-3) - (modified) llvm/lib/Target/AArch64/AArch64Features.td (+3-1) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+4) - (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (+1-1) - (modified) llvm/test/CodeGen/AArch64/sve-intrinsics-fexpa.ll (+1-1) - (modified) llvm/test/MC/AArch64/SVE/fexpa.s (+4-4) ``diff diff --git a/clang/include/clang/Basic/arm_sve.td b/clang/include/clang/Basic/arm_sve.td index 35263541b67ae..f09f40ce9202e 100644 --- a/clang/include/clang/Basic/arm_sve.td +++ b/clang/include/clang/Basic/arm_sve.td @@ -836,9 +836,11 @@ defm SVRINTP : SInstZPZ<"svrintp", "hfd", "aarch64_sve_frintp">; defm SVRINTX : SInstZPZ<"svrintx", "hfd", "aarch64_sve_frintx">; defm SVRINTZ : SInstZPZ<"svrintz", "hfd", "aarch64_sve_frintz">; defm SVSQRT : SInstZPZ<"svsqrt", "hfd", "aarch64_sve_fsqrt">; - +def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x", [VerifyRuntimeMode]>{ + let SVETargetGuard = "sve"; + let SMETargetGuard = "sme2,ssve-fexpa"; +} let SVETargetGuard = "sve", SMETargetGuard = InvalidMode in { -def SVEXPA : SInst<"svexpa[_{d}]", "du", "hfd", MergeNone, "aarch64_sve_fexpa_x">; def SVTMAD : SInst<"svtmad[_{d}]", "dddi", "hfd", MergeNone, "aarch64_sve_ftmad_x", [], [ImmCheck<2, ImmCheck0_7>]>; def SVTSMUL : SInst<"svtsmul[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftsmul_x">; def SVTSSEL : SInst<"svtssel[_{d}]", "ddu", "hfd", MergeNone, "aarch64_sve_ftssel_x">; diff --git a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c index 52b6822a833f7..8c34017b7750b 100644 --- a/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c +++ b/clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_expa.c @@ -1,10 +1,12 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py // REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -triple aarch64 -target-feature +sve -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 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -passes=mem2reg,tailcallelim | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -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 -triple aarch64 -target-feature +sve -S -disable-O0-optnone -Werror -Wall -o /dev/null %s +// RUN: %clang_cc1 -triple aarch64 -target-feature +ssve-fexpa -target-feature +sme2 -target-feature +sme -S -disable-O0-optnone -Werror -Wall -o /dev/null %s #include #ifdef SVE_OVERLOADED_FORMS @@ -14,6 +16,12 @@ #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 #endif +#ifdef __ARM_FEATURE_SME +#define STREAMING __arm_streaming +#else +#define STREAMING +#endif + // CHECK-LABEL: @test_svexpa_f16( // CHECK-NEXT: entry: // CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) @@ -24,7 +32,7 @@ // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv8f16( [[OP:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svfloat16_t test_svexpa_f16(svuint16_t op) +svfloat16_t test_svexpa_f16(svuint16_t op) STREAMING { return SVE_ACLE_FUNC(svexpa,_f16,,)(op); } @@ -39,7 +47,7 @@ svfloat16_t test_svexpa_f16(svuint16_t op) // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call @llvm.aarch64.sve.fexpa.x.nxv4f32( [[OP:%.*]]) // CPP-CHECK-NEXT:ret [[TMP0]] // -svfloat32_t test_svexpa_f32(svuint32_t op) +svfloat32_t test_svexpa_f32(svuint32_t op) STREAMING { return SVE_ACLE_FUNC(svexpa
[clang] Mark CXX module initializer with PACBTI attributes (PR #133716)
https://github.com/vhscampos updated https://github.com/llvm/llvm-project/pull/133716 >From bb649666995a2642c5eea944e55c0a38503ed7bf Mon Sep 17 00:00:00 2001 From: Victor Campos Date: Fri, 28 Mar 2025 15:55:07 + Subject: [PATCH 1/2] Mark CXX module initializer with PACBTI attributes The CXX module initializer function, which is called at program startup, needs to be tagged with Pointer Authentication and Branch Target Identification marks whenever relevant. Before this patch, in CPUs set up for PACBTI execution, the function wasn't protected with return address signing and no BTI instruction was inserted at the start of it, thus leading to an execution fault. This patch fixes the issue by marking the function with the function attributes related to PAC and BTI if relevant. --- clang/lib/CodeGen/CGDeclCXX.cpp | 6 .../cxx20-module-initializer-pacbti.cpp | 32 +++ 2 files changed, 38 insertions(+) create mode 100644 clang/test/CodeGenCXX/cxx20-module-initializer-pacbti.cpp diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index a01fa157c2b26..0366e3977b812 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -818,6 +818,12 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) { Fn->addFnAttr("device-init"); } + if (getTarget().isBranchProtectionSupportedArch( + getTarget().getTargetOpts().CPU)) { +TargetInfo::BranchProtectionInfo BPI(getLangOpts()); +getTargetCodeGenInfo().setBranchProtectionFnAttributes(BPI, (*Fn)); + } + // We are done with the inits. AllImports.clear(); PrioritizedCXXGlobalInits.clear(); diff --git a/clang/test/CodeGenCXX/cxx20-module-initializer-pacbti.cpp b/clang/test/CodeGenCXX/cxx20-module-initializer-pacbti.cpp new file mode 100644 index 0..7ebaa5e8f349e --- /dev/null +++ b/clang/test/CodeGenCXX/cxx20-module-initializer-pacbti.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -mbranch-target-enforce -std=c++20 %s -o %t.pcm +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -std=c++20 %t.pcm -emit-llvm -o - | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK-BTI %s + +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -msign-return-address=non-leaf -std=c++20 %s -o %t.pcm +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -std=c++20 %t.pcm -emit-llvm -o - | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK-PAC %s + +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -msign-return-address=all -std=c++20 %s -o %t.pcm +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -std=c++20 %t.pcm -emit-llvm -o - | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK-PAC-ALL %s + +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -msign-return-address=non-leaf -mbranch-target-enforce -std=c++20 %s -o %t.pcm +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -std=c++20 %t.pcm -emit-llvm -o - | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK-PAC-BTI %s + +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -msign-return-address=all -mbranch-target-enforce -std=c++20 %s -o %t.pcm +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -std=c++20 %t.pcm -emit-llvm -o - | \ +// RUN: FileCheck --check-prefixes=CHECK,CHECK-PAC-BTI-ALL %s + +// CHECK: define void @_ZGIW3foo() #0 +// CHECK-BTI: attributes #0 = { nounwind "branch-target-enforcement" } +// CHECK-PAC: attributes #0 = { nounwind "sign-return-address"="non-leaf" "sign-return-address-key"="a_key" } +// CHECK-PAC-ALL: attributes #0 = { nounwind "sign-return-address"="all" "sign-return-address-key"="a_key" } +// CHECK-PAC-BTI: attributes #0 = { nounwind "branch-target-enforcement" "sign-return-address"="non-leaf" "sign-return-address-key"="a_key" } +// CHECK-PAC-BTI-ALL: attributes #0 = { nounwind "branch-target-enforcement" "sign-return-address"="all" "sign-return-address-key"="a_key" } + +module; + +export module foo; + +export void func(); >From 6d23613662051546c0de1a1c9c0814147b47b425 Mon Sep 17 00:00:00 2001 From: Victor Campos Date: Fri, 4 Apr 2025 10:15:58 +0100 Subject: [PATCH 2/2] - Change patch to use existing function. - Modify setTargetAttributes function to work even without a function declaration. --- clang/lib/CodeGen/CGDeclCXX.cpp | 7 +-- clang/lib/CodeGen/Targets/ARM.cpp | 13 +++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 0366e3977b812..50b1bdde88d07 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -793,6 +793,7 @@ void CodeGenModule::E
[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)
https://github.com/AaronBallman approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/132387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
bassiounix wrote: Looks like that `BFloat16Format` for `amdgcn-amd-amdhsa` target is not properly initialized and the `hasBFloat16Type` method at [`clang/lib/Basic/Targets/AMDGPU.h`](https://github.com/llvm/llvm-project/blob/92923e517c2926eb94b7b6e403433ecf62953186/clang/lib/Basic/Targets/AMDGPU.h#L127) is using a dummy check to that is based on the triple value only. Also there's no overrides for a full type support. The global value of `BFloat16Format` in `AMDGPUTI` is properly initialized. I think `TargetInfo::adjust` at [`clang/lib/Basic/TargetInfo.cpp`](https://github.com/llvm/llvm-project/blob/92923e517c2926eb94b7b6e403433ecf62953186/clang/lib/Basic/TargetInfo.cpp#L409) may be the reason but I'm not sure https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/133871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
rorth wrote: The patch also breaks both the [Solaris/sparcv9](https://lab.llvm.org/buildbot/#/builders/13/builds/6362) and [Solaris/amd64](https://lab.llvm.org/staging/#/builders/120/builds/7512) bots. https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 22130ca - [MS][clang] Fix crash on deletion of array of pointers (#134088)
Author: Mariya Podchishchaeva Date: 2025-04-04T09:37:28+02:00 New Revision: 22130ca486b2fb43198453a53eb048cd8a97e9a8 URL: https://github.com/llvm/llvm-project/commit/22130ca486b2fb43198453a53eb048cd8a97e9a8 DIFF: https://github.com/llvm/llvm-project/commit/22130ca486b2fb43198453a53eb048cd8a97e9a8.diff LOG: [MS][clang] Fix crash on deletion of array of pointers (#134088) Sometimes a non-array delete is treated as delete[] when input pointer is pointer to array. With vector deleting destructors support we now generate a virtual destructor call instead of simple loop over the elements. This patch adjusts the codepath that generates virtual call to expect the case of pointer to array. Added: Modified: clang/lib/AST/Expr.cpp clang/lib/CodeGen/MicrosoftCXXABI.cpp clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp Removed: diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 389fa70a61b4b..e8e5f2fa0cc12 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -71,6 +71,9 @@ const CXXRecordDecl *Expr::getBestDynamicClassType() const { if (const PointerType *PTy = DerivedType->getAs()) DerivedType = PTy->getPointeeType(); + while (const ArrayType *ATy = DerivedType->getAsArrayTypeUnsafe()) +DerivedType = ATy->getElementType(); + if (DerivedType->isDependentType()) return nullptr; diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 91689bb2ec75f..ba5f74f153d59 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -2034,6 +2034,9 @@ llvm::Value *MicrosoftCXXABI::EmitVirtualDestructorCall( ThisTy = D->getDestroyedType(); } + while (const ArrayType *ATy = Context.getAsArrayType(ThisTy)) +ThisTy = ATy->getElementType(); + This = adjustThisArgumentForVirtualFunctionCall(CGF, GD, This, true); RValue RV = CGF.EmitCXXDestructorCall(GD, Callee, This.emitRawPointer(CGF), ThisTy, diff --git a/clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp b/clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp index 439ff84456033..9d23708602a43 100644 --- a/clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp +++ b/clang/test/CodeGenCXX/microsoft-vector-deleting-dtors.cpp @@ -35,6 +35,10 @@ void operator delete(void *p) { i-=2; } void operator delete[](void *p) { i--; } }; +struct AllocatedAsArray : public Bird { + +}; + // Vector deleting dtor for Bird is an alias because no new Bird[] expressions // in the TU. // X64: @"??_EBird@@UEAAPEAXI@Z" = weak dso_local unnamed_addr alias ptr (ptr, i32), ptr @"??_GBird@@UEAAPEAXI@Z" @@ -55,6 +59,14 @@ Bird* alloc() { return P; } + +template +struct S { + void foo() { void *p = new C(); delete (C *)p; } +}; + +S sp; + void bar() { dealloc(alloc()); @@ -63,6 +75,8 @@ void bar() { Bird *p = new HasOperatorDelete[2]; dealloc(p); + + sp.foo(); } // CHECK-LABEL: define dso_local void @{{.*}}dealloc{{.*}}( @@ -99,6 +113,36 @@ void bar() { // CHECK: delete.end: // CHECK-NEXT: ret void +// Definition of S::foo, check that it has vector deleting destructor call +// X64-LABEL: define linkonce_odr dso_local void @"?foo@?$S@$$BY102UAllocatedAsArrayQEAAXXZ" +// X86-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?foo@?$S@$$BY102UAllocatedAsArrayQAEXXZ" +// CHECK: delete.notnull: ; preds = %arrayctor.cont +// CHECK-NEXT: %[[DEL_PTR:.*]] = getelementptr inbounds [1 x [3 x %struct.AllocatedAsArray]], ptr %[[THE_ARRAY:.*]], i32 0, i32 0 +// X64-NEXT: %[[COOKIEGEP:.*]] = getelementptr inbounds i8, ptr %[[DEL_PTR]], i64 -8 +// X86-NEXT: %[[COOKIEGEP:.*]] = getelementptr inbounds i8, ptr %[[DEL_PTR]], i32 -4 +// X64-NEXT: %[[HOWMANY:.*]] = load i64, ptr %[[COOKIEGEP]] +// X86-NEXT: %[[HOWMANY:.*]] = load i32, ptr %[[COOKIEGEP]] +// X64-NEXT: %[[ISNOELEM:.*]] = icmp eq i64 %[[HOWMANY]], 0 +// X86-NEXT: %[[ISNOELEM:.*]] = icmp eq i32 %[[HOWMANY]], 0 +// CHECK-NEXT: br i1 %[[ISNOELEM]], label %vdtor.nocall, label %vdtor.call +// CHECK: vdtor.nocall: ; preds = %delete.notnull +// X64-NEXT: %[[HOWMANYBYTES:.*]] = mul i64 8, %[[HOWMANY]] +// X86-NEXT: %[[HOWMANYBYTES:.*]] = mul i32 4, %[[HOWMANY]] +// X64-NEXT: %[[ADDCOOKIESIZE:.*]] = add i64 %[[HOWMANYBYTES]], 8 +// X86-NEXT: %[[ADDCOOKIESIZE:.*]] = add i32 %[[HOWMANYBYTES]], 4 +// X64-NEXT: call void @"??_V@YAXPEAX_K@Z"(ptr noundef %[[COOKIEGEP]], i64 noundef %[[ADDCOOKIESIZE]]) +// X86-NEXT: call void @"??_V@YAXPAXI@Z"(ptr noundef %[[COOKIEGEP]], i32 noundef %[[ADDCOOKIESIZE]]) +// CHECK-NEXT: br label %delete.end +// CHECK: vdtor.call: ; preds = %delete.notnull +// CHECK-NEXT: %[[VTABLE:.*]] = load ptr, ptr %[[DEL_PTR]] +// CHECK-NEXT: %[[FPGEP:.*]] = gete
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
@@ -978,6 +979,28 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (!isFPConstant) +break; // Error for integer constant. + if (isBFloat16) +break; + if (!Target.hasBFloat16Type()) +break; overmighty wrote: Nit: I think target support for bfloat16 should be checked first. Some of the other `switch` cases start by checking `LangOpts`. There's no need to check both `isBFloat16` and `HasSize`, we can just check `HasSize`. ```suggestion if (!Target.hasBFloat16Type()) break; if (!isFPConstant) break; // Error for integer constant. ``` https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
overmighty wrote: We could also add the following test cases: - `bf16` suffix on integer literal. - `bf16` suffix after another suffix. - `bf16` suffix but no target support for bfloat16. https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
@@ -978,6 +979,28 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (!isFPConstant) +break; // Error for integer constant. + if (isBFloat16) +break; + if (!Target.hasBFloat16Type()) +break; + if (HasSize) +break; + HasSize = true; + + if ((Target.hasBFloat16Type() || LangOpts.CUDA || + (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && overmighty wrote: We might not need to check for `LangOpts.CUDA || (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())` in our case: https://github.com/llvm/llvm-project/blob/9eb7e64145f66f59f07edffb4f9c8a648174543e/clang/lib/Basic/Targets/NVPTX.h#L202 I'm not sure why it was needed for `f16` literals. https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
mstorsjo wrote: > Maybe the test needs to be relaxed a bit because of stack layout differences > in other OS targets? Although I'm not sure why they're different. See > https://lab.llvm.org/buildbot/#/builders/186/builds/7896: > > ``` > TEST 'AddressSanitizer-arm-android :: > TestCases/shadowed-stack-serialization.cpp' FAILED > Exit Code: 1 > Command Output (stderr): > -- > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py > > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang > --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer > -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only > --target=armv7-linux-androideabi24 > --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot > > --gcc-toolchain=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 > > -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 > -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -fuse-ld=lld > -shared-libasan -O0 > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp > -o > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Output/shadowed-stack-serialization.cpp.tmp > # RUN: at line 1 > + > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/sanitizer_common/android_commands/android_compile.py > > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang > --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer > -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only > --target=armv7-linux-androideabi24 > --sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot > > --gcc-toolchain=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 > > -B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 > -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -fuse-ld=lld > -shared-libasan -O0 > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp > -o > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Output/shadowed-stack-serialization.cpp.tmp > not > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Output/shadowed-stack-serialization.cpp.tmp > 2>&1 | FileCheck > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp > # RUN: at line 2 > + not > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/compiler_rt_build_android_arm/test/asan/ARMAndroidConfig/TestCases/Output/shadowed-stack-serialization.cpp.tmp > + FileCheck > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp:12:11: > error: CHECK: expected string not found in input > // CHECK: [32, 36) 'x' > ^ > :1:1: note: scanning from here > = > ^ > :11:2: note: possible intended match here > [16, 20) 'x' (line 7) <== Memory access at offset 16 is inside this variable > ^ > Input file: > Check file: > /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/compiler-rt/test/asan/TestCases/shadowed-stack-serialization.cpp > ``` I'm also hitting this failure; in my case it's cropping up on i686 windows: https://github.com/mstorsjo/llvm-mingw/actions/runs/14255796193/job/39971583775 https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
@@ -978,6 +979,28 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': overmighty wrote: ```suggestion case 'b': // FP Suffix for "__bf16" ``` https://github.com/llvm/llvm-project/pull/134214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Define pointer layout for AVR program address space (PR #134254)
benshi001 wrote: > CC @benshi001 > > To be 100% honest I haven't tested this on AVR silicon yet. My motivation for > the change is to allow for non-zero data address spaces in Rust which parses > these LLVM data format specs, but would then use both 64-bit and 16-bit > pointers for AVR. Apologies if this is bad practice! Thanks! I will have a look later. https://github.com/llvm/llvm-project/pull/134254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/13] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/13] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/14] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/14] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
gbMattN wrote: You're right, I don't think there is a reason to check the stack location in this test, just how it was serialized. I'll push a change and hopefully this'll be fixed. Thanks for the notes! https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/133910 >From 6d61256a73c64ef4351266d6ef76067f5a2568db Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Fri, 4 Apr 2025 13:40:55 +0200 Subject: [PATCH] [WIP] Implement -dump-deserialized-declaration-ranges flag to dump source ranges of deserialized decls. --- clang/include/clang/Driver/Options.td | 4 + .../include/clang/Frontend/FrontendOptions.h | 3 + clang/lib/Frontend/FrontendAction.cpp | 161 +- .../dump-deserialized-declaration-ranges.cpp | 80 + 4 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 clang/test/Frontend/dump-deserialized-declaration-ranges.cpp diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3af072242d039..1737e40b776e1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7968,6 +7968,10 @@ def print_dependency_directives_minimized_source : Flag<["-"], "print-dependency-directives-minimized-source">, HelpText<"Print the output of the dependency directives source minimizer">; } +def dump_deserialized_declaration_ranges : Joined<["-"], + "dump-deserialized-declaration-ranges=">, + HelpText<"Dump ranges of deserialized declarations to aid debugging and minimization">, + MarshallingInfoString>; defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", CodeGenOpts<"EmitLLVMUseLists">, DefaultFalse, diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index a9c9849ff52ab..8ef9ce9db8783 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -530,6 +530,9 @@ class FrontendOptions { /// Output Path for module output file. std::string ModuleOutputPath; + /// Output path to dump ranges of deserialized declarations. + std::string DumpDeserializedDeclarationRangesPath; + public: FrontendOptions() : DisableFree(false), RelocatablePCH(false), ShowHelp(false), diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 2d77f06be7446..f98aa5ab1fe51 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/FileEntry.h" #include "clang/Basic/LangStandard.h" #include "clang/Basic/Sarif.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" @@ -35,6 +36,7 @@ #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/GlobalModuleIndex.h" #include "llvm/ADT/ScopeExit.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/BuryPointer.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -49,6 +51,144 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations to aid debugging and bug minimization. +/// It implements ASTConsumer and ASTDeserializationListener, so that an object of DeserializedDeclsLineRangePrinter registers +/// as its own listener. +/// The ASTDeserializationListener interface provides the DeclRead callback that we use to collect the deserialized Decls. +/// Note that printing or otherwise processing them as this point is dangerous, since that could trigger additional +/// deserialization and crash compilation. +/// Therefore, we process the collected Decls in HandleTranslationUnit method of ASTConsumer. +/// This is a safe point, since we know that by this point all the Decls needed by the compiler frontend have been +/// deserialized. In case our processing causes further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter(SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || + isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { + StringRef Filename; + std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); +if (!PendingDecls.empty()) { + llvm::errs() << "Deserialized more decls while printing, total of " +<< PendingDecl
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Viktoriia Bakalova (VitaNuo) Changes This PR implements a CC1 flag `-dump-deserialized-declaration-ranges`. The flag allows to specify a file path to dump ranges of deserialized declarations in `ASTReader`. Example usage: ``` clang -Xclang=-dump-deserialized-declaration-ranges=/tmp/decls -c file.cc -o file.o ``` Example output: ``` // /tmp/decls { "required_ranges": [ { "file": "foo.h", "range": [ { "from": { "line": 26, "column": 1 }, "to": { "line": 27, "column": 77 } } ] }, { "file": "bar.h", "range": [ { "from": { "line": 30, "column": 1 }, "to": { "line": 35, "column": 1 } }, { "from": { "line": 92, "column": 1 }, "to": { "line": 95, "column": 1 } } ] } ] } ``` Specifying the flag creates an instance of `DeserializedDeclsLineRangePrinter`, which dumps ranges of deserialized declarations to aid debugging and bug minimization. Required ranges are computed from source ranges of Decls. `TranslationUnitDecl`, `LinkageSpecDecl` and `NamespaceDecl` are ignored for the sake of this PR. Technical details: * `DeserializedDeclsLineRangePrinter` implements `ASTConsumer` and `ASTDeserializationListener`, so that an object of `DeserializedDeclsLineRangePrinter` registers as its own listener. * `ASTDeserializationListener` interface provides the `DeclRead` callback that we use to collect the deserialized Decls. Printing or otherwise processing them as this point is dangerous, since that could trigger additional deserialization and crash compilation. * The collected Decls are processed in `HandleTranslationUnit` method of `ASTConsumer`. This is a safe point, since we know that by this point all the Decls needed by the compiler frontend have been deserialized. * In case our processing causes further deserialization, `DeclRead` from the listener might be called again. However, at that point we don't accept any more Decls for processing. --- Full diff: https://github.com/llvm/llvm-project/pull/133910.diff 4 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+4) - (modified) clang/include/clang/Frontend/FrontendOptions.h (+3) - (modified) clang/lib/Frontend/FrontendAction.cpp (+156-5) - (added) clang/test/Frontend/dump-deserialized-declaration-ranges.cpp (+80) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3af072242d039..1737e40b776e1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7968,6 +7968,10 @@ def print_dependency_directives_minimized_source : Flag<["-"], "print-dependency-directives-minimized-source">, HelpText<"Print the output of the dependency directives source minimizer">; } +def dump_deserialized_declaration_ranges : Joined<["-"], + "dump-deserialized-declaration-ranges=">, + HelpText<"Dump ranges of deserialized declarations to aid debugging and minimization">, + MarshallingInfoString>; defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", CodeGenOpts<"EmitLLVMUseLists">, DefaultFalse, diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index a9c9849ff52ab..8ef9ce9db8783 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -530,6 +530,9 @@ class FrontendOptions { /// Output Path for module output file. std::string ModuleOutputPath; + /// Output path to dump ranges of deserialized declarations. + std::string DumpDeserializedDeclarationRangesPath; + public: FrontendOptions() : DisableFree(false), RelocatablePCH(false), ShowHelp(false), diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 2d77f06be7446..f98aa5ab1fe51 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/FileEntry.h" #include "clang/Basic/LangStandard.h" #include "clang/Basic/Sarif.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" @@ -35,6 +36,7 @@ #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/GlobalModuleIndex.h" #include "llvm/ADT/ScopeExit.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/BuryPointer.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -49,6 +51,144 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of des
[clang] [libcxxabi] [lldb] [llvm] [WIP][lldb] Alternative implementation of more reliable function call infrastructure (PR #115245)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- clang/lib/AST/Mangle.cpp clang/lib/Sema/SemaDeclAttr.cpp libcxxabi/src/demangle/ItaniumDemangle.h lldb/source/Expression/IRExecutionUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp llvm/include/llvm/Demangle/Demangle.h llvm/include/llvm/Demangle/ItaniumDemangle.h llvm/lib/Demangle/ItaniumDemangle.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 1056195b1..f864b0f38 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -892,43 +892,44 @@ static std::string FindStructorLinkageName(DWARFDIE die, return {}; } -static lldb::addr_t FindSpecialLinkageName( -LoadAddressResolver &resolver,ConstString name, llvm::StringRef symbol) { +static lldb::addr_t FindSpecialLinkageName(LoadAddressResolver &resolver, + ConstString name, + llvm::StringRef symbol) { uintptr_t module_ptr; if (symbol.consumeInteger(0, module_ptr)) return LLDB_INVALID_ADDRESS; - + if (module_ptr == 0) { // TODO: log this case. We should ever be putting a null module pointer // here return LLDB_INVALID_ADDRESS; } - + auto *mod = (lldb_private::Module *)module_ptr; assert(mod); auto *sym = mod->GetSymbolFile(); assert(sym); - + if (!symbol.consume_front(":")) return LLDB_INVALID_ADDRESS; - + lldb::user_id_t die_id; if (symbol.consumeInteger(10, die_id)) return LLDB_INVALID_ADDRESS; - + auto *dwarf = llvm::dyn_cast(sym); if (!dwarf) return LLDB_INVALID_ADDRESS; - + auto die = dwarf->GetDIE(die_id); if (!die.IsValid()) return LLDB_INVALID_ADDRESS; - + // TODO: account for MS-ABI (where there are no ctor variants in the // mangling) if (!symbol.consume_front(":")) return LLDB_INVALID_ADDRESS; - + auto structor_variant_or_err = MakeStructorVariant(symbol); if (!structor_variant_or_err) { LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), @@ -937,13 +938,12 @@ static lldb::addr_t FindSpecialLinkageName( name.GetStringRef()); return LLDB_INVALID_ADDRESS; } - - ConstString mangled( - FindStructorLinkageName(die, *structor_variant_or_err)); - - Module::LookupInfo lookup_info( - mangled, lldb::FunctionNameType::eFunctionNameTypeAny, - lldb::LanguageType::eLanguageTypeC_plus_plus); + + ConstString mangled(FindStructorLinkageName(die, *structor_variant_or_err)); + + Module::LookupInfo lookup_info(mangled, + lldb::FunctionNameType::eFunctionNameTypeAny, + lldb::LanguageType::eLanguageTypeC_plus_plus); SymbolContextList sc_list; dwarf->FindFunctions(lookup_info, {}, false, sc_list); if (auto load_addr = resolver.Resolve(sc_list)) `` https://github.com/llvm/llvm-project/pull/115245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -139,16 +283,17 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, return nullptr; // If there are no registered plugins we don't need to wrap the consumer - if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) -return Consumer; + if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) { VitaNuo wrote: Thanks for the detailed explanation, addressed that. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,135 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// Dumps deserialized declarations. VitaNuo wrote: Yes, sorry, I responded to the comment before pushing the actual change. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)
zahiraam wrote: > In general, I don't fully understand the scope of this patch. Surely, there's > thousands of things that could be improved in the codebase. Which of those > belong to this patch? Reviewers can always point out things that could be > improved ad infinitum, leading to a patch with lots of unrelated changes. > When do we decide that we are done? I totally agree. Our code sanitizer points us to many edits that are most of the time false positive. I have proposed in this PR fixes that I have judged might be real issues (I might be wrong). As you suggested I have reverted the changes for clang-tidy. The 2 that are left are in `cland/Headers.cpp` and `clang/ConfigCompile.cpp`. If you agree with the edits, please approve. If not I will close the PR. Thanks. https://github.com/llvm/llvm-project/pull/134138 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Do not diagnose unused deleted operator delete[] (PR #134357)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/134357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [NVPTX] Add intrinsics for cvt .f6x2 and .ue8m0x2 variants (PR #134345)
@@ -1548,6 +1548,45 @@ let TargetPrefix = "nvvm" in { Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; def int_nvvm_e5m2x2_to_f16x2_rn_relu : ClangBuiltin<"__nvvm_e5m2x2_to_f16x2_rn_relu">, Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; + + def int_nvvm_ff_to_e2m3x2_rn : ClangBuiltin<"__nvvm_ff_to_e2m3x2_rn">, + Intrinsic<[llvm_i16_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_ff_to_e2m3x2_rn_relu : ClangBuiltin<"__nvvm_ff_to_e2m3x2_rn_relu">, + Intrinsic<[llvm_i16_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_ff_to_e3m2x2_rn : ClangBuiltin<"__nvvm_ff_to_e3m2x2_rn">, + Intrinsic<[llvm_i16_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_ff_to_e3m2x2_rn_relu : ClangBuiltin<"__nvvm_ff_to_e3m2x2_rn_relu">, + Intrinsic<[llvm_i16_ty], [llvm_float_ty, llvm_float_ty], [IntrNoMem, IntrNoCallback]>; + + def int_nvvm_e2m3x2_to_f16x2_rn : ClangBuiltin<"__nvvm_e2m3x2_to_f16x2_rn">, + Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_e2m3x2_to_f16x2_rn_relu : ClangBuiltin<"__nvvm_e2m3x2_to_f16x2_rn_relu">, + Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_e3m2x2_to_f16x2_rn : ClangBuiltin<"__nvvm_e3m2x2_to_f16x2_rn">, + Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; + def int_nvvm_e3m2x2_to_f16x2_rn_relu : ClangBuiltin<"__nvvm_e3m2x2_to_f16x2_rn_relu">, + Intrinsic<[llvm_v2f16_ty], [llvm_i16_ty], [IntrNoMem, IntrNoCallback]>; durga4github wrote: optional: We may combine this chunk with the e4m3/e5m2 conversions above since they all take an i16 and return v2f16, to reduce the verbosity. But this can be a separate NFC change. https://github.com/llvm/llvm-project/pull/134345 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Handle AttributedType in template deduction with derived-to-base conversions (PR #134361)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Ilya Biryukov (ilya-biryukov) Changes Fix #134356. We accidentally skipped checking derived-to-base conversions because deduction did not strip sugar in the relevant code. This caused deduction failures when a parameter type had an attribute. --- Full diff: https://github.com/llvm/llvm-project/pull/134361.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+1-1) - (added) clang/test/Sema/nullability-and-template-deduction.cpp (+16) ``diff diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 9969f1762fe36..92283867c38cd 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4446,7 +4446,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction( // transformed A can be a pointer to a derived class pointed to by // the deduced A. if (isSimpleTemplateIdType(ParamType) || - (isa(ParamType) && + (ParamType->getAs() && isSimpleTemplateIdType( ParamType->castAs()->getPointeeType( TDF |= TDF_DerivedClass; diff --git a/clang/test/Sema/nullability-and-template-deduction.cpp b/clang/test/Sema/nullability-and-template-deduction.cpp new file mode 100644 index 0..3ea6d38d26b69 --- /dev/null +++ b/clang/test/Sema/nullability-and-template-deduction.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify +// expected-no-diagnostics + +template struct Base {}; +template struct Derived : Base {}; + +template void foo(Base *_Nonnull); + +template void bar(Base *); + + +void test() { +Derived d; +foo(&d); +bar(&d); +} `` https://github.com/llvm/llvm-project/pull/134361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)
mstorsjo wrote: > You're right, I don't think there is a reason to check the stack location in > this test, just how it was serialized. I'll push a change and hopefully > this'll be fixed. Thanks for the notes! Thanks for the fix in 4da5e9dd320e9d48be0fa05ba1a8faf50fb53834, that does seem to have fixed the issue on i686 windows at least! https://github.com/llvm/llvm-project/pull/119387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [driver] Generalize the code that adds the path of libflang_rt.runtime.a. (PR #134362)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Daniel Chen (DanielCChen) Changes The PR is to generalize the re-use of the `compilerRT` code of adding the path of `libflang_rt.runtime.a (so)` from AIX and LoP only to all platforms via a new function `addFlangRTLibPath`. Also, PR #134320 exposed an issue in PR #131041 that the the overriding `addFortranRuntimeLibs` is missing the link to `libquadmath`. This PR also fixed that and restored the test case that PR #131041 broke. --- Full diff: https://github.com/llvm/llvm-project/pull/134362.diff 7 Files Affected: - (modified) clang/include/clang/Driver/ToolChain.h (+4) - (modified) clang/lib/Driver/ToolChain.cpp (+18-2) - (modified) clang/lib/Driver/ToolChains/AIX.cpp (-8) - (modified) clang/lib/Driver/ToolChains/AIX.h (-3) - (modified) clang/lib/Driver/ToolChains/PPCLinux.cpp (-16) - (modified) clang/lib/Driver/ToolChains/PPCLinux.h (-3) - (modified) flang/test/Driver/linker-flags.f90 (+1-1) ``diff diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 076e4296c3090..d0059673d6a67 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -521,6 +521,10 @@ class ToolChain { addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; + /// Add the path for libflang_rt.runtime.a + void addFlangRTLibPath(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + const char *getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type = ToolChain::FT_Static, diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 36d0ae34dec86..054618a44d7bc 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -816,8 +816,7 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args, if (AsNeeded) addAsNeededOption(*this, Args, CmdArgs, /*as_needed=*/false); } -CmdArgs.push_back("-lflang_rt.runtime"); -addArchSpecificRPath(*this, Args, CmdArgs); +addFlangRTLibPath(Args, CmdArgs); // needs libexecinfo for backtrace functions if (getTriple().isOSFreeBSD() || getTriple().isOSNetBSD() || @@ -850,6 +849,23 @@ void ToolChain::addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args, CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath)); } +void ToolChain::addFlangRTLibPath(const ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const { + // Link static flang_rt.runtime.a or shared flang_rt.runtime.so + const char *Path; + if (getVFS().exists(Twine(Path = getCompilerRTArgString( +Args, "runtime", ToolChain::FT_Static, true +CmdArgs.push_back(Path); + else if (getVFS().exists( + Twine(Path = getCompilerRTArgString( + Args, "runtime", ToolChain::FT_Shared, true +CmdArgs.push_back(Path); + else { +CmdArgs.push_back("-lflang_rt.runtime"); +addArchSpecificRPath(*this, Args, CmdArgs); + } +} + // Android target triples contain a target version. If we don't have libraries // for the exact target version, we should fall back to the next newest version // or a versionless path, if any. diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index 26b9d4c772be6..5dc80bc5a3d25 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -608,14 +608,6 @@ void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args, ToolChain::addProfileRTLibs(Args, CmdArgs); } -void AIX::addFortranRuntimeLibs(const ArgList &Args, -llvm::opt::ArgStringList &CmdArgs) const { - // Link flang_rt.runtime.a. On AIX, the static and shared library are all - // named .a - CmdArgs.push_back( - getCompilerRTArgString(Args, "runtime", ToolChain::FT_Static, true)); -} - ToolChain::CXXStdlibType AIX::GetDefaultCXXStdlibType() const { return ToolChain::CST_Libcxx; } diff --git a/clang/lib/Driver/ToolChains/AIX.h b/clang/lib/Driver/ToolChains/AIX.h index 17e8370cd1218..8f130f6b54547 100644 --- a/clang/lib/Driver/ToolChains/AIX.h +++ b/clang/lib/Driver/ToolChains/AIX.h @@ -87,9 +87,6 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain { void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; - void addFortranRuntimeLibs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const override; - CXXStdlibType GetDefaultCXXStdlibType() const override; RuntimeLibType GetDefaultRuntimeLibType() const override; diff --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driv
[clang] [flang] [driver] Generalize the code that adds the path of libflang_rt.runtime.a. (PR #134362)
https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/134362 The PR is to generalize the re-use of the `compilerRT` code of adding the path of `libflang_rt.runtime.a (so)` from AIX and LoP only to all platforms via a new function `addFlangRTLibPath`. Also, PR #134320 exposed an issue in PR #131041 that the the overriding `addFortranRuntimeLibs` is missing the link to `libquadmath`. This PR also fixed that and restored the test case that PR #131041 broke. >From cd100a70479adbb4619d685e345485eea99987c5 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Fri, 4 Apr 2025 06:10:56 -0400 Subject: [PATCH] [driver] Generalize adding the path of libflang_rt.runtime.a. --- clang/include/clang/Driver/ToolChain.h | 4 clang/lib/Driver/ToolChain.cpp | 20 ++-- clang/lib/Driver/ToolChains/AIX.cpp | 8 clang/lib/Driver/ToolChains/AIX.h| 3 --- clang/lib/Driver/ToolChains/PPCLinux.cpp | 16 clang/lib/Driver/ToolChains/PPCLinux.h | 3 --- flang/test/Driver/linker-flags.f90 | 2 +- 7 files changed, 23 insertions(+), 33 deletions(-) diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 076e4296c3090..d0059673d6a67 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -521,6 +521,10 @@ class ToolChain { addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; + /// Add the path for libflang_rt.runtime.a + void addFlangRTLibPath(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + const char *getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type = ToolChain::FT_Static, diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 36d0ae34dec86..054618a44d7bc 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -816,8 +816,7 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args, if (AsNeeded) addAsNeededOption(*this, Args, CmdArgs, /*as_needed=*/false); } -CmdArgs.push_back("-lflang_rt.runtime"); -addArchSpecificRPath(*this, Args, CmdArgs); +addFlangRTLibPath(Args, CmdArgs); // needs libexecinfo for backtrace functions if (getTriple().isOSFreeBSD() || getTriple().isOSNetBSD() || @@ -850,6 +849,23 @@ void ToolChain::addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args, CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath)); } +void ToolChain::addFlangRTLibPath(const ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const { + // Link static flang_rt.runtime.a or shared flang_rt.runtime.so + const char *Path; + if (getVFS().exists(Twine(Path = getCompilerRTArgString( +Args, "runtime", ToolChain::FT_Static, true +CmdArgs.push_back(Path); + else if (getVFS().exists( + Twine(Path = getCompilerRTArgString( + Args, "runtime", ToolChain::FT_Shared, true +CmdArgs.push_back(Path); + else { +CmdArgs.push_back("-lflang_rt.runtime"); +addArchSpecificRPath(*this, Args, CmdArgs); + } +} + // Android target triples contain a target version. If we don't have libraries // for the exact target version, we should fall back to the next newest version // or a versionless path, if any. diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index 26b9d4c772be6..5dc80bc5a3d25 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -608,14 +608,6 @@ void AIX::addProfileRTLibs(const llvm::opt::ArgList &Args, ToolChain::addProfileRTLibs(Args, CmdArgs); } -void AIX::addFortranRuntimeLibs(const ArgList &Args, -llvm::opt::ArgStringList &CmdArgs) const { - // Link flang_rt.runtime.a. On AIX, the static and shared library are all - // named .a - CmdArgs.push_back( - getCompilerRTArgString(Args, "runtime", ToolChain::FT_Static, true)); -} - ToolChain::CXXStdlibType AIX::GetDefaultCXXStdlibType() const { return ToolChain::CST_Libcxx; } diff --git a/clang/lib/Driver/ToolChains/AIX.h b/clang/lib/Driver/ToolChains/AIX.h index 17e8370cd1218..8f130f6b54547 100644 --- a/clang/lib/Driver/ToolChains/AIX.h +++ b/clang/lib/Driver/ToolChains/AIX.h @@ -87,9 +87,6 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain { void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; - void addFortranRuntimeLibs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const override; - CXXStdlibType GetDefaultCXXStdlibType() con
[clang] d579622 - [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (#133871)
Author: Mats Jun Larsen Date: 2025-04-04T07:18:01Z New Revision: d579622b1e1a6bc59fbe0135ab30fc0fd9849882 URL: https://github.com/llvm/llvm-project/commit/d579622b1e1a6bc59fbe0135ab30fc0fd9849882 DIFF: https://github.com/llvm/llvm-project/commit/d579622b1e1a6bc59fbe0135ab30fc0fd9849882.diff LOG: [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (#133871) Part of #123569 Added: Modified: clang/lib/CodeGen/CGObjCMac.cpp Removed: diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 639c38e7c4555..98f988dfecf84 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2011,7 +2011,7 @@ CodeGen::RValue CGObjCMac::GenerateMessageSendSuper( CGF.Builder.CreateStructGEP(ObjCSuper, 0)); // If this is a class message the metaclass is passed as the target. - llvm::Type *ClassTyPtr = llvm::PointerType::getUnqual(ObjCTypes.ClassTy); + llvm::Type *ClassTyPtr = llvm::PointerType::getUnqual(VMContext); llvm::Value *Target; if (IsClassMessage) { if (isCategoryImpl) { @@ -5657,7 +5657,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) IvarOffsetVarTy = LongTy; ObjectPtrTy = cast(Types.ConvertType(Ctx.getObjCIdType())); - PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy); + PtrObjectPtrTy = llvm::PointerType::getUnqual(VMContext); SelectorPtrTy = cast(Types.ConvertType(Ctx.getObjCSelType())); @@ -5688,7 +5688,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) SuperPtrCTy = Ctx.getPointerType(SuperCTy); SuperTy = cast(Types.ConvertType(SuperCTy)); - SuperPtrTy = llvm::PointerType::getUnqual(SuperTy); + SuperPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _prop_t { // char *name; @@ -5704,7 +5704,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) PropertyListTy = llvm::StructType::create( "struct._prop_list_t", IntTy, IntTy, llvm::ArrayType::get(PropertyTy, 0)); // struct _prop_list_t * - PropertyListPtrTy = llvm::PointerType::getUnqual(PropertyListTy); + PropertyListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_method { // SEL _cmd; @@ -5716,7 +5716,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_cache * CacheTy = llvm::StructType::create(VMContext, "struct._objc_cache"); - CachePtrTy = llvm::PointerType::getUnqual(CacheTy); + CachePtrTy = llvm::PointerType::getUnqual(VMContext); } ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) @@ -5737,8 +5737,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) llvm::ArrayType::get(MethodDescriptionTy, 0)); // struct _objc_method_description_list * - MethodDescriptionListPtrTy = - llvm::PointerType::getUnqual(MethodDescriptionListTy); + MethodDescriptionListPtrTy = llvm::PointerType::getUnqual(VMContext); // Protocol description structures @@ -5756,7 +5755,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) PropertyListPtrTy); // struct _objc_protocol_extension * - ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(ProtocolExtensionTy); + ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(VMContext); // Handle construction of Protocol and ProtocolList types @@ -5779,9 +5778,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) "struct._objc_protocol_list"); // struct _objc_protocol_list * - ProtocolListPtrTy = llvm::PointerType::getUnqual(ProtocolListTy); + ProtocolListPtrTy = llvm::PointerType::getUnqual(VMContext); - ProtocolPtrTy = llvm::PointerType::getUnqual(ProtocolTy); + ProtocolPtrTy = llvm::PointerType::getUnqual(VMContext); // Class description structures @@ -5795,17 +5794,17 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_ivar_list * IvarListTy = llvm::StructType::create(VMContext, "struct._objc_ivar_list"); - IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy); + IvarListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_method_list * MethodListTy = llvm::StructType::create(VMContext, "struct._objc_method_list"); - MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy); + MethodListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_class_extension * ClassExtensionTy = llvm::StructType::create( "struct._objc_class_extension", IntTy, Int8PtrTy, PropertyListPtrTy); - ClassExtensionPtrTy = llvm::PointerType::getUnqual(ClassExtensionTy); + ClassExtensionPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_class { // Class isa; @@ -5828,7 +5827,7 @@ ObjCTypesHelper::ObjCTypes
[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/133871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM][Clang] Make `+nosimd` functional for AArch32 Targets (PR #130623)
https://github.com/Stylie777 updated https://github.com/llvm/llvm-project/pull/130623 >From 8b2ad7c1475ff4aee065e9feb21469d184320472 Mon Sep 17 00:00:00 2001 From: Jack Styles Date: Fri, 7 Mar 2025 15:51:34 + Subject: [PATCH 01/10] [NFC][ARM] Split SIMD identifier away from MVE Previously, the use of MVE or MVE.FP would be defined by using the `ARM::AEK_SIMD` identifier. SIMD relates to the Cortex-A and Cortex-R extension that enables NEON instructions, which is called MVE for Cortex-M. To enable the linking of `+simd` and `+nosimd` to `+neon` and `-neon` when using clang, MVE and MVE.FP can now be defined using a unique enum identifier, rather than using the existing identifier for SIMD. This was originally planned to be merged as part of #130296 but the changes made `+nosimd` an invalid argument, which, while not having any functionality, was allowed in previous versions of LLVM. To avoid regressions being introduced, this has been combined with the fix for `+nosimd` on AArch32. --- llvm/include/llvm/TargetParser/ARMTargetParser.def | 10 +- llvm/include/llvm/TargetParser/ARMTargetParser.h | 1 + llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 2 +- llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp | 2 +- llvm/unittests/TargetParser/TargetParserTest.cpp | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/TargetParser/ARMTargetParser.def b/llvm/include/llvm/TargetParser/ARMTargetParser.def index 6b96c3e83c8c4..e515ab665d117 100644 --- a/llvm/include/llvm/TargetParser/ARMTargetParser.def +++ b/llvm/include/llvm/TargetParser/ARMTargetParser.def @@ -224,8 +224,8 @@ ARM_ARCH_EXT_NAME("dotprod", ARM::AEK_DOTPROD, "+dotprod", "-dotprod") ARM_ARCH_EXT_NAME("dsp", ARM::AEK_DSP, "+dsp", "-dsp") ARM_ARCH_EXT_NAME("fp", ARM::AEK_FP, {}, {}) ARM_ARCH_EXT_NAME("fp.dp", ARM::AEK_FP_DP, {}, {}) -ARM_ARCH_EXT_NAME("mve", (ARM::AEK_DSP | ARM::AEK_SIMD), "+mve", "-mve") -ARM_ARCH_EXT_NAME("mve.fp", (ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP), +ARM_ARCH_EXT_NAME("mve", (ARM::AEK_DSP | ARM::AEK_MVE), "+mve", "-mve") +ARM_ARCH_EXT_NAME("mve.fp", (ARM::AEK_DSP | ARM::AEK_MVE | ARM::AEK_FP), "+mve.fp", "-mve.fp") ARM_ARCH_EXT_NAME("idiv", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB), {}, {}) ARM_ARCH_EXT_NAME("mp", ARM::AEK_MP, {}, {}) @@ -345,12 +345,12 @@ ARM_CPU_NAME("cortex-m33", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP) ARM_CPU_NAME("star-mc1", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP) ARM_CPU_NAME("cortex-m35p", ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP) ARM_CPU_NAME("cortex-m55", ARMV8_1MMainline, FK_FP_ARMV8_FULLFP16_D16, false, - (ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP | ARM::AEK_FP16)) + (ARM::AEK_DSP | ARM::AEK_MVE | ARM::AEK_FP | ARM::AEK_FP16)) ARM_CPU_NAME("cortex-m85", ARMV8_1MMainline, FK_FP_ARMV8_FULLFP16_D16, false, - (ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP | ARM::AEK_FP16 | + (ARM::AEK_DSP | ARM::AEK_MVE | ARM::AEK_FP | ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_PACBTI)) ARM_CPU_NAME("cortex-m52", ARMV8_1MMainline, FK_FP_ARMV8_FULLFP16_D16, false, - (ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP | ARM::AEK_FP16 | + (ARM::AEK_DSP | ARM::AEK_MVE | ARM::AEK_FP | ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_PACBTI)) ARM_CPU_NAME("cortex-a32", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC) ARM_CPU_NAME("cortex-a35", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC) diff --git a/llvm/include/llvm/TargetParser/ARMTargetParser.h b/llvm/include/llvm/TargetParser/ARMTargetParser.h index 5dbcfd3d2d693..b2403f42f1b79 100644 --- a/llvm/include/llvm/TargetParser/ARMTargetParser.h +++ b/llvm/include/llvm/TargetParser/ARMTargetParser.h @@ -61,6 +61,7 @@ enum ArchExtKind : uint64_t { AEK_CDECP6 = 1 << 28, AEK_CDECP7 = 1 << 29, AEK_PACBTI = 1 << 30, + AEK_MVE = 1ULL << 31, // Unsupported extensions. AEK_OS = 1ULL << 59, AEK_IWMMXT = 1ULL << 60, diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 456c3b5396fc9..956fc9680ee33 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -12970,7 +12970,7 @@ bool ARMAsmParser::enableArchExtFeature(StringRef Name, SMLoc &ExtLoc) { {ARM::AEK_CRYPTO, {Feature_HasV8Bit}, {ARM::FeatureCrypto, ARM::FeatureNEON, ARM::FeatureFPARMv8}}, - {(ARM::AEK_DSP | ARM::AEK_SIMD | ARM::AEK_FP), + {(ARM::AEK_DSP | ARM::AEK_MVE | ARM::AEK_FP), {Feature_HasV8_1MMainlineBit}, {ARM::HasMVEFloatOps}}, {ARM::AEK_FP, diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp index b0fa03a35ec04..632dbebf58f04 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp +++
[clang] [llvm] [ARM][Clang] Make `+nosimd` functional for AArch32 Targets (PR #130623)
@@ -0,0 +1,31 @@ +// Ensures that when targeting an ARM target with an Asm file, clang +// collects the features from the FPU. This is critical in the +// activation of NEON for supported targets. The Cortex-R52 will be +// used and tested for VFP and NEON Support + +// RUN: %clang -target arm-none-eabi -mcpu=cortex-r52 -c %s -o /dev/null | count 0 Stylie777 wrote: Done https://github.com/llvm/llvm-project/pull/130623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ARM][NFC] Remove lines unnecessary for test (PR #134359)
https://github.com/VladiKrapp-Arm created https://github.com/llvm/llvm-project/pull/134359 None >From 4518846c9cbaf2c76249cb16729861740ab3c292 Mon Sep 17 00:00:00 2001 From: Vladi Krapp Date: Fri, 4 Apr 2025 10:41:44 +0100 Subject: [PATCH] [ARM][NFC] Remove lines unnecessary for test --- clang/test/Driver/arm-thread-pointer.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/clang/test/Driver/arm-thread-pointer.c b/clang/test/Driver/arm-thread-pointer.c index 9433cbfa091ff..7d87ed2a8e7f7 100644 --- a/clang/test/Driver/arm-thread-pointer.c +++ b/clang/test/Driver/arm-thread-pointer.c @@ -88,6 +88,3 @@ // RUN: %clang --target=thumbv6t2-linux -mtp=cp15 -x assembler -### %s 2>&1 | FileCheck -check-prefix=Thumbv6t2_Asm %s // Thumbv6t2_Asm-NOT: "-target-feature" "+read-tp-" -// A dummy main is provided to form a valid translation unit. -int main(void) { return 0; } - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/16] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/16] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/17] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/17] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/17] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/17] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [CLANG] Enable alignas after GNU attributes (PR #133107)
https://github.com/DenisGZM updated https://github.com/llvm/llvm-project/pull/133107 >From c46eda67cd7434dcce5c1f29125a940dc4ff64ba Mon Sep 17 00:00:00 2001 From: Denis Gerasimov Date: Wed, 26 Mar 2025 18:29:38 +0300 Subject: [PATCH 1/3] [CLANG] Enable alignas after GNU attributes --- clang/lib/Parse/ParseStmt.cpp | 5 + clang/test/SemaCUDA/cuda-attr-order.cu | 15 +++ 2 files changed, 20 insertions(+) create mode 100644 clang/test/SemaCUDA/cuda-attr-order.cu diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 150b2879fc94f..33b9f63bcfa08 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -296,6 +296,11 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes( goto Retry; } + case tok::kw_alignas: { +ParseAlignmentSpecifier(CXX11Attrs); +goto Retry; + } + case tok::kw_template: { SourceLocation DeclEnd; ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd, diff --git a/clang/test/SemaCUDA/cuda-attr-order.cu b/clang/test/SemaCUDA/cuda-attr-order.cu new file mode 100644 index 0..d3bf5b014d1c6 --- /dev/null +++ b/clang/test/SemaCUDA/cuda-attr-order.cu @@ -0,0 +1,15 @@ +// Verify that we can parse a simple CUDA file with different attributes order. +// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" -fsyntax-only -verify %s +// expected-no-diagnostics +#include "Inputs/cuda.h" + +struct alignas(16) float4 { +float x, y, z, w; +}; + +__attribute__((device)) float func() { +__shared__ alignas(alignof(float4)) float As[4][4]; // Both combinations +alignas(alignof(float4)) __shared__ float Bs[4][4]; // must be legal + +return As[0][0] + Bs[0][0]; +} >From 517ba9e99f06c23ec675f5bf808b84273f5b409d Mon Sep 17 00:00:00 2001 From: Denis Gerasimov Date: Fri, 28 Mar 2025 18:27:49 +0300 Subject: [PATCH 2/3] [CLANG] Enable cxx11 attributes after gnu attributes in ParseCXXClassMemberDeclaration --- clang/lib/Parse/ParseDeclCXX.cpp | 7 +-- clang/test/AST/ast-dump-color.cpp | 2 +- clang/test/Index/annotate-attribute.cpp| 2 +- clang/test/Parser/cxx0x-attributes.cpp | 6 ++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp | 8 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 51fe0663a8d1a..42db9ceb89a2b 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -3035,10 +3035,13 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration( } ParsedAttributes DeclSpecAttrs(AttrFactory); - MaybeParseMicrosoftAttributes(DeclSpecAttrs); - // Hold late-parsed attributes so we can attach a Decl to them later. LateParsedAttrList CommonLateParsedAttrs; + while (MaybeParseCXX11Attributes(DeclAttrs) || + MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs)) { + } + + MaybeParseMicrosoftAttributes(DeclSpecAttrs); // decl-specifier-seq: // Parse the common declaration-specifiers piece. diff --git a/clang/test/AST/ast-dump-color.cpp b/clang/test/AST/ast-dump-color.cpp index 87797f6bffc5b..2bd9ab7c3c841 100644 --- a/clang/test/AST/ast-dump-color.cpp +++ b/clang/test/AST/ast-dump-color.cpp @@ -91,7 +91,7 @@ struct Invalid { //CHECK: {{^}}[[Blue]]| `-[[RESET]][[MAGENTA]]DeclRefExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:40[[RESET]]> [[Green]]'class Mutex':'Mutex'[[RESET]][[Cyan]] lvalue[[RESET]][[Cyan]][[RESET]] [[GREEN]]Var[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]][[CYAN]] 'mu1'[[RESET]] [[Green]]'class Mutex':'Mutex'[[RESET]] non_odr_use_unevaluated{{$}} //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:1[[RESET]], [[Yellow]]line:30:1[[RESET]]> [[Yellow]]line:28:8[[RESET]] struct[[CYAN]] Invalid[[RESET]] definition //CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit referenced struct[[CYAN]] Invalid[[RESET]] -//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:3[[RESET]], [[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] Invalid[[RESET]] [[Green]]'void (int)'[[RESET]] +//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:29[[RESET]], [[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] Invalid[[RESET]] [[Green]]'void (int)'[[RESET]] //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:37[[RESET]], [[Yellow]][[RESET]]> [[Yellow]]col:42[[RESET]] invalid [[Green]]'int'[[RESET]] //CHECK: {{^}}[[Blue]
[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/134214 >From 620bdbed2b372b97b66147684d4ded5b666c7786 Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:08:59 +0200 Subject: [PATCH 01/17] add `bf16`/`BF16` suffix support --- clang/include/clang/Lex/LiteralSupport.h | 1 + clang/lib/Lex/LiteralSupport.cpp | 17 - clang/lib/Sema/SemaExpr.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h index ea5f63bc20399..1907cfc365d97 100644 --- a/clang/include/clang/Lex/LiteralSupport.h +++ b/clang/include/clang/Lex/LiteralSupport.h @@ -77,6 +77,7 @@ class NumericLiteralParser { bool isFloat : 1; // 1.0f bool isImaginary : 1; // 1.0i bool isFloat16 : 1; // 1.0f16 + bool isBFloat16 : 1; // 1.0bf16 bool isFloat128 : 1; // 1.0q bool isFract : 1; // 1.0hr/r/lr/uhr/ur/ulr bool isAccum : 1; // 1.0hk/k/lk/uhk/uk/ulk diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 20933cc8dee69..ab0d301a70fbd 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -917,6 +917,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isFloat = false; isImaginary = false; isFloat16 = false; + isBFloat16 = false; isFloat128 = false; MicrosoftInteger = 0; isFract = false; @@ -973,11 +974,20 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, bool isFPConstant = isFloatingLiteral(); bool HasSize = false; bool DoubleUnderscore = false; + bool isBF16 = false; // Loop over all of the characters of the suffix. If we see something bad, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { +case 'b': +case 'B': + if (isBFloat16) break; + if (isBF16) break; + if (HasSize) break; + + isBF16 = true; + continue; case 'R': case 'r': if (!LangOpts.FixedPoint) @@ -1022,7 +1032,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) && s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') { s += 2; // success, eat up 2 characters. -isFloat16 = true; +if (isBF16) { + isBFloat16 = true; +} else { + isFloat16 = true; +} continue; } @@ -1183,6 +1197,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isSizeT = false; isFloat = false; isFloat16 = false; +isBFloat16 = false; isHalf = false; isImaginary = false; isBitInt = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3af6d6c23438f..b4210fc22ae52 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3878,6 +3878,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Ty = !getLangOpts().HLSL ? Context.LongDoubleTy : Context.DoubleTy; else if (Literal.isFloat16) Ty = Context.Float16Ty; +else if (Literal.isBFloat16) + Ty = Context.BFloat16Ty; else if (Literal.isFloat128) Ty = Context.Float128Ty; else if (getLangOpts().HLSL) >From d55e0ca50eb50ec4a2fdb0e7ba9e3c11be70065d Mon Sep 17 00:00:00 2001 From: bassiounix Date: Thu, 3 Apr 2025 10:09:22 +0200 Subject: [PATCH 02/17] add `__bf16` macros --- clang/lib/Frontend/InitPreprocessor.cpp | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 0b54665501c76..9bca74a8b4bd6 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -96,7 +96,7 @@ static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, template static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, -T IEEEQuadVal) { +T BFloatVal, T IEEEQuadVal) { if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf()) return IEEEHalfVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle()) @@ -107,6 +107,8 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, return X87DoubleExtendedVal; if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble()) return PPCDoubleDoubleVal; + if (Sem == (const llvm::fltSemantics*)&llvm::APFloat::BFloat()) +return BFloatVal; assert(Sem == (const llvm::fltSemantics*)&llvm::APFloat::IEEEquad()); return IEEEQuadVal; } @@ -117,29 +119,34 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
[clang] [ARM][NFC] Remove lines unnecessary for test (PR #134359)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vladi Krapp (VladiKrapp-Arm) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/134359.diff 1 Files Affected: - (modified) clang/test/Driver/arm-thread-pointer.c (-3) ``diff diff --git a/clang/test/Driver/arm-thread-pointer.c b/clang/test/Driver/arm-thread-pointer.c index 9433cbfa091ff..7d87ed2a8e7f7 100644 --- a/clang/test/Driver/arm-thread-pointer.c +++ b/clang/test/Driver/arm-thread-pointer.c @@ -88,6 +88,3 @@ // RUN: %clang --target=thumbv6t2-linux -mtp=cp15 -x assembler -### %s 2>&1 | FileCheck -check-prefix=Thumbv6t2_Asm %s // Thumbv6t2_Asm-NOT: "-target-feature" "+read-tp-" -// A dummy main is provided to form a valid translation unit. -int main(void) { return 0; } - `` https://github.com/llvm/llvm-project/pull/134359 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [MS][clang] Fix crash on deletion of array of pointers (PR #134088)
https://github.com/Fznamznon closed https://github.com/llvm/llvm-project/pull/134088 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/133910 >From 6d61256a73c64ef4351266d6ef76067f5a2568db Mon Sep 17 00:00:00 2001 From: Viktoriia Bakalova Date: Fri, 4 Apr 2025 13:40:55 +0200 Subject: [PATCH 1/2] [WIP] Implement -dump-deserialized-declaration-ranges flag to dump source ranges of deserialized decls. --- clang/include/clang/Driver/Options.td | 4 + .../include/clang/Frontend/FrontendOptions.h | 3 + clang/lib/Frontend/FrontendAction.cpp | 161 +- .../dump-deserialized-declaration-ranges.cpp | 80 + 4 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 clang/test/Frontend/dump-deserialized-declaration-ranges.cpp diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 3af072242d039..1737e40b776e1 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7968,6 +7968,10 @@ def print_dependency_directives_minimized_source : Flag<["-"], "print-dependency-directives-minimized-source">, HelpText<"Print the output of the dependency directives source minimizer">; } +def dump_deserialized_declaration_ranges : Joined<["-"], + "dump-deserialized-declaration-ranges=">, + HelpText<"Dump ranges of deserialized declarations to aid debugging and minimization">, + MarshallingInfoString>; defm emit_llvm_uselists : BoolOption<"", "emit-llvm-uselists", CodeGenOpts<"EmitLLVMUseLists">, DefaultFalse, diff --git a/clang/include/clang/Frontend/FrontendOptions.h b/clang/include/clang/Frontend/FrontendOptions.h index a9c9849ff52ab..8ef9ce9db8783 100644 --- a/clang/include/clang/Frontend/FrontendOptions.h +++ b/clang/include/clang/Frontend/FrontendOptions.h @@ -530,6 +530,9 @@ class FrontendOptions { /// Output Path for module output file. std::string ModuleOutputPath; + /// Output path to dump ranges of deserialized declarations. + std::string DumpDeserializedDeclarationRangesPath; + public: FrontendOptions() : DisableFree(false), RelocatablePCH(false), ShowHelp(false), diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 2d77f06be7446..f98aa5ab1fe51 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/FileEntry.h" #include "clang/Basic/LangStandard.h" #include "clang/Basic/Sarif.h" +#include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" @@ -35,6 +36,7 @@ #include "clang/Serialization/ASTReader.h" #include "clang/Serialization/GlobalModuleIndex.h" #include "llvm/ADT/ScopeExit.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/BuryPointer.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -49,6 +51,144 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations to aid debugging and bug minimization. +/// It implements ASTConsumer and ASTDeserializationListener, so that an object of DeserializedDeclsLineRangePrinter registers +/// as its own listener. +/// The ASTDeserializationListener interface provides the DeclRead callback that we use to collect the deserialized Decls. +/// Note that printing or otherwise processing them as this point is dangerous, since that could trigger additional +/// deserialization and crash compilation. +/// Therefore, we process the collected Decls in HandleTranslationUnit method of ASTConsumer. +/// This is a safe point, since we know that by this point all the Decls needed by the compiler frontend have been +/// deserialized. In case our processing causes further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter(SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || + isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { + StringRef Filename; + std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); +if (!PendingDecls.empty()) { + llvm::errs() << "Deserialized more decls while printing, total of " +<< Pending
[clang] [clang] [ARM] Explicitly enable NEON for Windows/Darwin targets (PR #122095)
@@ -659,13 +659,21 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, CPUArgFPUKind != llvm::ARM::FK_INVALID ? CPUArgFPUKind : ArchArgFPUKind; (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } else { +bool Generic = true; if (!ForAS) { std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); + if (CPU != "generic") +Generic = false; llvm::ARM::ArchKind ArchKind = arm::getLLVMArchKindForARM(CPU, ArchName, Triple); FPUKind = llvm::ARM::getDefaultFPU(CPU, ArchKind); (void)llvm::ARM::getFPUFeatures(FPUKind, Features); } +if (Generic && (Triple.isOSWindows() || Triple.isOSDarwin()) && Stylie777 wrote: I would agree with @DavidSpickett here, the changes I have made in #130623 would change behaviour for users who rely on features from the FPU not being present in the assembler, so I am not sure it is appropriate to backport when a release has already been made. https://github.com/llvm/llvm-project/pull/122095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix the signature for __builtin___clear_cache (PR #134376)
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/134376 The signature was changed from void(char *, char *) to void(void *, void *) to match GCC's signature for the same builtin. Fixes #47833 >From e37b125713c436d88b49516a1adbbff7c78154c3 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 4 Apr 2025 09:02:35 -0400 Subject: [PATCH] Fix the signature for __builtin___clear_cache The signature was changed from void(char *, char *) to void(void *, void *) to match GCC's signature for the same builtin. Fixes #47833 --- clang/docs/ReleaseNotes.rst | 4 clang/include/clang/Basic/Builtins.td | 2 +- clang/test/Sema/clear_cache.c | 12 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/clear_cache.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3055394dd8b6c..969bfb04623ed 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -354,6 +354,10 @@ Bug Fixes to Compiler Builtins - The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed. +- The signature for ``__builtin___clear_cache`` was changed from + ``void(char *, char *)`` to ``void(void *, void *)`` to match GCC's signature + for the same builtin. (#GH47833) + Bug Fixes to Attribute Support ^^ - Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125 diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index b2c7ddb43de55..868e5b92acdc9 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -920,7 +920,7 @@ def FrameAddress : Builtin { def ClearCache : Builtin { let Spellings = ["__builtin___clear_cache"]; let Attributes = [NoThrow]; - let Prototype = "void(char*, char*)"; + let Prototype = "void(void*, void*)"; } def BuiltinSetjmp : Builtin { diff --git a/clang/test/Sema/clear_cache.c b/clang/test/Sema/clear_cache.c new file mode 100644 index 0..e6a3421309967 --- /dev/null +++ b/clang/test/Sema/clear_cache.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Ensure that __builtin___clear_cache has the expected signature. Clang used +// to have a signature accepting char * while GCC had a signature accepting +// void * that was documented incorrectly. +void test(void) { + int n = 0; + __builtin___clear_cache(&n, &n + 1); // Ok + + __builtin___clear_cache((const void *)&n, (const void *)(&n + 1)); // expected-warning 2 {{passing 'const void *' to parameter of type 'void *' discards qualifiers}} +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { +StringRef Filename; +std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); +if (!PendingDecls.empty()) { + llvm::errs() << "Deserialized more decls while printing, total of " + << PendingDecls.size() << "\n"; + PendingDecls.clear(); +} + +// Merge ranges in each of the files. For simplicity, track lines and hope +// they do not break things. +struct FileData { + std::vector> FromTo; + std::vector> Columns; ilya-biryukov wrote: NIT: Columns is unused and can be removed? https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { +StringRef Filename; +std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); +if (!PendingDecls.empty()) { + llvm::errs() << "Deserialized more decls while printing, total of " + << PendingDecls.size() << "\n"; + PendingDecls.clear(); +} + +// Merge ranges in each of the files. For simplicity, track lines and hope +// they do not break things. +struct FileData { + std::vector> FromTo; + std::vector> Columns; + OptionalFileEntryRef Ref; +}; +llvm::DenseMap FileToLines; +for (const Decl *D : Decls) { + CharSourceRange R = SM.getExpansionRange(D->getSourceRange()); + if (!R.isValid()) +continue; + + auto *F = SM.getFileEntryForID(SM.getFileID(R.getBegin())); + if (F != SM.getFileEntryForID(SM.getFileID(R.getEnd( +continue; ilya-biryukov wrote: NIT: Add a comment explaining that handling these cases is too difficult and they should be rare. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); ilya-biryukov wrote: NIT: remove this line, we know it's a no-op. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) ilya-biryukov wrote: NIT: add a comment explaining why we only report top-level declarations. In most cases, it's impossible to get a hold of non-top-level entities with deserializing the top-level entities they are a part of. Therefore we choose to work at namespace-level granularity to simplify the implementation and reduce the number of cases we need to care about. I can also see us making this more fine-grained in the future for other things that get deserialized in a more fine-grained manner, e.g. for class members. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || ilya-biryukov wrote: NIT: it would be useful to explain why we exclude `LinkageSpecDecl` and `NamespaceDecl`. They represent `extern "C" { /* ... */ }` and `namespace { /* ... */ }` blocks that would cover too many declarations that could otherwise be used and make outputs less useful for minimization. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { +StringRef Filename; +std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); ilya-biryukov wrote: We don't need this and the following `if` now that we do not collect more stuff in `DeclRead` https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { +StringRef Filename; +std::vector> FromTo; ilya-biryukov wrote: NIT: Could we add ```cpp struct Position { unsigned Line; unsigned Column; }; ``` to avoid code like `a.first.second`. I think it may require passing a lambda to some comparator, but the code should be easier to comprehend overall. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -121,6 +267,26 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, if (!Consumer) return nullptr; + std::vector> Consumers; + llvm::StringRef DumpDeserializedDeclarationRangesPath = + CI.getFrontendOpts().DumpDeserializedDeclarationRangesPath; + if (!DumpDeserializedDeclarationRangesPath.empty()) { +std::error_code ErrorCode; +auto FileStream = std::make_unique( +DumpDeserializedDeclarationRangesPath, ErrorCode, +llvm::sys::fs::OF_None); +if (!ErrorCode) { + auto Printer = std::make_unique( + CI.getSourceManager(), std::move(FileStream)); + Consumers.push_back(std::move(Printer)); ilya-biryukov wrote: NIT: inline Printer, `Consumers.push_back(std::make_unique...)` https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
ilya-biryukov wrote: Could you also update the PR description and change `[WIP]` to `[Clang]` in the title so that we don't accidentally forget this before comitting? https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -49,6 +51,150 @@ LLVM_INSTANTIATE_REGISTRY(FrontendPluginRegistry) namespace { +/// DeserializedDeclsLineRangePrinter dumps ranges of deserialized declarations +/// to aid debugging and bug minimization. It implements ASTConsumer and +/// ASTDeserializationListener, so that an object of +/// DeserializedDeclsLineRangePrinter registers as its own listener. The +/// ASTDeserializationListener interface provides the DeclRead callback that we +/// use to collect the deserialized Decls. Note that printing or otherwise +/// processing them as this point is dangerous, since that could trigger +/// additional deserialization and crash compilation. Therefore, we process the +/// collected Decls in HandleTranslationUnit method of ASTConsumer. This is a +/// safe point, since we know that by this point all the Decls needed by the +/// compiler frontend have been deserialized. In case our processing causes +/// further deserialization, DeclRead from the listener might be called again. +/// However, at that point we don't accept any more Decls for processing. +class DeserializedDeclsLineRangePrinter : public ASTDeserializationListener, + public ASTConsumer { +public: + explicit DeserializedDeclsLineRangePrinter( + SourceManager &SM, std::unique_ptr OS) + : ASTDeserializationListener(), SM(SM), OS(std::move(OS)) {} + + void DeclRead(GlobalDeclID ID, const Decl *D) override { +if (!IsCollectingDecls) { + return; +} +if (!D || isa(D) || isa(D) || +isa(D)) + return; +if (auto *DC = D->getDeclContext(); !DC || !DC->isFileContext()) + return; +PendingDecls.push_back(D); +ASTDeserializationListener::DeclRead(ID, D); + } + + using Position = std::pair; + struct RequiredRanges { +StringRef Filename; +std::vector> FromTo; + }; + void HandleTranslationUnit(ASTContext &Context) override { +IsCollectingDecls = false; +std::vector Decls = std::move(PendingDecls); +if (!PendingDecls.empty()) { + llvm::errs() << "Deserialized more decls while printing, total of " + << PendingDecls.size() << "\n"; + PendingDecls.clear(); +} + +// Merge ranges in each of the files. For simplicity, track lines and hope +// they do not break things. +struct FileData { + std::vector> FromTo; + std::vector> Columns; + OptionalFileEntryRef Ref; +}; +llvm::DenseMap FileToLines; +for (const Decl *D : Decls) { + CharSourceRange R = SM.getExpansionRange(D->getSourceRange()); + if (!R.isValid()) +continue; + + auto *F = SM.getFileEntryForID(SM.getFileID(R.getBegin())); + if (F != SM.getFileEntryForID(SM.getFileID(R.getEnd( +continue; + + auto &Data = FileToLines[F]; + if (!Data.Ref) +Data.Ref = SM.getFileEntryRefForID(SM.getFileID(R.getBegin())); + Data.FromTo.push_back({{SM.getSpellingLineNumber(R.getBegin()), ilya-biryukov wrote: NIT: maybe a static helper method `Position::getSpelling(R.getBegin())` could improve the readability a little if we choose to introduce a new type here. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WIP] Implement `-dump-deserialized-declaration-ranges` flag. (PR #133910)
@@ -121,6 +267,26 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, if (!Consumer) return nullptr; + std::vector> Consumers; ilya-biryukov wrote: NIT: `llvm::SmallVector, 1> Consumers` is a good choice here since we have 1 consumer most of the time. https://github.com/llvm/llvm-project/pull/133910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Teach Barmetal toolchain about GCC installation (PR #121829)
https://github.com/quic-garvgupt edited https://github.com/llvm/llvm-project/pull/121829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)
https://github.com/AmrDeveloper updated https://github.com/llvm/llvm-project/pull/132974 >From 4dc1e77299c71b8f01fb73f7fba5f14e0fbe3edd Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Fri, 21 Mar 2025 21:07:11 +0100 Subject: [PATCH 01/10] [CIR] [Upstream local initialization for ArrayType --- .../CIR/Dialect/Builder/CIRBaseBuilder.h | 35 +++ .../include/clang/CIR/Dialect/IR/CIRDialect.h | 25 ++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 44 +++ clang/include/clang/CIR/LoweringHelpers.h | 40 +++ clang/lib/CIR/CodeGen/Address.h | 10 + clang/lib/CIR/CodeGen/CIRGenBuilder.h | 4 + clang/lib/CIR/CodeGen/CIRGenDecl.cpp | 2 +- clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp | 277 ++ clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp | 23 ++ clang/lib/CIR/CodeGen/CIRGenFunction.cpp | 46 +++ clang/lib/CIR/CodeGen/CIRGenFunction.h| 12 +- clang/lib/CIR/CodeGen/CIRGenModule.cpp| 12 + clang/lib/CIR/CodeGen/CIRGenModule.h | 5 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 13 + clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 24 ++ clang/lib/CIR/CodeGen/CIRGenTypes.h | 4 + clang/lib/CIR/CodeGen/CIRGenValue.h | 44 ++- clang/lib/CIR/CodeGen/CMakeLists.txt | 1 + clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 42 ++- clang/lib/CIR/Lowering/CMakeLists.txt | 1 + .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 109 +++ .../CIR/Lowering/DirectToLLVM/LowerToLLVM.h | 15 + clang/lib/CIR/Lowering/LoweringHelpers.cpp| 150 ++ clang/test/CIR/CodeGen/array.cpp | 97 +- clang/test/CIR/Lowering/array.cpp | 77 - 25 files changed, 1087 insertions(+), 25 deletions(-) create mode 100644 clang/include/clang/CIR/LoweringHelpers.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp create mode 100644 clang/lib/CIR/Lowering/LoweringHelpers.cpp diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index c6aea10d46b63..4c7e6ec061d46 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -32,6 +32,11 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { return create(loc, attr.getType(), attr); } + // Creates constant null value for integral type ty. + cir::ConstantOp getNullValue(mlir::Type ty, mlir::Location loc) { +return create(loc, ty, getZeroInitAttr(ty)); + } + cir::ConstantOp getBool(bool state, mlir::Location loc) { return create(loc, getBoolTy(), getCIRBoolAttr(state)); } @@ -68,6 +73,36 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { getContext(), mlir::cast(type), valueAttr); } + mlir::TypedAttr getConstNullPtrAttr(mlir::Type t) { +assert(mlir::isa(t) && "expected cir.ptr"); +return getConstPtrAttr(t, 0); + } + + mlir::TypedAttr getZeroAttr(mlir::Type t) { +return cir::ZeroAttr::get(getContext(), t); + } + + mlir::TypedAttr getZeroInitAttr(mlir::Type ty) { +if (mlir::isa(ty)) + return cir::IntAttr::get(ty, 0); +if (auto fltType = mlir::dyn_cast(ty)) + return cir::FPAttr::getZero(fltType); +if (auto fltType = mlir::dyn_cast(ty)) + return cir::FPAttr::getZero(fltType); +if (auto fltType = mlir::dyn_cast(ty)) + return cir::FPAttr::getZero(fltType); +if (auto fltType = mlir::dyn_cast(ty)) + return cir::FPAttr::getZero(fltType); +if (auto arrTy = mlir::dyn_cast(ty)) + return getZeroAttr(arrTy); +if (auto ptrTy = mlir::dyn_cast(ty)) + return getConstNullPtrAttr(ptrTy); +if (mlir::isa(ty)) { + return getCIRBoolAttr(false); +} +llvm_unreachable("Zero initializer for given type is NYI"); + } + mlir::Value createAlloca(mlir::Location loc, cir::PointerType addrType, mlir::Type type, llvm::StringRef name, mlir::IntegerAttr alignment) { diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h index da3b41371b9ab..ba7bbedf4714e 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.h @@ -32,6 +32,31 @@ #include "clang/CIR/Interfaces/CIRLoopOpInterface.h" #include "clang/CIR/Interfaces/CIROpInterfaces.h" +namespace mlir { +namespace OpTrait { + +namespace impl { +// These functions are out-of-line implementations of the methods in the +// corresponding trait classes. This avoids them being template +// instantiated/duplicated. +LogicalResult verifySameFirstOperandAndResultType(Operation *op); +} // namespace impl + +/// This class provides verification for ops that are known to have the same +/// first operand and result type. +/// +template +class SameFirstOperandAndResultType +: public TraitBase { +public: + static llvm::LogicalResu
[clang-tools-extra] [clang-tidy] Improve integer comparison by matching valid expressions outside implicitCastExpr (PR #134188)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp -- clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp `` View the diff from clang-format here. ``diff diff --git a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp index 63e044f8c..8f2bb4c4b 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp @@ -54,7 +54,8 @@ intCastExpression(bool IsSigned, const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr)); const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr)); - // Match function calls or variable references not directly wrapped by an implicit cast + // Match function calls or variable references not directly wrapped by an + // implicit cast const auto CallIntExpr = CastBindName.empty() ? callExpr(HasIntegerType) : callExpr(HasIntegerType).bind(CastBindName); `` https://github.com/llvm/llvm-project/pull/134188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang,debuginfo] added vtt parameter in destructor DISubroutineType (PR #130674)
Markus =?utf-8?q?Gschoßmann?= , Markus =?utf-8?q?Gschoßmann?= Message-ID: In-Reply-To: @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s rnk wrote: Thanks, I looked at the files, and I think the new debug info looks good, it adds a DISubroutineType int parameter. However, I don't understand why the patch you've posted here has that effect. Do you have more local changes? Why does skipping more arguments in this loop create more subroutine parameter types? I'm struggling to understand, and I just assumed adding more testing would provide answers to these questions. Please do create a test case out of the IR you shared, it does seem relevant. https://github.com/llvm/llvm-project/pull/130674 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebKit checkers] Treat Objective-C message send return value as safe (PR #133605)
https://github.com/t-rasmud approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/133605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC] Initial implementation of P2719 (PR #113510)
@@ -16147,6 +16169,108 @@ bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, return Invalid; } +bool Sema::isTypeAwareOperatorNewOrDelete(const NamedDecl *ND) const { + const FunctionDecl *FnDecl = nullptr; + if (auto *FTD = dyn_cast(ND)) +FnDecl = FTD->getTemplatedDecl(); + else if (auto *FD = dyn_cast(ND)) +FnDecl = FD; + + return FnDecl->isTypeAwareOperatorNewOrDelete(); +} + +FunctionDecl * +Sema::instantiateTypeAwareUsualDelete(FunctionTemplateDecl *FnTemplateDecl, + QualType DeallocType) { + if (!getLangOpts().TypeAwareAllocators) +return nullptr; + + TemplateParameterList *TemplateParameters = + FnTemplateDecl->getTemplateParameters(); + if (TemplateParameters->hasParameterPack()) +return nullptr; + + FunctionDecl *FnDecl = FnTemplateDecl->getTemplatedDecl(); + if (!FnDecl->isTypeAwareOperatorNewOrDelete()) +return nullptr; + + if (FnDecl->isVariadic()) +return nullptr; + + unsigned NumParams = FnDecl->getNumParams(); + if (NumParams < 2) +return nullptr; + + for (size_t Idx = 1; Idx < NumParams; ++Idx) { +// A type aware allocation is only usual if the only dependent parameter is +// the first parameter. +const ParmVarDecl *ParamDecl = FnDecl->getParamDecl(Idx); +if (ParamDecl->getType()->isDependentType()) + return nullptr; + } + + QualType SpecializedTypeIdentity = + instantiateSpecializedTypeIdentity(DeallocType); + if (SpecializedTypeIdentity.isNull()) +return nullptr; + SmallVector ArgTypes; + ArgTypes.reserve(NumParams); + ArgTypes.push_back(SpecializedTypeIdentity); + ArgTypes.push_back(FnDecl->getParamDecl(1)->getType()); + unsigned UsualParamsIdx = 2; + if (UsualParamsIdx < NumParams && FnDecl->isDestroyingOperatorDelete()) { +QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType(); +ArgTypes.push_back(Type); +++UsualParamsIdx; + } + + if (UsualParamsIdx < NumParams) { +QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType(); +if (Context.hasSameUnqualifiedType(Type, Context.getSizeType())) { + ArgTypes.push_back(Type); + ++UsualParamsIdx; +} + } + + if (UsualParamsIdx < NumParams) { +QualType Type = FnDecl->getParamDecl(UsualParamsIdx)->getType(); +if (Type->isAlignValT()) { + ArgTypes.push_back(Type); + ++UsualParamsIdx; +} + } + + if (UsualParamsIdx != NumParams) +return nullptr; + + FunctionProtoType::ExtProtoInfo EPI; + QualType ExpectedFunctionType = + Context.getFunctionType(Context.VoidTy, ArgTypes, EPI); + SourceLocation Loc; + sema::TemplateDeductionInfo Info(Loc); + FunctionDecl *Result; + if (DeduceTemplateArguments(FnTemplateDecl, nullptr, ExpectedFunctionType, + Result, Info) != TemplateDeductionResult::Success) +return nullptr; + return Result; cor3ntin wrote: I'm not sure either, but looking at other places in the code this actually looks correct. https://github.com/llvm/llvm-project/pull/113510 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)
https://github.com/benshi001 updated https://github.com/llvm/llvm-project/pull/131976 >From 163c73d21af736c94f1bb8f8c63caf96e127aba5 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Wed, 19 Mar 2025 13:21:48 +0800 Subject: [PATCH 1/3] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo fixes https://github.com/llvm/llvm-project/issues/131967 --- clang/lib/CodeGen/Targets/AVR.cpp | 7 --- clang/test/CodeGen/avr/argument.c | 10 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/Targets/AVR.cpp b/clang/lib/CodeGen/Targets/AVR.cpp index 26e2a22f14d1e..d0def86376f89 100644 --- a/clang/lib/CodeGen/Targets/AVR.cpp +++ b/clang/lib/CodeGen/Targets/AVR.cpp @@ -59,7 +59,7 @@ class AVRABIInfo : public DefaultABIInfo { unsigned TySize = getContext().getTypeSize(Ty); // An int8 type argument always costs two registers like an int16. -if (TySize == 8 && NumRegs >= 2) { +if (TySize == 8 && NumRegs >= 2 && Ty->isIntegralOrEnumerationType()) { NumRegs -= 2; return ABIArgInfo::getExtend(Ty); } @@ -135,7 +135,8 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo { if (GV->isDeclaration()) return; const auto *FD = dyn_cast_or_null(D); -if (!FD) return; +if (!FD) + return; auto *Fn = cast(GV); if (FD->getAttr()) @@ -145,7 +146,7 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo { Fn->addFnAttr("signal"); } }; -} +} // namespace std::unique_ptr CodeGen::createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, diff --git a/clang/test/CodeGen/avr/argument.c b/clang/test/CodeGen/avr/argument.c index 31bf678c05a54..5f4b300f350ae 100644 --- a/clang/test/CodeGen/avr/argument.c +++ b/clang/test/CodeGen/avr/argument.c @@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) { x.arr[1] = b; return x; } + +struct s8_t { + char a; +}; + +// AVR-NOT: {{.*}} signext +// TINY-NOT: {{.*}} signext +char foob(struct s8_t a) { + return a.a + 1; +} >From db000cf7c012ebe8d7fb30e47089b61b7ad9c045 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Thu, 20 Mar 2025 09:02:21 +0800 Subject: [PATCH 2/3] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo fixes https://github.com/llvm/llvm-project/issues/131967 --- clang/lib/CodeGen/Targets/AVR.cpp | 5 ++--- clang/test/CodeGen/avr/argument.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/Targets/AVR.cpp b/clang/lib/CodeGen/Targets/AVR.cpp index d0def86376f89..5399d12f7ce80 100644 --- a/clang/lib/CodeGen/Targets/AVR.cpp +++ b/clang/lib/CodeGen/Targets/AVR.cpp @@ -135,8 +135,7 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo { if (GV->isDeclaration()) return; const auto *FD = dyn_cast_or_null(D); -if (!FD) - return; +if (!FD) return; auto *Fn = cast(GV); if (FD->getAttr()) @@ -146,7 +145,7 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo { Fn->addFnAttr("signal"); } }; -} // namespace +} std::unique_ptr CodeGen::createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, diff --git a/clang/test/CodeGen/avr/argument.c b/clang/test/CodeGen/avr/argument.c index 5f4b300f350ae..a7682f4ed6299 100644 --- a/clang/test/CodeGen/avr/argument.c +++ b/clang/test/CodeGen/avr/argument.c @@ -119,8 +119,8 @@ struct s8_t { char a; }; -// AVR-NOT: {{.*}} signext -// TINY-NOT: {{.*}} signext +// AVR: define {{.*}} i8 @foob(i8 {{.*}}) +// TINY define {{.*}} i8 @foob(i8 {{.*}}) char foob(struct s8_t a) { return a.a + 1; } >From 3864ab2200c5cf8107c9fe29c3d4092d90b80c30 Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Fri, 21 Mar 2025 12:56:11 +0800 Subject: [PATCH 3/3] fix test --- clang/test/CodeGen/avr/argument.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/CodeGen/avr/argument.c b/clang/test/CodeGen/avr/argument.c index a7682f4ed6299..1776cd7cf2c01 100644 --- a/clang/test/CodeGen/avr/argument.c +++ b/clang/test/CodeGen/avr/argument.c @@ -120,7 +120,7 @@ struct s8_t { }; // AVR: define {{.*}} i8 @foob(i8 {{.*}}) -// TINY define {{.*}} i8 @foob(i8 {{.*}}) +// TINY: define {{.*}} i8 @foob(i8 {{.*}}) char foob(struct s8_t a) { return a.a + 1; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [alpha.webkit.UnretainedLambdaCapturesChecker] Add the support for protectedSelf (PR #132363)
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 fe6bced9e40f7d4c35550c51ef9cdc7be2a055e7 cf415a9cf9933bc4e55d3c8da9b27551b09061fe --extensions cpp -- clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp index e8dcf3aaf5..8ecb6da45e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp @@ -377,7 +377,8 @@ public: if (auto *ImplicitParam = dyn_cast(CapturedVar)) { auto kind = ImplicitParam->getParameterKind(); if ((kind == ImplicitParamKind::ObjCSelf || - kind == ImplicitParamKind::CXXThis) && !shouldCheckThis) + kind == ImplicitParamKind::CXXThis) && + !shouldCheckThis) continue; } QualType CapturedVarQualType = CapturedVar->getType(); `` https://github.com/llvm/llvm-project/pull/132363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits