[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)
https://github.com/h-vetinari updated https://github.com/llvm/llvm-project/pull/93429 >From 8c1b899aa174b107fece1edbf99eaf261bdea516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 25 Apr 2022 09:45:22 +0300 Subject: [PATCH 1/5] [runtimes] [CMake] Use CMAKE_REQUIRED_LINK_OPTIONS to simplify handling of the --unwindlib=none option This avoids passing the option unnecessarily to compilation commands (where it causes warnings). This fails in practice with libunwind, where setting CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY breaks it, as the option from CMAKE_REQUIRED_LINK_OPTIONS ends up passed to the "ar" tool too. --- libunwind/CMakeLists.txt | 3 +++ runtimes/CMakeLists.txt | 22 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index b22ade0a7d71e..3d2fadca9d2ec 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -221,9 +221,12 @@ add_cxx_compile_flags_if_supported(-EHsc) # This leads to libunwind not being built with this flag, which makes # libunwind quite useless in this setup. set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +set(CMAKE_REQUIRED_LINK_OPTIONS) add_compile_flags_if_supported(-funwind-tables) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE}) +set(CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS}) if (LIBUNWIND_USES_ARM_EHABI AND NOT CXX_SUPPORTS_FUNWIND_TABLES_FLAG) message(SEND_ERROR "The -funwind-tables flag must be supported " diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 24f4851169591..8f909322c9a98 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -116,27 +116,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C # brittle. We should ideally move this to runtimes/CMakeLists.txt. llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) - set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none") - # TODO: When we can require CMake 3.14, we should use - # CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround: - # When using CMAKE_REQUIRED_FLAGS, this option gets added both to - # compilation and linking commands. That causes warnings in the - # compilation commands during cmake tests. This is normally benign, but - # when testing whether -Werror works, that test fails (due to the - # preexisting warning). - # - # Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we - # can use --start-no-unused-arguments to silence the warnings about - # --unwindlib=none during compilation. - # - # We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to - # allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS - # below. - check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS) - if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS) -set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments") - endif() + list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "--unwindlib=none") endif() # Disable use of the installed C++ standard library when building runtimes. >From 816e9e6d81ac12537879406e0495fc80394a1a66 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Thu, 20 Jun 2024 23:18:51 +1100 Subject: [PATCH 2/5] add comment (and CMake issue reference) about incompatible options --- libunwind/CMakeLists.txt | 4 1 file changed, 4 insertions(+) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 3d2fadca9d2ec..d84f8fa6ff954 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -220,6 +220,10 @@ add_cxx_compile_flags_if_supported(-EHsc) # # This leads to libunwind not being built with this flag, which makes # libunwind quite useless in this setup. +# +# NOTE: we need to work around https://gitlab.kitware.com/cmake/cmake/-/issues/23454 +# because CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) +# is incompatible with CMAKE_TRY_COMPILE_TARGET_TYPE==STATIC_LIBRARY. set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) >From 3f917d22bdcd8b398cf7162563547418a056ecec Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Thu, 20 Jun 2024 23:18:51 +1100 Subject: [PATCH 3/5] [cmake] move check for `-fno-exceptions` to "safe zone" w.r.t. interference between CMAKE_REQUIRED_LINK_OPTIONS and static libraries --- libunwind/CMakeLists.txt | 2 +-
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,134 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change h-vetinari wrote: A slightly cleaner formulation might be "non-cascading X" or perhaps "non-percolating Y". https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcalls (PR #96025)
https://github.com/vfdff updated https://github.com/llvm/llvm-project/pull/96025 >From ed6292fd0e9119322c39e5f37e2225c76e324101 Mon Sep 17 00:00:00 2001 From: zhongyunde 00443407 Date: Tue, 18 Jun 2024 09:21:07 -0400 Subject: [PATCH 1/6] [TBAA] Emit int TBAA metadata on FP math libcalls Base on the discussion https://discourse.llvm.org/t/fp-can-we-add-pure-attribute-for-math-library-functions-default/79459, math libcalls set errno, so it should emit "int" TBAA metadata on FP libcalls to solve the alias issue. Fix https://github.com/llvm/llvm-project/issues/86635 --- clang/lib/CodeGen/CGBuiltin.cpp | 33 ++- clang/test/CodeGen/math-libcalls-tbaa.cpp | 22 +++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGen/math-libcalls-tbaa.cpp diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 08a89bd123d03..dc4af109cdbdb 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -707,7 +707,38 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD, const CallExpr *E, llvm::Constant *calleeValue) { CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD)); - return CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + RValue Call = + CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + + // Check the supported intrinsic. + if (unsigned BuiltinID = FD->getBuiltinID()) { +auto IntrinsicID = [&]() -> unsigned { + switch (BuiltinID) { + case Builtin::BIexpf: + case Builtin::BI__builtin_expf: + case Builtin::BI__builtin_expf128: +return true; + } + // TODO: support more FP math libcalls + return false; +}(); + +if (IntrinsicID) { + llvm::MDBuilder MDHelper(CGF.getLLVMContext()); + MDNode *RootMD; + if (CGF.getLangOpts().CPlusPlus) +RootMD = MDHelper.createTBAARoot("Simple C++ TBAA"); + else +RootMD = MDHelper.createTBAARoot("Simple C/C++ TBAA"); + // Emit "int" TBAA metadata on FP math libcalls. + MDNode *AliasType = MDHelper.createTBAANode("int", RootMD); + MDNode *MDInt = MDHelper.createTBAAStructTagNode(AliasType, AliasType, 0); + + Value *Val = Call.getScalarVal(); + cast(Val)->setMetadata(LLVMContext::MD_tbaa, MDInt); +} + } + return Call; } /// Emit a call to llvm.{sadd,uadd,ssub,usub,smul,umul}.with.overflow.* diff --git a/clang/test/CodeGen/math-libcalls-tbaa.cpp b/clang/test/CodeGen/math-libcalls-tbaa.cpp new file mode 100644 index 0..d5b0741a476cb --- /dev/null +++ b/clang/test/CodeGen/math-libcalls-tbaa.cpp @@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 +// RUN: %clang -S -O3 -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK + +#include + + +// Emit int TBAA metadata on FP math libcalls, which is useful for alias analysis + +// CHECK-LABEL: define dso_local noundef float @_Z3fooPffi +// CHECK-SAME: (ptr nocapture noundef readonly [[NUM:%.*]], float noundef [[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 40 +// CHECK-NEXT:[[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA6:![0-9]+]] +// CHECK-NEXT:[[CALL_I:%.*]] = tail call noundef float @expf(float noundef [[TMP0]]) #[[ATTR2:[0-9]+]], !tbaa [[TBAA10:![0-9]+]] +// CHECK-NEXT:[[MUL:%.*]] = fmul float [[TMP0]], [[CALL_I]] +// CHECK-NEXT:ret float [[MUL]] +// +float foo (float num[], float r2inv, int n) { + const float expm2 = std::exp(num[10]); // Emit TBAA metadata on @expf + float tmp = expm2 * num[10]; + return tmp; +} >From 9990877a2b9736c684c8cabeb03c6d98a3d078ce Mon Sep 17 00:00:00 2001 From: zhongyunde 00443407 Date: Thu, 20 Jun 2024 02:29:11 -0400 Subject: [PATCH 2/6] Address comment, reuse CodeGenTBAA::getRoot --- clang/lib/CodeGen/CGBuiltin.cpp | 6 +- clang/lib/CodeGen/CodeGenModule.h | 2 ++ clang/lib/CodeGen/CodeGenTBAA.h | 8 clang/test/CodeGen/math-libcalls-tbaa.cpp | 20 +++- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index dc4af109cdbdb..3f448e11bca1a 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -725,11 +725,7 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD, if (IntrinsicID) { llvm::MDBuilder MDHelper(CGF.getLLVMContext()); - MDNode *RootMD; - if (CGF.getLangOpts().CPlusPlus) -RootMD = MDHelper.createTBAARoot("Simple C++ TBAA"); - else -RootMD = MDHelper.createTBAARoot("Si
[clang] clang/AMDGPU: Use atomicrmw for ds fmin/fmax builtins (PR #96738)
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/96738 None >From 0d9ab2bcbaa2b4b11832a8ac1848505cf73f4880 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 11 Jun 2024 10:40:27 +0200 Subject: [PATCH] clang/AMDGPU: Use atomicrmw for ds fmin/fmax builtins --- clang/lib/CodeGen/CGBuiltin.cpp | 40 --- clang/test/CodeGenCUDA/builtins-amdgcn.cu | 8 +-- .../test/CodeGenCUDA/builtins-spirv-amdgcn.cu | 8 +-- .../test/CodeGenOpenCL/builtins-amdgcn-vi.cl | 66 ++- 4 files changed, 86 insertions(+), 36 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 4edd8283aa03c..5ade65ac112a6 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18622,28 +18622,6 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, Function *F = CGM.getIntrinsic(Intrin, { Src0->getType() }); return Builder.CreateCall(F, { Src0, Builder.getFalse() }); } - case AMDGPU::BI__builtin_amdgcn_ds_fminf: - case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: { -Intrinsic::ID Intrin; -switch (BuiltinID) { -case AMDGPU::BI__builtin_amdgcn_ds_fminf: - Intrin = Intrinsic::amdgcn_ds_fmin; - break; -case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: - Intrin = Intrinsic::amdgcn_ds_fmax; - break; -} -llvm::Value *Src0 = EmitScalarExpr(E->getArg(0)); -llvm::Value *Src1 = EmitScalarExpr(E->getArg(1)); -llvm::Value *Src2 = EmitScalarExpr(E->getArg(2)); -llvm::Value *Src3 = EmitScalarExpr(E->getArg(3)); -llvm::Value *Src4 = EmitScalarExpr(E->getArg(4)); -llvm::Function *F = CGM.getIntrinsic(Intrin, { Src1->getType() }); -llvm::FunctionType *FTy = F->getFunctionType(); -llvm::Type *PTy = FTy->getParamType(0); -Src0 = Builder.CreatePointerBitCastOrAddrSpaceCast(Src0, PTy); -return Builder.CreateCall(F, { Src0, Src1, Src2, Src3, Src4 }); - } case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64: case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32: case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16: @@ -19077,11 +19055,13 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, case AMDGPU::BI__builtin_amdgcn_atomic_inc64: case AMDGPU::BI__builtin_amdgcn_atomic_dec32: case AMDGPU::BI__builtin_amdgcn_atomic_dec64: - case AMDGPU::BI__builtin_amdgcn_ds_faddf: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f64: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f32: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2f16: - case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: { + case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: + case AMDGPU::BI__builtin_amdgcn_ds_faddf: + case AMDGPU::BI__builtin_amdgcn_ds_fminf: + case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: { llvm::AtomicRMWInst::BinOp BinOp; switch (BuiltinID) { case AMDGPU::BI__builtin_amdgcn_atomic_inc32: @@ -19099,6 +19079,12 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: BinOp = llvm::AtomicRMWInst::FAdd; break; +case AMDGPU::BI__builtin_amdgcn_ds_fminf: + BinOp = llvm::AtomicRMWInst::FMin; + break; +case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: + BinOp = llvm::AtomicRMWInst::FMax; + break; } Address Ptr = CheckAtomicAlignment(*this, E); @@ -19108,8 +19094,10 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, bool Volatile; -if (BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_faddf) { - // __builtin_amdgcn_ds_faddf has an explicit volatile argument +if (BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_faddf || +BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_fminf || +BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_fmaxf) { + // __builtin_amdgcn_ds_faddf/fminf/fmaxf has an explicit volatile argument Volatile = cast(EmitScalarExpr(E->getArg(4)))->getZExtValue(); } else { diff --git a/clang/test/CodeGenCUDA/builtins-amdgcn.cu b/clang/test/CodeGenCUDA/builtins-amdgcn.cu index 132cbd27b08fc..2e88afac813f4 100644 --- a/clang/test/CodeGenCUDA/builtins-amdgcn.cu +++ b/clang/test/CodeGenCUDA/builtins-amdgcn.cu @@ -98,7 +98,7 @@ __global__ // CHECK-NEXT:[[X_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[X]] to ptr // CHECK-NEXT:store float [[SRC:%.*]], ptr [[SRC_ADDR_ASCAST]], align 4 // CHECK-NEXT:[[TMP0:%.*]] = load float, ptr [[SRC_ADDR_ASCAST]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = call contract float @llvm.amdgcn.ds.fmax.f32(ptr addrspace(3) @_ZZ12test_ds_fmaxfE6shared, float [[TMP0]], i32 0, i32 0, i1 false) +// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw fmax ptr addrspace(3) @_ZZ12test_ds_fmaxfE6shared, float [[TMP0]] monotonic, align 4 // CHECK-NEXT:store volatile float [[TMP1]], ptr [[X_ASCAST]], align 4 // CHECK-NEXT:ret void // @@ -142,7 +142,7 @@ __global__ v
[clang] clang/AMDGPU: Use atomicrmw for ds fmin/fmax builtins (PR #96738)
arsenm wrote: * **#96739** https://app.graphite.dev/github/pr/llvm/llvm-project/96739?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#96738** https://app.graphite.dev/github/pr/llvm/llvm-project/96738?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 * `main` This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about stacking. Join @arsenm and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="11px" height="11px"/> Graphite https://github.com/llvm/llvm-project/pull/96738 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang/AMDGPU: Use atomicrmw for ds fmin/fmax builtins (PR #96738)
llvmbot wrote: @llvm/pr-subscribers-backend-amdgpu Author: Matt Arsenault (arsenm) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/96738.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+14-26) - (modified) clang/test/CodeGenCUDA/builtins-amdgcn.cu (+4-4) - (modified) clang/test/CodeGenCUDA/builtins-spirv-amdgcn.cu (+4-4) - (modified) clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl (+64-2) ``diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 4edd8283aa03c..5ade65ac112a6 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18622,28 +18622,6 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, Function *F = CGM.getIntrinsic(Intrin, { Src0->getType() }); return Builder.CreateCall(F, { Src0, Builder.getFalse() }); } - case AMDGPU::BI__builtin_amdgcn_ds_fminf: - case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: { -Intrinsic::ID Intrin; -switch (BuiltinID) { -case AMDGPU::BI__builtin_amdgcn_ds_fminf: - Intrin = Intrinsic::amdgcn_ds_fmin; - break; -case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: - Intrin = Intrinsic::amdgcn_ds_fmax; - break; -} -llvm::Value *Src0 = EmitScalarExpr(E->getArg(0)); -llvm::Value *Src1 = EmitScalarExpr(E->getArg(1)); -llvm::Value *Src2 = EmitScalarExpr(E->getArg(2)); -llvm::Value *Src3 = EmitScalarExpr(E->getArg(3)); -llvm::Value *Src4 = EmitScalarExpr(E->getArg(4)); -llvm::Function *F = CGM.getIntrinsic(Intrin, { Src1->getType() }); -llvm::FunctionType *FTy = F->getFunctionType(); -llvm::Type *PTy = FTy->getParamType(0); -Src0 = Builder.CreatePointerBitCastOrAddrSpaceCast(Src0, PTy); -return Builder.CreateCall(F, { Src0, Src1, Src2, Src3, Src4 }); - } case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64: case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32: case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16: @@ -19077,11 +19055,13 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, case AMDGPU::BI__builtin_amdgcn_atomic_inc64: case AMDGPU::BI__builtin_amdgcn_atomic_dec32: case AMDGPU::BI__builtin_amdgcn_atomic_dec64: - case AMDGPU::BI__builtin_amdgcn_ds_faddf: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f64: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f32: case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2f16: - case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: { + case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: + case AMDGPU::BI__builtin_amdgcn_ds_faddf: + case AMDGPU::BI__builtin_amdgcn_ds_fminf: + case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: { llvm::AtomicRMWInst::BinOp BinOp; switch (BuiltinID) { case AMDGPU::BI__builtin_amdgcn_atomic_inc32: @@ -19099,6 +19079,12 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16: BinOp = llvm::AtomicRMWInst::FAdd; break; +case AMDGPU::BI__builtin_amdgcn_ds_fminf: + BinOp = llvm::AtomicRMWInst::FMin; + break; +case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: + BinOp = llvm::AtomicRMWInst::FMax; + break; } Address Ptr = CheckAtomicAlignment(*this, E); @@ -19108,8 +19094,10 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, bool Volatile; -if (BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_faddf) { - // __builtin_amdgcn_ds_faddf has an explicit volatile argument +if (BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_faddf || +BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_fminf || +BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_fmaxf) { + // __builtin_amdgcn_ds_faddf/fminf/fmaxf has an explicit volatile argument Volatile = cast(EmitScalarExpr(E->getArg(4)))->getZExtValue(); } else { diff --git a/clang/test/CodeGenCUDA/builtins-amdgcn.cu b/clang/test/CodeGenCUDA/builtins-amdgcn.cu index 132cbd27b08fc..2e88afac813f4 100644 --- a/clang/test/CodeGenCUDA/builtins-amdgcn.cu +++ b/clang/test/CodeGenCUDA/builtins-amdgcn.cu @@ -98,7 +98,7 @@ __global__ // CHECK-NEXT:[[X_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[X]] to ptr // CHECK-NEXT:store float [[SRC:%.*]], ptr [[SRC_ADDR_ASCAST]], align 4 // CHECK-NEXT:[[TMP0:%.*]] = load float, ptr [[SRC_ADDR_ASCAST]], align 4 -// CHECK-NEXT:[[TMP1:%.*]] = call contract float @llvm.amdgcn.ds.fmax.f32(ptr addrspace(3) @_ZZ12test_ds_fmaxfE6shared, float [[TMP0]], i32 0, i32 0, i1 false) +// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw fmax ptr addrspace(3) @_ZZ12test_ds_fmaxfE6shared, float [[TMP0]] monotonic, align 4 // CHECK-NEXT:store volatile float [[TMP1]], ptr [[X_ASCAST]], align 4 // CHECK-NEXT:ret void // @@ -142,7 +142,7 @@ __global__ void test_ds_fadd(float src) { // CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[SHARED_ADDR_ASCAST]], align 8 // CHECK-NEXT:[[TMP2:
[clang] clang/AMDGPU: Use atomicrmw for ds fmin/fmax builtins (PR #96738)
https://github.com/arsenm ready_for_review https://github.com/llvm/llvm-project/pull/96738 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)
balazske wrote: These results look correct according to the checker, but I am not sure if such results are useful or really invalid: https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=vim_v8.2.1920_pointersub1&is-unique=on&diff-type=New&checker-name=alpha.core.PointerSub In these cases the address difference of an (array) member of a struct and start of the struct is taken. According to the checker rules, taking difference of addresses of any variables or member variables is invalid. https://github.com/llvm/llvm-project/pull/96501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)
https://github.com/DominikAdamski created https://github.com/llvm/llvm-project/pull/96742 Flang-new needs to add `mlink-builtin-bitcode` objects to properly support offload code generation for AMD GPU. fcuda-is-device flag is not used by Flang currently. In the future it will be needed for Flang equivalent function: `AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace`. >From 80d46755e741cb9daa743574a3a4bfb580e0ad06 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Fri, 21 Jun 2024 18:03:53 +0200 Subject: [PATCH] [Flang-new][OpenMP] Add offload related flags for AMDGPU Flang-new needs to add mlink-builtin-bitcode objects to properly support offload code generation for AMD GPU. fcuda-is-device flag is not used by Flang currently. In the future it will be needed for Flang equivalent function: AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace. --- clang/include/clang/Driver/Options.td| 4 ++-- clang/lib/Driver/ToolChains/Flang.cpp| 3 +++ flang/test/Driver/omp-driver-offload.f90 | 8 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index dd55838dcf384..612d5793232ce 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8016,7 +8016,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, // CUDA Options //===--===// -let Visibility = [CC1Option] in { +let Visibility = [CC1Option, FC1Option] in { def fcuda_is_device : Flag<["-"], "fcuda-is-device">, HelpText<"Generate code for CUDA device">, @@ -8031,7 +8031,7 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">, MarshallingInfoNegativeFlag>; -} // let Visibility = [CC1Option] +} // let Visibility = [CC1Option, FC1Option] //===--===// // OpenMP Options diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 42b45dba2bd31..2679f284c5016 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, StringRef Val = A->getValue(); CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val)); } + + const ToolChain &TC = getToolChain(); + TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP); } void Flang::addTargetOptions(const ArgList &Args, diff --git a/flang/test/Driver/omp-driver-offload.f90 b/flang/test/Driver/omp-driver-offload.f90 index 6fb4f4ca1..b8afbe65961dc 100644 --- a/flang/test/Driver/omp-driver-offload.f90 +++ b/flang/test/Driver/omp-driver-offload.f90 @@ -227,3 +227,11 @@ ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" ! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" + +! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \ +! RUN: --offload-arch=gfx900 \ +! RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +! RUN: | FileCheck --check-prefix=MLINK-BUILTIN-BITCODE %s +! MLINK-BUILTIN-BITCODE: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" +! MLINK-BUILTIN-BITCODE-SAME: "-fcuda-is-device" +! MLINK-BUILTIN-BITCODE-SAME: "-mlink-builtin-bitcode" {{.*Inputs.*rocm.*amdgcn.*bitcode.*}}oclc_isa_version_900.bc ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Dominik Adamski (DominikAdamski) Changes Flang-new needs to add `mlink-builtin-bitcode` objects to properly support offload code generation for AMD GPU. fcuda-is-device flag is not used by Flang currently. In the future it will be needed for Flang equivalent function: `AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace`. --- Full diff: https://github.com/llvm/llvm-project/pull/96742.diff 3 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+2-2) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (+3) - (modified) flang/test/Driver/omp-driver-offload.f90 (+8) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index dd55838dcf384..612d5793232ce 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8016,7 +8016,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, // CUDA Options //===--===// -let Visibility = [CC1Option] in { +let Visibility = [CC1Option, FC1Option] in { def fcuda_is_device : Flag<["-"], "fcuda-is-device">, HelpText<"Generate code for CUDA device">, @@ -8031,7 +8031,7 @@ def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">, MarshallingInfoNegativeFlag>; -} // let Visibility = [CC1Option] +} // let Visibility = [CC1Option, FC1Option] //===--===// // OpenMP Options diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 42b45dba2bd31..2679f284c5016 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, StringRef Val = A->getValue(); CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val)); } + + const ToolChain &TC = getToolChain(); + TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP); } void Flang::addTargetOptions(const ArgList &Args, diff --git a/flang/test/Driver/omp-driver-offload.f90 b/flang/test/Driver/omp-driver-offload.f90 index 6fb4f4ca1..b8afbe65961dc 100644 --- a/flang/test/Driver/omp-driver-offload.f90 +++ b/flang/test/Driver/omp-driver-offload.f90 @@ -227,3 +227,11 @@ ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" ! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" + +! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \ +! RUN: --offload-arch=gfx900 \ +! RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \ +! RUN: | FileCheck --check-prefix=MLINK-BUILTIN-BITCODE %s +! MLINK-BUILTIN-BITCODE: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" +! MLINK-BUILTIN-BITCODE-SAME: "-fcuda-is-device" +! MLINK-BUILTIN-BITCODE-SAME: "-mlink-builtin-bitcode" {{.*Inputs.*rocm.*amdgcn.*bitcode.*}}oclc_isa_version_900.bc `` https://github.com/llvm/llvm-project/pull/96742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Enable atomic optimizer for 64 bit divergent values (PR #96473)
@@ -228,10 +228,11 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) { // If the value operand is divergent, each lane is contributing a different // value to the atomic calculation. We can only optimize divergent values if - // we have DPP available on our subtarget, and the atomic operation is 32 - // bits. + // we have DPP available on our subtarget, and the atomic operation is either + // 32 or 64 bits. if (ValDivergent && - (!ST->hasDPP() || DL->getTypeSizeInBits(I.getType()) != 32)) { + (!ST->hasDPP() || (DL->getTypeSizeInBits(I.getType()) != 32 && + DL->getTypeSizeInBits(I.getType()) != 64))) { vikramRH wrote: Done https://github.com/llvm/llvm-project/pull/96473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Enable atomic optimizer for 64 bit divergent values (PR #96473)
vikramRH wrote: Apologies for the commit spam here, graphite seems a good option now onwards. However all dependent patches have landed now, the diff here is now up to date. https://github.com/llvm/llvm-project/pull/96473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)
https://github.com/DominikAdamski edited https://github.com/llvm/llvm-project/pull/96742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
https://github.com/labrinea edited https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)
@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> { let OnlyBuiltinPrefixedAliasIsConstexpr = 1; } +def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> { philnik777 wrote: In that case this should probably be a `GNULibBuiltin`. Or is it actually standardized? https://github.com/llvm/llvm-project/pull/96281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't count template template parameter as declaration (PR #96396)
mydeveloperday wrote: > Isn't fixing bugs meant to change defaults? See #61732, #48746 and #93793. > The old version is confusing since it looks like a separate template > parameter when it isn't. I'm ok, if the second style is what we want if thats what we are expecting then I'm good with it.. https://github.com/llvm/llvm-project/pull/96396 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add a new style for the clang-format source code (PR #69814)
mydeveloperday wrote: > Where is the documentation for the value? CLion reports `clang-format` option > as an error by the reason. No doc, no schema rule. Personally, I'm not a fan of CLion enough to care! especially following JetBrains slating of clang-format: (thanks for doing that at a massive public C++ forum without contacting us), their content even questionable as to its accuracy. https://www.youtube.com/watch?v=NnQraMtpvws https://blog.jetbrains.com/clion/2023/12/a-clangformat-story-and-the-third-clion-nova-update/ Maybe they can try contributing rather than complaining. https://github.com/llvm/llvm-project/pull/69814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Enable atomic optimizer for 64 bit divergent values (PR #96473)
@@ -402,34 +413,30 @@ Value *AMDGPUAtomicOptimizerImpl::buildReduction(IRBuilder<> &B, // Reduce within each pair of rows (i.e. 32 lanes). assert(ST->hasPermLaneX16()); - V = B.CreateBitCast(V, IntNTy); jayfoad wrote: Please submit an NFC cleanup patch that just removes unnecessary bitcasting, before adding support for new atomic operations. https://github.com/llvm/llvm-project/pull/96473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 90e4eb8 - [clang][Interp][NFC] Add more source ranges to diagnostics
Author: Timm Bäder Date: 2024-06-26T11:44:55+02:00 New Revision: 90e4eb8a479dbef4f98f7d8ccd2de5494c6366c7 URL: https://github.com/llvm/llvm-project/commit/90e4eb8a479dbef4f98f7d8ccd2de5494c6366c7 DIFF: https://github.com/llvm/llvm-project/commit/90e4eb8a479dbef4f98f7d8ccd2de5494c6366c7.diff LOG: [clang][Interp][NFC] Add more source ranges to diagnostics Added: Modified: clang/lib/AST/Interp/Interp.cpp Removed: diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index 49015b1dd63d3..fc4c0058fbda4 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -341,7 +341,9 @@ bool CheckNull(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (!Ptr.isZero()) return true; const SourceInfo &Loc = S.Current->getSource(OpPC); - S.FFDiag(Loc, diag::note_constexpr_null_subobject) << CSK; + S.FFDiag(Loc, diag::note_constexpr_null_subobject) + << CSK << S.Current->getRange(OpPC); + return false; } @@ -350,7 +352,8 @@ bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (!Ptr.isOnePastEnd()) return true; const SourceInfo &Loc = S.Current->getSource(OpPC); - S.FFDiag(Loc, diag::note_constexpr_access_past_end) << AK; + S.FFDiag(Loc, diag::note_constexpr_access_past_end) + << AK << S.Current->getRange(OpPC); return false; } @@ -359,7 +362,8 @@ bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (!Ptr.isElementPastEnd()) return true; const SourceInfo &Loc = S.Current->getSource(OpPC); - S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) << CSK; + S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) + << CSK << S.Current->getRange(OpPC); return false; } @@ -369,7 +373,8 @@ bool CheckSubobject(InterpState &S, CodePtr OpPC, const Pointer &Ptr, return true; const SourceInfo &Loc = S.Current->getSource(OpPC); - S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) << CSK; + S.FFDiag(Loc, diag::note_constexpr_past_end_subobject) + << CSK << S.Current->getRange(OpPC); return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Enable atomic optimizer for 64 bit divergent values (PR #96473)
@@ -178,6 +178,20 @@ bool AMDGPUAtomicOptimizerImpl::run(Function &F) { return Changed; } +static bool shouldOptimize(Type *Ty) { + switch (Ty->getTypeID()) { + case Type::FloatTyID: + case Type::DoubleTyID: +return true; + case Type::IntegerTyID: { +if (Ty->getIntegerBitWidth() == 32 || Ty->getIntegerBitWidth() == 64) + return true; + } arsenm wrote: Don't forget pointers https://github.com/llvm/llvm-project/pull/96473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Enable atomic optimizer for 64 bit divergent values (PR #96473)
@@ -178,6 +178,20 @@ bool AMDGPUAtomicOptimizerImpl::run(Function &F) { return Changed; } +static bool shouldOptimize(Type *Ty) { arsenm wrote: Better name that expresses why this type is handleable. Also in a follow up, really should cover the i16/half/bfloat and 2 x half, 2 x bfloat cases https://github.com/llvm/llvm-project/pull/96473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -1130,7 +1130,8 @@ INSTANTIATE_TEST_SUITE_P( AArch64::AEK_MTE, AArch64::AEK_SSBS, AArch64::AEK_FP16,AArch64::AEK_FP16FML, AArch64::AEK_SB, AArch64::AEK_JSCVT, - AArch64::AEK_FCMA,AArch64::AEK_PERFMON}), + AArch64::AEK_FCMA,AArch64::AEK_PERFMON, + AArch64::AEK_ETE, AArch64::AEK_AM}), pratlucas wrote: Yes, that's a very good idea! I'll work on migrating those tests in a follow up PR. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [llvm] [runtimes] remove workaround for old CMake when setting `--unwindlib=none` (PR #93429)
https://github.com/h-vetinari updated https://github.com/llvm/llvm-project/pull/93429 >From 8c1b899aa174b107fece1edbf99eaf261bdea516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 25 Apr 2022 09:45:22 +0300 Subject: [PATCH 1/6] [runtimes] [CMake] Use CMAKE_REQUIRED_LINK_OPTIONS to simplify handling of the --unwindlib=none option This avoids passing the option unnecessarily to compilation commands (where it causes warnings). This fails in practice with libunwind, where setting CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY breaks it, as the option from CMAKE_REQUIRED_LINK_OPTIONS ends up passed to the "ar" tool too. --- libunwind/CMakeLists.txt | 3 +++ runtimes/CMakeLists.txt | 22 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index b22ade0a7d71e..3d2fadca9d2ec 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -221,9 +221,12 @@ add_cxx_compile_flags_if_supported(-EHsc) # This leads to libunwind not being built with this flag, which makes # libunwind quite useless in this setup. set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +set(CMAKE_REQUIRED_LINK_OPTIONS) add_compile_flags_if_supported(-funwind-tables) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE}) +set(CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS}) if (LIBUNWIND_USES_ARM_EHABI AND NOT CXX_SUPPORTS_FUNWIND_TABLES_FLAG) message(SEND_ERROR "The -funwind-tables flag must be supported " diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 24f4851169591..8f909322c9a98 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -116,27 +116,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C # brittle. We should ideally move this to runtimes/CMakeLists.txt. llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) - set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none") - # TODO: When we can require CMake 3.14, we should use - # CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround: - # When using CMAKE_REQUIRED_FLAGS, this option gets added both to - # compilation and linking commands. That causes warnings in the - # compilation commands during cmake tests. This is normally benign, but - # when testing whether -Werror works, that test fails (due to the - # preexisting warning). - # - # Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we - # can use --start-no-unused-arguments to silence the warnings about - # --unwindlib=none during compilation. - # - # We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to - # allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS - # below. - check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS) - if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS) -set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments") - endif() + list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "--unwindlib=none") endif() # Disable use of the installed C++ standard library when building runtimes. >From 816e9e6d81ac12537879406e0495fc80394a1a66 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Thu, 20 Jun 2024 23:18:51 +1100 Subject: [PATCH 2/6] add comment (and CMake issue reference) about incompatible options --- libunwind/CMakeLists.txt | 4 1 file changed, 4 insertions(+) diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 3d2fadca9d2ec..d84f8fa6ff954 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -220,6 +220,10 @@ add_cxx_compile_flags_if_supported(-EHsc) # # This leads to libunwind not being built with this flag, which makes # libunwind quite useless in this setup. +# +# NOTE: we need to work around https://gitlab.kitware.com/cmake/cmake/-/issues/23454 +# because CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG) +# is incompatible with CMAKE_TRY_COMPILE_TARGET_TYPE==STATIC_LIBRARY. set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) >From 3f917d22bdcd8b398cf7162563547418a056ecec Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Thu, 20 Jun 2024 23:18:51 +1100 Subject: [PATCH 3/6] [cmake] move check for `-fno-exceptions` to "safe zone" w.r.t. interference between CMAKE_REQUIRED_LINK_OPTIONS and static libraries --- libunwind/CMakeLists.txt | 2 +-
[clang] [lldb] [clang][lldb] Don't assert structure layout correctness for layouts provided by LLDB (PR #93809)
Michael137 wrote: While fixing the libc++ formatters in preparation for the [compressed_pair change](https://github.com/llvm/llvm-project/issues/93069), i encountered another issue which I'm not sure entirely how to best reconcile. There's [this assumption in `RecordLayoutBuilder`](https://github.com/llvm/llvm-project/blob/f782ff8fc6426890863be0791a9ace2394da3887/clang/lib/AST/RecordLayoutBuilder.cpp#L2258-L2264) for external layouts, where, if we encounter overlapping field offsets, we assume the structure is packed and set the alignment back to `1`: ``` uint64_t ItaniumRecordLayoutBuilder::updateExternalFieldOffset(const FieldDecl *Field, uint64_t ComputedOffset) { uint64_t ExternalFieldOffset = External.getExternalFieldOffset(Field); if (InferAlignment && ExternalFieldOffset < ComputedOffset) { // The externally-supplied field offset is before the field offset we // computed. Assume that the structure is packed. Alignment = CharUnits::One(); PreferredAlignment = CharUnits::One(); InferAlignment = false; } ... ``` The assumption in that comment doesn't hold for layouts where the overlap occurred because of `[[no_unique_address]]`. In those cases, the alignment of `1` will prevent us from aligning the `FieldOffset` correctly and cause LLDB to read out the fields incorrectly. We can't guard this with `Field->isZeroSize()` because we don't have the attribute in the AST. Can we infer packedness more accurately here? Or maybe that's just putting a bandaid on a bigger underlying issue https://github.com/llvm/llvm-project/pull/93809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
https://github.com/skatrak commented: Thanks for working on my previous comments. I just have a couple more minor ones. https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -5272,36 +5682,53 @@ static void emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, Value *DynCGGroupMem = Builder.getInt32(0); bool HasNoWait = false; + bool HasDependencies = Dependencies.size() > 0; + bool RequiresOuterTargetTask = HasNoWait || HasDependencies; OpenMPIRBuilder::TargetKernelArgs KArgs(NumTargetItems, RTArgs, NumIterations, NumTeamsVal, NumThreadsVal, DynCGGroupMem, HasNoWait); - Builder.restoreIP(OMPBuilder.emitKernelLaunch( - Builder, OutlinedFn, OutlinedFnID, EmitTargetCallFallbackCB, KArgs, - DeviceID, RTLoc, AllocaIP)); + // The presence of certain clauses on the target directive require the + // explicit generation of the target task. + if (RequiresOuterTargetTask) { +OMPBuilder.emitTargetTask(OutlinedFn, OutlinedFnID, skatrak wrote: I agree with you, since I have noticed this redundant pattern as well, though in a way I think it makes sense from a uniformity point of view. There are several codegen functions that return an insertion point, which should be used by the caller to proceed with any further codegen. I think that the fact that oftentimes the insertion point that's being returned is indeed already the current one shouldn't be relied on by the caller unless we make this a contract followed by all such functions. To be consistent, I think these codegen function must either always return an insertion point which must be used by the caller (the current approach) or all codegen functions must not return an insertion point and set it themselves to the spot follow-up codegen should go. In my opinion, I believe it's currently better to keep the current approach even though it results in some redundant setting of the insertion point. Skipping the call to `Builder.restoreIP()` in the caller could result in unintended problems in the future, since the current contract is that the returned insertion point is the one that should be used and not the current one. https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -5229,13 +5382,284 @@ static void emitTargetOutlinedFunction( OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, true, OutlinedFn, OutlinedFnID); } +OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask( +Function *OutlinedFn, Value *OutlinedFnID, +EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args, +Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP, +SmallVector &Dependencies, +bool HasNoWait) { + + // When we arrive at this function, the target region itself has been + // outlined into the function OutlinedFn. + // So at ths point, for + // -- + // void user_code_that_offloads(...) { + // omp target depend(..) map(from:a) map(to:b, c) + //a = b + c + // } + // + // -- + // + // we have + // + // -- + // + // void user_code_that_offloads(...) { + // %.offload_baseptrs = alloca [3 x ptr], align 8 + // %.offload_ptrs = alloca [3 x ptr], align 8 + // %.offload_mappers = alloca [3 x ptr], align 8 + // ;; target region has been outlined and now we need to + // ;; offload to it via a target task. + // } + // void outlined_device_function(ptr a, ptr b, ptr c) { + // *a = *b + *c + // } + // + // We have to now do the following + // (i) Make an offloading call to outlined_device_function using the OpenMP + // RTL. See 'kernel_launch_function' in the pseudo code below. This is + // emitted by emitKernelLaunch + // (ii) Create a task entry point function that calls kernel_launch_function + // and is the entry point for the target task. See + // '@.omp_target_task_proxy_func in the pseudocode below. + // (iii) Create a task with the task entry point created in (ii) + // + // That is we create the following + // + // void user_code_that_offloads(...) { + // %.offload_baseptrs = alloca [3 x ptr], align 8 + // %.offload_ptrs = alloca [3 x ptr], align 8 + // %.offload_mappers = alloca [3 x ptr], align 8 + // + // %structArg = alloca { ptr, ptr, ptr }, align 8 + // %strucArg[0] = %.offload_baseptrs + // %strucArg[1] = %.offload_ptrs + // %strucArg[2] = %.offload_mappers + // proxy_target_task = @__kmpc_omp_task_alloc(..., + // @.omp_target_task_proxy_func) + // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg)) + // dependencies_array = ... + // ;; if nowait not present + // call @__kmpc_omp_wait_deps(..., dependencies_array) + // call @__kmpc_omp_task_begin_if0(...) + // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr + // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...) + // } + // + // define internal void @.omp_target_task_proxy_func(i32 %thread.id, + // ptr %task) { + // %structArg = alloca {ptr, ptr, ptr} + // %shared_data = load (getelementptr %task, 0, 0) + // mempcy(%structArg, %shared_data, sizeof(structArg)) + // kernel_launch_function(%thread.id, %structArg) + // } + // + // We need the proxy function because the signature of the task entry point + // expected by kmpc_omp_task is always the same and will be different from + // that of the kernel_launch function. + // + // kernel_launch_function is generated by emitKernelLaunch and has the + // always_inline attribute. + // void kernel_launch_function(thread_id, + // structArg) alwaysinline { + // %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 + // offload_baseptrs = load(getelementptr structArg, 0, 0) + // offload_ptrs = load(getelementptr structArg, 0, 1) + // offload_mappers = load(getelementptr structArg, 0, 2) + // ; setup kernel_args using offload_baseptrs, offload_ptrs and + // ; offload_mappers + // call i32 @__tgt_target_kernel(..., + // outlined_device_function, + // ptr %kernel_args) + // } + // void outlined_device_function(ptr a, ptr b, ptr c) { + // *a = *b + *c + // } + // + BasicBlock *TargetTaskBodyBB = + splitBB(Builder, /*CreateBranch=*/true, "target.task.body"); + BasicBlock *TargetTaskAllocaBB = + splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca"); + + InsertPointTy TargetTaskAllocaIP = + InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin()); + InsertPointTy TargetTaskBodyIP = + InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin()); + + OutlineInfo OI; + OI.EntryBB = TargetTaskAllocaBB; + OI.OuterAllocaBB = AllocaIP.getBlock(); + + //
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO +! UNSUPPORTED: x86_64-pc-linux-gnu +! UNSUPPORTED: x86_64-pc-linux-gnu-LTO + +! RUN: %libomptarget-compile-fortran-run-and-check-generic +program main + implicit none + integer :: a = 0 + INTERFACE + FUNCTION omp_get_device_num() BIND(C) + USE, INTRINSIC :: iso_c_binding, ONLY: C_INT + integer :: omp_get_device_num + END FUNCTION omp_get_device_num + END INTERFACE + + call foo(5, a) + print*, "=== FORTRAN Test passed! ===" + print*, "foo(5) returned ", a, ", expected 6\n" + + ! stop 0 + contains +subroutine foo(N, r) + integer, intent(in) :: N + integer, intent(out) :: r + integer :: z, i, j, k, accumulator + z = 1 + accumulator = 0 + ! Spawn 3 threads + !$omp parallel num_threads(3) + + ! A single thread will then create two tasks + ! One is the 'producer' and potentially slower + ! task that updates 'z' to 'N'. The second is an + ! offloaded target task that increments 'z'. + ! If the depend clauses work properly, the + ! target task should wait for the 'producer' + ! task to complete before incrementing z + ! We use !$omp single here because only + ! the depend clause establishes dependencies + ! between sibling tasks only. This is the easiest + ! way of creating two sibling tasks. + !$omp single + !$omp task depend(out: z) shared(z) + do while (k < 32000) + do while (j < 32766) +do while (i < 32766) + ! dumb loop nest to slow down the update of + ! z + i = i + 1 + ! Adding a function call slows down the producer + ! to the point that removing the depend clause + ! from the target construct below frequently + ! results in the wrong answer. + accumulator = accumulator + omp_get_device_num() +end do +j = j +1 + end do + k = k + 1 + end do + z = N + !$omp end task + + ! z is 5 now. Increment z to 6. + !$omp target map(tofrom: z) depend(in:z) + z = z + 1 + !$omp end target + !$omp end single + !$omp end parallel + ! Use 'accumulator' so it is not optimized away + ! by the compiler. + print *, accumulator + r = z +end subroutine foo skatrak wrote: ```suggestion end subroutine foo ``` https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO +! UNSUPPORTED: x86_64-pc-linux-gnu +! UNSUPPORTED: x86_64-pc-linux-gnu-LTO + +! RUN: %libomptarget-compile-fortran-run-and-check-generic +program main + implicit none + integer :: a = 0 + INTERFACE + FUNCTION omp_get_device_num() BIND(C) + USE, INTRINSIC :: iso_c_binding, ONLY: C_INT + integer :: omp_get_device_num + END FUNCTION omp_get_device_num + END INTERFACE + + call foo(5, a) + print*, "=== FORTRAN Test passed! ===" + print*, "foo(5) returned ", a, ", expected 6\n" + + ! stop 0 + contains +subroutine foo(N, r) + integer, intent(in) :: N + integer, intent(out) :: r + integer :: z, i, j, k, accumulator + z = 1 + accumulator = 0 + ! Spawn 3 threads + !$omp parallel num_threads(3) + + ! A single thread will then create two tasks + ! One is the 'producer' and potentially slower + ! task that updates 'z' to 'N'. The second is an + ! offloaded target task that increments 'z'. + ! If the depend clauses work properly, the + ! target task should wait for the 'producer' + ! task to complete before incrementing z + ! We use !$omp single here because only + ! the depend clause establishes dependencies + ! between sibling tasks only. This is the easiest + ! way of creating two sibling tasks. + !$omp single + !$omp task depend(out: z) shared(z) + do while (k < 32000) skatrak wrote: Couldn't this loop be written more concisely as `do k=1, 32000 ... end do`? Same for the other two loops nested in it. https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -705,28 +728,9 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder, }; SmallVector dds; - if (!taskOp.getDependVars().empty() && taskOp.getDepends()) { -for (auto dep : - llvm::zip(taskOp.getDependVars(), taskOp.getDepends()->getValue())) { - llvm::omp::RTLDependenceKindTy type; - switch ( - cast(std::get<1>(dep)).getValue()) { - case mlir::omp::ClauseTaskDepend::taskdependin: -type = llvm::omp::RTLDependenceKindTy::DepIn; -break; - // The OpenMP runtime requires that the codegen for 'depend' clause for - // 'out' dependency kind must be the same as codegen for 'depend' clause - // with 'inout' dependency. - case mlir::omp::ClauseTaskDepend::taskdependout: - case mlir::omp::ClauseTaskDepend::taskdependinout: -type = llvm::omp::RTLDependenceKindTy::DepInOut; -break; - }; - llvm::Value *depVal = moduleTranslation.lookupValue(std::get<0>(dep)); - llvm::OpenMPIRBuilder::DependData dd(type, depVal->getType(), depVal); - dds.emplace_back(dd); -} - } + if (!taskOp.getDependVars().empty() && taskOp.getDepends()) skatrak wrote: It looks like this comment hasn't been addressed. Let me know if you just missed it, if you disagree with it or if it isn't very clear and I should try to explain better. https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO +! UNSUPPORTED: x86_64-pc-linux-gnu +! UNSUPPORTED: x86_64-pc-linux-gnu-LTO + +! RUN: %libomptarget-compile-fortran-run-and-check-generic +program main + implicit none + integer :: a = 0 + INTERFACE + FUNCTION omp_get_device_num() BIND(C) + USE, INTRINSIC :: iso_c_binding, ONLY: C_INT + integer :: omp_get_device_num + END FUNCTION omp_get_device_num + END INTERFACE + + call foo(5, a) + print*, "=== FORTRAN Test passed! ===" + print*, "foo(5) returned ", a, ", expected 6\n" + + ! stop 0 + contains +subroutine foo(N, r) + integer, intent(in) :: N + integer, intent(out) :: r + integer :: z, i, j, k, accumulator + z = 1 + accumulator = 0 + ! Spawn 3 threads + !$omp parallel num_threads(3) + + ! A single thread will then create two tasks skatrak wrote: Nit: It looks like comments in this file are split very early on, can you extend to 80 characters? https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Add INFINITY and NAN macros to (PR #96659)
AaronBallman wrote: > > I looked at my meeting notes for discussion of this paper and I think we do > > need to worry about what the C standard says. From my notes: `The big > > intent from this change seems to be about making INFINITY to be a feature > > test macro.`, so if users are going to portably expect `#ifdef INFINITY` to > > mean that their use of the macro will generate an actual infinity, we > > really should support that IMO. > > I went looking through the CFP history of the proposal. It's based on a > comp.std.c thread here: https://groups.google.com/g/comp.std.c/c/XCzEiwD9n_A, > which became a CFP discussion here: > https://mailman.oakapple.net/pipermail/cfp-interest/2021-October/002216.html > (and more in the September portion of the archives, but the relevant part of > the discussion is in October), and the minutes of the CFP meeting where this > was discussed here: > https://mailman.oakapple.net/pipermail/cfp-interest/2021-October/002253.html > > The entire history of this discussion is about FP types that do not have a > format for infinity (say, VAX FP), and there was commentary on the CFP thread > that there was evidence that users thought that `INFINITY` was conditionally > defined like `NAN` was. Note that `NAN` has been similarly conditionally > defined for a long time, and gcc doesn't undefine it in `-ffinite-math-only` > mode, so that's strong precedent for not undefining INFINITY in fast-math. I spoke with the chair of CFP and he agreed with my assessment that `INFINITY` and `NAN` should not be defined in `-ffinite-math-only` mode, at least in terms of intent behind N2848. He also pointed out that not defining the macro is a security win because it makes it harder for people to write code using that macro and expecting it to do anything useful, which I strongly agree with. Aside from "compatibility/historically", do we have any technical arguments against following the intent of the standard here? (We already deviate from GCC in so many other ways, I'm not worried about a deviation here; I would presume GCC will eventually get around to doing the same thing, at least for C23 and up). https://github.com/llvm/llvm-project/pull/96659 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Add *_NORM_MAX macros to (PR #96643)
@@ -207,6 +211,23 @@ #error "Mandatory macros {FLT,DBL,LDBL}_MAX_10_EXP are invalid." #endif +#if __STDC_VERSION__ >= 202311L || !defined(__STRICT_ANSI__) +#ifndef FLT_NORM_MAX + #error "Mandatory macro FLT_NORM_MAX is missing." +#else + _Static_assert(FLT_NORM_MAX >= 1.0E+37F, "Mandatory macro FLT_NORM_MAX is invalid."); +#endif +#ifndef DBL_NORM_MAX + #error "Mandatory macro DBL_NORM_MAX is missing." +#else + _Static_assert(DBL_NORM_MAX >= 1.0E+37F, "Mandatory macro DBL_NORM_MAX is invalid."); +#endif +#ifndef LDBL_NORM_MAX + #error "Mandatory macro LDBL_NORM_MAX is missing." +#else + _Static_assert(LDBL_NORM_MAX >= 1.0E+37F, "Mandatory macro LDBL_NORM_MAX is invalid."); +#endif +#endif AaronBallman wrote: Oops, no, that's copy pasta from me, good catch! I'll correct that. https://github.com/llvm/llvm-project/pull/96643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Add *_NORM_MAX macros to (PR #96643)
@@ -113,7 +113,11 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext) { - const char *DenormMin, *Epsilon, *Max, *Min; + const char *DenormMin, *NormMax, *Epsilon, *Max, *Min; + NormMax = PickFP(Sem, "6.5504e+4", "3.40282347e+38", + "1.7976931348623157e+308", "1.18973149535723176502e+4932", + "1.79769313486231580793728971405301e+308", AaronBallman wrote: Good catch, thank you! I see now that GCC uses the following values for `long double`: ``` #define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L #define __LDBL_NORM_MAX__ 8.98846567431157953864652595394501e+307L ``` so I should probably go with `8.98846567431157953864652595394501e+307` as the value? CC @hubert-reinterpretcast https://github.com/llvm/llvm-project/pull/96643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Add *_NORM_MAX macros to (PR #96643)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/96643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
https://github.com/nikola-tesic-ns updated https://github.com/llvm/llvm-project/pull/96633 >From 41427a3de345517025477257bfd4f614f06cbcfe Mon Sep 17 00:00:00 2001 From: Nikola Tesic Date: Tue, 25 Jun 2024 15:58:18 +0300 Subject: [PATCH 1/2] [Clang] Access tls_guard via llvm.threadlocal.address This patch fixes compiler generated code in `tls_init` function to access TLS variable (`tls_guard`) via llvm.threadlocal.address intrinsic. --- clang/lib/CodeGen/CGDeclCXX.cpp | 29 +++--- clang/test/CodeGenCXX/cxx11-thread-local.cpp | 9 -- .../static-initializer-branch-weights.cpp | 3 +- clang/test/OpenMP/parallel_copyin_codegen.cpp | 6 ++-- .../OpenMP/target_has_device_addr_codegen.cpp | 6 ++-- clang/test/OpenMP/threadprivate_codegen.cpp | 30 --- 6 files changed, 55 insertions(+), 28 deletions(-) diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index e18b339b31d24..0663a083bf3e8 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -1059,9 +1059,10 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, if (Guard.isValid()) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. - llvm::Value *GuardVal = Builder.CreateLoad(Guard); - llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, - "guard.uninitialized"); + llvm::Value *GuardVal = EmitLoadOfScalar( + MakeAddrLValue(Guard, getContext().IntTy), SourceLocation()); + llvm::Value *Uninit = + Builder.CreateIsNull(GuardVal, "guard.uninitialized"); llvm::BasicBlock *InitBlock = createBasicBlock("init"); ExitBlock = createBasicBlock("exit"); EmitCXXGuardedInitBranch(Uninit, InitBlock, ExitBlock, @@ -1070,13 +1071,21 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, // Mark as initialized before initializing anything else. If the // initializers use previously-initialized thread_local vars, that's // probably supposed to be OK, but the standard doesn't say. - Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard); - - // The guard variable can't ever change again. - EmitInvariantStart( - Guard.getPointer(), - CharUnits::fromQuantity( - CGM.getDataLayout().getTypeAllocSize(GuardVal->getType(; + EmitStoreOfScalar(llvm::ConstantInt::get(GuardVal->getType(), 1), +MakeAddrLValue(Guard, getContext().IntTy)); + + // Emit invariant start for TLS guard address. + if (CGM.getCodeGenOpts().OptimizationLevel > 0) { +uint64_t Width = +CGM.getDataLayout().getTypeAllocSize(GuardVal->getType()); +llvm::Value *TLSAddr = Guard.getPointer(); +// Get the thread-local address via intrinsic. +if (auto *GV = dyn_cast(Guard.getPointer())) + if (GV->isThreadLocal()) +TLSAddr = Builder.CreateThreadLocalAddress(Guard.getPointer()); +Builder.CreateInvariantStart( +TLSAddr, llvm::ConstantInt::getSigned(Int64Ty, Width)); + } } RunCleanupsScope Scope(*this); diff --git a/clang/test/CodeGenCXX/cxx11-thread-local.cpp b/clang/test/CodeGenCXX/cxx11-thread-local.cpp index bcc490bc32e6e..e9a0799cf8d9a 100644 --- a/clang/test/CodeGenCXX/cxx11-thread-local.cpp +++ b/clang/test/CodeGenCXX/cxx11-thread-local.cpp @@ -358,12 +358,15 @@ void set_anon_i() { // CHECK: define {{.*}}@__tls_init() -// CHECK: load i8, ptr @__tls_guard +// CHECK: [[TLS_GUARD_ADDR_1:%.+]] = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @__tls_guard) +// CHECK: load i8, ptr [[TLS_GUARD_ADDR_1]] // CHECK: %[[NEED_TLS_INIT:.*]] = icmp eq i8 %{{.*}}, 0 // CHECK: br i1 %[[NEED_TLS_INIT]], // init: -// CHECK: store i8 1, ptr @__tls_guard -// CHECK-OPT: call ptr @llvm.invariant.start.p0(i64 1, ptr @__tls_guard) +// CHECK: [[TLS_GUARD_ADDR_2:%.+]] = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @__tls_guard) +// CHECK: store i8 1, ptr [[TLS_GUARD_ADDR_2]] +// CHECK-OPT: [[TLS_GUARD_ADDR_3:%.+]] = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @__tls_guard) +// CHECK-OPT: call ptr @llvm.invariant.start.p0(i64 1, ptr [[TLS_GUARD_ADDR_3]]) // CHECK-NOT: call void @[[V_M_INIT]]() // CHECK: call void @[[A_INIT]]() // CHECK-NOT: call void @[[V_M_INIT]]() diff --git a/clang/test/CodeGenCXX/static-initializer-branch-weights.cpp b/clang/test/CodeGenCXX/static-initializer-branch-weights.cpp index 121b9b2029959..e855f54643eae 100644 --- a/clang/test/CodeGenCXX/static-initializer-branch-weights.cpp +++ b/clang/test/CodeGenCXX/static-initializer-branch-weights.cpp @@ -118,7 +118,8 @@ void use_b() { } // CHECK-LABEL: define {{.*}}tls_init() -// CHECK: load i8, ptr @__tls_guard, align 1 +// CHECK: [[TLS_GUARD_
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1059,9 +1059,10 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, if (Guard.isValid()) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. - llvm::Value *GuardVal = Builder.CreateLoad(Guard); - llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, - "guard.uninitialized"); + llvm::Value *GuardVal = EmitLoadOfScalar( + MakeAddrLValue(Guard, getContext().IntTy), SourceLocation()); nikola-tesic-ns wrote: Makes sense, thanks. https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)
https://github.com/hokein commented: Thanks, this looks good overall. https://github.com/llvm/llvm-project/pull/96084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/96084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)
@@ -108,8 +108,11 @@ struct Foo { Foo(T const (&)[N]); }; +// FIXME: Prefer non-canonical template arguments in the deduction guide? template using Bar = Foo; // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} \ + // expected-note {{implicit deduction guide declared as 'template Bar(Foo) -> Foo'}} \ hokein wrote: I think it would be useful to print the associated constraints. I thought the attached constraints will be print automatically in the `FunctionTemplateDecl::print`(it is not implemented in the pretty printer yet?). No need to address here, but please add a FIXME. https://github.com/llvm/llvm-project/pull/96084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)
@@ -108,8 +108,11 @@ struct Foo { Foo(T const (&)[N]); }; +// FIXME: Prefer non-canonical template arguments in the deduction guide? hokein wrote: We have a open bug for this, https://github.com/llvm/llvm-project/issues/79798. https://github.com/llvm/llvm-project/pull/96084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Clarify diagnostic notes for implicitly generated deduction guides (PR #96084)
@@ -108,8 +108,11 @@ struct Foo { Foo(T const (&)[N]); }; +// FIXME: Prefer non-canonical template arguments in the deduction guide? template using Bar = Foo; // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} \ + // expected-note {{implicit deduction guide declared as 'template Bar(Foo) -> Foo'}} \ + // expected-note {{implicit deduction guide declared as 'template Bar(const type-parameter-0-0 (&)[sizeof(type-parameter-0-0)]) -> Foo'}} \ // expected-note {{candidate template ignored: constraints not satisfied [with X = int]}} \ hokein wrote: Right, it is not great for constraints not written in the source code. If we print constraints (see my another comment), it will improve the situation. https://github.com/llvm/llvm-project/pull/96084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
https://github.com/CarolineConcatto closed https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 847d046 - [clang][Interp] Fix comparing one-past-the-end pointers
Author: Timm Bäder Date: 2024-06-26T13:54:53+02:00 New Revision: 847d046a82a760caa1b05206d77ed0b3d7bd4be6 URL: https://github.com/llvm/llvm-project/commit/847d046a82a760caa1b05206d77ed0b3d7bd4be6 DIFF: https://github.com/llvm/llvm-project/commit/847d046a82a760caa1b05206d77ed0b3d7bd4be6.diff LOG: [clang][Interp] Fix comparing one-past-the-end pointers Added: Modified: clang/lib/AST/Interp/Pointer.h clang/test/AST/Interp/arrays.cpp Removed: diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h index 609367a462b00..0cd26ecf73f24 100644 --- a/clang/lib/AST/Interp/Pointer.h +++ b/clang/lib/AST/Interp/Pointer.h @@ -513,6 +513,8 @@ class Pointer { unsigned getByteOffset() const { if (isIntegralPointer()) return asIntPointer().Value + Offset; +if (isOnePastEnd()) + return PastEndMark; return Offset; } diff --git a/clang/test/AST/Interp/arrays.cpp b/clang/test/AST/Interp/arrays.cpp index 6f6fca8c1cfd8..7d231d3759421 100644 --- a/clang/test/AST/Interp/arrays.cpp +++ b/clang/test/AST/Interp/arrays.cpp @@ -26,6 +26,9 @@ static_assert(foo[2][2] == nullptr, ""); static_assert(foo[2][3] == &m, ""); static_assert(foo[2][4] == nullptr, ""); +constexpr int afterEnd[] = {1,2,3}; +static_assert(&afterEnd[3] == afterEnd + 3, ""); + constexpr int ZeroSizeArray[] = {}; constexpr int SomeInt[] = {1}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the +outputs of the BMI to change. Starting with Clang 19, changes to non-direct +dependencies should not directly affect the output BMI, unless they affect the +results of the compilations. We expect that there are many more opportunities +for this optimization than we currently have realized and would appreaciate +feedback about missed optimization opportunities. For example, + +.. code-block:: c++ + + // m-partA.cppm + export module m:partA; + + // m-partB.cppm + export module m:partB; + export int getB() { return 44; } + + // m.cppm + export module m; + export import :partA; + export import :partB; + + // useBOnly.cppm + export module useBOnly; + import m; + export int B() { +return getB(); + } + + // Use.cc + import useBOnly; + int get() { +return B(); + } + +To compile the project (for brevity, some commands are omitted.): + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +If the interface of ``m-partA.cppm`` is changed to: + +.. code-block:: c++ + + // m-partA.v1.cppm + export module m:partA; + export int getA() { return 43; } + +and the BMI for ``useBOnly`` is recompiled as in: + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +then the contents of ``useBOnly.pcm`` remain unchanged. +Consequently, if the build system only bases recompilation decisions on directly imported modules, +it becomes possible to skip the recompilation of ``Use.cc``. +It should be fine because the altered interfaces do not affect ``Use.cc`` in any way; +there are no transitive changes. + +When clang generates a BMI, it records the hash values of all potentially contributory BMIs +for the BMI being produced. This ensures that build systems are not required to consider +transitively imported modules when deciding whether to recompile. + +What is considered to be a potential contributory BMIs is currently unspecified. +However, it is a severe bug for a BMI to remain unchanged following an observable change +that affects its consumers. + +We recommend that build systems support this feature as a configurable option so that users +can go back to the transitive change mode safely at any time. + +Interactions with Reduced BMI +~ + +With reduced BMI, the no transitive change feature can be more powerful. For example, + +.. code-block:: c++ + + // A.cppm + export module A; + export int a() { return 44; } + + // B.cppm + export module B; + import A; + export int b() { return a(); } + +.. code-block:: console + + $ clang++ -std=c++20 A.cppm -c -fmodule-output=A.pcm -fexperimental-modules-reduced-bmi -o A.o + $ clang++ -std=c++20 B.cppm -c -fmodule-output=B.pcm -fexperimental-modules-reduced-bmi -o B.o -fmodule-file=A=A.pcm + $md5sum B.pcm mathstuf wrote: ```suggestion $ md5sum B.pcm ``` https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the +outputs of the BMI to change. Starting with Clang 19, changes to non-direct +dependencies should not directly affect the output BMI, unless they affect the +results of the compilations. We expect that there are many more opportunities +for this optimization than we currently have realized and would appreaciate +feedback about missed optimization opportunities. For example, + +.. code-block:: c++ + + // m-partA.cppm + export module m:partA; + + // m-partB.cppm + export module m:partB; + export int getB() { return 44; } + + // m.cppm + export module m; + export import :partA; + export import :partB; + + // useBOnly.cppm + export module useBOnly; + import m; + export int B() { +return getB(); + } + + // Use.cc + import useBOnly; + int get() { +return B(); + } + +To compile the project (for brevity, some commands are omitted.): + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +If the interface of ``m-partA.cppm`` is changed to: + +.. code-block:: c++ + + // m-partA.v1.cppm + export module m:partA; + export int getA() { return 43; } + +and the BMI for ``useBOnly`` is recompiled as in: + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +then the contents of ``useBOnly.pcm`` remain unchanged. +Consequently, if the build system only bases recompilation decisions on directly imported modules, +it becomes possible to skip the recompilation of ``Use.cc``. +It should be fine because the altered interfaces do not affect ``Use.cc`` in any way; +there are no transitive changes. + +When clang generates a BMI, it records the hash values of all potentially contributory BMIs mathstuf wrote: ```suggestion When Clang generates a BMI, it records the hash values of all potentially contributory BMIs ``` or ```suggestion When ``clang`` generates a BMI, it records the hash values of all potentially contributory BMIs ``` https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the +outputs of the BMI to change. Starting with Clang 19, changes to non-direct +dependencies should not directly affect the output BMI, unless they affect the +results of the compilations. We expect that there are many more opportunities +for this optimization than we currently have realized and would appreaciate +feedback about missed optimization opportunities. For example, + +.. code-block:: c++ + + // m-partA.cppm + export module m:partA; + + // m-partB.cppm + export module m:partB; + export int getB() { return 44; } + + // m.cppm + export module m; + export import :partA; + export import :partB; + + // useBOnly.cppm + export module useBOnly; + import m; + export int B() { +return getB(); + } + + // Use.cc + import useBOnly; + int get() { +return B(); + } + +To compile the project (for brevity, some commands are omitted.): + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +If the interface of ``m-partA.cppm`` is changed to: + +.. code-block:: c++ + + // m-partA.v1.cppm + export module m:partA; + export int getA() { return 43; } + +and the BMI for ``useBOnly`` is recompiled as in: + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +then the contents of ``useBOnly.pcm`` remain unchanged. +Consequently, if the build system only bases recompilation decisions on directly imported modules, +it becomes possible to skip the recompilation of ``Use.cc``. +It should be fine because the altered interfaces do not affect ``Use.cc`` in any way; +there are no transitive changes. + +When clang generates a BMI, it records the hash values of all potentially contributory BMIs +for the BMI being produced. This ensures that build systems are not required to consider +transitively imported modules when deciding whether to recompile. + +What is considered to be a potential contributory BMIs is currently unspecified. +However, it is a severe bug for a BMI to remain unchanged following an observable change +that affects its consumers. + +We recommend that build systems support this feature as a configurable option so that users +can go back to the transitive change mode safely at any time. mathstuf wrote: How does this happen? Is something missing in the example commands? They look "normal" to me. https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the +outputs of the BMI to change. Starting with Clang 19, changes to non-direct +dependencies should not directly affect the output BMI, unless they affect the +results of the compilations. We expect that there are many more opportunities +for this optimization than we currently have realized and would appreaciate +feedback about missed optimization opportunities. For example, + +.. code-block:: c++ + + // m-partA.cppm + export module m:partA; + + // m-partB.cppm + export module m:partB; + export int getB() { return 44; } + + // m.cppm + export module m; + export import :partA; + export import :partB; + + // useBOnly.cppm + export module useBOnly; + import m; + export int B() { +return getB(); + } + + // Use.cc + import useBOnly; + int get() { +return B(); + } + +To compile the project (for brevity, some commands are omitted.): + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +If the interface of ``m-partA.cppm`` is changed to: + +.. code-block:: c++ + + // m-partA.v1.cppm + export module m:partA; + export int getA() { return 43; } + +and the BMI for ``useBOnly`` is recompiled as in: + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +then the contents of ``useBOnly.pcm`` remain unchanged. +Consequently, if the build system only bases recompilation decisions on directly imported modules, +it becomes possible to skip the recompilation of ``Use.cc``. +It should be fine because the altered interfaces do not affect ``Use.cc`` in any way; +there are no transitive changes. + +When clang generates a BMI, it records the hash values of all potentially contributory BMIs +for the BMI being produced. This ensures that build systems are not required to consider +transitively imported modules when deciding whether to recompile. + +What is considered to be a potential contributory BMIs is currently unspecified. +However, it is a severe bug for a BMI to remain unchanged following an observable change +that affects its consumers. + +We recommend that build systems support this feature as a configurable option so that users +can go back to the transitive change mode safely at any time. + +Interactions with Reduced BMI +~ + +With reduced BMI, the no transitive change feature can be more powerful. For example, + +.. code-block:: c++ + + // A.cppm + export module A; + export int a() { return 44; } + + // B.cppm + export module B; + import A; + export int b() { return a(); } + +.. code-block:: console + + $ clang++ -std=c++20 A.cppm -c -fmodule-output=A.pcm -fexperimental-modules-reduced-bmi -o A.o + $ clang++ -std=c++20 B.cppm -c -fmodule-output=B.pcm -fexperimental-modules-reduced-bmi -o B.o -fmodule-file=A=A.pcm + $md5sum B.pcm + 6c2bd452ca32ab418bf35cd141b060b9 B.pcm + +And let's change the implementation for ``A.cppm`` into: + +.. code-block:: c++ + + export module A; + int a_impl() { return 99; } + export int a() { return a_impl(); } + +and recompile the example: + +.. code-block:: console + + $ clang++ -std=c++20 A.cppm -c -fmodule-output=A.pcm -fexperimental-modules-reduced-bmi -o A.o + $ clang++ -std=c++20 B.cppm -c -fmodule-output=B.pcm -fexperimental-modules-reduced-bmi -o B.o -fmodule-file=A=A.pcm + $md5sum B.pcm mathstuf wrote: ```suggestion $ md5sum B.pcm ``` https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the mathstuf wrote: ```suggestion Before Clang 19, a change in BMI of any (transitive) dependency would cause the ``` https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (PR #96731)
https://github.com/ymand approved this pull request. https://github.com/llvm/llvm-project/pull/96731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)
@@ -3216,6 +3226,44 @@ void DeclareImplicitDeductionGuidesForTypeAlias( Guides.suppressDiagnostics(); for (auto *G : Guides) { +if (auto *DG = dyn_cast(G)) { + // The deduction guide is a non-template function decl, we just clone it. + auto *FunctionType = + SemaRef.Context.getTrivialTypeSourceInfo(DG->getType()); + FunctionProtoTypeLoc FPTL = + FunctionType->getTypeLoc().castAs(); + + // Clone the parameters. + unsigned ProcessedParamIndex = 0; + for (auto *P : DG->parameters()) { +auto *TSI = SemaRef.Context.getTrivialTypeSourceInfo(P->getType()); +ParmVarDecl *NewParam = ParmVarDecl::Create( +SemaRef.Context, G->getDeclContext(), P->getBeginLoc(), +P->getLocation(), nullptr, TSI->getType(), TSI, SC_None, nullptr); +NewParam->setScopeInfo(0, ProcessedParamIndex); +FPTL.setParam(ProcessedParamIndex, NewParam); +ProcessedParamIndex++; hokein wrote: It is not needed here, this is already handled in the `buildDeductionGuide` call below. https://github.com/llvm/llvm-project/pull/96686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ve-ninja` running on `hpce-ve-main` while building `clang,llvm` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/720 Here is the relevant piece of the build log for the reference: ``` Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure) ... [300/306] Building CXX object tools/clang/unittests/Interpreter/CMakeFiles/ClangReplInterpreterTests.dir/InterpreterTest.cpp.o [301/306] Linking CXX executable tools/clang/unittests/Frontend/FrontendTests [302/306] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests [303/306] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests [304/306] Linking CXX executable tools/clang/unittests/Interpreter/ExceptionTests/ClangReplInterpreterExceptionTests [305/306] Linking CXX executable tools/clang/unittests/Interpreter/ClangReplInterpreterTests [305/306] Running the Clang regression tests -- Testing: 20665 tests, 48 workers -- llvm-lit: /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using clang: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang Testing: 0.. 10.. 20. FAIL: Clang :: CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c (5659 of 20665) TEST 'Clang :: CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 2: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 -internal-isystem /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -S -p mem2reg,instcombine,tailcallelim | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 -internal-isystem /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -S -p mem2reg,instcombine,tailcallelim + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:6:10: fatal error: 'arm_sme.h' file not found 6 | #include | ^~~ 1 error generated. /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:10:17: error: CHECK-LABEL: expected string not found in input // CHECK-LABEL: define dso_local @test_svreadz_hor_za8_s8_x2( ^ :1:1: note: scanning from here ; ModuleID = '' ^ Input file: Check file: /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c -dump-input=help explains the following input dump. Input was: << 1: ; ModuleID = '' label:10 X~~ error: no match found 2: source_filename = "" label:10 >> -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Step 8 (check-llvm) failure: check-llvm (failure) ... [300/306] Building CXX object tools/clang/unittests/Interpreter/CMakeFiles/ClangReplInterpreterTests.dir/InterpreterTest.cpp.o [301/306] Linking CXX executable tools/clang/unittests/Frontend/FrontendTests [302/306] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests [303/306] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests [304/306] Linking CXX executable tools/clang/unittests/Interpreter/ExceptionTests/ClangReplInterpreterExceptionTests [305/306] Linking CXX executable tools/clang/unittests/Interpreter/ClangReplInterpreterTests [305/306] Running the Clang regression tests -- Testing: 20665 tests, 48 workers -- llvm-lit: /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using clang: /scratch/buildbot/bo
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while building `clang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/905 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 2: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -cc1 -internal-isystem /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt -S -p mem2reg,instcombine,tailcallelim | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -cc1 -internal-isystem /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/opt -S -p mem2reg,instcombine,tailcallelim + /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:6:10: fatal error: 'arm_sme.h' file not found 6 | #include | ^~~ 1 error generated. [1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:10:17: [0m[0;1;31merror: [0m[1mCHECK-LABEL: expected string not found in input [0m// CHECK-LABEL: define dso_local @test_svreadz_hor_za8_s8_x2( [0;1;32m^ [0m[1m:1:1: [0m[0;1;30mnote: [0m[1mscanning from here [0m; ModuleID = '' [0;1;32m^ [0m Input file: Check file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c -dump-input=help explains the following input dump. Input was: << [1m[0m[0;1;30m 1: [0m[1m[0;1;46m; ModuleID = '' [0m [0;1;31mlabel:10 X~~ error: no match found [0m[0;1;30m 2: [0m[1m[0;1;46msource_filename = "" [0m [0;1;31mlabel:10 [0m>> -- ``` https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while building `clang,llvm` at step 6 "Add check check-clang". Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/815 Here is the relevant piece of the build log for the reference: ``` Step 6 (Add check check-clang) failure: test (failure) TEST 'Clang :: CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 2: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang -cc1 -internal-isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/opt -S -p mem2reg,instcombine,tailcallelim | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang -cc1 -internal-isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/opt -S -p mem2reg,instcombine,tailcallelim /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:6:10: fatal error: 'arm_sme.h' file not found 6 | #include | ^~~ 1 error generated. /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:10:17: error: CHECK-LABEL: expected string not found in input // CHECK-LABEL: define dso_local @test_svreadz_hor_za8_s8_x2( ^ :1:1: note: scanning from here ; ModuleID = '' ^ Input file: Check file: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c -dump-input=help explains the following input dump. Input was: << 1: ; ModuleID = '' label:10 X~~ error: no match found 2: source_filename = "" label:10 >> -- ``` https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)
https://github.com/jhuber6 approved this pull request. The fact that it's called `-fcuda-is-device` is historical cruft, but I guess it's easiest to just work with it. I also hate `-mlink-builtin-bitcode` as a concept, but we're not quite ready to move away from its hacks unfortunately. https://github.com/llvm/llvm-project/pull/96742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)
@@ -336,9 +336,12 @@ def warn_anyx86_excessive_regsave : Warning< " with attribute 'no_caller_saved_registers'" " or be compiled with '-mgeneral-regs-only'">, InGroup>; -def warn_arm_interrupt_calling_convention : Warning< - "call to function without interrupt attribute could clobber interruptee's VFP registers">, - InGroup; +def warn_arm_interrupt_vfp_clobber : Warning< + "interrupt service routine with vfp enabled may clobber the " + "interruptee's vfp state">, + InGroup>; +def err_arm_interrupt_called : Error< + "interrupt service routine cannot be called directly">; DavidSpickett wrote: I don't see a test case for this error. https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)
@@ -448,6 +448,11 @@ Modified Compiler Flags evaluating to ``true`` and an empty body such as ``while(1);``) are considered infinite, even when the ``-ffinite-loop`` flag is set. +- Removed "arm interrupt calling convention" warning that was included in + ``-Wextra`` without its own flag. + +- Added ``-Warm-interrupt-vfp-clobber``, with its own warning group. DavidSpickett wrote: We should be very clear whether this warning is serving the same function as the one that was removed, or not. If it is, perhaps it is better to merge the two points so it is clear one is replaced by the other. If not, perhaps you can include a sentence for each like "that would be emitted when..." - "that will be emitted when..." that shows the purpose of each one. (I know this is in the help, but we can save interested parties a round trip here) https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `arc-builder` running on `arc-worker` while building `clang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/624 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 2: /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c | /buildbot/worker/arc-folder/build/bin/opt -S -p mem2reg,instcombine,tailcallelim | /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /buildbot/worker/arc-folder/build/bin/opt -S -p mem2reg,instcombine,tailcallelim + /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c + /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/19/include -nostdsysteminc -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:6:10: fatal error: 'arm_sme.h' file not found 6 | #include | ^~~ 1 error generated. /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c:10:17: error: CHECK-LABEL: expected string not found in input // CHECK-LABEL: define dso_local @test_svreadz_hor_za8_s8_x2( ^ :1:1: note: scanning from here ; ModuleID = '' ^ Input file: Check file: /buildbot/worker/arc-folder/llvm-project/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c -dump-input=help explains the following input dump. Input was: << 1: ; ModuleID = '' label:10 X~~ error: no match found 2: source_filename = "" label:10 >> -- ``` https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C23] Add *_NORM_MAX macros to (PR #96643)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/96643 >From 408c34b84966a256bb6e7fdf45758f5c77380bbe Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 25 Jun 2024 10:27:10 -0400 Subject: [PATCH 1/4] [C23] Add *_NORM_MAX macros to This adds the *_NORM_MAX macros to for freestanding mode in Clang; the values were chosen based on the behavior seen coming from GCC and the values already produced for the *_MAX macros by Clang. --- clang/docs/ReleaseNotes.rst | 3 +++ clang/lib/Frontend/InitPreprocessor.cpp | 7 ++- clang/lib/Headers/float.h | 13 clang/test/Headers/float.c | 27 + 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index df579ae398c5e..8879a77ba4dd9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -336,6 +336,9 @@ C23 Feature Support - Properly promote bit-fields of bit-precise integer types to the field's type rather than to ``int``. #GH87641 +- Added the ``FLT_NORM_MAX``, ``DBL_NORM_MAX``, and ``LDBL_NORM_MAX`` to the + freestanding implementation of that ships with Clang. + Non-comprehensive list of changes in this release - diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 55ec460064830..afc4c16ab685b 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -113,7 +113,11 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext) { - const char *DenormMin, *Epsilon, *Max, *Min; + const char *DenormMin, *NormMax, *Epsilon, *Max, *Min; + NormMax = PickFP(Sem, "6.5504e+4", "3.40282347e+38", + "1.7976931348623157e+308", "1.18973149535723176502e+4932", + "1.79769313486231580793728971405301e+308", + "1.18973149535723176508575932662800702e+4932"); DenormMin = PickFP(Sem, "5.9604644775390625e-8", "1.40129846e-45", "4.9406564584124654e-324", "3.64519953188247460253e-4951", "4.94065645841246544176568792868221e-324", @@ -144,6 +148,7 @@ static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, DefPrefix += "_"; Builder.defineMacro(DefPrefix + "DENORM_MIN__", Twine(DenormMin)+Ext); + Builder.defineMacro(DefPrefix + "NORM_MAX__", Twine(NormMax)+Ext); Builder.defineMacro(DefPrefix + "HAS_DENORM__"); Builder.defineMacro(DefPrefix + "DIG__", Twine(Digits)); Builder.defineMacro(DefPrefix + "DECIMAL_DIG__", Twine(DecimalDigits)); diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h index 642c8f06cc938..61f65dad8debc 100644 --- a/clang/lib/Headers/float.h +++ b/clang/lib/Headers/float.h @@ -86,6 +86,12 @@ #undef DBL_HAS_SUBNORM #undef LDBL_HAS_SUBNORM # endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ +!defined(__STRICT_ANSI__) +#undef FLT_NORM_MAX +#undef DBL_NORM_MAX +#undef LDBL_NORM_MAX +#endif #endif /* Characteristics of floating point types, C99 5.2.4.2.2 */ @@ -155,6 +161,13 @@ # define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ #endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ +!defined(__STRICT_ANSI__) +# define FLT_NORM_MAX __FLT_NORM_MAX__ +# define DBL_NORM_MAX __DBL_NORM_MAX__ +# define LDBL_NORM_MAX __LDBL_NORM_MAX__ +#endif + #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ # define FLT16_MANT_DIG__FLT16_MANT_DIG__ # define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ diff --git a/clang/test/Headers/float.c b/clang/test/Headers/float.c index 70c11b0537537..59cc0faa074db 100644 --- a/clang/test/Headers/float.c +++ b/clang/test/Headers/float.c @@ -1,17 +1,21 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++11 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++14 -ffreestanding %s // RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++17 -ffreestanding %s +// RUN: %clang_cc1 -fsyntax-only -verify -xc++ -std=c++23 -ffreestanding %s // expected-no-diagnostics /* Basic floating point conformance checks against: +- C23 Final Std. - N1570 draft of C11 Std. - N1256 draft of C99 Std. - http://port70.net/~nsz/c/c89/c89-draft.html draft of C89/C90 Std. */ /* +C23,5.2.5.3.3p21, pp. 25 C11,5.2.4.2.2p11, pp. 30 C99,5.2.4.2.2p9,pp. 25
[clang] [flang] [Flang-new][OpenMP] Add offload related flags for AMDGPU (PR #96742)
@@ -333,6 +333,9 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, StringRef Val = A->getValue(); CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val)); } + + const ToolChain &TC = getToolChain(); + TC.addClangTargetOptions(Args, CmdArgs, Action::OffloadKind::OFK_OpenMP); tblah wrote: Should there be some kind of warning if these flags are used not with AMDGPU? I don't have a strong opinion here as it is only an fc1 flag. https://github.com/llvm/llvm-project/pull/96742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][transformer] Introduce a `constructExprArgs` range selector. (PR #95901)
https://github.com/ymand approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/95901 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Move the initializer lifetime checking code from SemaInit.cpp to a new place, NFC (PR #96758)
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/96758 This is a refactoring change for better code isolation and reuse, the first step to extend it for assignments. >From 3c5318893322d1f904a52b2f92d5ccd191aa5930 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 21 Jun 2024 11:48:33 +0200 Subject: [PATCH] [clang][sema] Move the initializer lifetime checking code from SemaInit.cpp to a new place. NFC This is a refactoring change for better code isolation and reuse, a first step to extend it for assignments. --- clang/lib/Sema/CMakeLists.txt|1 + clang/lib/Sema/CheckExprLifetime.cpp | 1258 ++ clang/lib/Sema/CheckExprLifetime.h | 29 + clang/lib/Sema/SemaInit.cpp | 1231 + 4 files changed, 1290 insertions(+), 1229 deletions(-) create mode 100644 clang/lib/Sema/CheckExprLifetime.cpp create mode 100644 clang/lib/Sema/CheckExprLifetime.h diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt index f152d243d39a5..980a83d4431aa 100644 --- a/clang/lib/Sema/CMakeLists.txt +++ b/clang/lib/Sema/CMakeLists.txt @@ -15,6 +15,7 @@ clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins add_clang_library(clangSema AnalysisBasedWarnings.cpp + CheckExprLifetime.cpp CodeCompleteConsumer.cpp DeclSpec.cpp DelayedDiagnostic.cpp diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp new file mode 100644 index 0..2b44330ef0336 --- /dev/null +++ b/clang/lib/Sema/CheckExprLifetime.cpp @@ -0,0 +1,1258 @@ +//===--- CheckExprLifetime.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "CheckExprLifetime.h" +#include "clang/AST/Expr.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/PointerIntPair.h" + +namespace clang::sema { +namespace { +enum LifetimeKind { + /// The lifetime of a temporary bound to this entity ends at the end of the + /// full-expression, and that's (probably) fine. + LK_FullExpression, + + /// The lifetime of a temporary bound to this entity is extended to the + /// lifeitme of the entity itself. + LK_Extended, + + /// The lifetime of a temporary bound to this entity probably ends too soon, + /// because the entity is allocated in a new-expression. + LK_New, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is a return object. + LK_Return, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is the result of a statement expression. + LK_StmtExprResult, + + /// This is a mem-initializer: if it would extend a temporary (other than via + /// a default member initializer), the program is ill-formed. + LK_MemInitializer, +}; +using LifetimeResult = +llvm::PointerIntPair; +} + +/// Determine the declaration which an initialized entity ultimately refers to, +/// for the purpose of lifetime-extending a temporary bound to a reference in +/// the initialization of \p Entity. +static LifetimeResult getEntityLifetime( +const InitializedEntity *Entity, +const InitializedEntity *InitField = nullptr) { + // C++11 [class.temporary]p5: + switch (Entity->getKind()) { + case InitializedEntity::EK_Variable: +// The temporary [...] persists for the lifetime of the reference +return {Entity, LK_Extended}; + + + case InitializedEntity::EK_Member: +// For subobjects, we look at the complete object. +if (Entity->getParent()) + return getEntityLifetime(Entity->getParent(), Entity); + +// except: +// C++17 [class.base.init]p8: +// A temporary expression bound to a reference member in a +// mem-initializer is ill-formed. +// C++17 [class.base.init]p11: +// A temporary expression bound to a reference member from a +// default member initializer is ill-formed. +// +// The context of p11 and its example suggest that it's only the use of a +// default member initializer from a constructor that makes the program +// ill-formed, not its mere existence, and that it can even be used by +// aggregate initialization. +return {Entity, Entity->isDefaultMemberInitializer() ? LK_Extended + : LK_MemInitializer}; + + case InitializedEntity::EK_Binding: +// Per [dcl.decomp]p3, the binding is treated as a variable of reference +// type. +return {Entity, LK_Extended}; + + case InitializedEntity::EK_Parameter: + case InitializedEntity::EK_Parameter_CF_Audited: +// -- A temporary bound to a reference parameter in a function call +// persists until the completion of t
[clang] [clang][Sema] Move the initializer lifetime checking code from SemaInit.cpp to a new place, NFC (PR #96758)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haojian Wu (hokein) Changes This is a refactoring change for better code isolation and reuse, the first step to extend it for assignments. --- Patch is 102.58 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96758.diff 4 Files Affected: - (modified) clang/lib/Sema/CMakeLists.txt (+1) - (added) clang/lib/Sema/CheckExprLifetime.cpp (+1258) - (added) clang/lib/Sema/CheckExprLifetime.h (+29) - (modified) clang/lib/Sema/SemaInit.cpp (+2-1229) ``diff diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt index f152d243d39a5..980a83d4431aa 100644 --- a/clang/lib/Sema/CMakeLists.txt +++ b/clang/lib/Sema/CMakeLists.txt @@ -15,6 +15,7 @@ clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins add_clang_library(clangSema AnalysisBasedWarnings.cpp + CheckExprLifetime.cpp CodeCompleteConsumer.cpp DeclSpec.cpp DelayedDiagnostic.cpp diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp new file mode 100644 index 0..2b44330ef0336 --- /dev/null +++ b/clang/lib/Sema/CheckExprLifetime.cpp @@ -0,0 +1,1258 @@ +//===--- CheckExprLifetime.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "CheckExprLifetime.h" +#include "clang/AST/Expr.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/PointerIntPair.h" + +namespace clang::sema { +namespace { +enum LifetimeKind { + /// The lifetime of a temporary bound to this entity ends at the end of the + /// full-expression, and that's (probably) fine. + LK_FullExpression, + + /// The lifetime of a temporary bound to this entity is extended to the + /// lifeitme of the entity itself. + LK_Extended, + + /// The lifetime of a temporary bound to this entity probably ends too soon, + /// because the entity is allocated in a new-expression. + LK_New, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is a return object. + LK_Return, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is the result of a statement expression. + LK_StmtExprResult, + + /// This is a mem-initializer: if it would extend a temporary (other than via + /// a default member initializer), the program is ill-formed. + LK_MemInitializer, +}; +using LifetimeResult = +llvm::PointerIntPair; +} + +/// Determine the declaration which an initialized entity ultimately refers to, +/// for the purpose of lifetime-extending a temporary bound to a reference in +/// the initialization of \p Entity. +static LifetimeResult getEntityLifetime( +const InitializedEntity *Entity, +const InitializedEntity *InitField = nullptr) { + // C++11 [class.temporary]p5: + switch (Entity->getKind()) { + case InitializedEntity::EK_Variable: +// The temporary [...] persists for the lifetime of the reference +return {Entity, LK_Extended}; + + + case InitializedEntity::EK_Member: +// For subobjects, we look at the complete object. +if (Entity->getParent()) + return getEntityLifetime(Entity->getParent(), Entity); + +// except: +// C++17 [class.base.init]p8: +// A temporary expression bound to a reference member in a +// mem-initializer is ill-formed. +// C++17 [class.base.init]p11: +// A temporary expression bound to a reference member from a +// default member initializer is ill-formed. +// +// The context of p11 and its example suggest that it's only the use of a +// default member initializer from a constructor that makes the program +// ill-formed, not its mere existence, and that it can even be used by +// aggregate initialization. +return {Entity, Entity->isDefaultMemberInitializer() ? LK_Extended + : LK_MemInitializer}; + + case InitializedEntity::EK_Binding: +// Per [dcl.decomp]p3, the binding is treated as a variable of reference +// type. +return {Entity, LK_Extended}; + + case InitializedEntity::EK_Parameter: + case InitializedEntity::EK_Parameter_CF_Audited: +// -- A temporary bound to a reference parameter in a function call +// persists until the completion of the full-expression containing +// the call. +return {nullptr, LK_FullExpression}; + + case InitializedEntity::EK_TemplateParameter: +// FIXME: This will always be ill-formed; should we eagerly diagnose it here? +return {nullptr, LK_FullExpression}; + + case InitializedEntity::EK_Result: +// -- The lifetime of a temporary bound to the returned value in a +
[clang] [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (PR #96731)
https://github.com/Xazax-hun approved this pull request. https://github.com/llvm/llvm-project/pull/96731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -449,6 +449,23 @@ OMPUnrollDirective *OMPUnrollDirective::CreateEmpty(const ASTContext &C, SourceLocation(), SourceLocation()); } +OMPReverseDirective * +OMPReverseDirective::Create(const ASTContext &C, SourceLocation StartLoc, +SourceLocation EndLoc, Stmt *AssociatedStmt, +Stmt *TransformedStmt, Stmt *PreInits) { + OMPReverseDirective *Dir = createDirective( + C, {}, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc); alexey-bataev wrote: ```suggestion C, std::nullopt, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc); ``` https://github.com/llvm/llvm-project/pull/92916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -15749,6 +15757,186 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef Clauses, buildPreInits(Context, PreInits)); } +StmtResult SemaOpenMP::ActOnOpenMPReverseDirective(Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + ASTContext &Context = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + + // Empty statement should only be possible if there already was an error. + if (!AStmt) +return StmtError(); + + constexpr unsigned NumLoops = 1; + Stmt *Body = nullptr; + SmallVector LoopHelpers( + NumLoops); + SmallVector, NumLoops + 1> OriginalInits; + if (!checkTransformableLoopNest(OMPD_reverse, AStmt, NumLoops, LoopHelpers, + Body, OriginalInits)) +return StmtError(); + + // Delay applying the transformation to when template is completely + // instantiated. + if (SemaRef.CurContext->isDependentContext()) +return OMPReverseDirective::Create(Context, StartLoc, EndLoc, AStmt, + nullptr, nullptr); + + assert(LoopHelpers.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + assert(OriginalInits.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers.front(); + + // Find the loop statement. + Stmt *LoopStmt = nullptr; + collectLoopStmts(AStmt, {LoopStmt}); + + // Determine the PreInit declarations. + SmallVector PreInits; + addLoopPreInits(Context, LoopHelper, LoopStmt, OriginalInits[0], PreInits); + + auto *IterationVarRef = cast(LoopHelper.IterationVarRef); + QualType IVTy = IterationVarRef->getType(); + uint64_t IVWidth = Context.getTypeSize(IVTy); + auto *OrigVar = cast(LoopHelper.Counters.front()); + + // Iteration variable SourceLocations. + SourceLocation OrigVarLoc = OrigVar->getExprLoc(); + SourceLocation OrigVarLocBegin = OrigVar->getBeginLoc(); + SourceLocation OrigVarLocEnd = OrigVar->getEndLoc(); + + // Locations pointing to the transformation. + SourceLocation TransformLoc = StartLoc; + SourceLocation TransformLocBegin = StartLoc; + SourceLocation TransformLocEnd = EndLoc; + + // Internal variable names. + std::string OrigVarName = OrigVar->getNameInfo().getAsString(); + std::string TripCountName = (Twine(".tripcount.") + OrigVarName).str(); + std::string ForwardIVName = (Twine(".forward.iv.") + OrigVarName).str(); + std::string ReversedIVName = (Twine(".reversed.iv.") + OrigVarName).str(); + + // LoopHelper.Updates will read the logical iteration number from + // LoopHelper.IterationVarRef, compute the value of the user loop counter of + // that logical iteration from it, then assign it to the user loop counter + // variable. We cannot directly use LoopHelper.IterationVarRef as the + // induction variable of the generated loop because it may cause an underflow: + // \code + // for (unsigned i = 0; i < n; ++i) + // body(i); + // \endcode + // + // Naive reversal: + // \code + // for (unsigned i = n-1; i >= 0; --i) + // body(i); + // \endcode + // + // Instead, we introduce a new iteration variable representing the logical + // iteration counter of the original loop, convert it to the logical iteration + // number of the reversed loop, then let LoopHelper.Updates compute the user's + // loop iteration variable from it. + // \code + // for (auto .forward.iv = 0; .forward.iv < n; ++.forward.iv) { + // auto .reversed.iv = n - .forward.iv - 1; + // i = (.reversed.iv + 0) * 1;// LoopHelper.Updates + // body(i); // Body + // } + // \endcode + + // Subexpressions with more than one use. One of the constraints of an AST is + // that every node object must appear at most once, hence we define a lambda + // that creates a new AST node at every use. + CaptureVars CopyTransformer(SemaRef); + auto MakeNumIterations = [&CopyTransformer, &LoopHelper]() -> Expr * { +return AssertSuccess( +CopyTransformer.TransformExpr(LoopHelper.NumIterations)); + }; + + // Create the iteration variable for the forward loop (from 0 to n-1). + VarDecl *ForwardIVDecl = + buildVarDecl(SemaRef, {}, IVTy, ForwardIVName, nullptr, OrigVar); + auto MakeForwardRef = [&SemaRef = this->SemaRef, ForwardIVDecl, IVTy, + OrigVarLoc]() { +return buildDeclRefExpr(SemaRef, ForwardIVDecl, IVTy, OrigVarLoc); + }; + + // Iteration variable for the reversed induction variable (from n-1 downto 0): + // Reuse the iteration variable created by checkOpenMPLoop. + auto *ReversedIVDecl = cast(IterationVarRef->getDecl()); + ReversedIVDecl->setDeclName( + &SemaRef.PP.getIdentifierTable().get(ReversedIVName)); + + // For init-statement: + // \co
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -15749,6 +15757,186 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef Clauses, buildPreInits(Context, PreInits)); } +StmtResult SemaOpenMP::ActOnOpenMPReverseDirective(Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + ASTContext &Context = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + + // Empty statement should only be possible if there already was an error. + if (!AStmt) +return StmtError(); + + constexpr unsigned NumLoops = 1; + Stmt *Body = nullptr; + SmallVector LoopHelpers( + NumLoops); + SmallVector, NumLoops + 1> OriginalInits; + if (!checkTransformableLoopNest(OMPD_reverse, AStmt, NumLoops, LoopHelpers, + Body, OriginalInits)) +return StmtError(); + + // Delay applying the transformation to when template is completely + // instantiated. + if (SemaRef.CurContext->isDependentContext()) +return OMPReverseDirective::Create(Context, StartLoc, EndLoc, AStmt, + nullptr, nullptr); + + assert(LoopHelpers.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + assert(OriginalInits.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers.front(); + + // Find the loop statement. + Stmt *LoopStmt = nullptr; + collectLoopStmts(AStmt, {LoopStmt}); + + // Determine the PreInit declarations. + SmallVector PreInits; + addLoopPreInits(Context, LoopHelper, LoopStmt, OriginalInits[0], PreInits); + + auto *IterationVarRef = cast(LoopHelper.IterationVarRef); + QualType IVTy = IterationVarRef->getType(); + uint64_t IVWidth = Context.getTypeSize(IVTy); + auto *OrigVar = cast(LoopHelper.Counters.front()); + + // Iteration variable SourceLocations. + SourceLocation OrigVarLoc = OrigVar->getExprLoc(); + SourceLocation OrigVarLocBegin = OrigVar->getBeginLoc(); + SourceLocation OrigVarLocEnd = OrigVar->getEndLoc(); + + // Locations pointing to the transformation. + SourceLocation TransformLoc = StartLoc; + SourceLocation TransformLocBegin = StartLoc; + SourceLocation TransformLocEnd = EndLoc; + + // Internal variable names. + std::string OrigVarName = OrigVar->getNameInfo().getAsString(); + std::string TripCountName = (Twine(".tripcount.") + OrigVarName).str(); + std::string ForwardIVName = (Twine(".forward.iv.") + OrigVarName).str(); + std::string ReversedIVName = (Twine(".reversed.iv.") + OrigVarName).str(); + + // LoopHelper.Updates will read the logical iteration number from + // LoopHelper.IterationVarRef, compute the value of the user loop counter of + // that logical iteration from it, then assign it to the user loop counter + // variable. We cannot directly use LoopHelper.IterationVarRef as the + // induction variable of the generated loop because it may cause an underflow: + // \code + // for (unsigned i = 0; i < n; ++i) + // body(i); + // \endcode + // + // Naive reversal: + // \code + // for (unsigned i = n-1; i >= 0; --i) + // body(i); + // \endcode + // + // Instead, we introduce a new iteration variable representing the logical + // iteration counter of the original loop, convert it to the logical iteration + // number of the reversed loop, then let LoopHelper.Updates compute the user's + // loop iteration variable from it. + // \code + // for (auto .forward.iv = 0; .forward.iv < n; ++.forward.iv) { + // auto .reversed.iv = n - .forward.iv - 1; + // i = (.reversed.iv + 0) * 1;// LoopHelper.Updates + // body(i); // Body + // } + // \endcode + + // Subexpressions with more than one use. One of the constraints of an AST is + // that every node object must appear at most once, hence we define a lambda + // that creates a new AST node at every use. + CaptureVars CopyTransformer(SemaRef); + auto MakeNumIterations = [&CopyTransformer, &LoopHelper]() -> Expr * { +return AssertSuccess( +CopyTransformer.TransformExpr(LoopHelper.NumIterations)); + }; + + // Create the iteration variable for the forward loop (from 0 to n-1). + VarDecl *ForwardIVDecl = + buildVarDecl(SemaRef, {}, IVTy, ForwardIVName, nullptr, OrigVar); + auto MakeForwardRef = [&SemaRef = this->SemaRef, ForwardIVDecl, IVTy, + OrigVarLoc]() { +return buildDeclRefExpr(SemaRef, ForwardIVDecl, IVTy, OrigVarLoc); + }; + + // Iteration variable for the reversed induction variable (from n-1 downto 0): + // Reuse the iteration variable created by checkOpenMPLoop. + auto *ReversedIVDecl = cast(IterationVarRef->getDecl()); + ReversedIVDecl->setDeclName( + &SemaRef.PP.getIdentifierTable().get(ReversedIVName)); + + // For init-statement: + // \co
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -15749,6 +15757,186 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef Clauses, buildPreInits(Context, PreInits)); } +StmtResult SemaOpenMP::ActOnOpenMPReverseDirective(Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + ASTContext &Context = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + + // Empty statement should only be possible if there already was an error. + if (!AStmt) +return StmtError(); + + constexpr unsigned NumLoops = 1; + Stmt *Body = nullptr; + SmallVector LoopHelpers( + NumLoops); + SmallVector, NumLoops + 1> OriginalInits; + if (!checkTransformableLoopNest(OMPD_reverse, AStmt, NumLoops, LoopHelpers, + Body, OriginalInits)) +return StmtError(); + + // Delay applying the transformation to when template is completely + // instantiated. + if (SemaRef.CurContext->isDependentContext()) +return OMPReverseDirective::Create(Context, StartLoc, EndLoc, AStmt, + nullptr, nullptr); + + assert(LoopHelpers.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + assert(OriginalInits.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers.front(); + + // Find the loop statement. + Stmt *LoopStmt = nullptr; + collectLoopStmts(AStmt, {LoopStmt}); + + // Determine the PreInit declarations. + SmallVector PreInits; + addLoopPreInits(Context, LoopHelper, LoopStmt, OriginalInits[0], PreInits); + + auto *IterationVarRef = cast(LoopHelper.IterationVarRef); + QualType IVTy = IterationVarRef->getType(); + uint64_t IVWidth = Context.getTypeSize(IVTy); + auto *OrigVar = cast(LoopHelper.Counters.front()); + + // Iteration variable SourceLocations. + SourceLocation OrigVarLoc = OrigVar->getExprLoc(); + SourceLocation OrigVarLocBegin = OrigVar->getBeginLoc(); + SourceLocation OrigVarLocEnd = OrigVar->getEndLoc(); + + // Locations pointing to the transformation. + SourceLocation TransformLoc = StartLoc; + SourceLocation TransformLocBegin = StartLoc; + SourceLocation TransformLocEnd = EndLoc; + + // Internal variable names. + std::string OrigVarName = OrigVar->getNameInfo().getAsString(); + std::string TripCountName = (Twine(".tripcount.") + OrigVarName).str(); + std::string ForwardIVName = (Twine(".forward.iv.") + OrigVarName).str(); + std::string ReversedIVName = (Twine(".reversed.iv.") + OrigVarName).str(); alexey-bataev wrote: Twine should be enough, without std::string, no? https://github.com/llvm/llvm-project/pull/92916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [openmp] [Clang][OpenMP] Add reverse directive (PR #92916)
@@ -15749,6 +15757,186 @@ StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef Clauses, buildPreInits(Context, PreInits)); } +StmtResult SemaOpenMP::ActOnOpenMPReverseDirective(Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc) { + ASTContext &Context = getASTContext(); + Scope *CurScope = SemaRef.getCurScope(); + + // Empty statement should only be possible if there already was an error. + if (!AStmt) +return StmtError(); + + constexpr unsigned NumLoops = 1; + Stmt *Body = nullptr; + SmallVector LoopHelpers( + NumLoops); + SmallVector, NumLoops + 1> OriginalInits; + if (!checkTransformableLoopNest(OMPD_reverse, AStmt, NumLoops, LoopHelpers, + Body, OriginalInits)) +return StmtError(); + + // Delay applying the transformation to when template is completely + // instantiated. + if (SemaRef.CurContext->isDependentContext()) +return OMPReverseDirective::Create(Context, StartLoc, EndLoc, AStmt, + nullptr, nullptr); + + assert(LoopHelpers.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + assert(OriginalInits.size() == NumLoops && + "Expecting a single-dimensional loop iteration space"); + OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers.front(); + + // Find the loop statement. + Stmt *LoopStmt = nullptr; + collectLoopStmts(AStmt, {LoopStmt}); + + // Determine the PreInit declarations. + SmallVector PreInits; + addLoopPreInits(Context, LoopHelper, LoopStmt, OriginalInits[0], PreInits); + + auto *IterationVarRef = cast(LoopHelper.IterationVarRef); + QualType IVTy = IterationVarRef->getType(); + uint64_t IVWidth = Context.getTypeSize(IVTy); + auto *OrigVar = cast(LoopHelper.Counters.front()); + + // Iteration variable SourceLocations. + SourceLocation OrigVarLoc = OrigVar->getExprLoc(); + SourceLocation OrigVarLocBegin = OrigVar->getBeginLoc(); + SourceLocation OrigVarLocEnd = OrigVar->getEndLoc(); + + // Locations pointing to the transformation. + SourceLocation TransformLoc = StartLoc; + SourceLocation TransformLocBegin = StartLoc; + SourceLocation TransformLocEnd = EndLoc; + + // Internal variable names. + std::string OrigVarName = OrigVar->getNameInfo().getAsString(); + std::string TripCountName = (Twine(".tripcount.") + OrigVarName).str(); + std::string ForwardIVName = (Twine(".forward.iv.") + OrigVarName).str(); + std::string ReversedIVName = (Twine(".reversed.iv.") + OrigVarName).str(); + + // LoopHelper.Updates will read the logical iteration number from + // LoopHelper.IterationVarRef, compute the value of the user loop counter of + // that logical iteration from it, then assign it to the user loop counter + // variable. We cannot directly use LoopHelper.IterationVarRef as the + // induction variable of the generated loop because it may cause an underflow: + // \code + // for (unsigned i = 0; i < n; ++i) + // body(i); + // \endcode + // + // Naive reversal: + // \code + // for (unsigned i = n-1; i >= 0; --i) + // body(i); + // \endcode + // + // Instead, we introduce a new iteration variable representing the logical + // iteration counter of the original loop, convert it to the logical iteration + // number of the reversed loop, then let LoopHelper.Updates compute the user's + // loop iteration variable from it. + // \code + // for (auto .forward.iv = 0; .forward.iv < n; ++.forward.iv) { + // auto .reversed.iv = n - .forward.iv - 1; + // i = (.reversed.iv + 0) * 1;// LoopHelper.Updates + // body(i); // Body + // } + // \endcode + + // Subexpressions with more than one use. One of the constraints of an AST is + // that every node object must appear at most once, hence we define a lambda + // that creates a new AST node at every use. + CaptureVars CopyTransformer(SemaRef); + auto MakeNumIterations = [&CopyTransformer, &LoopHelper]() -> Expr * { +return AssertSuccess( +CopyTransformer.TransformExpr(LoopHelper.NumIterations)); + }; + + // Create the iteration variable for the forward loop (from 0 to n-1). + VarDecl *ForwardIVDecl = + buildVarDecl(SemaRef, {}, IVTy, ForwardIVName, nullptr, OrigVar); + auto MakeForwardRef = [&SemaRef = this->SemaRef, ForwardIVDecl, IVTy, + OrigVarLoc]() { +return buildDeclRefExpr(SemaRef, ForwardIVDecl, IVTy, OrigVarLoc); + }; + + // Iteration variable for the reversed induction variable (from n-1 downto 0): + // Reuse the iteration variable created by checkOpenMPLoop. + auto *ReversedIVDecl = cast(IterationVarRef->getDecl()); + ReversedIVDecl->setDeclName( + &SemaRef.PP.getIdentifierTable().get(ReversedIVName)); + + // For init-statement: + // \co
[clang] 177cbd1 - [Clang][SME2.1] Add REQUIRES: aarch64-registered-target to test
Author: Caroline Concatto Date: 2024-06-26T12:53:34Z New Revision: 177cbd16663a2ca36d0d7145c3b62f2d756f8f7f URL: https://github.com/llvm/llvm-project/commit/177cbd16663a2ca36d0d7145c3b62f2d756f8f7f DIFF: https://github.com/llvm/llvm-project/commit/177cbd16663a2ca36d0d7145c3b62f2d756f8f7f.diff LOG: [Clang][SME2.1] Add REQUIRES: aarch64-registered-target to test PR#88710 is failing because the test file needs REQUIRES: aarch64-registered-target Added: Modified: clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c Removed: diff --git a/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c b/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c index 3f5337c2b23d2..d0c7230ade761 100644 --- a/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c +++ b/clang/test/CodeGen/aarch64-sme2p1-intrinsics/acle_sme2p1_movaz.c @@ -1,5 +1,6 @@ // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 - //RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s +// REQUIRES: aarch64-registered-target +//RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +sme -target-feature +bf16 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dfe80a7 - [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (#96731)
Author: martinboehme Date: 2024-06-26T15:01:57+02:00 New Revision: dfe80a73223edff5c53f8be7925d302883cb40bc URL: https://github.com/llvm/llvm-project/commit/dfe80a73223edff5c53f8be7925d302883cb40bc DIFF: https://github.com/llvm/llvm-project/commit/dfe80a73223edff5c53f8be7925d302883cb40bc.diff LOG: [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (#96731) We were previously treating the operand of `typeid()` as being definitely unevaluated, but it can be evaluated if it is a glvalue of polymorphic type. This patch includes a test that fails without the fix. Added: Modified: clang/include/clang/Analysis/FlowSensitive/ASTOps.h clang/unittests/Analysis/FlowSensitive/TransferTest.cpp Removed: diff --git a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h index 925b99af9141a..f9c923a36ad22 100644 --- a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h +++ b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h @@ -113,7 +113,11 @@ class AnalysisASTVisitor : public RecursiveASTVisitor { // nevertheless it appears in the Clang CFG, so we don't exclude it here. bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; } bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; } - bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; } + bool TraverseCXXTypeidExpr(CXXTypeidExpr *TIE) { +if (TIE->isPotentiallyEvaluated()) + return RecursiveASTVisitor::TraverseCXXTypeidExpr(TIE); +return true; + } bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) { return true; } diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index cfbc64c77b0cc..2ce83399c5453 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -1637,6 +1637,49 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) { }); } +TEST(TransferTest, StructModeledFieldsInTypeid) { + // Test that we model fields mentioned inside a `typeid()` expression only if + // that expression is potentially evaluated -- i.e. if the expression inside + // `typeid()` is a glvalue of polymorphic type (see + // `CXXTypeidExpr::isPotentiallyEvaluated()` and [expr.typeid]p3). + std::string Code = R"( +// Definitions needed for `typeid`. +namespace std { + class type_info {}; + class bad_typeid {}; +} // namespace std + +struct NonPolymorphic {}; + +struct Polymorphic { + virtual ~Polymorphic() = default; +}; + +struct S { + NonPolymorphic *NonPoly; + Polymorphic *Poly; +}; + +void target(S &s) { + typeid(*s.NonPoly); + typeid(*s.Poly); + // [[p]] +} + )"; + runDataflow( + Code, + [](const llvm::StringMap> &Results, + ASTContext &ASTCtx) { +const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); +auto &SLoc = getLocForDecl(ASTCtx, Env, "s"); +std::vector Fields; +for (auto [Field, _] : SLoc.children()) + Fields.push_back(Field); +EXPECT_THAT(Fields, +UnorderedElementsAre(findValueDecl(ASTCtx, "Poly"))); + }); +} + TEST(TransferTest, StructModeledFieldsWithComplicatedInheritance) { std::string Code = R"( struct Base1 { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (PR #96731)
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/96731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 85f47fd - [clang][nullability] Improve modeling of `++`/`--` operators. (#96601)
Author: martinboehme Date: 2024-06-26T15:03:37+02:00 New Revision: 85f47fdd039549ed7e89b53ca34b0b35456ffe3d URL: https://github.com/llvm/llvm-project/commit/85f47fdd039549ed7e89b53ca34b0b35456ffe3d DIFF: https://github.com/llvm/llvm-project/commit/85f47fdd039549ed7e89b53ca34b0b35456ffe3d.diff LOG: [clang][nullability] Improve modeling of `++`/`--` operators. (#96601) We definitely know that these operations change the value of their operand, so clear out any value associated with it. We don't create a new value, instead leaving it to the analysis to do this if desired. Added: Modified: clang/lib/Analysis/FlowSensitive/Transfer.cpp clang/unittests/Analysis/FlowSensitive/TransferTest.cpp Removed: diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp b/clang/lib/Analysis/FlowSensitive/Transfer.cpp index 8109ac6a781e7..3c896d373a211 100644 --- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp +++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp @@ -391,17 +391,22 @@ class TransferVisitor : public ConstStmtVisitor { } case UO_PreInc: case UO_PreDec: - // Propagate the storage location, but don't create a new value; to - // avoid generating unnecessary values, we leave it to the specific - // analysis to do this if desired. + // Propagate the storage location and clear out any value associated with + // it (to represent the fact that the value has definitely changed). + // To avoid generating unnecessary values, we leave it to the specific + // analysis to create a new value if desired. propagateStorageLocation(*S->getSubExpr(), *S, Env); + if (StorageLocation *Loc = Env.getStorageLocation(*S->getSubExpr())) +Env.clearValue(*Loc); break; case UO_PostInc: case UO_PostDec: - // Propagate the old value, but don't create a new value; to avoid - // generating unnecessary values, we leave it to the specific analysis - // to do this if desired. + // Propagate the old value, then clear out any value associated with the + // storage location (to represent the fact that the value has definitely + // changed). See above for rationale. propagateValue(*S->getSubExpr(), *S, Env); + if (StorageLocation *Loc = Env.getStorageLocation(*S->getSubExpr())) +Env.clearValue(*Loc); break; default: break; diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index 2ce83399c5453..39e7001393e5e 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -3832,36 +3832,51 @@ TEST(TransferTest, AddrOfReference) { TEST(TransferTest, Preincrement) { std::string Code = R"( void target(int I) { + (void)0; // [[before]] int &IRef = ++I; - // [[p]] + // [[after]] } )"; runDataflow( Code, [](const llvm::StringMap> &Results, ASTContext &ASTCtx) { -const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); +const Environment &EnvBefore = +getEnvironmentAtAnnotation(Results, "before"); +const Environment &EnvAfter = +getEnvironmentAtAnnotation(Results, "after"); -EXPECT_EQ(&getLocForDecl(ASTCtx, Env, "IRef"), - &getLocForDecl(ASTCtx, Env, "I")); +EXPECT_EQ(&getLocForDecl(ASTCtx, EnvAfter, "IRef"), + &getLocForDecl(ASTCtx, EnvBefore, "I")); + +const ValueDecl *IDecl = findValueDecl(ASTCtx, "I"); +EXPECT_NE(EnvBefore.getValue(*IDecl), nullptr); +EXPECT_EQ(EnvAfter.getValue(*IDecl), nullptr); }); } TEST(TransferTest, Postincrement) { std::string Code = R"( void target(int I) { + (void)0; // [[before]] int OldVal = I++; - // [[p]] + // [[after]] } )"; runDataflow( Code, [](const llvm::StringMap> &Results, ASTContext &ASTCtx) { -const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); +const Environment &EnvBefore = +getEnvironmentAtAnnotation(Results, "before"); +const Environment &EnvAfter = +getEnvironmentAtAnnotation(Results, "after"); + +EXPECT_EQ(&getValueForDecl(ASTCtx, EnvBefore, "I"), + &getValueForDecl(ASTCtx, EnvAfter, "OldVal")); -EXPECT_EQ(&getValueForDecl(ASTCtx, Env, "OldVal"), - &getValueForDecl(ASTCtx, Env, "I")); +const ValueDecl *IDecl = findValueDecl(ASTCtx, "I"); +EXPECT_EQ(EnvAfter.getValue(*IDecl), nullptr); }); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][nullability] Improve modeling of `++`/`--` operators. (PR #96601)
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/96601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CLANG][LLVM][AArch64]SME2.1 intrinsics for MOVAZ tile to 2/4 vectors (PR #88710)
CarolineConcatto wrote: I believe it is fixed with this patch: commit 177cbd16663a2ca36d0d7145c3b62f2d756f8f7f (HEAD -> main, origin/main, origin/HEAD) Author: Caroline Concatto Date: Wed Jun 26 12:35:21 2024 + [Clang][SME2.1] Add REQUIRES: aarch64-registered-target to test PR#88710 is failing because the test file needs REQUIRES: aarch64-registered-target https://github.com/llvm/llvm-project/pull/88710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e24a212 - [clang][OpenMP] Shorten directive classification in ParseOpenMP (#94691)
Author: Krzysztof Parzyszek Date: 2024-06-26T08:11:09-05:00 New Revision: e24a21291ac35a0660ec7cf19d4c36019ee7437e URL: https://github.com/llvm/llvm-project/commit/e24a21291ac35a0660ec7cf19d4c36019ee7437e DIFF: https://github.com/llvm/llvm-project/commit/e24a21291ac35a0660ec7cf19d4c36019ee7437e.diff LOG: [clang][OpenMP] Shorten directive classification in ParseOpenMP (#94691) Use directive categories to simplify long lists of `case` statements in the OpenMP parser. This is a step towards avoiding dependence on explicitly specified sets of directives that can be expressed more generically. The upcoming OpenMP 6.0 will introduce many new combined directives, and the more generically we handle directives, the easier the introduction of the new standard will be. - Co-authored-by: Alexey Bataev Added: Modified: clang/include/clang/Parse/Parser.h clang/lib/Parse/ParseOpenMP.cpp Removed: diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 95c0655f9a214..39b17f7f9bd7c 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3511,6 +3511,19 @@ class Parser : public CodeCompletionHandler { /// metadirective and therefore ends on the closing paren. StmtResult ParseOpenMPDeclarativeOrExecutableDirective( ParsedStmtContext StmtCtx, bool ReadDirectiveWithinMetadirective = false); + + /// Parses executable directive. + /// + /// \param StmtCtx The context in which we're parsing the directive. + /// \param DKind The kind of the executable directive. + /// \param Loc Source location of the beginning of the directive. + /// \param ReadDirectiveWithinMetadirective true if directive is within a + /// metadirective and therefore ends on the closing paren. + StmtResult + ParseOpenMPExecutableDirective(ParsedStmtContext StmtCtx, + OpenMPDirectiveKind DKind, SourceLocation Loc, + bool ReadDirectiveWithinMetadirective); + /// Parses clause of kind \a CKind for directive of a kind \a Kind. /// /// \param DKind Kind of current directive. diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 76d1854520382..00f9ebb65d876 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -24,10 +24,10 @@ #include "clang/Sema/SemaAMDGPU.h" #include "clang/Sema/SemaCodeCompletion.h" #include "clang/Sema/SemaOpenMP.h" +#include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Frontend/OpenMP/OMPAssume.h" #include "llvm/Frontend/OpenMP/OMPContext.h" -#include #include using namespace clang; @@ -2146,7 +2146,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_requires: { SourceLocation StartLoc = ConsumeToken(); SmallVector Clauses; -std::bitset SeenClauses; +llvm::SmallBitVector SeenClauses(llvm::omp::Clause_enumSize + 1); if (Tok.is(tok::annot_pragma_openmp_end)) { Diag(Tok, diag::err_omp_expected_clause) << getOpenMPDirectiveName(OMPD_requires); @@ -2374,81 +2374,19 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_unknown: Diag(Tok, diag::err_omp_unknown_directive); break; - case OMPD_parallel: - case OMPD_simd: - case OMPD_tile: - case OMPD_unroll: - case OMPD_task: - case OMPD_taskyield: - case OMPD_barrier: - case OMPD_taskwait: - case OMPD_taskgroup: - case OMPD_flush: - case OMPD_depobj: - case OMPD_scan: - case OMPD_for: - case OMPD_for_simd: - case OMPD_sections: - case OMPD_section: - case OMPD_single: - case OMPD_master: - case OMPD_ordered: - case OMPD_critical: - case OMPD_parallel_for: - case OMPD_parallel_for_simd: - case OMPD_parallel_sections: - case OMPD_parallel_master: - case OMPD_parallel_masked: - case OMPD_atomic: - case OMPD_target: - case OMPD_teams: - case OMPD_cancellation_point: - case OMPD_cancel: - case OMPD_target_data: - case OMPD_target_enter_data: - case OMPD_target_exit_data: - case OMPD_target_parallel: - case OMPD_target_parallel_for: - case OMPD_taskloop: - case OMPD_taskloop_simd: - case OMPD_master_taskloop: - case OMPD_master_taskloop_simd: - case OMPD_parallel_master_taskloop: - case OMPD_parallel_master_taskloop_simd: - case OMPD_masked_taskloop: - case OMPD_masked_taskloop_simd: - case OMPD_parallel_masked_taskloop: - case OMPD_parallel_masked_taskloop_simd: - case OMPD_distribute: - case OMPD_target_update: - case OMPD_distribute_parallel_for: - case OMPD_distribute_parallel_for_simd: - case OMPD_distribute_simd: - case OMPD_target_parallel_for_simd: - case OMPD_target_simd: - case OMPD_scope: - case OMPD_teams_distribute: - case OMPD_teams_distribute_simd: - case OMPD_teams_distribute_parallel_for_simd: - case OMPD_teams_d
[clang] [llvm] [clang][OpenMP] Shorten directive classification in ParseOpenMP (PR #94691)
https://github.com/kparzysz closed https://github.com/llvm/llvm-project/pull/94691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm approved this pull request. LGTM. Shame the order of the `-target-features` has to change again, but I can see why (there are non-user-visible extensions in the ExtensionInfo table now, which also need sorted). https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated. (PR #96731)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while building `clang` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/913 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang-Unit :: Analysis/FlowSensitive/./ClangAnalysisFlowSensitiveTests/35/42' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/unittests/Analysis/FlowSensitive/./ClangAnalysisFlowSensitiveTests-Clang-Unit-4189086-35-42.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=42 GTEST_SHARD_INDEX=35 /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/unittests/Analysis/FlowSensitive/./ClangAnalysisFlowSensitiveTests -- Script: -- /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/unittests/Analysis/FlowSensitive/./ClangAnalysisFlowSensitiveTests --gtest_filter=TransferTest.StructModeledFieldsInTypeid -- input.cc:20:7: error: use of typeid requires -frtti 20 | typeid(*s.NonPoly); | ^ input.cc:21:7: error: use of typeid requires -frtti 21 | typeid(*s.Poly); | ^ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:92: Failure Value of: llvm::detail::TakeError(checkDataflowWithNoopAnalysis(Code, VerifyResults, Options, Std, TargetFun)) Expected: succeeded Actual: failed (Invalid argument Source file has syntax or type errors, they were printed to the test log) /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:92 Value of: llvm::detail::TakeError(checkDataflowWithNoopAnalysis(Code, VerifyResults, Options, Std, TargetFun)) Expected: succeeded Actual: failed (Invalid argument Source file has syntax or type errors, they were printed to the test log) ``` https://github.com/llvm/llvm-project/pull/96731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Sema] Move the initializer lifetime checking code from SemaInit.cpp to a new place, NFC (PR #96758)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/96758 >From 6b18b58f4b3c4032c21252177709ab7759060c1f Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 21 Jun 2024 11:48:33 +0200 Subject: [PATCH] [clang][sema] Move the initializer lifetime checking code from SemaInit.cpp to a new place. NFC This is a refactoring change for better code isolation and reuse, a first step to extend it for assignments. --- clang/lib/Sema/CMakeLists.txt|1 + clang/lib/Sema/CheckExprLifetime.cpp | 1259 ++ clang/lib/Sema/CheckExprLifetime.h | 29 + clang/lib/Sema/SemaInit.cpp | 1232 + 4 files changed, 1291 insertions(+), 1230 deletions(-) create mode 100644 clang/lib/Sema/CheckExprLifetime.cpp create mode 100644 clang/lib/Sema/CheckExprLifetime.h diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt index f152d243d39a5..980a83d4431aa 100644 --- a/clang/lib/Sema/CMakeLists.txt +++ b/clang/lib/Sema/CMakeLists.txt @@ -15,6 +15,7 @@ clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins add_clang_library(clangSema AnalysisBasedWarnings.cpp + CheckExprLifetime.cpp CodeCompleteConsumer.cpp DeclSpec.cpp DelayedDiagnostic.cpp diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp new file mode 100644 index 0..54e2f1c22536d --- /dev/null +++ b/clang/lib/Sema/CheckExprLifetime.cpp @@ -0,0 +1,1259 @@ +//===--- CheckExprLifetime.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "CheckExprLifetime.h" +#include "clang/AST/Expr.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/PointerIntPair.h" + +namespace clang::sema { +namespace { +enum LifetimeKind { + /// The lifetime of a temporary bound to this entity ends at the end of the + /// full-expression, and that's (probably) fine. + LK_FullExpression, + + /// The lifetime of a temporary bound to this entity is extended to the + /// lifeitme of the entity itself. + LK_Extended, + + /// The lifetime of a temporary bound to this entity probably ends too soon, + /// because the entity is allocated in a new-expression. + LK_New, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is a return object. + LK_Return, + + /// The lifetime of a temporary bound to this entity ends too soon, because + /// the entity is the result of a statement expression. + LK_StmtExprResult, + + /// This is a mem-initializer: if it would extend a temporary (other than via + /// a default member initializer), the program is ill-formed. + LK_MemInitializer, +}; +using LifetimeResult = +llvm::PointerIntPair; +} // namespace + +/// Determine the declaration which an initialized entity ultimately refers to, +/// for the purpose of lifetime-extending a temporary bound to a reference in +/// the initialization of \p Entity. +static LifetimeResult +getEntityLifetime(const InitializedEntity *Entity, + const InitializedEntity *InitField = nullptr) { + // C++11 [class.temporary]p5: + switch (Entity->getKind()) { + case InitializedEntity::EK_Variable: +// The temporary [...] persists for the lifetime of the reference +return {Entity, LK_Extended}; + + case InitializedEntity::EK_Member: +// For subobjects, we look at the complete object. +if (Entity->getParent()) + return getEntityLifetime(Entity->getParent(), Entity); + +// except: +// C++17 [class.base.init]p8: +// A temporary expression bound to a reference member in a +// mem-initializer is ill-formed. +// C++17 [class.base.init]p11: +// A temporary expression bound to a reference member from a +// default member initializer is ill-formed. +// +// The context of p11 and its example suggest that it's only the use of a +// default member initializer from a constructor that makes the program +// ill-formed, not its mere existence, and that it can even be used by +// aggregate initialization. +return {Entity, Entity->isDefaultMemberInitializer() ? LK_Extended + : LK_MemInitializer}; + + case InitializedEntity::EK_Binding: +// Per [dcl.decomp]p3, the binding is treated as a variable of reference +// type. +return {Entity, LK_Extended}; + + case InitializedEntity::EK_Parameter: + case InitializedEntity::EK_Parameter_CF_Audited: +// -- A temporary bound to a reference parameter in a function call +// persists until the completion of the full-expression containing +// the call. +return {nullptr, LK_FullExpression}
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/pratlucas closed https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Emit bad shift warnings (PR #70307)
https://github.com/budimirarandjelovicsyrmia updated https://github.com/llvm/llvm-project/pull/70307 From 9e4309a805f31096d72cb21cd266175cac5b07c1 Mon Sep 17 00:00:00 2001 From: budimirarandjelovicsyrmia Date: Thu, 26 Oct 2023 10:39:52 +0200 Subject: [PATCH] [clang] Emit bad shift warnings --- clang/docs/ReleaseNotes.rst| 2 ++ clang/lib/AST/ExprConstant.cpp | 7 ++ clang/lib/Sema/SemaExpr.cpp| 35 +++--- clang/test/C/drs/dr0xx.c | 3 ++- clang/test/C/drs/dr2xx.c | 4 ++- clang/test/Sema/builtins.c | 6 +++-- clang/test/Sema/constant-builtins-2.c | 12 ++--- clang/test/Sema/integer-overflow.c | 2 ++ clang/test/Sema/shift-count-negative.c | 8 ++ clang/test/Sema/shift-count-overflow.c | 9 +++ clang/test/Sema/shift-negative-value.c | 13 ++ clang/test/Sema/vla-2.c| 6 +++-- clang/test/SemaCXX/enum.cpp| 16 +++- clang/test/SemaCXX/shift.cpp | 2 +- 14 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 clang/test/Sema/shift-count-negative.c create mode 100644 clang/test/Sema/shift-count-overflow.c create mode 100644 clang/test/Sema/shift-negative-value.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9ed3ff4507671c..d09cec913fd162 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -626,6 +626,8 @@ Improvements to Clang's diagnostics used rather than when they are needed for constant evaluation or when code is generated for them. The check is now stricter to prevent crashes for some unsupported declarations (Fixes #GH95495). +- Clang now diagnoses non-C++11 integer constant expressions. Fixes #GH59863 + Improvements to Clang's time-trace -- diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index fe4b9a569ab874..5196d85d2a9852 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2858,6 +2858,9 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E, else if (LHS.countl_zero() < SA) Info.CCEDiag(E, diag::note_constexpr_lshift_discards); } +if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() && +Info.getLangOpts().CPlusPlus11) + return false; Result = LHS << SA; return true; } @@ -2881,6 +2884,10 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E, if (SA != RHS) Info.CCEDiag(E, diag::note_constexpr_large_shift) << RHS << E->getType() << LHS.getBitWidth(); + +if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() && +Info.getLangOpts().CPlusPlus11) + return false; Result = LHS >> SA; return true; } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 4a2f3a65eac96f..0c7d0fc6173e1a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11256,7 +11256,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, if (Right.isNegative()) { S.DiagRuntimeBehavior(Loc, RHS.get(), S.PDiag(diag::warn_shift_negative) -<< RHS.get()->getSourceRange()); + << RHS.get()->getSourceRange()); return; } @@ -11271,7 +11271,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, if (Right.uge(LeftSize)) { S.DiagRuntimeBehavior(Loc, RHS.get(), S.PDiag(diag::warn_shift_gt_typewidth) -<< RHS.get()->getSourceRange()); + << RHS.get()->getSourceRange()); return; } @@ -11304,7 +11304,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS, if (Left.isNegative()) { S.DiagRuntimeBehavior(Loc, LHS.get(), S.PDiag(diag::warn_shift_lhs_negative) -<< LHS.get()->getSourceRange()); + << LHS.get()->getSourceRange()); return; } @@ -17138,11 +17138,38 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, // Circumvent ICE checking in C++11 to avoid evaluating the expression twice // in the non-ICE case. if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) { +SmallVector Notes; if (Result) - *Result = E->EvaluateKnownConstIntCheckOverflow(Context); + *Result = E->EvaluateKnownConstIntCheckOverflow(Context, &Notes); if (!isa(E)) E = Result ? ConstantExpr::Create(Context, E, APValue(*Result)) : ConstantExpr::Create(Context, E); + +if (Notes.empty()) + return E; + +// If our only note is the usual "invalid subexpression" note, just point +// the caret at its location rather than producing an essentially +
[clang] [Doc] Update documentation for no-transitive-change (PR #96453)
@@ -652,6 +652,141 @@ in the future. The expected roadmap for Reduced BMIs as of Clang 19.x is: comes, the term BMI will refer to the Reduced BMI and the Full BMI will only be meaningful to build systems which elect to support two-phase compilation. +Experimental No Transitive Change +- + +This section is primarily for build system vendors. For end compiler users, +if you don't want to read it all, this is helpful to reduce recompilations +We encourage build system vendors and end users try this out and bring feedbacks + +Before Clang 19, a change in BMI of any (transitive) dependency would case the +outputs of the BMI to change. Starting with Clang 19, changes to non-direct +dependencies should not directly affect the output BMI, unless they affect the +results of the compilations. We expect that there are many more opportunities +for this optimization than we currently have realized and would appreaciate +feedback about missed optimization opportunities. For example, + +.. code-block:: c++ + + // m-partA.cppm + export module m:partA; + + // m-partB.cppm + export module m:partB; + export int getB() { return 44; } + + // m.cppm + export module m; + export import :partA; + export import :partB; + + // useBOnly.cppm + export module useBOnly; + import m; + export int B() { +return getB(); + } + + // Use.cc + import useBOnly; + int get() { +return B(); + } + +To compile the project (for brevity, some commands are omitted.): + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +If the interface of ``m-partA.cppm`` is changed to: + +.. code-block:: c++ + + // m-partA.v1.cppm + export module m:partA; + export int getA() { return 43; } + +and the BMI for ``useBOnly`` is recompiled as in: + +.. code-block:: console + + $ clang++ -std=c++20 m-partA.cppm --precompile -o m-partA.pcm + $ clang++ -std=c++20 m-partB.cppm --precompile -o m-partB.pcm + $ clang++ -std=c++20 m.cppm --precompile -o m.pcm -fprebuilt-module-path=. + $ clang++ -std=c++20 useBOnly.cppm --precompile -o useBOnly.pcm -fprebuilt-module-path=. + $ md5sum useBOnly.pcm + 07656bf4a6908626795729295f9608da useBOnly.pcm + +then the contents of ``useBOnly.pcm`` remain unchanged. +Consequently, if the build system only bases recompilation decisions on directly imported modules, +it becomes possible to skip the recompilation of ``Use.cc``. +It should be fine because the altered interfaces do not affect ``Use.cc`` in any way; +there are no transitive changes. + +When clang generates a BMI, it records the hash values of all potentially contributory BMIs +for the BMI being produced. This ensures that build systems are not required to consider +transitively imported modules when deciding whether to recompile. + +What is considered to be a potential contributory BMIs is currently unspecified. +However, it is a severe bug for a BMI to remain unchanged following an observable change +that affects its consumers. + +We recommend that build systems support this feature as a configurable option so that users +can go back to the transitive change mode safely at any time. ChuanqiXu9 wrote: Do you mean in what cases the users need to go back to normal mode? The answer may be when they meet compiler bugs. Or if you're asking about the command line options, there is no such option in the compiler side. We refactored the format in the BMI so it is in some level always "enabled". But the users have to wait the build system's support to feel so called "no-transitive-change". So the "option" here means a build system option. https://github.com/llvm/llvm-project/pull/96453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][transformer] Introduce a `constructExprArgs` range selector. (PR #95901)
https://github.com/legrosbuffle updated https://github.com/llvm/llvm-project/pull/95901 >From 8f6ff99ddb035d63e99910f873a8d9938bd0b3e4 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Mon, 17 Jun 2024 15:33:34 + Subject: [PATCH] [clang][transformer] Introduce a `constructExprArgs` range selector. This is similar to `callArgs` but for construct exprs like `S(42)` or `{42}`. --- .../clang/Tooling/Transformer/RangeSelector.h | 5 ++ .../lib/Tooling/Transformer/RangeSelector.cpp | 51 ++- clang/unittests/Tooling/RangeSelectorTest.cpp | 42 +++ 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/clang/include/clang/Tooling/Transformer/RangeSelector.h b/clang/include/clang/Tooling/Transformer/RangeSelector.h index 1e288043f0a8e..462a9da8f10eb 100644 --- a/clang/include/clang/Tooling/Transformer/RangeSelector.h +++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h @@ -86,6 +86,11 @@ RangeSelector name(std::string ID); // source between the call's parentheses). RangeSelector callArgs(std::string ID); +// Given a \c CXXConstructExpr (bound to \p ID), selects the +// arguments' source text. Depending on the syntactic form of the construct, +// this is the range between parentheses or braces. +RangeSelector constructExprArgs(std::string ID); + // Given a \c CompoundStmt (bound to \p ID), selects the source of the // statements (all source between the braces). RangeSelector statements(std::string ID); diff --git a/clang/lib/Tooling/Transformer/RangeSelector.cpp b/clang/lib/Tooling/Transformer/RangeSelector.cpp index 7370baf010834..e84ddde74a707 100644 --- a/clang/lib/Tooling/Transformer/RangeSelector.cpp +++ b/clang/lib/Tooling/Transformer/RangeSelector.cpp @@ -96,13 +96,6 @@ static SourceLocation findPreviousTokenKind(SourceLocation Start, } } -static SourceLocation findOpenParen(const CallExpr &E, const SourceManager &SM, -const LangOptions &LangOpts) { - SourceLocation EndLoc = - E.getNumArgs() == 0 ? E.getRParenLoc() : E.getArg(0)->getBeginLoc(); - return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren); -} - RangeSelector transformer::before(RangeSelector Selector) { return [Selector](const MatchResult &Result) -> Expected { Expected SelectedRange = Selector(Result); @@ -287,18 +280,50 @@ RangeSelector transformer::statements(std::string ID) { } namespace { -// Returns the range of the source between the call's parentheses. -CharSourceRange getCallArgumentsRange(const MatchResult &Result, - const CallExpr &CE) { + +SourceLocation getRLoc(const CallExpr &E) { return E.getRParenLoc(); } + +SourceLocation getRLoc(const CXXConstructExpr &E) { + return E.getParenOrBraceRange().getEnd(); +} + +tok::TokenKind getStartToken(const CallExpr &E) { + return tok::TokenKind::l_paren; +} + +tok::TokenKind getStartToken(const CXXConstructExpr &E) { + return isa(E) ? tok::TokenKind::l_paren +: tok::TokenKind::l_brace; +} + +template +SourceLocation findArgStartDelimiter(const ExprWithArgs &E, SourceLocation RLoc, + const SourceManager &SM, + const LangOptions &LangOpts) { + SourceLocation Loc = E.getNumArgs() == 0 ? RLoc : E.getArg(0)->getBeginLoc(); + return findPreviousTokenKind(Loc, SM, LangOpts, getStartToken(E)); +} +// Returns the range of the source between the call's or construct expr's +// parentheses/braces. +template +CharSourceRange getArgumentsRange(const MatchResult &Result, + const ExprWithArgs &CE) { + const SourceLocation RLoc = getRLoc(CE); return CharSourceRange::getCharRange( - findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts()) + findArgStartDelimiter(CE, RLoc, *Result.SourceManager, +Result.Context->getLangOpts()) .getLocWithOffset(1), - CE.getRParenLoc()); + RLoc); } } // namespace RangeSelector transformer::callArgs(std::string ID) { - return RelativeSelector(std::move(ID)); + return RelativeSelector>(std::move(ID)); +} + +RangeSelector transformer::constructExprArgs(std::string ID) { + return RelativeSelector>(std::move(ID)); } namespace { diff --git a/clang/unittests/Tooling/RangeSelectorTest.cpp b/clang/unittests/Tooling/RangeSelectorTest.cpp index 03ab66235e43c..ad2f4218a1d84 100644 --- a/clang/unittests/Tooling/RangeSelectorTest.cpp +++ b/clang/unittests/Tooling/RangeSelectorTest.cpp @@ -651,6 +651,48 @@ TEST(RangeSelectorTest, CallArgsErrors) { Failed(withTypeErrorMessage("stmt"))); } +TEST(RangeSelectorTest, ConstructExprArgs) { + const StringRef Code = R"cc( +struct C { + C(int, int); +}; +C f() { + return C(1, 2); +} + )cc"; + const char *ID = "id"; + TestMatch Match = matchCode(Code, cxxConstructExpr().bin
[clang] Revert "[clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated." (PR #96766)
https://github.com/martinboehme created https://github.com/llvm/llvm-project/pull/96766 Reverts llvm/llvm-project#96731 It causes CI failures. >From d1ed32e5cb1cb43acf2d9085960ff37c3fe6b09b Mon Sep 17 00:00:00 2001 From: martinboehme Date: Wed, 26 Jun 2024 15:40:06 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"[clang][dataflow]=20Teach=20`Analysis?= =?UTF-8?q?ASTVisitor`=20that=20`typeid()`=20can=20be=20e=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dfe80a73223edff5c53f8be7925d302883cb40bc. --- .../clang/Analysis/FlowSensitive/ASTOps.h | 6 +-- .../Analysis/FlowSensitive/TransferTest.cpp | 43 --- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h index f9c923a36ad22..925b99af9141a 100644 --- a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h +++ b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h @@ -113,11 +113,7 @@ class AnalysisASTVisitor : public RecursiveASTVisitor { // nevertheless it appears in the Clang CFG, so we don't exclude it here. bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; } bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; } - bool TraverseCXXTypeidExpr(CXXTypeidExpr *TIE) { -if (TIE->isPotentiallyEvaluated()) - return RecursiveASTVisitor::TraverseCXXTypeidExpr(TIE); -return true; - } + bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; } bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) { return true; } diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index 39e7001393e5e..e743eefa5d458 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -1637,49 +1637,6 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) { }); } -TEST(TransferTest, StructModeledFieldsInTypeid) { - // Test that we model fields mentioned inside a `typeid()` expression only if - // that expression is potentially evaluated -- i.e. if the expression inside - // `typeid()` is a glvalue of polymorphic type (see - // `CXXTypeidExpr::isPotentiallyEvaluated()` and [expr.typeid]p3). - std::string Code = R"( -// Definitions needed for `typeid`. -namespace std { - class type_info {}; - class bad_typeid {}; -} // namespace std - -struct NonPolymorphic {}; - -struct Polymorphic { - virtual ~Polymorphic() = default; -}; - -struct S { - NonPolymorphic *NonPoly; - Polymorphic *Poly; -}; - -void target(S &s) { - typeid(*s.NonPoly); - typeid(*s.Poly); - // [[p]] -} - )"; - runDataflow( - Code, - [](const llvm::StringMap> &Results, - ASTContext &ASTCtx) { -const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); -auto &SLoc = getLocForDecl(ASTCtx, Env, "s"); -std::vector Fields; -for (auto [Field, _] : SLoc.children()) - Fields.push_back(Field); -EXPECT_THAT(Fields, -UnorderedElementsAre(findValueDecl(ASTCtx, "Poly"))); - }); -} - TEST(TransferTest, StructModeledFieldsWithComplicatedInheritance) { std::string Code = R"( struct Base1 { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6e96e5a - Revert "[clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated." (#96766)
Author: martinboehme Date: 2024-06-26T15:40:42+02:00 New Revision: 6e96e5ab8a0e40fba0302a5c32574be41ef57354 URL: https://github.com/llvm/llvm-project/commit/6e96e5ab8a0e40fba0302a5c32574be41ef57354 DIFF: https://github.com/llvm/llvm-project/commit/6e96e5ab8a0e40fba0302a5c32574be41ef57354.diff LOG: Revert "[clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated." (#96766) Reverts llvm/llvm-project#96731 It causes CI failures. Added: Modified: clang/include/clang/Analysis/FlowSensitive/ASTOps.h clang/unittests/Analysis/FlowSensitive/TransferTest.cpp Removed: diff --git a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h index f9c923a36ad22..925b99af9141a 100644 --- a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h +++ b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h @@ -113,11 +113,7 @@ class AnalysisASTVisitor : public RecursiveASTVisitor { // nevertheless it appears in the Clang CFG, so we don't exclude it here. bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; } bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; } - bool TraverseCXXTypeidExpr(CXXTypeidExpr *TIE) { -if (TIE->isPotentiallyEvaluated()) - return RecursiveASTVisitor::TraverseCXXTypeidExpr(TIE); -return true; - } + bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; } bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) { return true; } diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index 39e7001393e5e..e743eefa5d458 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -1637,49 +1637,6 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) { }); } -TEST(TransferTest, StructModeledFieldsInTypeid) { - // Test that we model fields mentioned inside a `typeid()` expression only if - // that expression is potentially evaluated -- i.e. if the expression inside - // `typeid()` is a glvalue of polymorphic type (see - // `CXXTypeidExpr::isPotentiallyEvaluated()` and [expr.typeid]p3). - std::string Code = R"( -// Definitions needed for `typeid`. -namespace std { - class type_info {}; - class bad_typeid {}; -} // namespace std - -struct NonPolymorphic {}; - -struct Polymorphic { - virtual ~Polymorphic() = default; -}; - -struct S { - NonPolymorphic *NonPoly; - Polymorphic *Poly; -}; - -void target(S &s) { - typeid(*s.NonPoly); - typeid(*s.Poly); - // [[p]] -} - )"; - runDataflow( - Code, - [](const llvm::StringMap> &Results, - ASTContext &ASTCtx) { -const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); -auto &SLoc = getLocForDecl(ASTCtx, Env, "s"); -std::vector Fields; -for (auto [Field, _] : SLoc.children()) - Fields.push_back(Field); -EXPECT_THAT(Fields, -UnorderedElementsAre(findValueDecl(ASTCtx, "Poly"))); - }); -} - TEST(TransferTest, StructModeledFieldsWithComplicatedInheritance) { std::string Code = R"( struct Base1 { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated." (PR #96766)
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/96766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang][dataflow] Teach `AnalysisASTVisitor` that `typeid()` can be evaluated." (PR #96766)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (martinboehme) Changes Reverts llvm/llvm-project#96731 It causes CI failures. --- Full diff: https://github.com/llvm/llvm-project/pull/96766.diff 2 Files Affected: - (modified) clang/include/clang/Analysis/FlowSensitive/ASTOps.h (+1-5) - (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (-43) ``diff diff --git a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h index f9c923a36ad22..925b99af9141a 100644 --- a/clang/include/clang/Analysis/FlowSensitive/ASTOps.h +++ b/clang/include/clang/Analysis/FlowSensitive/ASTOps.h @@ -113,11 +113,7 @@ class AnalysisASTVisitor : public RecursiveASTVisitor { // nevertheless it appears in the Clang CFG, so we don't exclude it here. bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; } bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; } - bool TraverseCXXTypeidExpr(CXXTypeidExpr *TIE) { -if (TIE->isPotentiallyEvaluated()) - return RecursiveASTVisitor::TraverseCXXTypeidExpr(TIE); -return true; - } + bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; } bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) { return true; } diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp index 39e7001393e5e..e743eefa5d458 100644 --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -1637,49 +1637,6 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) { }); } -TEST(TransferTest, StructModeledFieldsInTypeid) { - // Test that we model fields mentioned inside a `typeid()` expression only if - // that expression is potentially evaluated -- i.e. if the expression inside - // `typeid()` is a glvalue of polymorphic type (see - // `CXXTypeidExpr::isPotentiallyEvaluated()` and [expr.typeid]p3). - std::string Code = R"( -// Definitions needed for `typeid`. -namespace std { - class type_info {}; - class bad_typeid {}; -} // namespace std - -struct NonPolymorphic {}; - -struct Polymorphic { - virtual ~Polymorphic() = default; -}; - -struct S { - NonPolymorphic *NonPoly; - Polymorphic *Poly; -}; - -void target(S &s) { - typeid(*s.NonPoly); - typeid(*s.Poly); - // [[p]] -} - )"; - runDataflow( - Code, - [](const llvm::StringMap> &Results, - ASTContext &ASTCtx) { -const Environment &Env = getEnvironmentAtAnnotation(Results, "p"); -auto &SLoc = getLocForDecl(ASTCtx, Env, "s"); -std::vector Fields; -for (auto [Field, _] : SLoc.children()) - Fields.push_back(Field); -EXPECT_THAT(Fields, -UnorderedElementsAre(findValueDecl(ASTCtx, "Poly"))); - }); -} - TEST(TransferTest, StructModeledFieldsWithComplicatedInheritance) { std::string Code = R"( struct Base1 { `` https://github.com/llvm/llvm-project/pull/96766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e5e0d87 - [clang][Interp] Implement CXXStdInitializerListExprs
Author: Timm Bäder Date: 2024-06-26T15:40:54+02:00 New Revision: e5e0d8739d4a2b70d7ad317863d7b168e4895b18 URL: https://github.com/llvm/llvm-project/commit/e5e0d8739d4a2b70d7ad317863d7b168e4895b18 DIFF: https://github.com/llvm/llvm-project/commit/e5e0d8739d4a2b70d7ad317863d7b168e4895b18.diff LOG: [clang][Interp] Implement CXXStdInitializerListExprs Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Removed: diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 7b5aaa02a22c5..3170b2faeaa0b 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2930,6 +2930,39 @@ bool ByteCodeExprGen::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { return this->delegate(E->getSubExpr()); } +template +bool ByteCodeExprGen::VisitCXXStdInitializerListExpr( +const CXXStdInitializerListExpr *E) { + const Expr *SubExpr = E->getSubExpr(); + const ConstantArrayType *ArrayType = + Ctx.getASTContext().getAsConstantArrayType(SubExpr->getType()); + const Record *R = getRecord(E->getType()); + assert(Initializing); + assert(SubExpr->isGLValue()); + + if (!this->visit(SubExpr)) +return false; + if (!this->emitInitFieldPtr(R->getField(0u)->Offset, E)) +return false; + + PrimType SecondFieldT = classifyPrim(R->getField(1u)->Decl->getType()); + if (isIntegralType(SecondFieldT)) { +if (!this->emitConst(static_cast(ArrayType->getSize()), + SecondFieldT, E)) + return false; +return this->emitInitField(SecondFieldT, R->getField(1u)->Offset, E); + } + assert(SecondFieldT == PT_Ptr); + + if (!this->emitGetFieldPtr(R->getField(0u)->Offset, E)) +return false; + if (!this->emitConst(static_cast(ArrayType->getSize()), PT_Uint64, E)) +return false; + if (!this->emitArrayElemPtrPop(PT_Uint64, E)) +return false; + return this->emitInitFieldPtr(R->getField(1u)->Offset, E); +} + template bool ByteCodeExprGen::discard(const Expr *E) { OptionScope Scope(this, /*NewDiscardResult=*/true, /*NewInitializing=*/false); diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 2921ffe49c45f..88e9eddd55be4 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -177,6 +177,7 @@ class ByteCodeExprGen : public ConstStmtVisitor, bool>, bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E); bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E); bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E); + bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E); protected: bool visitExpr(const Expr *E) override; diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 74aa7cb2abe83..41b4f6dc308d9 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter // RUN: %clang_cc1 -std=c++11 -fsyntax-only -DUNION_TEST -verify %s #ifdef UNION_TEST ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clangd-ubuntu-tsan` running on `clangd-ubuntu-clang` while building `clang,flang,llvm` at step 6 "test-build-clangd-clangd-index-server-clangd-indexer-check-clangd". Full details are available at: https://lab.llvm.org/buildbot/#/builders/134/builds/680 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-clangd-clangd-index-server-clangd-indexer-check-clangd) failure: test (failure) TEST 'Clangd :: execute-command.test' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: clangd -lit-test < /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/execute-command.test | /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck -strict-whitespace /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/execute-command.test + clangd -lit-test + /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck -strict-whitespace /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/execute-command.test WARNING: ThreadSanitizer: unexpected memory mapping 0x79e72000-0x7a30 FATAL: ThreadSanitizer: unexpectedly found incompatible memory layout. FATAL: Please file a bug. FileCheck error: '' is empty. FileCheck command line: /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/build/bin/FileCheck -strict-whitespace /vol/worker/clangd-ubuntu-clang/clangd-ubuntu-tsan/llvm-project/clang-tools-extra/clangd/test/execute-command.test -- ``` https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while building `clang,flang,llvm` at step 6 "Add check check-clang". Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/823 Here is the relevant piece of the build log for the reference: ``` Step 6 (Add check check-clang) failure: test (failure) TEST 'Clang :: Driver/aarch64-v85a.c' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c 2>&1 | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c RUN: at line 2: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -march=armv8.5-a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c 2>&1 | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -march=armv8.5-a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c RUN: at line 3: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -mlittle-endian -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c 2>&1 | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -mlittle-endian -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c RUN: at line 4: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -mlittle-endian -march=armv8.5-a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c 2>&1 | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64 -mlittle-endian -march=armv8.5-a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c RUN: at line 5: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64_be -mlittle-endian -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c 2>&1 | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck -check-prefix=GENERICV85A /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c + /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang --target=aarch64_be -mlittle-endian -march=armv8.5a -### -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Driver/aarch64-v85a.c RUN: at line 6:
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ve-ninja` running on `hpce-ve-main` while building `clang,flang,llvm` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/729 Here is the relevant piece of the build log for the reference: ``` Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure) ... [300/306] Building CXX object tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o [301/306] Building CXX object tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o [302/306] Linking CXX executable tools/clang/unittests/AST/ASTTests [303/306] Linking CXX executable tools/clang/unittests/ASTMatchers/ASTMatchersTests [304/306] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/SourceCodeTest.cpp.o [305/306] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests [305/306] Running the Clang regression tests -- Testing: 20667 tests, 48 workers -- llvm-lit: /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using clang: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang Testing: 0.. 10.. 20.. 30.. 40.. FAIL: Clang :: Driver/aarch64-v82a.c (10125 of 20667) TEST 'Clang :: Driver/aarch64-v82a.c' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -march=armv8.2a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c 2>&1 | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -march=armv8.2a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c RUN: at line 2: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -march=armv8.2-a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c 2>&1 | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -march=armv8.2-a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c RUN: at line 3: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -mlittle-endian -march=armv8.2a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c 2>&1 | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -mlittle-endian -march=armv8.2a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c RUN: at line 4: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -mlittle-endian -march=armv8.2-a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c 2>&1 | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64 -mlittle-endian -march=armv8.2-a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c + /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck -check-prefix=GENERICV82A /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.c RUN: at line 5: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang --target=aarch64_be -mlittle-endian -march=armv8.2a -### -c /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/Driver/aarch64-v82a.
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1059,9 +1059,15 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, if (Guard.isValid()) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. - llvm::Value *GuardVal = Builder.CreateLoad(Guard); - llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, - "guard.uninitialized"); + Address GuardAddr = Guard; ChuanqiXu9 wrote: It looks like the change can be simpler if we don't introduce new the variable `GuardAddr`, is it? https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1070,13 +1076,26 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, // Mark as initialized before initializing anything else. If the // initializers use previously-initialized thread_local vars, that's // probably supposed to be OK, but the standard doesn't say. - Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard); - - // The guard variable can't ever change again. - EmitInvariantStart( - Guard.getPointer(), - CharUnits::fromQuantity( - CGM.getDataLayout().getTypeAllocSize(GuardVal->getType(; + if (auto *GV = dyn_cast(Guard.getPointer())) +// Get the thread-local address via intrinsic. +if (GV->isThreadLocal()) ChuanqiXu9 wrote: ditto https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1059,9 +1059,15 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, if (Guard.isValid()) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. - llvm::Value *GuardVal = Builder.CreateLoad(Guard); - llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, - "guard.uninitialized"); + Address GuardAddr = Guard; + if (auto *GV = dyn_cast(Guard.getPointer())) +// Get the thread-local address via intrinsic. +if (GV->isThreadLocal()) + GuardAddr = GuardAddr.withPointer( + Builder.CreateThreadLocalAddress(GV), NotKnownNonNull); + llvm::Value *GuardVal = Builder.CreateLoad(GuardAddr); ChuanqiXu9 wrote: These lines are not changed. So we'd better to not touch them. https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1070,13 +1076,26 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, // Mark as initialized before initializing anything else. If the // initializers use previously-initialized thread_local vars, that's // probably supposed to be OK, but the standard doesn't say. - Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard); - - // The guard variable can't ever change again. - EmitInvariantStart( - Guard.getPointer(), - CharUnits::fromQuantity( - CGM.getDataLayout().getTypeAllocSize(GuardVal->getType(; + if (auto *GV = dyn_cast(Guard.getPointer())) +// Get the thread-local address via intrinsic. +if (GV->isThreadLocal()) + GuardAddr = GuardAddr.withPointer( + Builder.CreateThreadLocalAddress(GV), NotKnownNonNull); + Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(), 1), + GuardAddr); + + // Emit invariant start for TLS guard address. + if (CGM.getCodeGenOpts().OptimizationLevel > 0) { +uint64_t Width = +CGM.getDataLayout().getTypeAllocSize(GuardVal->getType()); +llvm::Value *TLSAddr = Guard.getPointer(); +if (auto *GV = dyn_cast(Guard.getPointer())) + // Get the thread-local address via intrinsic. + if (GV->isThreadLocal()) +TLSAddr = Builder.CreateThreadLocalAddress(GV); +Builder.CreateInvariantStart( ChuanqiXu9 wrote: Why do the ABI used change? And is it necessary? If not, can we remove it? https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Access tls_guard via llvm.threadlocal.address (PR #96633)
@@ -1059,9 +1059,15 @@ CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn, if (Guard.isValid()) { // If we have a guard variable, check whether we've already performed // these initializations. This happens for TLS initialization functions. - llvm::Value *GuardVal = Builder.CreateLoad(Guard); - llvm::Value *Uninit = Builder.CreateIsNull(GuardVal, - "guard.uninitialized"); + Address GuardAddr = Guard; + if (auto *GV = dyn_cast(Guard.getPointer())) +// Get the thread-local address via intrinsic. +if (GV->isThreadLocal()) ChuanqiXu9 wrote: ```suggestion // Get the thread-local address via intrinsic. if (auto *GV = dyn_cast(Guard.getPointer()); GV && GV->isThreadLocal()) ``` https://github.com/llvm/llvm-project/pull/96633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `arc-builder` running on `arc-worker` while building `clang,flang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/630 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'Clang :: Driver/aarch64-v81a.c' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 2: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 3: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -mbig-endian -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -mbig-endian -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 4: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -mbig-endian -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -mbig-endian -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 5: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -mbig-endian -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -mbig-endian -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 6: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -mbig-endian -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A-BE /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64_be -mbig-endian -march=armv8.1-a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c RUN: at line 9: /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -march=armv8.1a -### -c /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck -check-prefix=GENERICV81A /buildbot/worker/arc-folder/llvm-project/clang/test/Driver/aarch64-v81a.c + /buildbot/worker/arc-folder/build/bin/clang --target=aarch64 -m
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-cmake-x86_64-avx512-linux` running on `avx512-intel64` while building `clang,flang,llvm` at step 7 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/621 Here is the relevant piece of the build log for the reference: ``` Step 7 (ninja check 1) failure: stage 1 checked (failure) TEST 'Clang :: Driver/aarch64-v81a.c' FAILED Exit Code: 2 Command Output (stderr): -- RUN: at line 1: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64_be -march=armv8.1a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c 2>&1 | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64_be -march=armv8.1a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c RUN: at line 2: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64_be -march=armv8.1-a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c 2>&1 | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64_be -march=armv8.1-a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c RUN: at line 3: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64 -mbig-endian -march=armv8.1a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c 2>&1 | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64 -mbig-endian -march=armv8.1a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c RUN: at line 4: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64 -mbig-endian -march=armv8.1-a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c 2>&1 | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64 -mbig-endian -march=armv8.1-a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c RUN: at line 5: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang --target=aarch64_be -mbig-endian -march=armv8.1a -### -c /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c 2>&1 | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/Driver/aarch64-v81a.c + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck -check-prefix=GENERICV81A-BE /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/