[clang-tools-extra] 599adf3 - [include-cleaner] Dont apply name-match for non-owning headers (#82625)
Author: kadir çetinkaya Date: 2024-04-11T15:33:35+02:00 New Revision: 599adf30afe5802fab80419ec5bb896036a1c8fb URL: https://github.com/llvm/llvm-project/commit/599adf30afe5802fab80419ec5bb896036a1c8fb DIFF: https://github.com/llvm/llvm-project/commit/599adf30afe5802fab80419ec5bb896036a1c8fb.diff LOG: [include-cleaner] Dont apply name-match for non-owning headers (#82625) Added: Modified: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp Removed: diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp index fd2de6a17ad4a5..7b28d1c252d715 100644 --- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp +++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp @@ -275,6 +275,12 @@ llvm::SmallVector headersForSymbol(const Symbol &S, // are already ranked in the stdlib mapping. if (H.kind() == Header::Standard) continue; +// Don't apply name match hints to exporting headers. As they usually have +// names similar to the original header, e.g. foo_wrapper/foo.h vs +// foo/foo.h, but shouldn't be preferred (unless marked as the public +// interface). +if ((H.Hint & Hints::OriginHeader) == Hints::None) + continue; if (nameMatch(SymbolName, H)) H.Hint |= Hints::PreferredHeader; } diff --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp index 5a2a41b2d99bdd..07302142a13e36 100644 --- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp @@ -628,5 +628,24 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) { tooling::stdlib::Header::named(""))); } +TEST_F(HeadersForSymbolTest, ExporterNoNameMatch) { + Inputs.Code = R"cpp( +#include "exporter/foo.h" +#include "foo_public.h" + )cpp"; + Inputs.ExtraArgs.emplace_back("-I."); + // Deliberately named as foo_public to make sure it doesn't get name-match + // boost and also gets lexicographically bigger order than "exporter/foo.h". + Inputs.ExtraFiles["foo_public.h"] = guard(R"cpp( +struct foo {}; + )cpp"); + Inputs.ExtraFiles["exporter/foo.h"] = guard(R"cpp( +#include "foo_public.h" // IWYU pragma: export + )cpp"); + buildAST(); + EXPECT_THAT(headersForFoo(), ElementsAre(physicalHeader("foo_public.h"), + physicalHeader("exporter/foo.h"))); +} + } // namespace } // namespace clang::include_cleaner ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][AMDGPU] Add rocm-path flag (PR #88190)
@@ -345,7 +345,13 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, // Check ROCm path if specified const ToolChain &TC = getToolChain(); - TC.getDeviceLibs(Args); + std::string HIPVersion; + llvm::raw_string_ostream HIPInfo(HIPVersion); + TC.printVerboseInfo(HIPInfo); + llvm::StringRef HIPInfoStrRef(HIPInfo.str()); + if (!HIPInfoStrRef.contains("Found HIP installation") && DominikAdamski wrote: Clang reports an error if `--rocm-path` points to an invalid directory. I need to do a similar check for Flang. The ROCm toolchain checks rocm-path within function `RocmInstallationDetector::checkCommonBitcodeLibs`. This function is called inside `ROCMToolChain::addClangTargetOptions` or `ROCMToolChain::getCommonDeviceLibNames`. `ROCMToolChain::getCommonDeviceLibNames` is called by `AMDGPUOpenMPToolChain::getDeviceLibs`. I decided not to call `ROCMToolChain::addClangTargetOptions` because Flang does not support all Clang options. That's why I initially decided to call `AMDGPUOpenMPToolChain::getDeviceLibs` to check the ROCm path. The second (current) approach is a workaround to emit an error if rocm-path is specified incorrectly. https://github.com/llvm/llvm-project/pull/88190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)
@@ -674,3 +674,27 @@ let TargetGuard = "sme2" in { def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>; } + + +// SME2p1 - FMOPA, FMOPS (non-widening) +let TargetGuard = "sme,b16b16" in { momchil-velikov wrote: Done. The Clang instrinsics use the same target features as the underlying assembly instructions. If the features on the assembly instruction are not entirely correct we should fix it, but in a separate patch. https://github.com/llvm/llvm-project/pull/88105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)
@@ -815,8 +815,8 @@ defm FMLS_VG4_M4Z2Z_H : sme2_dot_mla_add_sub_array_vg4_multi<"fmls", 0b0100011, defm FCVT_2ZZ_H : sme2p1_fp_cvt_vector_vg2_single<"fcvt", 0b0>; defm FCVTL_2ZZ_H : sme2p1_fp_cvt_vector_vg2_single<"fcvtl", 0b1>; -defm FMOPA_MPPZZ_H : sme2p1_fmop_tile_fp16<"fmopa", 0b0, 0b0, 0b11, ZPR16>; -defm FMOPS_MPPZZ_H : sme2p1_fmop_tile_fp16<"fmops", 0b0, 0b1, 0b11, ZPR16>; +defm FMOPA_MPPZZ_H : sme2p1_fmop_tile_fp16<"fmopa", 0b0, 0b0, 0b11, nxv8f16, int_aarch64_sme_mopa_nonwide>; momchil-velikov wrote: Discussed offline. https://github.com/llvm/llvm-project/pull/88105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)
@@ -674,3 +674,27 @@ let TargetGuard = "sme2" in { def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>; } + + +// SME2p1 - FMOPA, FMOPS (non-widening) +let TargetGuard = "sme,b16b16" in { + def SVMOPA_BF16_NW : SInst<"svmopa_za16[_bf16]", "viPPdd", "b", + MergeOp1, "aarch64_sme_mopa_nonwide", + [IsStreaming, IsInOutZA], + [ImmCheck<0, ImmCheck0_1>]>; + def SVMOPS_BF16_NW : SInst<"svmops_za16[_bf16]", "viPPdd", "b", + MergeOp1, "aarch64_sme_mops_nonwide", + [IsStreaming, IsInOutZA], + [ImmCheck<0, ImmCheck0_1>]>; +} + +let TargetGuard = "sme2,sme-f16f16" in { + def SVMOPA_F16_NW : SInst<"svmopa_za16[_f16]", "viPPdd", "h", +MergeOp1, "aarch64_sme_mopa_nonwide", momchil-velikov wrote: In fact we can reuse the existing `aarch64_sme_mopa` which is used for other non-widening operations and since they are polymorphic and non-widening the instantiation type is enough to disambiguate the operation. https://github.com/llvm/llvm-project/pull/88105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)
@@ -674,3 +674,27 @@ let TargetGuard = "sme2" in { def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>; } + + +// SME2p1 - FMOPA, FMOPS (non-widening) +let TargetGuard = "sme,b16b16" in { + def SVMOPA_BF16_NW : SInst<"svmopa_za16[_bf16]", "viPPdd", "b", + MergeOp1, "aarch64_sme_mopa_nonwide", momchil-velikov wrote: Done https://github.com/llvm/llvm-project/pull/88105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)
@@ -7735,7 +7735,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, } if (CXXMethodDecl *Method = dyn_cast_or_null(FDecl)) -if (Method->isImplicitObjectMemberFunction()) +if (!isa(CurContext) && erichkeane wrote: I don't really understand the change, can you better explain why this is the solution here? https://github.com/llvm/llvm-project/pull/85198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS (PR #88105)
https://github.com/momchil-velikov updated https://github.com/llvm/llvm-project/pull/88105 >From 2b0befb9078f8c9116ad52be937c8722045708ef Mon Sep 17 00:00:00 2001 From: Momchil Velikov Date: Tue, 9 Apr 2024 10:52:41 +0100 Subject: [PATCH] [AArch64] Add intrinsics for non-widening FMOPA/FMOPS According to the specification in https://github.com/ARM-software/acle/pull/309 this adds the intrinsics void svmopa_za16[_f16]_m(uint64_t tile, svbool_t pn, svbool_t pm, svfloat16_t zn, svfloat16_t zm) __arm_streaming __arm_inout("za"); void svmops_za16[_f16]_m(uint64_t tile, svbool_t pn, svbool_t pm, svfloat16_t zn, svfloat16_t zm) __arm_streaming __arm_inout("za"); as well as the corresponding `bf16` variants. --- clang/include/clang/Basic/arm_sme.td | 24 + .../acle_sme2_mopa_nonwide.c | 97 +++ .../acle_sme2_mopa_nonwide.c | 34 +++ llvm/include/llvm/IR/IntrinsicsAArch64.td | 5 +- .../lib/Target/AArch64/AArch64SMEInstrInfo.td | 10 +- llvm/lib/Target/AArch64/SMEInstrFormats.td| 16 ++- .../CodeGen/AArch64/sme2-intrinsics-mopa.ll | 42 7 files changed, 220 insertions(+), 8 deletions(-) create mode 100644 clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c create mode 100644 clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-mopa.ll diff --git a/clang/include/clang/Basic/arm_sme.td b/clang/include/clang/Basic/arm_sme.td index 1ac6d5170ea283..a18a5094a15ed3 100644 --- a/clang/include/clang/Basic/arm_sme.td +++ b/clang/include/clang/Basic/arm_sme.td @@ -674,3 +674,27 @@ let TargetGuard = "sme2" in { def SVLUTI2_LANE_ZT_X2 : Inst<"svluti2_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti2_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_7>]>; def SVLUTI4_LANE_ZT_X2 : Inst<"svluti4_lane_zt_{d}_x2", "2.di[i", "cUcsUsiUibhf", MergeNone, "aarch64_sme_luti4_lane_zt_x2", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>; } + + +// SME2p1 - FMOPA, FMOPS (non-widening) +let TargetGuard = "sme2,b16b16" in { + def SVMOPA_BF16_NW : SInst<"svmopa_za16[_bf16]_m", "viPPdd", "b", + MergeNone, "aarch64_sme_mopa", + [IsStreaming, IsInOutZA], + [ImmCheck<0, ImmCheck0_1>]>; + def SVMOPS_BF16_NW : SInst<"svmops_za16[_bf16]_m", "viPPdd", "b", + MergeNone, "aarch64_sme_mops", + [IsStreaming, IsInOutZA], + [ImmCheck<0, ImmCheck0_1>]>; +} + +let TargetGuard = "sme2p1,sme-f16f16" in { + def SVMOPA_F16_NW : SInst<"svmopa_za16[_f16]_m", "viPPdd", "h", +MergeNone, "aarch64_sme_mopa", +[IsStreaming, IsInOutZA], +[ImmCheck<0, ImmCheck0_1>]>; + def SVMOPS_F16_NW : SInst<"svmops_za16[_f16]_m", "viPPdd", "h", +MergeNone, "aarch64_sme_mops", +[IsStreaming, IsInOutZA], +[ImmCheck<0, ImmCheck0_1>]>; +} diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c new file mode 100644 index 00..40fcad6a576483 --- /dev/null +++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mopa_nonwide.c @@ -0,0 +1,97 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +b16b16 -target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK +// RUN: %clang_cc1-x c++ -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +b16b16 -target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK-CXX +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS-fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +b16b16 -target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feature +b16b16 -target-feature +sme-f16f16 -S -O2 -Werror -emit-llvm -o - %s | FileCheck %s -check-prefixes=CHECK-CXX + +// RUN: %clang_cc1 -DSME_OVERLOADED_FORMS -x c++ -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -target-feat
[clang] 6fd2fdc - [VectorCombine] foldShuffleOfCastops - extend shuffle(bitcast(x),bitcast(y)) -> bitcast(shuffle(x,y)) support
Author: Simon Pilgrim Date: 2024-04-11T14:02:56+01:00 New Revision: 6fd2fdccf2f28fc155f614eec41f785492aad618 URL: https://github.com/llvm/llvm-project/commit/6fd2fdccf2f28fc155f614eec41f785492aad618 DIFF: https://github.com/llvm/llvm-project/commit/6fd2fdccf2f28fc155f614eec41f785492aad618.diff LOG: [VectorCombine] foldShuffleOfCastops - extend shuffle(bitcast(x),bitcast(y)) -> bitcast(shuffle(x,y)) support Handle shuffle mask scaling handling for cases where the bitcast src/dst element counts are different Added: Modified: clang/test/CodeGen/X86/avx-shuffle-builtins.c llvm/lib/Transforms/Vectorize/VectorCombine.cpp llvm/test/Transforms/PhaseOrdering/X86/pr67803.ll llvm/test/Transforms/VectorCombine/X86/shuffle-of-casts.ll llvm/test/Transforms/VectorCombine/X86/shuffle.ll Removed: diff --git a/clang/test/CodeGen/X86/avx-shuffle-builtins.c b/clang/test/CodeGen/X86/avx-shuffle-builtins.c index 49a56e73230d7d..d184d28f3e07aa 100644 --- a/clang/test/CodeGen/X86/avx-shuffle-builtins.c +++ b/clang/test/CodeGen/X86/avx-shuffle-builtins.c @@ -61,8 +61,7 @@ __m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) { __m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) { // CHECK-LABEL: test_mm256_permute2f128_si256 - // X64: shufflevector{{.*}} - // X86: shufflevector{{.*}} + // CHECK: shufflevector{{.*}} return _mm256_permute2f128_si256(a, b, 0x20); } diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp index b74fdf27d213a1..658e8e74fe5b80 100644 --- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -1448,9 +1448,9 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) { /// into "castop (shuffle)". bool VectorCombine::foldShuffleOfCastops(Instruction &I) { Value *V0, *V1; - ArrayRef Mask; + ArrayRef OldMask; if (!match(&I, m_Shuffle(m_OneUse(m_Value(V0)), m_OneUse(m_Value(V1)), - m_Mask(Mask + m_Mask(OldMask return false; auto *C0 = dyn_cast(V0); @@ -1473,12 +1473,32 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) { auto *ShuffleDstTy = dyn_cast(I.getType()); auto *CastDstTy = dyn_cast(C0->getDestTy()); auto *CastSrcTy = dyn_cast(C0->getSrcTy()); - if (!ShuffleDstTy || !CastDstTy || !CastSrcTy || - CastDstTy->getElementCount() != CastSrcTy->getElementCount()) + if (!ShuffleDstTy || !CastDstTy || !CastSrcTy) return false; + unsigned NumSrcElts = CastSrcTy->getNumElements(); + unsigned NumDstElts = CastDstTy->getNumElements(); + assert((NumDstElts == NumSrcElts || Opcode == Instruction::BitCast) && + "Only bitcasts expected to alter src/dst element counts"); + + SmallVector NewMask; + if (NumSrcElts >= NumDstElts) { +// The bitcast is from wide to narrow/equal elements. The shuffle mask can +// always be expanded to the equivalent form choosing narrower elements. +assert(NumSrcElts % NumDstElts == 0 && "Unexpected shuffle mask"); +unsigned ScaleFactor = NumSrcElts / NumDstElts; +narrowShuffleMaskElts(ScaleFactor, OldMask, NewMask); + } else { +// The bitcast is from narrow elements to wide elements. The shuffle mask +// must choose consecutive elements to allow casting first. +assert(NumDstElts % NumSrcElts == 0 && "Unexpected shuffle mask"); +unsigned ScaleFactor = NumDstElts / NumSrcElts; +if (!widenShuffleMaskElts(ScaleFactor, OldMask, NewMask)) + return false; + } + auto *NewShuffleDstTy = - FixedVectorType::get(CastSrcTy->getScalarType(), Mask.size()); + FixedVectorType::get(CastSrcTy->getScalarType(), NewMask.size()); // Try to replace a castop with a shuffle if the shuffle is not costly. TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput; @@ -1489,11 +1509,11 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) { TTI.getCastInstrCost(C1->getOpcode(), CastDstTy, CastSrcTy, TTI::CastContextHint::None, CostKind); OldCost += - TTI.getShuffleCost(TargetTransformInfo::SK_PermuteTwoSrc, CastDstTy, Mask, - CostKind, 0, nullptr, std::nullopt, &I); + TTI.getShuffleCost(TargetTransformInfo::SK_PermuteTwoSrc, CastDstTy, + OldMask, CostKind, 0, nullptr, std::nullopt, &I); InstructionCost NewCost = TTI.getShuffleCost( - TargetTransformInfo::SK_PermuteTwoSrc, CastSrcTy, Mask, CostKind); + TargetTransformInfo::SK_PermuteTwoSrc, CastSrcTy, NewMask, CostKind); NewCost += TTI.getCastInstrCost(Opcode, ShuffleDstTy, NewShuffleDstTy, TTI::CastContextHint::None, CostKind); @@ -1503,8 +1523,8 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) { if (NewCost > OldCost) return false; - Value *Shuf
[clang] [flang] [Flang][AMDGPU] Add rocm-path flag (PR #88190)
@@ -345,7 +345,13 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, // Check ROCm path if specified const ToolChain &TC = getToolChain(); - TC.getDeviceLibs(Args); + std::string HIPVersion; + llvm::raw_string_ostream HIPInfo(HIPVersion); + TC.printVerboseInfo(HIPInfo); + llvm::StringRef HIPInfoStrRef(HIPInfo.str()); + if (!HIPInfoStrRef.contains("Found HIP installation") && jhuber6 wrote: What's the utility of this bit? Don't we already do this checking inside of the ROCm toolchain? Does Flang not use that? https://github.com/llvm/llvm-project/pull/88190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Claim conformance for _Complex support (PR #88161)
@@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -verify -std=c99 %s + +/* WG14 N620, N638, N657, N694, N809: Yes* + * Complex and imaginary support in + * + * NB: Clang supports _Complex but not _Imaginary. In C99, _Complex support is + * required outside of freestanding, but _Imaginary support is fully optional. + * In C11, both are made fully optional. We claim full conformance because we + * are actually conforming, but this gets an asterisk because it's also only + * partially implemented in a way and users should know about that. + * + * Because the functionality is so intertwined between the various papers, + * we're testing all of the functionality in one file. + */ + +// Demonstrate that we support spelling complex floating-point objects. +float _Complex f1; +_Complex float f2; + +double _Complex d1; +_Complex double d2; + +long double _Complex ld1; +_Complex long double ld2; + +// Show that we don't support spelling imaginary types. +float _Imaginary fi1; // expected-error {{imaginary types are not supported}} +_Imaginary float fi2; // expected-error {{imaginary types are not supported}} + +double _Imaginary di1; // expected-error {{imaginary types are not supported}} +_Imaginary double di2; // expected-error {{imaginary types are not supported}} + +long double _Imaginary ldi1; // expected-error {{imaginary types are not supported}} +_Imaginary long double ldi2; // expected-error {{imaginary types are not supported}} + +// Each complex type has the same representation and alignment as an array +// containing two elements of the corresponding real type. +_Static_assert(sizeof(float _Complex) == sizeof(struct { float mem[2]; }), ""); +_Static_assert(_Alignof(float _Complex) == _Alignof(struct { float mem[2]; }), ""); AaronBallman wrote: I added a comment to clarify that. https://github.com/llvm/llvm-project/pull/88161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Claim conformance for _Complex support (PR #88161)
@@ -373,6 +355,10 @@ C99 implementation status Yes +(2): Clang supports _Complex type specifiers but +does not support _Imaginary type specifiers. Support for +_Imaginary is optional in C99 which is why Clang is fully conforming. AaronBallman wrote: Done https://github.com/llvm/llvm-project/pull/88161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 402f15e - [clang][dataflow] Remove deprecated alias `ControlFlowContext`. (#88358)
Author: martinboehme Date: 2024-04-11T14:38:18+02:00 New Revision: 402f15ea92061d94412807887c8115374974967e URL: https://github.com/llvm/llvm-project/commit/402f15ea92061d94412807887c8115374974967e DIFF: https://github.com/llvm/llvm-project/commit/402f15ea92061d94412807887c8115374974967e.diff LOG: [clang][dataflow] Remove deprecated alias `ControlFlowContext`. (#88358) Added: Modified: clang/docs/tools/clang-formatted-files.txt Removed: clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h diff --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt index 8fd4fed25a32a1..3089438c23d94e 100644 --- a/clang/docs/tools/clang-formatted-files.txt +++ b/clang/docs/tools/clang-formatted-files.txt @@ -123,7 +123,6 @@ clang/include/clang/Analysis/Analyses/CalledOnceCheck.h clang/include/clang/Analysis/Analyses/CFGReachabilityAnalysis.h clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h -clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h diff --git a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h deleted file mode 100644 index 3972962d0b2daa..00 --- a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h +++ /dev/null @@ -1,27 +0,0 @@ -//===-- ControlFlowContext.h *- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// -// -// This file defines a deprecated alias for AdornedCFG. -// -//===--===// - -#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CONTROLFLOWCONTEXT_H -#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CONTROLFLOWCONTEXT_H - -#include "clang/Analysis/FlowSensitive/AdornedCFG.h" - -namespace clang { -namespace dataflow { - -// This is a deprecated alias. Use `AdornedCFG` instead. -using ControlFlowContext = AdornedCFG; - -} // namespace dataflow -} // namespace clang - -#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CONTROLFLOWCONTEXT_H ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][dataflow] Remove deprecated alias `ControlFlowContext`. (PR #88358)
https://github.com/martinboehme closed https://github.com/llvm/llvm-project/pull/88358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
https://github.com/jhuber6 approved this pull request. https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Claim conformance for _Complex support (PR #88161)
@@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -verify -std=c99 %s + +/* WG14 N620, N638, N657, N694, N809: Yes* + * Complex and imaginary support in + * + * NB: Clang supports _Complex but not _Imaginary. In C99, _Complex support is + * required outside of freestanding, but _Imaginary support is fully optional. + * In C11, both are made fully optional. We claim full conformance because we + * are actually conforming, but this gets an asterisk because it's also only + * partially implemented in a way and users should know about that. + * + * Because the functionality is so intertwined between the various papers, + * we're testing all of the functionality in one file. + */ + +// Demonstrate that we support spelling complex floating-point objects. +float _Complex f1; +_Complex float f2; + +double _Complex d1; +_Complex double d2; + +long double _Complex ld1; +_Complex long double ld2; + +// Show that we don't support spelling imaginary types. +float _Imaginary fi1; // expected-error {{imaginary types are not supported}} +_Imaginary float fi2; // expected-error {{imaginary types are not supported}} + +double _Imaginary di1; // expected-error {{imaginary types are not supported}} +_Imaginary double di2; // expected-error {{imaginary types are not supported}} + +long double _Imaginary ldi1; // expected-error {{imaginary types are not supported}} +_Imaginary long double ldi2; // expected-error {{imaginary types are not supported}} + +// Each complex type has the same representation and alignment as an array +// containing two elements of the corresponding real type. +_Static_assert(sizeof(float _Complex) == sizeof(struct { float mem[2]; }), ""); +_Static_assert(_Alignof(float _Complex) == _Alignof(struct { float mem[2]; }), ""); + +_Static_assert(sizeof(double _Complex) == sizeof(struct { double mem[2]; }), ""); +_Static_assert(_Alignof(double _Complex) == _Alignof(struct { double mem[2]; }), ""); + +_Static_assert(sizeof(long double _Complex) == sizeof(struct { long double mem[2]; }), ""); +_Static_assert(_Alignof(long double _Complex) == _Alignof(struct { long double mem[2]; }), ""); + +// The first element corresponds to the real part and the second element +// corresponds to the imaginary part. +_Static_assert(__real((float _Complex){ 1.0f, 2.0f }) == 1.0f, ""); +_Static_assert(__imag((float _Complex){ 1.0f, 2.0f }) == 2.0f, ""); AaronBallman wrote: The other alternative would be to use a builtin function, I can go either way. Maybe I should use one of each to show they're equivalent? https://github.com/llvm/llvm-project/pull/88161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C99] Claim conformance for _Complex support (PR #88161)
@@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -verify -std=c99 %s + +/* WG14 N620, N638, N657, N694, N809: Yes* + * Complex and imaginary support in + * + * NB: Clang supports _Complex but not _Imaginary. In C99, _Complex support is + * required outside of freestanding, but _Imaginary support is fully optional. + * In C11, both are made fully optional. We claim full conformance because we + * are actually conforming, but this gets an asterisk because it's also only + * partially implemented in a way and users should know about that. + * + * Because the functionality is so intertwined between the various papers, + * we're testing all of the functionality in one file. + */ + +// Demonstrate that we support spelling complex floating-point objects. +float _Complex f1; +_Complex float f2; + +double _Complex d1; +_Complex double d2; + +long double _Complex ld1; +_Complex long double ld2; + +// Show that we don't support spelling imaginary types. +float _Imaginary fi1; // expected-error {{imaginary types are not supported}} +_Imaginary float fi2; // expected-error {{imaginary types are not supported}} + +double _Imaginary di1; // expected-error {{imaginary types are not supported}} +_Imaginary double di2; // expected-error {{imaginary types are not supported}} + +long double _Imaginary ldi1; // expected-error {{imaginary types are not supported}} +_Imaginary long double ldi2; // expected-error {{imaginary types are not supported}} + +// Each complex type has the same representation and alignment as an array +// containing two elements of the corresponding real type. +_Static_assert(sizeof(float _Complex) == sizeof(struct { float mem[2]; }), ""); +_Static_assert(_Alignof(float _Complex) == _Alignof(struct { float mem[2]; }), ""); AaronBallman wrote: I think this is a property we want to guarantee, so it seems reasonable-ish to test it here as part of our conformance testing. https://github.com/llvm/llvm-project/pull/88161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Simplify RenamerClangTidyCheck API (PR #88268)
revane wrote: I don't have write access. Would someone please land the PR for me? https://github.com/llvm/llvm-project/pull/88268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
asb wrote: > It passed public review[1] and merged into riscv-isa-manual[2], so I think > it's time to mark it as 1.0 and moving forward :) > > [1] > https://groups.google.com/a/groups.riscv.org/g/isa-dev/c/KetVUCQkfK4/m/Y3Dbd2pvAAAJ?utm_medium=email&utm_source=footer > [2] > [riscv/riscv-isa-manual@cdb2585](https://github.com/riscv/riscv-isa-manual/commit/cdb25859bcce5a6edbdc34914c1f86f079b3fddd) That's probably true - though historically I've been using https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions to determine if a spec is ratified or not, now moved to https://wiki.riscv.org/display/HOME/Ratified+Extensions seemingly. B doesn't seem to be listed yet. @jjscheel - is it just not added to the wiki page yet, or is it technically not yet ratified? (I know it's really a trivial "extension" so might be a special case) https://github.com/llvm/llvm-project/pull/76893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/76893 >From 169ef33f585b964d9af7a7628919271245f318fc Mon Sep 17 00:00:00 2001 From: wangpc Date: Thu, 4 Jan 2024 13:05:53 +0800 Subject: [PATCH 1/3] [RISCV] Add B extension It seems that we have `B` extension again: https://github.com/riscv/riscv-b According to the spec, `B` extension represents the collection of the `Zba`, `Zbb`, `Zbs` extensions. --- clang/test/Driver/riscv-arch.c | 5 - clang/test/Preprocessor/riscv-target-features.c | 12 llvm/docs/RISCVUsage.rst| 1 + llvm/lib/Support/RISCVISAInfo.cpp | 3 +++ llvm/lib/Target/RISCV/RISCVFeatures.td | 8 llvm/test/CodeGen/RISCV/attributes.ll | 4 llvm/unittests/Support/RISCVISAInfoTest.cpp | 6 ++ 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c index 8399b4e97f86d5..8e48ed9160992d 100644 --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -231,11 +231,6 @@ // RV32-STD: error: invalid arch name 'rv32imqc', // RV32-STD: unsupported standard user-level extension 'q' -// RUN: not %clang --target=riscv32-unknown-elf -march=rv32ib -### %s \ -// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-B %s -// RV32-B: error: invalid arch name 'rv32ib', -// RV32-B: unsupported standard user-level extension 'b' - // RUN: not %clang --target=riscv32-unknown-elf -march=rv32xabc -### %s \ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s // RV32X: error: invalid arch name 'rv32xabc', diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index ec7764bb538189..dfdef72cb1e755 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -7,6 +7,7 @@ // CHECK-NOT: __riscv_64e {{.*$}} // CHECK-NOT: __riscv_a {{.*$}} // CHECK-NOT: __riscv_atomic +// CHECK-NOT: __riscv_b {{.*$}} // CHECK-NOT: __riscv_c {{.*$}} // CHECK-NOT: __riscv_compressed {{.*$}} // CHECK-NOT: __riscv_d {{.*$}} @@ -191,6 +192,17 @@ // CHECK-A-EXT: __riscv_a 2001000{{$}} // CHECK-A-EXT: __riscv_atomic 1 +// RUN: %clang --target=riscv32-unknown-linux-gnu \ +// RUN: -march=rv32ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// RUN: %clang --target=riscv64-unknown-linux-gnu \ +// RUN: -march=rv64ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// CHECK-B-EXT: __riscv_b 100{{$}} +// CHECK-B-EXT: __riscv_zba 100{{$}} +// CHECK-B-EXT: __riscv_zbb 100{{$}} +// CHECK-B-EXT: __riscv_zbs 100{{$}} + // RUN: %clang --target=riscv32-unknown-linux-gnu \ // RUN: -march=rv32ic -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index 6f5eba263def43..232604788f9972 100644 --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -85,6 +85,7 @@ on support follow. Extension Status = ``A`` Supported + ``B`` Supported ``C`` Supported ``D`` Supported ``F`` Supported diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp index 7a19d24d1ff483..99962501153b0e 100644 --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -52,6 +52,7 @@ static const char *RISCVGImplications[] = { // NOTE: This table should be sorted alphabetically by extension name. static const RISCVSupportedExtension SupportedExtensions[] = { {"a", {2, 1}}, +{"b", {1, 0}}, {"c", {2, 0}}, {"d", {2, 2}}, {"e", {2, 0}}, @@ -1106,6 +1107,7 @@ Error RISCVISAInfo::checkDependency() { return Error::success(); } +static const char *ImpliedExtsB[] = {"zba", "zbb", "zbs"}; static const char *ImpliedExtsD[] = {"f"}; static const char *ImpliedExtsF[] = {"zicsr"}; static const char *ImpliedExtsV[] = {"zvl128b", "zve64d"}; @@ -1181,6 +1183,7 @@ struct ImpliedExtsEntry { // Note: The table needs to be sorted by name. static constexpr ImpliedExtsEntry ImpliedExts[] = { +{{"b"}, {ImpliedExtsB}}, {{"d"}, {ImpliedExtsD}}, {{"f"}, {ImpliedExtsF}}, {{"v"}, {ImpliedExtsV}}, diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 794455aa730400..33541be37537df 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -430,6 +430,14 @@ def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">, // Bitmanip Extensions for Cryptography Extensions +def FeatureStdExtB +: SubtargetFeature<"b", "HasStdExtB", "true", + "'B' (the collection of the Zba, Zbb, Zbs e
[clang-tools-extra] [include-cleaner] Dont apply name-match for non-owning headers (PR #82625)
https://github.com/kadircet updated https://github.com/llvm/llvm-project/pull/82625 From d5e35aac5bc4103b668766aa10d42bc4dc2c9087 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Thu, 22 Feb 2024 15:46:20 +0100 Subject: [PATCH] [include-cleaner] Dont apply name-match for non-owning headers --- .../include-cleaner/lib/FindHeaders.cpp | 6 ++ .../unittests/FindHeadersTest.cpp | 19 +++ 2 files changed, 25 insertions(+) diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp index fd2de6a17ad4a5..7b28d1c252d715 100644 --- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp +++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp @@ -275,6 +275,12 @@ llvm::SmallVector headersForSymbol(const Symbol &S, // are already ranked in the stdlib mapping. if (H.kind() == Header::Standard) continue; +// Don't apply name match hints to exporting headers. As they usually have +// names similar to the original header, e.g. foo_wrapper/foo.h vs +// foo/foo.h, but shouldn't be preferred (unless marked as the public +// interface). +if ((H.Hint & Hints::OriginHeader) == Hints::None) + continue; if (nameMatch(SymbolName, H)) H.Hint |= Hints::PreferredHeader; } diff --git a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp index 5a2a41b2d99bdd..07302142a13e36 100644 --- a/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp @@ -628,5 +628,24 @@ TEST_F(HeadersForSymbolTest, StandardHeaders) { tooling::stdlib::Header::named(""))); } +TEST_F(HeadersForSymbolTest, ExporterNoNameMatch) { + Inputs.Code = R"cpp( +#include "exporter/foo.h" +#include "foo_public.h" + )cpp"; + Inputs.ExtraArgs.emplace_back("-I."); + // Deliberately named as foo_public to make sure it doesn't get name-match + // boost and also gets lexicographically bigger order than "exporter/foo.h". + Inputs.ExtraFiles["foo_public.h"] = guard(R"cpp( +struct foo {}; + )cpp"); + Inputs.ExtraFiles["exporter/foo.h"] = guard(R"cpp( +#include "foo_public.h" // IWYU pragma: export + )cpp"); + buildAST(); + EXPECT_THAT(headersForFoo(), ElementsAre(physicalHeader("foo_public.h"), + physicalHeader("exporter/foo.h"))); +} + } // namespace } // namespace clang::include_cleaner ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Use TargetOpts from preamble when building ASTs (PR #88381)
llvmbot wrote: @llvm/pr-subscribers-clangd Author: kadir çetinkaya (kadircet) Changes Building ASTs with compile flags that are incompatible to the ones used for the Preamble are not really supported by clang and can trigger crashes. In an ideal world, we should be re-using not only TargetOpts, but the full ParseInputs from the Preamble to prevent such failures. Unfortunately current contracts of ThreadSafeFS makes this a non-safe change for certain implementations. As there are no guarantees that the same ThreadSafeFS is going to be valid in the Context::current() we're building the AST in. --- Full diff: https://github.com/llvm/llvm-project/pull/88381.diff 4 Files Affected: - (modified) clang-tools-extra/clangd/ParsedAST.cpp (+1) - (modified) clang-tools-extra/clangd/Preamble.cpp (+1) - (modified) clang-tools-extra/clangd/Preamble.h (+5) - (modified) clang-tools-extra/clangd/unittests/ParsedASTTests.cpp (+32-7) ``diff diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 3ff759415f7c8b..b6e784db4719fe 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -451,6 +451,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, DiagnosticConsumer *DiagConsumer = &ASTDiags; IgnoreDiagnostics DropDiags; if (Preamble) { +CI->TargetOpts = Preamble->TargetOpts; Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble); Patch->apply(*CI); } diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp index f181c7befec156..d579e90adc49df 100644 --- a/clang-tools-extra/clangd/Preamble.cpp +++ b/clang-tools-extra/clangd/Preamble.cpp @@ -700,6 +700,7 @@ buildPreamble(PathRef FileName, CompilerInvocation CI, Result->Marks = CapturedInfo.takeMarks(); Result->StatCache = StatCache; Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded(); +Result->TargetOpts = CI.TargetOpts; if (PreambleCallback) { trace::Span Tracer("Running PreambleCallback"); auto Ctx = CapturedInfo.takeLife(); diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index 37da3833748a9c..160b884beb56bb 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -30,6 +30,7 @@ #include "clang-include-cleaner/Record.h" #include "support/Path.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetOptions.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/PrecompiledPreamble.h" #include "clang/Lex/Lexer.h" @@ -97,6 +98,10 @@ struct PreambleData { // Version of the ParseInputs this preamble was built from. std::string Version; tooling::CompileCommand CompileCommand; + // Target options used when building the preamble. Changes in target can cause + // crashes when deserializing preamble, this enables consumers to use the + // same target (without reparsing CompileCommand). + std::shared_ptr TargetOpts = nullptr; PrecompiledPreamble Preamble; std::vector Diags; // Processes like code completions and go-to-definitions will need #include diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp index 500b72b9b327a0..4bb76cd6ab8304 100644 --- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp @@ -12,10 +12,7 @@ //===--===// #include "../../clang-tidy/ClangTidyCheck.h" -#include "../../clang-tidy/ClangTidyModule.h" -#include "../../clang-tidy/ClangTidyModuleRegistry.h" #include "AST.h" -#include "CompileCommands.h" #include "Compiler.h" #include "Config.h" #include "Diagnostics.h" @@ -32,7 +29,6 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TokenKinds.h" -#include "clang/Lex/PPCallbacks.h" #include "clang/Tooling/Syntax/Tokens.h" #include "llvm/ADT/StringRef.h" #include "llvm/Testing/Annotations/Annotations.h" @@ -41,6 +37,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include +#include #include #include @@ -347,9 +344,8 @@ TEST(ParsedASTTest, CollectsMainFileMacroExpansions) { } for (const auto &R : AST.getMacros().UnknownMacros) MacroExpansionPositions.push_back(R.StartOffset); - EXPECT_THAT( - MacroExpansionPositions, - testing::UnorderedElementsAreArray(TestCase.points())); + EXPECT_THAT(MacroExpansionPositions, + testing::UnorderedElementsAreArray(TestCase.points())); } MATCHER_P(withFileName, Inc, "") { return arg.FileName == Inc; } @@ -768,6 +764,35 @@ TEST(ParsedASTTest, GracefulFailureOnAssemblyFile) { << "Should not try to build AST for assembly source file"; } +TEST(ParsedASTTest, PreambleWithDifferentTarget) { + constexpr std::s
[clang-tools-extra] [clangd] Use TargetOpts from preamble when building ASTs (PR #88381)
https://github.com/kadircet created https://github.com/llvm/llvm-project/pull/88381 Building ASTs with compile flags that are incompatible to the ones used for the Preamble are not really supported by clang and can trigger crashes. In an ideal world, we should be re-using not only TargetOpts, but the full ParseInputs from the Preamble to prevent such failures. Unfortunately current contracts of ThreadSafeFS makes this a non-safe change for certain implementations. As there are no guarantees that the same ThreadSafeFS is going to be valid in the Context::current() we're building the AST in. From d23a0e1da78abe76f2f178ed4f97927147682ec4 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Thu, 11 Apr 2024 14:02:43 +0200 Subject: [PATCH] [clangd] Use TargetOpts from preamble when building ASTs Building ASTs with compile flags that are incompatible to the ones used for the Preamble are not really supported by clang and can trigger crashes. In an ideal world, we should be re-using not only TargetOpts, but the full ParseInputs from the Preamble to prevent such failures. Unfortunately current contracts of ThreadSafeFS makes this a non-safe change for certain implementations. As there are no guarantees that the same ThreadSafeFS is going to be valid in the Context::current() we're building the AST in. --- clang-tools-extra/clangd/ParsedAST.cpp| 1 + clang-tools-extra/clangd/Preamble.cpp | 1 + clang-tools-extra/clangd/Preamble.h | 5 +++ .../clangd/unittests/ParsedASTTests.cpp | 39 +++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index 3ff759415f7c8b..b6e784db4719fe 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -451,6 +451,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, DiagnosticConsumer *DiagConsumer = &ASTDiags; IgnoreDiagnostics DropDiags; if (Preamble) { +CI->TargetOpts = Preamble->TargetOpts; Patch = PreamblePatch::createFullPatch(Filename, Inputs, *Preamble); Patch->apply(*CI); } diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp index f181c7befec156..d579e90adc49df 100644 --- a/clang-tools-extra/clangd/Preamble.cpp +++ b/clang-tools-extra/clangd/Preamble.cpp @@ -700,6 +700,7 @@ buildPreamble(PathRef FileName, CompilerInvocation CI, Result->Marks = CapturedInfo.takeMarks(); Result->StatCache = StatCache; Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded(); +Result->TargetOpts = CI.TargetOpts; if (PreambleCallback) { trace::Span Tracer("Running PreambleCallback"); auto Ctx = CapturedInfo.takeLife(); diff --git a/clang-tools-extra/clangd/Preamble.h b/clang-tools-extra/clangd/Preamble.h index 37da3833748a9c..160b884beb56bb 100644 --- a/clang-tools-extra/clangd/Preamble.h +++ b/clang-tools-extra/clangd/Preamble.h @@ -30,6 +30,7 @@ #include "clang-include-cleaner/Record.h" #include "support/Path.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetOptions.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/PrecompiledPreamble.h" #include "clang/Lex/Lexer.h" @@ -97,6 +98,10 @@ struct PreambleData { // Version of the ParseInputs this preamble was built from. std::string Version; tooling::CompileCommand CompileCommand; + // Target options used when building the preamble. Changes in target can cause + // crashes when deserializing preamble, this enables consumers to use the + // same target (without reparsing CompileCommand). + std::shared_ptr TargetOpts = nullptr; PrecompiledPreamble Preamble; std::vector Diags; // Processes like code completions and go-to-definitions will need #include diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp index 500b72b9b327a0..4bb76cd6ab8304 100644 --- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp @@ -12,10 +12,7 @@ //===--===// #include "../../clang-tidy/ClangTidyCheck.h" -#include "../../clang-tidy/ClangTidyModule.h" -#include "../../clang-tidy/ClangTidyModuleRegistry.h" #include "AST.h" -#include "CompileCommands.h" #include "Compiler.h" #include "Config.h" #include "Diagnostics.h" @@ -32,7 +29,6 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TokenKinds.h" -#include "clang/Lex/PPCallbacks.h" #include "clang/Tooling/Syntax/Tokens.h" #include "llvm/ADT/StringRef.h" #include "llvm/Testing/Annotations/Annotations.h" @@ -41,6 +37,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" #include +#include #include #include @@ -347,9 +344,8 @@ TEST(ParsedASTTest, Colle
[clang] [clang][dataflow] Remove deprecated alias `ControlFlowContext`. (PR #88358)
https://github.com/ymand approved this pull request. https://github.com/llvm/llvm-project/pull/88358 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
https://github.com/tblah commented: Thanks for the fix. Other changes look good to me, but please wait for approval from @jhuber6 https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][AMDGPU] Add rocm-path flag (PR #88190)
https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/88190 >From 44def17f36e8e27eb4232681e5ae7eff5de6d90f Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Tue, 9 Apr 2024 14:35:26 -0500 Subject: [PATCH 1/3] [Flang][AMDGPU] Add rocm-path flag ROCm installation path is used for finding and automatically linking required bitcode libraries. --- clang/include/clang/Driver/Options.td| 3 ++- clang/lib/Driver/ToolChains/Flang.cpp| 4 flang/test/Driver/driver-help-hidden.f90 | 1 + flang/test/Driver/driver-help.f90| 1 + flang/test/Driver/omp-driver-offload.f90 | 21 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f745e573eb2686..651aa10150c06e 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1341,7 +1341,8 @@ def hip_link : Flag<["--"], "hip-link">, Group, HelpText<"Link clang-offload-bundler bundles for HIP">; def no_hip_rt: Flag<["-"], "no-hip-rt">, Group, HelpText<"Do not link against HIP runtime libraries">; -def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group, +def rocm_path_EQ : Joined<["--"], "rocm-path=">, + Visibility<[FlangOption]>, Group, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; def hip_path_EQ : Joined<["--"], "hip-path=">, Group, HelpText<"HIP runtime installation path, used for finding HIP version and adding HIP include path.">; diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 2c83f70eb7887e..75e4ead81e43ed 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -342,6 +342,10 @@ void Flang::AddAMDGPUTargetArgs(const ArgList &Args, StringRef Val = A->getValue(); CmdArgs.push_back(Args.MakeArgString("-mcode-object-version=" + Val)); } + + // Check ROCm path if specified + const ToolChain &TC = getToolChain(); + TC.getDeviceLibs(Args); } void Flang::addTargetOptions(const ArgList &Args, diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 index 48f48f5384fdc5..10b15fb454b9aa 100644 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -144,6 +144,7 @@ ! CHECK-NEXT: -print-target-triplePrint the normalized target triple ! CHECK-NEXT: -pthreadSupport POSIX threads in generated code ! CHECK-NEXT: -P Disable linemarker output in -E mode +! CHECK-NEXT: --rocm-path= ROCm installation path, used for finding and automatically linking required bitcode libraries. ! CHECK-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression ! CHECK-NEXT: -Rpass-missed= Report missed transformations by optimization passes whose name matches the given POSIX regular expression ! CHECK-NEXT: -Rpass= Report transformations performed by optimization passes whose name matches the given POSIX regular expression diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 index 38f74395a678ab..ed5af2a68eb044 100644 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -132,6 +132,7 @@ ! HELP-NEXT: -print-target-triplePrint the normalized target triple ! HELP-NEXT: -pthreadSupport POSIX threads in generated code ! HELP-NEXT: -P Disable linemarker output in -E mode +! HELP-NEXT: --rocm-path= ROCm installation path, used for finding and automatically linking required bitcode libraries. ! HELP-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression ! HELP-NEXT: -Rpass-missed= Report missed transformations by optimization passes whose name matches the given POSIX regular expression ! HELP-NEXT: -Rpass= Report transformations performed by optimization passes whose name matches the given POSIX regular expression diff --git a/flang/test/Driver/omp-driver-offload.f90 b/flang/test/Driver/omp-driver-offload.f90 index 7e9a73627cd757..836dcfc85eb9de 100644 --- a/flang/test/Driver/omp-driver-offload.f90 +++ b/flang/test/Driver/omp-driver-offload.f90 @@ -201,3 +201,24 @@ ! RUN: -nogpulibc %s 2>&1 \ ! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-AMDGPU %s ! NO-LIBC-GPU-AMDGPU-NOT: "-lcgpu-amdgpu" + +! RUN: rm -rf %t/Inputs + +! RUN: not %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \ +! RUN: --offload-arch=gfx900 \ +! RUN: --rocm-path=%t/Inputs/rocm %s 2>&1 \ +! RUN: | FileCheck --check-prefix=ROCM-PATH-NOT-FOUND %s +! ROCM-PATH-NOT-FOUND: error: cannot find ROCm device library; + +! RUN: rm -rf %t/Inputs +! RUN: mkdir -p %t/Inputs +! RUN: cp -r %S/../../../clang/tes
[clang] [Clang][CWG1815] Support lifetime extension of temporary created by aggregate initialization using a default member initializer (PR #87933)
yronglin wrote: friendly ping~ https://github.com/llvm/llvm-project/pull/87933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
paschalis-mpeis wrote: Rebased to main after #80296 was merged: - #80296 https://github.com/llvm/llvm-project/pull/78432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
https://github.com/paschalis-mpeis ready_for_review https://github.com/llvm/llvm-project/pull/78432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/87622 >From 47cd6ddbf292fd8a50534e091ac64ebee3c40ee5 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 3 Apr 2024 16:09:30 +0100 Subject: [PATCH 1/4] [libclc] Refactor build system to allow in-tree builds The previous build system was adding custom "OpenCL" and "LLVM IR" languages in CMake to build the builtin libraries. This was making it harder to build in-tree because the tool binaries needed to be present at configure time. This commit refactors the build system to use custom commands to build the bytecode files one by one, and link them all together into the final bytecode library. It also enables in-tree builds by aliasing the clang/llvm-link/etc. tool targets to internal targets, which are imported from the LLVM installation directory when building out of tree. Diffing (with llvm-diff) all of the final bytecode libraries in an out-of-tree configuration against those built using the current tip system shows no changes. Note that there are textual changes to metadata IDs which confuse regular diff, and that llvm-diff 14 and below may show false-positives. This commit also removes a file listed in one of the SOURCEs which didn't exist and which was preventing the use of ENABLE_RUNTIME_SUBNORMAL when configuring CMake. --- libclc/CMakeLists.txt | 257 ++ libclc/cmake/CMakeCLCCompiler.cmake.in| 9 - libclc/cmake/CMakeCLCInformation.cmake| 12 - libclc/cmake/CMakeDetermineCLCCompiler.cmake | 18 -- .../cmake/CMakeDetermineLLAsmCompiler.cmake | 24 -- libclc/cmake/CMakeLLAsmCompiler.cmake.in | 10 - libclc/cmake/CMakeLLAsmInformation.cmake | 12 - libclc/cmake/CMakeTestCLCCompiler.cmake | 56 libclc/cmake/CMakeTestLLAsmCompiler.cmake | 56 libclc/cmake/modules/AddLibclc.cmake | 153 +++ libclc/generic/lib/SOURCES| 1 - llvm/tools/CMakeLists.txt | 3 + 12 files changed, 305 insertions(+), 306 deletions(-) delete mode 100644 libclc/cmake/CMakeCLCCompiler.cmake.in delete mode 100644 libclc/cmake/CMakeCLCInformation.cmake delete mode 100644 libclc/cmake/CMakeDetermineCLCCompiler.cmake delete mode 100644 libclc/cmake/CMakeDetermineLLAsmCompiler.cmake delete mode 100644 libclc/cmake/CMakeLLAsmCompiler.cmake.in delete mode 100644 libclc/cmake/CMakeLLAsmInformation.cmake delete mode 100644 libclc/cmake/CMakeTestCLCCompiler.cmake delete mode 100644 libclc/cmake/CMakeTestLLAsmCompiler.cmake create mode 100644 libclc/cmake/modules/AddLibclc.cmake diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index c6e3cdf23fe0c8..ff4e4369a7af39 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -4,6 +4,15 @@ project( libclc VERSION 0.2.0 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 17) +# Add path for custom modules +list( INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/modules" ) + +set( LIBCLC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) +set( LIBCLC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +set( LIBCLC_OBJFILE_DIR ${LIBCLC_BINARY_DIR}/obj.libclc.dir ) + +include( AddLibclc ) + include( GNUInstallDirs ) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS amdgcn-amdhsa/lib/SOURCES; @@ -27,31 +36,51 @@ set( LIBCLC_TARGETS_TO_BUILD "all" option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." OFF ) -find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") -include(AddLLVM) +if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + # Out-of-tree configuration + set( LIBCLC_STANDALONE_BUILD TRUE ) -message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" ) + find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}") + include(AddLLVM) -if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM ) - message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" ) -endif() + message( STATUS "libclc LLVM version: ${LLVM_PACKAGE_VERSION}" ) -find_program( LLVM_CLANG clang PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) -find_program( LLVM_AS llvm-as PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) -find_program( LLVM_LINK llvm-link PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) -find_program( LLVM_OPT opt PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) -find_program( LLVM_SPIRV llvm-spirv PATHS ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH ) + if( LLVM_PACKAGE_VERSION VERSION_LESS LIBCLC_MIN_LLVM ) +message( FATAL_ERROR "libclc needs at least LLVM ${LIBCLC_MIN_LLVM}" ) + endif() -# Print toolchain -message( STATUS "libclc toolchain - clang: ${LLVM_CLANG}" ) -message( STATUS "libclc toolchain - llvm-as: ${LLVM_AS}" ) -message( STATUS "libclc toolchain - llvm-link: ${LLVM_LINK}" ) -message( STATUS "libclc toolchain - opt: ${LLVM_OPT}" ) -message( STATUS "libclc toolchain - llvm-spirv: ${LLVM_SPIRV}" ) -if( NOT LLVM_CLANG OR NOT LLVM_OPT OR NOT LLVM_AS OR NOT
[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)
@@ -1230,11 +1230,26 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S, JumpDest LoopExit = getJumpDestInCurrentScope("for.end"); LexicalScope ForScope(*this, S.getSourceRange()); + const DeclStmt *RangeDS = cast(S.getRangeStmt()); + const VarDecl *RangeVar = cast(RangeDS->getSingleDecl()); + if (getLangOpts().CPlusPlus23) yronglin wrote: Thank you for your confirmation, I will add a special-case to ExprWithCleanups handling once PR https://github.com/llvm/llvm-project/pull/87930 https://github.com/llvm/llvm-project/pull/87933 merged. https://github.com/llvm/llvm-project/pull/86960 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix AST dump for {CXXDefaultArgExpr, CXXDefaultInitExpr} (PR #88269)
https://github.com/yronglin edited https://github.com/llvm/llvm-project/pull/88269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix AST dump for {CXXDefaultArgExpr, CXXDefaultInitExpr} (PR #88269)
https://github.com/yronglin updated https://github.com/llvm/llvm-project/pull/88269 >From 26b87c38856f2840a3a6a2487834f3b677aa14b9 Mon Sep 17 00:00:00 2001 From: yronglin Date: Wed, 10 Apr 2024 21:38:40 +0800 Subject: [PATCH 1/3] [Clang] Fix AST dump for {CXXDefaultArgExpr, CXXDefaultInitExpr} Signed-off-by: yronglin --- clang/include/clang/AST/ASTNodeTraverser.h| 8 +++ clang/lib/AST/TextNodeDumper.cpp | 14 ++- clang/test/AST/ast-dump-default-init.cpp | 24 +++ .../test/AST/ast-dump-for-range-lifetime.cpp | 21 clang/unittests/AST/ASTTraverserTest.cpp | 8 +++ 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 clang/test/AST/ast-dump-default-init.cpp diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index 94e7dd817809dd..a6e3b05b005968 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -932,6 +932,14 @@ class ASTNodeTraverser Visit(TArg); } + void VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node) { +Visit(Node->getExpr()); + } + + void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node) { +Visit(Node->getExpr()); + } + // Implements Visit methods for Attrs. #include "clang/AST/AttrNodeTraverse.inc" }; diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 431f5d8bdb2b5f..830d3ff0faebd4 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -1439,23 +1439,13 @@ void TextNodeDumper::VisitExpressionTraitExpr(const ExpressionTraitExpr *Node) { } void TextNodeDumper::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *Node) { - if (Node->hasRewrittenInit()) { + if (Node->hasRewrittenInit()) OS << " has rewritten init"; -AddChild([=] { - ColorScope Color(OS, ShowColors, StmtColor); - Visit(Node->getExpr()); -}); - } } void TextNodeDumper::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *Node) { - if (Node->hasRewrittenInit()) { + if (Node->hasRewrittenInit()) OS << " has rewritten init"; -AddChild([=] { - ColorScope Color(OS, ShowColors, StmtColor); - Visit(Node->getExpr()); -}); - } } void TextNodeDumper::VisitMaterializeTemporaryExpr( diff --git a/clang/test/AST/ast-dump-default-init.cpp b/clang/test/AST/ast-dump-default-init.cpp new file mode 100644 index 00..a2ce4ba57aa968 --- /dev/null +++ b/clang/test/AST/ast-dump-default-init.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump %s | FileCheck %s + +// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this case +// RecoveryExpr. + +struct A { + int arr[1]; +}; + +struct B { + const A &a = A{{0}}; +}; + +void test() { + B b{}; +} +// CHECK: -CXXDefaultInitExpr 0x{{[^ ]*}} <{{.*}}> 'const A' lvalue has rewritten init +// CHECK-NEXT: `-ExprWithCleanups 0x{{[^ ]*}} <{{.*}}> 'const A' lvalue +// CHECK-NEXT:`-MaterializeTemporaryExpr 0x{{[^ ]*}} <{{.*}}> 'const A' lvalue extended by Var 0x{{[^ ]*}} 'b' 'B' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}} <{{.*}}> 'const A' +// CHECK-NEXT:`-CXXFunctionalCastExpr 0x{{[^ ]*}} <{{.*}}> 'A' functional cast to A +// CHECK-NEXT: `-InitListExpr 0x{{[^ ]*}} <{{.*}}> 'A' +// CHECK-NEXT:`-InitListExpr 0x{{[^ ]*}} <{{.*}}> 'int[1]' +// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}} <{{.*}}> 'int' 0 diff --git a/clang/test/AST/ast-dump-for-range-lifetime.cpp b/clang/test/AST/ast-dump-for-range-lifetime.cpp index 88b838268be2e0..0e92b6990ed504 100644 --- a/clang/test/AST/ast-dump-for-range-lifetime.cpp +++ b/clang/test/AST/ast-dump-for-range-lifetime.cpp @@ -132,6 +132,9 @@ void test4() { // CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'int (&(const A &))[3]' lvalue Function {{.*}} 'default_arg_fn' 'int (&(const A &))[3]' // CHECK-NEXT: | `-CXXDefaultArgExpr {{.*}} <> 'const A':'const P2718R0::A' lvalue has rewritten init // CHECK-NEXT: | `-MaterializeTemporaryExpr {{.*}} 'const A':'const P2718R0::A' lvalue extended by Var {{.*}} '__range1' 'int (&)[3]' + // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'const A':'const P2718R0::A' + // CHECK-NEXT: | `-CXXBindTemporaryExpr {{.*}} 'A':'P2718R0::A' (CXXTemporary {{.*}}) + // CHECK-NEXT: | `-CXXTemporaryObjectExpr {{.*}} 'A':'P2718R0::A' 'void ()' for (auto e : default_arg_fn()) bar(e); } @@ -179,10 +182,19 @@ void test5() { // CHECK-NEXT: | | | | `-CXXTemporaryObjectExpr {{.*}} 'A':'P2718R0::A' 'void ()' // CHECK-NEXT: | | | `-CXXDefaultArgExpr {{.*}} <> 'const DefaultA':'const P2718R0::DefaultA' lvalue has rewritten init // CHECK-NEXT: | | | `-MaterializeTemporaryExpr {{.*}} 'const DefaultA':'const P2
[clang] [llvm] [InstCombine] Infer nsw/nuw for trunc (PR #87910)
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/87910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64] Extend diagnostics when warning non/streaming about … (PR #88380)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Dinar Temirbulatov (dtemirbulatov) Changes …vector size difference Add separate messages about passing arguments or returning parameters with scalable types. --- Full diff: https://github.com/llvm/llvm-project/pull/88380.diff 5 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3-4) - (modified) clang/lib/Sema/SemaChecking.cpp (+13-5) - (modified) clang/lib/Sema/SemaDecl.cpp (+7-3) - (modified) clang/test/Sema/aarch64-incompat-sm-builtin-calls.c (+8-4) - (modified) clang/test/Sema/aarch64-sme-func-attrs.c (+24-24) ``diff diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 059a8f58da5db1..7361400460b1cd 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3756,12 +3756,11 @@ def err_sme_definition_using_za_in_non_sme_target : Error< def err_sme_definition_using_zt0_in_non_sme2_target : Error< "function using ZT0 state requires 'sme2'">; def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning< - "passing a VL-dependent argument to/from a function that has a different" - " streaming-mode. The streaming and non-streaming vector lengths may be" - " different">, + "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a function with a different" + " streaming-mode is undefined behaviour if the streaming and non-streaming vector lengths are different at runtime">, InGroup, DefaultIgnore; def warn_sme_locally_streaming_has_vl_args_returns : Warning< - "passing/returning a VL-dependent argument to/from a __arm_locally_streaming" + "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a __arm_locally_streaming" " function. The streaming and non-streaming vector" " lengths may be different">, InGroup, DefaultIgnore; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index abfd9a3031577b..f711bc8e9ca096 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -7938,7 +7938,8 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, // For variadic functions, we may have more args than parameters. // For some K&R functions, we may have less args than parameters. const auto N = std::min(Proto->getNumParams(), Args.size()); -bool AnyScalableArgsOrRet = Proto->getReturnType()->isSizelessVectorType(); +bool IsScalableRet = Proto->getReturnType()->isSizelessVectorType(); +bool IsScalableArg = false; for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) { // Args[ArgIdx] can be null in malformed code. if (const Expr *Arg = Args[ArgIdx]) { @@ -7953,7 +7954,7 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, QualType ParamTy = Proto->getParamType(ArgIdx); if (ParamTy->isSizelessVectorType()) - AnyScalableArgsOrRet = true; + IsScalableArg = true; QualType ArgTy = Arg->getType(); CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1), ArgTy, ParamTy); @@ -7978,7 +7979,8 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, // arguments or return values, then warn the user that the streaming and // non-streaming vector lengths may be different. const auto *CallerFD = dyn_cast(CurContext); -if (CallerFD && (!FD || !FD->getBuiltinID()) && AnyScalableArgsOrRet) { +if (CallerFD && (!FD || !FD->getBuiltinID()) && +(IsScalableArg || IsScalableRet)) { bool IsCalleeStreaming = ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateSMEnabledMask; bool IsCalleeStreamingCompatible = @@ -7987,8 +7989,14 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, ArmStreamingType CallerFnType = getArmStreamingFnType(CallerFD); if (!IsCalleeStreamingCompatible && (CallerFnType == ArmStreamingCompatible || - ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming))) -Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming); + ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming))) { +if (IsScalableArg) + Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming) + << /*IsArg=*/true; +if (IsScalableRet) + Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming) + << /*IsArg=*/false; + } } FunctionType::ArmStateValue CalleeArmZAState = diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5a23179dfbbf44..1ae3029df50b5c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12404,12 +12404,16 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, bool UsesZT0 = Attr && Attr->isNewZT0();
[clang] [Clang][AArch64] Extend diagnostics when warning non/streaming about … (PR #88380)
https://github.com/dtemirbulatov created https://github.com/llvm/llvm-project/pull/88380 …vector size difference Add separate messages about passing arguments or returning parameters with scalable types. >From 48659137fa681d2e3fe32490cc8b565f8771ccbf Mon Sep 17 00:00:00 2001 From: Dinar Temirbulatov Date: Thu, 11 Apr 2024 10:59:49 + Subject: [PATCH] [Clang][AArch64] Extend diagnostics when warning non/streaming about vector size difference Add separate messages about passing arguments or returning parameters with scalable types. --- .../clang/Basic/DiagnosticSemaKinds.td| 7 ++- clang/lib/Sema/SemaChecking.cpp | 18 +-- clang/lib/Sema/SemaDecl.cpp | 10 ++-- .../Sema/aarch64-incompat-sm-builtin-calls.c | 12 +++-- clang/test/Sema/aarch64-sme-func-attrs.c | 48 +-- 5 files changed, 55 insertions(+), 40 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 059a8f58da5db1..7361400460b1cd 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3756,12 +3756,11 @@ def err_sme_definition_using_za_in_non_sme_target : Error< def err_sme_definition_using_zt0_in_non_sme2_target : Error< "function using ZT0 state requires 'sme2'">; def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning< - "passing a VL-dependent argument to/from a function that has a different" - " streaming-mode. The streaming and non-streaming vector lengths may be" - " different">, + "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a function with a different" + " streaming-mode is undefined behaviour if the streaming and non-streaming vector lengths are different at runtime">, InGroup, DefaultIgnore; def warn_sme_locally_streaming_has_vl_args_returns : Warning< - "passing/returning a VL-dependent argument to/from a __arm_locally_streaming" + "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a __arm_locally_streaming" " function. The streaming and non-streaming vector" " lengths may be different">, InGroup, DefaultIgnore; diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index abfd9a3031577b..f711bc8e9ca096 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -7938,7 +7938,8 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, // For variadic functions, we may have more args than parameters. // For some K&R functions, we may have less args than parameters. const auto N = std::min(Proto->getNumParams(), Args.size()); -bool AnyScalableArgsOrRet = Proto->getReturnType()->isSizelessVectorType(); +bool IsScalableRet = Proto->getReturnType()->isSizelessVectorType(); +bool IsScalableArg = false; for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) { // Args[ArgIdx] can be null in malformed code. if (const Expr *Arg = Args[ArgIdx]) { @@ -7953,7 +7954,7 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, QualType ParamTy = Proto->getParamType(ArgIdx); if (ParamTy->isSizelessVectorType()) - AnyScalableArgsOrRet = true; + IsScalableArg = true; QualType ArgTy = Arg->getType(); CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1), ArgTy, ParamTy); @@ -7978,7 +7979,8 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, // arguments or return values, then warn the user that the streaming and // non-streaming vector lengths may be different. const auto *CallerFD = dyn_cast(CurContext); -if (CallerFD && (!FD || !FD->getBuiltinID()) && AnyScalableArgsOrRet) { +if (CallerFD && (!FD || !FD->getBuiltinID()) && +(IsScalableArg || IsScalableRet)) { bool IsCalleeStreaming = ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateSMEnabledMask; bool IsCalleeStreamingCompatible = @@ -7987,8 +7989,14 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, ArmStreamingType CallerFnType = getArmStreamingFnType(CallerFD); if (!IsCalleeStreamingCompatible && (CallerFnType == ArmStreamingCompatible || - ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming))) -Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming); + ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming))) { +if (IsScalableArg) + Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming) + << /*IsArg=*/true; +if (IsScalableRet) + Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming) + << /*IsArg=*/false; + } } FunctionType::ArmStateValue CalleeArmZAState = diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sem
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
DominikAdamski wrote: > clang already tests this pretty well, but I'd still like to have at least one > check to make sure that flang is actually putting -rpath in the linker. Done. I added test. https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
@@ -0,0 +1,32 @@ +// REQUIRES: x86-registered-target DominikAdamski wrote: Done https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/88280 >From 1330d076904d98a0a594700cca1c3e4a6b15dd58 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Wed, 10 Apr 2024 09:42:09 -0500 Subject: [PATCH 1/3] [Flang] Add option frtlib-add-rpath This option is used by clang and should also be visible in flang. It is already handled by the toolchains used by both clang and flang. --- clang/include/clang/Driver/Options.td| 2 ++ flang/test/Driver/driver-help-hidden.f90 | 2 ++ flang/test/Driver/driver-help.f90| 2 ++ 3 files changed, 6 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f745e573eb2686..d26c48b3585de7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5472,10 +5472,12 @@ def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group, def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption]>, HelpText<"Compiler runtime library to use">; def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>, + Visibility<[ClangOption, FlangOption]>, HelpText<"Add -rpath with architecture-specific resource directory to the linker flags. " "When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags">; def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>, + Visibility<[ClangOption, FlangOption]>, HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags. " "When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags">; def offload_add_rpath: Flag<["--"], "offload-add-rpath">, diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 index 48f48f5384fdc5..46f6fb76fe41a8 100644 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -67,6 +67,7 @@ ! CHECK-NEXT: -fno-ltoDisable LTO mode (default) ! CHECK-NEXT: -fno-ppc-native-vector-element-order ! CHECK-NEXT: Specifies PowerPC non-native vector element order +! CHECK-NEXT: -fno-rtlib-add-rpath Do not add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags ! CHECK-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! CHECK-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) ! CHECK-NEXT: -fno-version-loops-for-stride @@ -92,6 +93,7 @@ ! CHECK-NEXT: Specifies PowerPC native vector element order (default) ! CHECK-NEXT: -freciprocal-math Allow division operations to be reassociated ! CHECK-NEXT: -fropi Generate read-only position independent code (ARM only) +! CHECK-NEXT: -frtlib-add-rpath Add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags ! CHECK-NEXT: -frwpi Generate read-write position independent code (ARM only) ! CHECK-NEXT: -fsave-optimization-record= ! CHECK-NEXT: Generate an optimization record file in a specific format diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 index 38f74395a678ab..f0d42090835590 100644 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -59,6 +59,7 @@ ! HELP-NEXT: -fno-ltoDisable LTO mode (default) ! HELP-NEXT: -fno-ppc-native-vector-element-order ! HELP-NEXT: Specifies PowerPC non-native vector element order +! HELP-NEXT: -fno-rtlib-add-rpath Do not add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) ! HELP-NEXT: -fno-version-loops-for-stride @@ -80,6 +81,7 @@ ! HELP-NEXT: Specifies PowerPC native vector element order (default) ! HELP-NEXT: -freciprocal-math Allow division operations to be reassociated ! HELP-NEXT: -fropi Generate read-only position independent code (ARM only) +! HELP-NEXT: -frtlib-add-rpath Add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags ! HELP-NEXT: -frwpi Generate read-write position independent code (ARM only) ! HELP-NEXT: -fsave-optimization-reco
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
https://github.com/DominikAdamski edited https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
@@ -0,0 +1,32 @@ +// REQUIRES: x86-registered-target tblah wrote: Please could you use fortran style comments (starting with `!`) https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)
https://github.com/jcsxky edited https://github.com/llvm/llvm-project/pull/85198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add options frtlib-add-rpath and resource-dir (PR #88280)
https://github.com/DominikAdamski edited https://github.com/llvm/llvm-project/pull/88280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang] Add option frtlib-add-rpath (PR #88280)
https://github.com/DominikAdamski updated https://github.com/llvm/llvm-project/pull/88280 >From 1330d076904d98a0a594700cca1c3e4a6b15dd58 Mon Sep 17 00:00:00 2001 From: Dominik Adamski Date: Wed, 10 Apr 2024 09:42:09 -0500 Subject: [PATCH 1/2] [Flang] Add option frtlib-add-rpath This option is used by clang and should also be visible in flang. It is already handled by the toolchains used by both clang and flang. --- clang/include/clang/Driver/Options.td| 2 ++ flang/test/Driver/driver-help-hidden.f90 | 2 ++ flang/test/Driver/driver-help.f90| 2 ++ 3 files changed, 6 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f745e573eb2686..d26c48b3585de7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5472,10 +5472,12 @@ def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group, def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption]>, HelpText<"Compiler runtime library to use">; def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>, + Visibility<[ClangOption, FlangOption]>, HelpText<"Add -rpath with architecture-specific resource directory to the linker flags. " "When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags">; def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>, + Visibility<[ClangOption, FlangOption]>, HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags. " "When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags">; def offload_add_rpath: Flag<["--"], "offload-add-rpath">, diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 index 48f48f5384fdc5..46f6fb76fe41a8 100644 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -67,6 +67,7 @@ ! CHECK-NEXT: -fno-ltoDisable LTO mode (default) ! CHECK-NEXT: -fno-ppc-native-vector-element-order ! CHECK-NEXT: Specifies PowerPC non-native vector element order +! CHECK-NEXT: -fno-rtlib-add-rpath Do not add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags ! CHECK-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! CHECK-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) ! CHECK-NEXT: -fno-version-loops-for-stride @@ -92,6 +93,7 @@ ! CHECK-NEXT: Specifies PowerPC native vector element order (default) ! CHECK-NEXT: -freciprocal-math Allow division operations to be reassociated ! CHECK-NEXT: -fropi Generate read-only position independent code (ARM only) +! CHECK-NEXT: -frtlib-add-rpath Add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags ! CHECK-NEXT: -frwpi Generate read-write position independent code (ARM only) ! CHECK-NEXT: -fsave-optimization-record= ! CHECK-NEXT: Generate an optimization record file in a specific format diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 index 38f74395a678ab..f0d42090835590 100644 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -59,6 +59,7 @@ ! HELP-NEXT: -fno-ltoDisable LTO mode (default) ! HELP-NEXT: -fno-ppc-native-vector-element-order ! HELP-NEXT: Specifies PowerPC non-native vector element order +! HELP-NEXT: -fno-rtlib-add-rpath Do not add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, do not add -rpath with HIP runtime library directory to the linker flags ! HELP-NEXT: -fno-signed-zeros Allow optimizations that ignore the sign of floating point zeros ! HELP-NEXT: -fno-stack-arrays Allocate array temporaries on the heap (default) ! HELP-NEXT: -fno-version-loops-for-stride @@ -80,6 +81,7 @@ ! HELP-NEXT: Specifies PowerPC native vector element order (default) ! HELP-NEXT: -freciprocal-math Allow division operations to be reassociated ! HELP-NEXT: -fropi Generate read-only position independent code (ARM only) +! HELP-NEXT: -frtlib-add-rpath Add -rpath with architecture-specific resource directory to the linker flags. When --hip-link is specified, also add -rpath with HIP runtime library directory to the linker flags ! HELP-NEXT: -frwpi Generate read-write position independent code (ARM only) ! HELP-NEXT: -fsave-optimization-reco
[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)
ilya-biryukov wrote: Most of the increase seems to be coming from module maps that describe textual headers: ``` // This describes builtin headers. Before: gen-crosstool-x86.cppmap:1:1: note: file entered 630 times using 83989080B of space After: gen-crosstool-x86.cppmap:1:1: note: file entered 2260 times using 319523320B of space ``` I will dig further to see where it's coming from. https://github.com/llvm/llvm-project/pull/83660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Integral pointers (PR #84159)
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + FunctionPointer(int IntVal = 0, const Descriptor *Desc = nullptr) RKSimon wrote: For reference @AaronBallman fixed this in 4d80dff819d1164775d0d55fc68bffedb90ba53c https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] NFC: Make clang resource headers an interface library (PR #88317)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/88317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Headers meant to be included multiple times can be completely invisible in clang module builds (PR #83660)
ilya-biryukov wrote: It's definitely caused by that change, reverting it fixes the failure. We use module maps so that some of our `#include` get processed as `#import`, I believe the same code gets executed for our use-case. Because our setup is so unusual, producing a repro is hard and make take some time. (Build system generated module maps and `#include` is essentially turned into `#import` by Clang). I will try to investigate this further today and come back with more details. https://github.com/llvm/llvm-project/pull/83660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Infer nsw/nuw for trunc (PR #87910)
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) { } } - return nullptr; + bool Changed = false; + if (!Trunc.hasNoSignedWrap() && + ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) { +Trunc.setHasNoSignedWrap(true); +Changed = true; + } + if (!Trunc.hasNoUnsignedWrap() && + MaskedValueIsZero(Src, APInt::getBitsSetFrom(SrcWidth, DestWidth), +/*Depth=*/0, &Trunc)) { +Trunc.setHasNoUnsignedWrap(true); +Changed = true; nikic wrote: Okay, I won't insist on this. https://github.com/llvm/llvm-project/pull/87910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Infer nsw/nuw for trunc (PR #87910)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/87910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Infer nsw/nuw for trunc (PR #87910)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/87910 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
https://github.com/hdoc updated https://github.com/llvm/llvm-project/pull/88367 >From 61612c5f340e25198deaf68e6904323955efe489 Mon Sep 17 00:00:00 2001 From: hdoc Date: Thu, 11 Apr 2024 01:54:18 -0700 Subject: [PATCH] Attach comments to decl even if preproc directives are in between --- clang/lib/AST/ASTContext.cpp | 7 +- clang/lib/Headers/amxcomplexintrin.h | 4 + clang/lib/Headers/ia32intrin.h | 2 + clang/test/Index/annotate-comments.cpp | 5 +- clang/unittests/AST/DeclTest.cpp | 310 + 5 files changed, 323 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 2fa6aedca4c6ab..1c8d55b8627452 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -282,9 +282,10 @@ RawComment *ASTContext::getRawCommentForDeclNoCacheImpl( StringRef Text(Buffer + CommentEndOffset, DeclLocDecomp.second - CommentEndOffset); - // There should be no other declarations or preprocessor directives between - // comment and declaration. - if (Text.find_last_of(";{}#@") != StringRef::npos) + // There should be no other declarations between comment and declaration. + // Preprocessor directives are implicitly allowed to be between a comment and + // its associated decl. + if (Text.find_last_of(";{}@") != StringRef::npos) return nullptr; return CommentBeforeDecl; diff --git a/clang/lib/Headers/amxcomplexintrin.h b/clang/lib/Headers/amxcomplexintrin.h index 84ef972fcadf03..19eaee10ede659 100644 --- a/clang/lib/Headers/amxcomplexintrin.h +++ b/clang/lib/Headers/amxcomplexintrin.h @@ -62,6 +62,8 @@ ///The 2nd source tile. Max size is 1024 Bytes. #define _tile_cmmimfp16ps(dst, a, b) __builtin_ia32_tcmmimfp16ps(dst, a, b) +; + /// Perform matrix multiplication of two tiles containing complex elements and ///accumulate the results into a packed single precision tile. Each dword ///element in input tiles \a a and \a b is interpreted as a complex number @@ -107,6 +109,8 @@ ///The 2nd source tile. Max size is 1024 Bytes. #define _tile_cmmrlfp16ps(dst, a, b) __builtin_ia32_tcmmrlfp16ps(dst, a, b) +; + static __inline__ _tile1024i __DEFAULT_FN_ATTRS_COMPLEX _tile_cmmimfp16ps_internal(unsigned short m, unsigned short n, unsigned short k, _tile1024i dst, _tile1024i src1, _tile1024i src2) { diff --git a/clang/lib/Headers/ia32intrin.h b/clang/lib/Headers/ia32intrin.h index 8e65f232a0def8..c9c92b9ee0f991 100644 --- a/clang/lib/Headers/ia32intrin.h +++ b/clang/lib/Headers/ia32intrin.h @@ -533,6 +533,8 @@ __rdtscp(unsigned int *__A) { /// \see __rdpmc #define _rdpmc(A) __rdpmc(A) +; + static __inline__ void __DEFAULT_FN_ATTRS _wbinvd(void) { __builtin_ia32_wbinvd(); diff --git a/clang/test/Index/annotate-comments.cpp b/clang/test/Index/annotate-comments.cpp index 6f9f8f0bbbc9e5..bff25d46cf80ee 100644 --- a/clang/test/Index/annotate-comments.cpp +++ b/clang/test/Index/annotate-comments.cpp @@ -204,9 +204,9 @@ void isdoxy45(void); /// Ggg. IS_DOXYGEN_END void isdoxy46(void); -/// IS_DOXYGEN_NOT_ATTACHED +/// isdoxy47 IS_DOXYGEN_SINGLE #define FOO -void notdoxy47(void); +void isdoxy47(void); /// IS_DOXYGEN_START Aaa bbb /// \param ccc @@ -330,6 +330,7 @@ void isdoxy54(int); // CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.] // CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.] // CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:209:6: FunctionDecl=isdoxy47:{{.*}} isdoxy47 IS_DOXYGEN_SINGLE // CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb] // CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa] // CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END] diff --git a/clang/unittests/AST/DeclTest.cpp b/clang/unittests/AST/DeclTest.cpp index 2530ce74eb6a37..e5c1a578864292 100644 --- a/clang/unittests/AST/DeclTest.cpp +++ b/clang/unittests/AST/DeclTest.cpp @@ -545,3 +545,313 @@ TEST(Decl, TemplateArgumentDefaulted) { EXPECT_TRUE(ArgList.get(2).getIsDefaulted()); EXPECT_TRUE(ArgList.get(3).getIsDefaulted()); } + +TEST(Decl, CommentsAttachedToDecl1) { + const SmallVector Sources{ + R"( +/// Test comment +void f(); + )", + + R"( +/// Test comment + +void f(); + )", + + R"( +/// Test comment +#if 0 +// tralala +#endif +void f(); + )", + + R"( +/// Test comment + +#if 0 +// tralala +#endif + +void f(); + )", + + R"( +/// Test comment +#ifdef DOCS +template +#endif +
[clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/78432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LV][LAA] Vectorize math lib calls with mem write-only attribute (PR #78432)
https://github.com/paschalis-mpeis edited https://github.com/llvm/llvm-project/pull/78432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
@@ -62,6 +62,8 @@ ///The 2nd source tile. Max size is 1024 Bytes. #define _tile_cmmimfp16ps(dst, a, b) __builtin_ia32_tcmmimfp16ps(dst, a, b) +; hdoc wrote: This is a workaround to a Clang issue where doc comments cannot be associated with macros in Clang. The semicolon breaks up the preceding doc comment from the subsequent function. Without this, we get `-Wdocumentation` errors during the build. https://github.com/llvm/llvm-project/pull/88367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
https://github.com/hdoc edited https://github.com/llvm/llvm-project/pull/88367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
kito-cheng wrote: Could you add `B` into CombinedExtsEntry and added a test for that? https://github.com/llvm/llvm-project/pull/76893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/88367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Comments] Attach comments to decl even if preproc directives are in between (PR #88367)
https://github.com/hdoc created https://github.com/llvm/llvm-project/pull/88367 # Background It's surprisingly common for C++ code in the wild to conditionally show/hide declarations to Doxygen through the use of preprocessor directives. One especially common version of this pattern is demonstrated below: ```cpp /// @brief Test comment #ifdef DOXYGEN_BUILD_ENABLED template #else template typename std::enable_if::value>::type #endif void f() {} ``` There are more examples I've collected below to demonstrate usage of this pattern: - Magnum: https://github.com/mosra/magnum/blob/8538610fa27e1db37070eaabe34f1e4e41648bab/src/Magnum/Resource.h#L117-L127 - libcds: https://github.com/khizmax/libcds/blob/9985d2a87feaa3e92532e28f4ab762a82855a49c/cds/container/michael_list_nogc.h#L36-L54 - rocPRIM: https://github.com/ROCm/rocPRIM/blob/609ae19565ff6a3499168b76a0be5652762e24f6/rocprim/include/rocprim/block/detail/block_reduce_raking_reduce.hpp#L60-L65 >From my research, it seems like the most common rationale for this >functionality is hiding difficult-to-parse code from Doxygen, especially where >template metaprogramming is concerned. Currently, Clang does not support attaching comments to decls if there are preprocessor comments between the comment and the decl. This is enforced here: https://github.com/llvm/llvm-project/blob/b6ebea7972cd05a8e4dcf0d5a54f2c79395a/clang/lib/AST/ASTContext.cpp#L284-L287 Alongside preprocessor directives, any instance of `;{}#@` between a comment and decl will cause the comment to not be attached to the decl. ## Rationale It would be nice for Clang-based documentation tools, such as [hdoc](https://hdoc.io), to support code using this pattern. Users expect to see comments attached to the relevant decl — even if there is an `#ifdef` in the way — which Clang does not currently do. ## History Originally, commas were also in the list of "banned" characters, but were removed in `b534d3a0ef69` ([link](https://github.com/llvm/llvm-project/commit/b534d3a0ef6970f5e42f10ba5cfcb562d8b184e1)) because availability macros often have commas in them. From my reading of the code, it appears that the original intent of the code was to exclude macros and decorators between comments and decls, possibly in an attempt to properly attribute comments to macros (discussed further in "Complications", below). There's some more discussion here: https://reviews.llvm.org/D125061. # Change This modifies Clang comment parsing so that comments are attached to subsequent declarations even if there are preprocessor directives between the end of the comment and the start of the decl. Furthermore, this change: - Adds tests to verify that comments are attached to their associated decls even if there are preprocessor directives in between - Adds tests to verify that current behavior has not changed (i.e. use of the other characters between comment and decl will result in the comment not being attached to the decl) - Updates existing `lit` tests which would otherwise break. ## Complications Clang [does not yet support](https://github.com/llvm/llvm-project/issues/38206) attaching doc comments to macros. Consequently, the change proposed in this RFC affects cases where a doc comment attached to a macro is followed immediately by a normal declaration. In these cases, the macro's doc comments will be attached to the subsequent decl. Previously they would be ignored because any preprocessor directives between a comment and a decl would result in the comment not being attached to the decl. An example of this is shown below. ```cpp /// Doc comment for a function-like macro /// @param n ///A macro argument #define custom_sqrt(n) __internal_sqrt(n) int __internal_sqrt(int n) { return __builtin_sqrt(n); } // NB: the doc comment for the custom_sqrt macro will actually be attached to __internal_sqrt! ``` There is a real instance of this problem in the Clang codebase, namely here: https://github.com/llvm/llvm-project/blob/be10070f91b86a6f126d2451852242bfcb2cd366/clang/lib/Headers/amxcomplexintrin.h#L65-L114 As part of this RFC, I've added a semicolon to break up the Clang comment parsing so that the `-Wdocumentation` errors go away, but this is a hack. The real solution is to fix Clang comment parsing so that doc comments are properly attached to macros, however this would be a large change that is outside of the scope of this RFC. >From 54c114738a063d18aadedf470f005c3e966bd6e5 Mon Sep 17 00:00:00 2001 From: hdoc Date: Thu, 11 Apr 2024 01:54:18 -0700 Subject: [PATCH] Attach comments to decl even if preproc directives are in between --- clang/lib/AST/ASTContext.cpp | 7 +- clang/lib/Headers/amxcomplexintrin.h | 4 + clang/test/Index/annotate-comments.cpp | 5 +- clang/unittests/AST/DeclTest.cpp | 310 + 4 files changed, 321 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext
[clang] [X86] Define __APX_F__ when APX is enabled. (PR #88343)
https://github.com/FreddyLeaf closed https://github.com/llvm/llvm-project/pull/88343 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] db2fb3d - [X86] Define __APX_F__ when APX is enabled. (#88343)
Author: Freddy Ye Date: 2024-04-11T16:57:32+08:00 New Revision: db2fb3d96b217f0d2e139e7816c98d9f95974f25 URL: https://github.com/llvm/llvm-project/commit/db2fb3d96b217f0d2e139e7816c98d9f95974f25 DIFF: https://github.com/llvm/llvm-project/commit/db2fb3d96b217f0d2e139e7816c98d9f95974f25.diff LOG: [X86] Define __APX_F__ when APX is enabled. (#88343) Relate gcc patch: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/648789.html Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/test/Preprocessor/x86_target_features.c Removed: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 1966af17904d65..bf1767c87fe1ce 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -954,6 +954,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__CCMP__"); if (HasCF) Builder.defineMacro("__CF__"); + // Condition here is aligned with the feature set of mapxf in Options.td + if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD) +Builder.defineMacro("__APX_F__"); // Each case falls through to the previous one here. switch (SSELevel) { diff --git a/clang/test/Preprocessor/x86_target_features.c b/clang/test/Preprocessor/x86_target_features.c index a1882043910f76..5602c59158fe5a 100644 --- a/clang/test/Preprocessor/x86_target_features.c +++ b/clang/test/Preprocessor/x86_target_features.c @@ -803,7 +803,8 @@ // RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=ndd -x c -E -dM -o - %s | FileCheck --check-prefix=NDD %s // RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=ccmp -x c -E -dM -o - %s | FileCheck --check-prefix=CCMP %s // RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapx-features=cf -x c -E -dM -o - %s | FileCheck --check-prefix=CF %s -// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapxf -x c -E -dM -o - %s | FileCheck --check-prefixes=EGPR,PUSH2POP2,PPX,NDD %s +// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mapxf -x c -E -dM -o - %s | FileCheck --check-prefixes=EGPR,PUSH2POP2,PPX,NDD,APXF %s +// APXF: #define __APX_F__ 1 // CCMP: #define __CCMP__ 1 // CF: #define __CF__ 1 // EGPR: #define __EGPR__ 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)
https://github.com/lawben updated https://github.com/llvm/llvm-project/pull/87750 >From a56d6eacc7053a0dac38c5b7ba21d2e37a790baa Mon Sep 17 00:00:00 2001 From: Lawrence Benson Date: Fri, 5 Apr 2024 09:15:30 +0200 Subject: [PATCH 1/2] [AARCH64,RISCV] Add support for scalable vectors in __builtin_reduce* functions. --- clang/include/clang/AST/Type.h | 4 ++ clang/lib/AST/Type.cpp | 12 + clang/lib/CodeGen/CGBuiltin.cpp | 10 +++- clang/lib/Sema/SemaChecking.cpp | 23 +++-- clang/test/CodeGen/builtins-reduction-math.c | 53 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 99f45d518c7960..a9f888a037109b 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2172,6 +2172,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// 'riscv_rvv_vector_bits' type attribute as VectorType. QualType getRVVEltType(const ASTContext &Ctx) const; + /// Returns the representative type for the element of a sizeless vector + /// builtin type. + QualType getSizelessVectorEltType(const ASTContext &Ctx) const; + /// Types are partitioned into 3 broad categories (C99 6.2.5p1): /// object types, function types, and incomplete types. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index cb22c91a12aa89..dcba47de0cc7ae 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2510,6 +2510,18 @@ bool Type::isSveVLSBuiltinType() const { return false; } +QualType Type::getSizelessVectorEltType(const ASTContext &Ctx) const { + assert(isSizelessVectorType() && "Must be sizeless vector type"); + // Currently supports SVE and RVV + if (isSVESizelessBuiltinType()) +return getSveEltType(Ctx); + + if (isRVVSizelessBuiltinType()) +return getRVVEltType(Ctx); + + llvm_unreachable("Unhandled type"); +} + QualType Type::getSveEltType(const ASTContext &Ctx) const { assert(isSveVLSBuiltinType() && "unsupported type!"); diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2537e715b63ee4..e76a211242fdd7 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -3868,9 +3868,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } case Builtin::BI__builtin_reduce_max: { -auto GetIntrinsicID = [](QualType QT) { +auto GetIntrinsicID = [this](QualType QT) { if (auto *VecTy = QT->getAs()) QT = VecTy->getElementType(); + else if (QT->isSizelessVectorType()) +QT = QT->getSizelessVectorEltType(CGM.getContext()); + if (QT->isSignedIntegerType()) return llvm::Intrinsic::vector_reduce_smax; if (QT->isUnsignedIntegerType()) @@ -3883,9 +3886,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } case Builtin::BI__builtin_reduce_min: { -auto GetIntrinsicID = [](QualType QT) { +auto GetIntrinsicID = [this](QualType QT) { if (auto *VecTy = QT->getAs()) QT = VecTy->getElementType(); + else if (QT->isSizelessVectorType()) +QT = QT->getSizelessVectorEltType(CGM.getContext()); + if (QT->isSignedIntegerType()) return llvm::Intrinsic::vector_reduce_smin; if (QT->isUnsignedIntegerType()) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 3dcd18b3afc8b4..6d45dd8bb7ed97 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3166,13 +3166,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, const Expr *Arg = TheCall->getArg(0); const auto *TyA = Arg->getType()->getAs(); -if (!TyA) { + +QualType ElTy; +if (TyA) + ElTy = TyA->getElementType(); +else if (Arg->getType()->isSizelessVectorType()) + ElTy = Arg->getType()->getSizelessVectorEltType(Context); + +if (ElTy.isNull()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) << 1 << /* vector ty*/ 4 << Arg->getType(); return ExprError(); } -TheCall->setType(TyA->getElementType()); +TheCall->setType(ElTy); break; } @@ -3188,12 +3195,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, const Expr *Arg = TheCall->getArg(0); const auto *TyA = Arg->getType()->getAs(); -if (!TyA || !TyA->getElementType()->isIntegerType()) { + +QualType ElTy; +if (TyA) + ElTy = TyA->getElementType(); +else if (Arg->getType()->isSizelessVectorType()) + ElTy = Arg->getType()->getSizelessVectorEltType(Context); + +if (ElTy.isNull() || !ElTy->isIntegerType()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) << 1 << /* vector of integers */ 6 << Arg->getType(); return ExprError(); } -TheCall->setTyp
[clang] [analyzer] Use CDM::CLibrary instead of isGlobalCFunction() (PR #88267)
https://github.com/NagyDonat closed https://github.com/llvm/llvm-project/pull/88267 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fe3b20d - [analyzer] Use CDM::CLibrary instead of isGlobalCFunction() (#88267)
Author: NagyDonat Date: 2024-04-11T10:44:35+02:00 New Revision: fe3b20d5ab4b47823fb48ad7cfbc47b8224ce826 URL: https://github.com/llvm/llvm-project/commit/fe3b20d5ab4b47823fb48ad7cfbc47b8224ce826 DIFF: https://github.com/llvm/llvm-project/commit/fe3b20d5ab4b47823fb48ad7cfbc47b8224ce826.diff LOG: [analyzer] Use CDM::CLibrary instead of isGlobalCFunction() (#88267) This commit updates several checkers to use call descriptions with the matching mode `CDM::CLibrary` instead of checking `Call.isGlobalCFunction()` after performing the match. This resolves several TODOs in various checkers. Note that both matching with `CDM::CLibrary` and calling `isGlobalCFunction` leads to `CheckerContext::isCLibraryFunction()` checks (so this change is close to being NFC), but if it is used via the matching mode then the checker can automatically recognize the builtin variants of the matched functions. I'll also make similar changes in GenericTaintChecker, but that checker has separate and inconsistent rules for handling the normal and the builtin variant of several functions (e.g. `memcpy` and `__builtin_memcpy`), so I'll put those changes into a separate commit. Added: Modified: clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index c72a97cc01e914..80f128b917b200 100644 --- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -542,10 +542,10 @@ namespace { class CFRetainReleaseChecker : public Checker { mutable APIMisuse BT{this, "null passed to CF memory management function"}; const CallDescriptionSet ModelledCalls = { - {{"CFRetain"}, 1}, - {{"CFRelease"}, 1}, - {{"CFMakeCollectable"}, 1}, - {{"CFAutorelease"}, 1}, + {CDM::CLibrary, {"CFRetain"}, 1}, + {CDM::CLibrary, {"CFRelease"}, 1}, + {CDM::CLibrary, {"CFMakeCollectable"}, 1}, + {CDM::CLibrary, {"CFAutorelease"}, 1}, }; public: @@ -555,10 +555,6 @@ class CFRetainReleaseChecker : public Checker { void CFRetainReleaseChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const { - // TODO: Make this check part of CallDescription. - if (!Call.isGlobalCFunction()) -return; - // Check if we called CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. if (!ModelledCalls.contains(Call)) return; diff --git a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp index fa8572cf85edfe..86530086ff1b27 100644 --- a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -87,7 +87,8 @@ class PthreadLockChecker : public Checker PThreadCallbacks = { // Init. - {{{"pthread_mutex_init"}, 2}, &PthreadLockChecker::InitAnyLock}, + {{CDM::CLibrary, {"pthread_mutex_init"}, 2}, + &PthreadLockChecker::InitAnyLock}, // TODO: pthread_rwlock_init(2 arguments). // TODO: lck_mtx_init(3 arguments). // TODO: lck_mtx_alloc_init(2 arguments) => returns the mutex. @@ -95,74 +96,106 @@ class PthreadLockChecker : public Checker returns the mutex. // Acquire. - {{{"pthread_mutex_lock"}, 1}, &PthreadLockChecker::AcquirePthreadLock}, - {{{"pthread_rwlock_rdlock"}, 1}, &PthreadLockChecker::AcquirePthreadLock}, - {{{"pthread_rwlock_wrlock"}, 1}, &PthreadLockChecker::AcquirePthreadLock}, - {{{"lck_mtx_lock"}, 1}, &PthreadLockChecker::AcquireXNULock}, - {{{"lck_rw_lock_exclusive"}, 1}, &PthreadLockChecker::AcquireXNULock}, - {{{"lck_rw_lock_shared"}, 1}, &PthreadLockChecker::AcquireXNULock}, + {{CDM::CLibrary, {"pthread_mutex_lock"}, 1}, + &PthreadLockChecker::AcquirePthreadLock}, + {{CDM::CLibrary, {"pthread_rwlock_rdlock"}, 1}, + &PthreadLockChecker::AcquirePthreadLock}, + {{CDM::CLibrary, {"pthread_rwlock_wrlock"}, 1}, + &PthreadLockChecker::AcquirePthreadLock}, + {{CDM::CLibrary, {"lck_mtx_lock"}, 1}, + &PthreadLockChecker::AcquireXNULock}, + {{CDM::CLibrary, {"lck_rw_lock_exclusive"}, 1}, + &PthreadLockChecker::AcquireXNULock}, + {{CDM::CLibrary, {"lck_rw_lock_shared"}, 1}, + &PthreadLockChecker::AcquireXNULock}, // Try. - {{{"pthread_mutex_trylock"}, 1}, &PthreadLockChecker::TryPthreadLock}, - {{{"pthread_rwlock_tryrdlock"}, 1}, &PthreadLockChecker::TryPthreadLock}, - {{{"pthread_rwlock_trywrloc
[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)
https://github.com/jcsxky ready_for_review https://github.com/llvm/llvm-project/pull/85198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/85198 >From a7bc05667f7280958e68fd82e01b620e18e4203c Mon Sep 17 00:00:00 2001 From: huqizhi Date: Thu, 14 Mar 2024 16:32:36 +0800 Subject: [PATCH] [Clang][Sema] Fix issue on requires expression with templated base class member function --- clang/docs/ReleaseNotes.rst| 1 + clang/lib/Sema/SemaExpr.cpp| 3 ++- clang/test/SemaCXX/PR84020.cpp | 23 +++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 clang/test/SemaCXX/PR84020.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c4a4893aec5cd6..e40090be6213bd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -528,6 +528,7 @@ Bug Fixes to C++ Support - Clang now correctly tracks type dependence of by-value captures in lambdas with an explicit object parameter. Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), (#GH86398), and (#GH86399). +- Fix a crash in requires expression with templated base class member function. Fixes (#GH84020). Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 4d4ef9b16381b4..99b938bb1ba26c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7735,7 +7735,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, } if (CXXMethodDecl *Method = dyn_cast_or_null(FDecl)) -if (Method->isImplicitObjectMemberFunction()) +if (!isa(CurContext) && +Method->isImplicitObjectMemberFunction()) return ExprError(Diag(LParenLoc, diag::err_member_call_without_object) << Fn->getSourceRange() << 0); diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp new file mode 100644 index 00..8ea5dcc4527ae7 --- /dev/null +++ b/clang/test/SemaCXX/PR84020.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// RUN: %clang_cc1 -std=c++23 -verify %s +// expected-no-diagnostics + +struct B { +template +void foo(); + +void bar(); +}; + +template +struct A : T { +auto foo() { +static_assert(requires { T::template foo(); }); +static_assert(requires { T::bar(); }); +} +}; + +int main() { +A a; +a.foo(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Fix issue on requires expression with templated base class member function (PR #85198)
https://github.com/jcsxky edited https://github.com/llvm/llvm-project/pull/85198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)
https://github.com/lawben updated https://github.com/llvm/llvm-project/pull/87750 >From a56d6eacc7053a0dac38c5b7ba21d2e37a790baa Mon Sep 17 00:00:00 2001 From: Lawrence Benson Date: Fri, 5 Apr 2024 09:15:30 +0200 Subject: [PATCH] [AARCH64,RISCV] Add support for scalable vectors in __builtin_reduce* functions. --- clang/include/clang/AST/Type.h | 4 ++ clang/lib/AST/Type.cpp | 12 + clang/lib/CodeGen/CGBuiltin.cpp | 10 +++- clang/lib/Sema/SemaChecking.cpp | 23 +++-- clang/test/CodeGen/builtins-reduction-math.c | 53 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 99f45d518c7960..a9f888a037109b 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2172,6 +2172,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// 'riscv_rvv_vector_bits' type attribute as VectorType. QualType getRVVEltType(const ASTContext &Ctx) const; + /// Returns the representative type for the element of a sizeless vector + /// builtin type. + QualType getSizelessVectorEltType(const ASTContext &Ctx) const; + /// Types are partitioned into 3 broad categories (C99 6.2.5p1): /// object types, function types, and incomplete types. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index cb22c91a12aa89..dcba47de0cc7ae 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2510,6 +2510,18 @@ bool Type::isSveVLSBuiltinType() const { return false; } +QualType Type::getSizelessVectorEltType(const ASTContext &Ctx) const { + assert(isSizelessVectorType() && "Must be sizeless vector type"); + // Currently supports SVE and RVV + if (isSVESizelessBuiltinType()) +return getSveEltType(Ctx); + + if (isRVVSizelessBuiltinType()) +return getRVVEltType(Ctx); + + llvm_unreachable("Unhandled type"); +} + QualType Type::getSveEltType(const ASTContext &Ctx) const { assert(isSveVLSBuiltinType() && "unsupported type!"); diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2537e715b63ee4..e76a211242fdd7 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -3868,9 +3868,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } case Builtin::BI__builtin_reduce_max: { -auto GetIntrinsicID = [](QualType QT) { +auto GetIntrinsicID = [this](QualType QT) { if (auto *VecTy = QT->getAs()) QT = VecTy->getElementType(); + else if (QT->isSizelessVectorType()) +QT = QT->getSizelessVectorEltType(CGM.getContext()); + if (QT->isSignedIntegerType()) return llvm::Intrinsic::vector_reduce_smax; if (QT->isUnsignedIntegerType()) @@ -3883,9 +3886,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } case Builtin::BI__builtin_reduce_min: { -auto GetIntrinsicID = [](QualType QT) { +auto GetIntrinsicID = [this](QualType QT) { if (auto *VecTy = QT->getAs()) QT = VecTy->getElementType(); + else if (QT->isSizelessVectorType()) +QT = QT->getSizelessVectorEltType(CGM.getContext()); + if (QT->isSignedIntegerType()) return llvm::Intrinsic::vector_reduce_smin; if (QT->isUnsignedIntegerType()) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 3dcd18b3afc8b4..6d45dd8bb7ed97 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3166,13 +3166,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, const Expr *Arg = TheCall->getArg(0); const auto *TyA = Arg->getType()->getAs(); -if (!TyA) { + +QualType ElTy; +if (TyA) + ElTy = TyA->getElementType(); +else if (Arg->getType()->isSizelessVectorType()) + ElTy = Arg->getType()->getSizelessVectorEltType(Context); + +if (ElTy.isNull()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) << 1 << /* vector ty*/ 4 << Arg->getType(); return ExprError(); } -TheCall->setType(TyA->getElementType()); +TheCall->setType(ElTy); break; } @@ -3188,12 +3195,20 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, const Expr *Arg = TheCall->getArg(0); const auto *TyA = Arg->getType()->getAs(); -if (!TyA || !TyA->getElementType()->isIntegerType()) { + +QualType ElTy; +if (TyA) + ElTy = TyA->getElementType(); +else if (Arg->getType()->isSizelessVectorType()) + ElTy = Arg->getType()->getSizelessVectorEltType(Context); + +if (ElTy.isNull() || !ElTy->isIntegerType()) { Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) << 1 << /* vector of integers */ 6 << Arg->getType(); return ExprError(); } -TheCall->setType(Ty
[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)
lawben wrote: @efriedma-quic While there is no target independent way to create a type, it is possible to pass this type around. This is the use case I'm thinking of. So if a user has one `#ifdef` block to get the right `using VecT = ...` for the platform, they can use that `VecT` all over the place, regardless of the exact type. I'll add this to the docs and release note. https://github.com/llvm/llvm-project/pull/87750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/76893 >From 169ef33f585b964d9af7a7628919271245f318fc Mon Sep 17 00:00:00 2001 From: wangpc Date: Thu, 4 Jan 2024 13:05:53 +0800 Subject: [PATCH 1/2] [RISCV] Add B extension It seems that we have `B` extension again: https://github.com/riscv/riscv-b According to the spec, `B` extension represents the collection of the `Zba`, `Zbb`, `Zbs` extensions. --- clang/test/Driver/riscv-arch.c | 5 - clang/test/Preprocessor/riscv-target-features.c | 12 llvm/docs/RISCVUsage.rst| 1 + llvm/lib/Support/RISCVISAInfo.cpp | 3 +++ llvm/lib/Target/RISCV/RISCVFeatures.td | 8 llvm/test/CodeGen/RISCV/attributes.ll | 4 llvm/unittests/Support/RISCVISAInfoTest.cpp | 6 ++ 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c index 8399b4e97f86d5..8e48ed9160992d 100644 --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -231,11 +231,6 @@ // RV32-STD: error: invalid arch name 'rv32imqc', // RV32-STD: unsupported standard user-level extension 'q' -// RUN: not %clang --target=riscv32-unknown-elf -march=rv32ib -### %s \ -// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-B %s -// RV32-B: error: invalid arch name 'rv32ib', -// RV32-B: unsupported standard user-level extension 'b' - // RUN: not %clang --target=riscv32-unknown-elf -march=rv32xabc -### %s \ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s // RV32X: error: invalid arch name 'rv32xabc', diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index ec7764bb538189..dfdef72cb1e755 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -7,6 +7,7 @@ // CHECK-NOT: __riscv_64e {{.*$}} // CHECK-NOT: __riscv_a {{.*$}} // CHECK-NOT: __riscv_atomic +// CHECK-NOT: __riscv_b {{.*$}} // CHECK-NOT: __riscv_c {{.*$}} // CHECK-NOT: __riscv_compressed {{.*$}} // CHECK-NOT: __riscv_d {{.*$}} @@ -191,6 +192,17 @@ // CHECK-A-EXT: __riscv_a 2001000{{$}} // CHECK-A-EXT: __riscv_atomic 1 +// RUN: %clang --target=riscv32-unknown-linux-gnu \ +// RUN: -march=rv32ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// RUN: %clang --target=riscv64-unknown-linux-gnu \ +// RUN: -march=rv64ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// CHECK-B-EXT: __riscv_b 100{{$}} +// CHECK-B-EXT: __riscv_zba 100{{$}} +// CHECK-B-EXT: __riscv_zbb 100{{$}} +// CHECK-B-EXT: __riscv_zbs 100{{$}} + // RUN: %clang --target=riscv32-unknown-linux-gnu \ // RUN: -march=rv32ic -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index 6f5eba263def43..232604788f9972 100644 --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -85,6 +85,7 @@ on support follow. Extension Status = ``A`` Supported + ``B`` Supported ``C`` Supported ``D`` Supported ``F`` Supported diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp index 7a19d24d1ff483..99962501153b0e 100644 --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -52,6 +52,7 @@ static const char *RISCVGImplications[] = { // NOTE: This table should be sorted alphabetically by extension name. static const RISCVSupportedExtension SupportedExtensions[] = { {"a", {2, 1}}, +{"b", {1, 0}}, {"c", {2, 0}}, {"d", {2, 2}}, {"e", {2, 0}}, @@ -1106,6 +1107,7 @@ Error RISCVISAInfo::checkDependency() { return Error::success(); } +static const char *ImpliedExtsB[] = {"zba", "zbb", "zbs"}; static const char *ImpliedExtsD[] = {"f"}; static const char *ImpliedExtsF[] = {"zicsr"}; static const char *ImpliedExtsV[] = {"zvl128b", "zve64d"}; @@ -1181,6 +1183,7 @@ struct ImpliedExtsEntry { // Note: The table needs to be sorted by name. static constexpr ImpliedExtsEntry ImpliedExts[] = { +{{"b"}, {ImpliedExtsB}}, {{"d"}, {ImpliedExtsD}}, {{"f"}, {ImpliedExtsF}}, {{"v"}, {ImpliedExtsV}}, diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 794455aa730400..33541be37537df 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -430,6 +430,14 @@ def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">, // Bitmanip Extensions for Cryptography Extensions +def FeatureStdExtB +: SubtargetFeature<"b", "HasStdExtB", "true", + "'B' (the collection of the Zba, Zbb, Zbs e
[clang] [llvm] [ARM] Armv8-R does not require fp64 or neon. (PR #88287)
https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/88287 >From 136ed3311445f498a9314a0feea0302327d5cf85 Mon Sep 17 00:00:00 2001 From: Chris Copeland Date: Fri, 5 Apr 2024 22:40:46 -0700 Subject: [PATCH] [ARM] Armv8-R does not require fp64 or neon. --- clang/test/Preprocessor/arm-target-features.c | 2 +- llvm/include/llvm/TargetParser/ARMTargetParser.def | 2 +- llvm/lib/Target/ARM/ARM.td | 6 +++--- llvm/test/Analysis/CostModel/ARM/arith.ll | 2 +- llvm/test/Analysis/CostModel/ARM/cast.ll | 4 ++-- llvm/test/Analysis/CostModel/ARM/cast_ldst.ll | 4 ++-- llvm/test/Analysis/CostModel/ARM/cmps.ll | 4 ++-- llvm/test/Analysis/CostModel/ARM/divrem.ll | 2 +- llvm/test/CodeGen/ARM/build-attributes.ll | 4 ++-- llvm/test/CodeGen/ARM/fpconv.ll| 4 ++-- llvm/test/CodeGen/ARM/half.ll | 4 ++-- llvm/test/CodeGen/ARM/pr42638-VMOVRRDCombine.ll| 2 +- llvm/test/CodeGen/ARM/useaa.ll | 4 ++-- llvm/unittests/TargetParser/TargetParserTest.cpp | 2 +- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clang/test/Preprocessor/arm-target-features.c b/clang/test/Preprocessor/arm-target-features.c index 236c9f2479b705..ad418bf6bcdcbf 100644 --- a/clang/test/Preprocessor/arm-target-features.c +++ b/clang/test/Preprocessor/arm-target-features.c @@ -96,7 +96,7 @@ // CHECK-V8R-ALLOW-FP-INSTR: #define __ARM_FEATURE_CRC32 1 // CHECK-V8R-ALLOW-FP-INSTR: #define __ARM_FEATURE_DIRECTED_ROUNDING 1 // CHECK-V8R-ALLOW-FP-INSTR: #define __ARM_FEATURE_NUMERIC_MAXMIN 1 -// CHECK-V8R-ALLOW-FP-INSTR: #define __ARM_FP 0xe +// CHECK-V8R-ALLOW-FP-INSTR: #define __ARM_FP 0x6 // RUN: %clang -target armv7a-none-linux-gnu -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V7 %s // CHECK-V7: #define __ARMEL__ 1 diff --git a/llvm/include/llvm/TargetParser/ARMTargetParser.def b/llvm/include/llvm/TargetParser/ARMTargetParser.def index b821d224d7a82c..dee0f383b4b234 100644 --- a/llvm/include/llvm/TargetParser/ARMTargetParser.def +++ b/llvm/include/llvm/TargetParser/ARMTargetParser.def @@ -329,7 +329,7 @@ ARM_CPU_NAME("cortex-r7", ARMV7R, FK_VFPV3_D16_FP16, false, (ARM::AEK_MP | ARM::AEK_HWDIVARM)) ARM_CPU_NAME("cortex-r8", ARMV7R, FK_VFPV3_D16_FP16, false, (ARM::AEK_MP | ARM::AEK_HWDIVARM)) -ARM_CPU_NAME("cortex-r52", ARMV8R, FK_NEON_FP_ARMV8, true, ARM::AEK_NONE) +ARM_CPU_NAME("cortex-r52", ARMV8R, FK_FPV5_SP_D16, true, ARM::AEK_NONE) ARM_CPU_NAME("sc300", ARMV7M, FK_NONE, false, ARM::AEK_NONE) ARM_CPU_NAME("cortex-m3", ARMV7M, FK_NONE, true, ARM::AEK_NONE) ARM_CPU_NAME("cortex-m4", ARMV7EM, FK_FPV4_SP_D16, true, ARM::AEK_NONE) diff --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td index 66596dbda83c95..6ee8c0540e6488 100644 --- a/llvm/lib/Target/ARM/ARM.td +++ b/llvm/lib/Target/ARM/ARM.td @@ -1167,9 +1167,7 @@ def ARMv8r: Architecture<"armv8-r", "ARMv8r", [HasV8Ops, FeatureDSP, FeatureCRC, FeatureMP, - FeatureVirtualization, - FeatureFPARMv8, - FeatureNEON]>; + FeatureVirtualization]>; def ARMv8mBaseline : Architecture<"armv8-m.base", "ARMv8mBaseline", [HasV8MBaselineOps, @@ -1726,6 +1724,8 @@ def : ProcNoItin<"kryo", [ARMv8a, ProcKryo, FeatureCRC]>; def : ProcessorModel<"cortex-r52", CortexR52Model, [ARMv8r, ProcR52, + FeatureFPARMv8_D16_SP, + FeatureFP16, FeatureUseMISched, FeatureFPAO]>; diff --git a/llvm/test/Analysis/CostModel/ARM/arith.ll b/llvm/test/Analysis/CostModel/ARM/arith.ll index 3a137a5af36664..8f173596c3b9a0 100644 --- a/llvm/test/Analysis/CostModel/ARM/arith.ll +++ b/llvm/test/Analysis/CostModel/ARM/arith.ll @@ -4,7 +4,7 @@ ; RUN: opt -passes="print" 2>&1 -disable-output -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve,+mve4beat < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-MVE4 ; RUN: opt -passes="print" 2>&1 -disable-output -mtriple=thumbv8m.main-none-eabi < %s | FileCheck %s --check-prefix=CHECK-V8M-MAIN ; RUN: opt -passes="print" 2>&1 -disable-output -mtriple=thumbv8m.base-none-eabi < %s | FileCheck %s --check-prefix=CHECK-V8M-BASE -; RUN: opt -passes="print" 2>&1 -disable-output
[clang] [llvm] [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg` (PR #88299)
nikic wrote: > > Can the implementation of foldFBinOpOfIntCastsFromSign be simplified to use > > nneg instead of KnownBits after this change? > > yeah we could. Should I do a survey of existing folds first to ensure we > don't incorrectly keep flags (like with `trunc nuw/nsw`) before integrating > too deeply? I don't think this is important for uitofp nneg, mainly because we only have very few folds for it, so there's just not a great deal of potential for things to go wrong... https://github.com/llvm/llvm-project/pull/88299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)
wzssyqa wrote: > It's better to do some normalization in CMake. I will try to work in CMake, then. https://github.com/llvm/llvm-project/pull/88334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/88334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)
MaskRay wrote: ``` cmake -Sllvm -B/tmp/out/d-a64 -G Ninja -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" -DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_C_COMPILER=~/Stable/bin/clang -DCMAKE_CXX_COMPILER=~/Stable/bin/clang++ -DCMAKE_BUILD_TYPE=Debug ninja -C /tmp/out/d-a64 builtins ``` gives me `/tmp/out/d-a64/lib/clang/19/lib/aarch64-linux-gnu/clang_rt.*`. Sanitizer targets are not available. I haven't investigated why. Anyhow, I posted a similar but probably more complete clang driver patch: https://reviews.llvm.org/D110663 , but I concluded that detecting Debian-style `x86_64-linux-gnu` is not a good idea. It's better to do some normalization in CMake. https://github.com/llvm/llvm-project/pull/88334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)
https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/85786 >From 239b404203c66ab5336ffdfb45969a50c439a1c0 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Tue, 19 Mar 2024 06:22:17 -0700 Subject: [PATCH 01/11] [RISCV][FMV] Support target_clones --- clang/include/clang/Basic/TargetInfo.h| 3 +- clang/lib/AST/ASTContext.cpp | 9 ++ clang/lib/Basic/Targets/RISCV.cpp | 10 +- clang/lib/Basic/Targets/RISCV.h | 2 + clang/lib/CodeGen/CodeGenFunction.cpp | 102 - clang/lib/CodeGen/CodeGenFunction.h | 3 + clang/lib/CodeGen/CodeGenModule.cpp | 2 + clang/lib/CodeGen/Targets/RISCV.cpp | 23 +++ clang/lib/Sema/SemaDeclAttr.cpp | 22 +++ clang/test/CodeGen/attr-target-clones-riscv.c | 135 + .../CodeGenCXX/attr-target-clones-riscv.cpp | 136 ++ .../test/SemaCXX/attr-target-clones-riscv.cpp | 19 +++ 12 files changed, 462 insertions(+), 4 deletions(-) create mode 100644 clang/test/CodeGen/attr-target-clones-riscv.c create mode 100644 clang/test/CodeGenCXX/attr-target-clones-riscv.cpp create mode 100644 clang/test/SemaCXX/attr-target-clones-riscv.cpp diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 374595edd2ce4a..aa48596fbce07d 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1445,7 +1445,8 @@ class TargetInfo : public TransferrableTargetInfo, /// Identify whether this target supports multiversioning of functions, /// which requires support for cpu_supports and cpu_is functionality. bool supportsMultiVersioning() const { -return getTriple().isX86() || getTriple().isAArch64(); +return getTriple().isX86() || getTriple().isAArch64() || + getTriple().isRISCV(); } /// Identify whether this target supports IFuncs. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5a8fae76a43a4d..0fd75e0b36b123 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13636,6 +13636,15 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap, Features.insert(Features.begin(), Target->getTargetOpts().FeaturesAsWritten.begin(), Target->getTargetOpts().FeaturesAsWritten.end()); +} else if (Target->getTriple().isRISCV()) { + if (VersionStr != "default") { +ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(VersionStr); +Features.insert(Features.begin(), ParsedAttr.Features.begin(), +ParsedAttr.Features.end()); + } + Features.insert(Features.begin(), + Target->getTargetOpts().FeaturesAsWritten.begin(), + Target->getTargetOpts().FeaturesAsWritten.end()); } else { if (VersionStr.starts_with("arch=")) TargetCPU = VersionStr.drop_front(sizeof("arch=") - 1); diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index a6d4af2b88111a..8e9132c9191a3c 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -257,7 +257,7 @@ bool RISCVTargetInfo::initFeatureMap( // If a target attribute specified a full arch string, override all the ISA // extension target features. - const auto I = llvm::find(FeaturesVec, "__RISCV_TargetAttrNeedOverride"); + const auto I = llvm::find(FeaturesVec, "+__RISCV_TargetAttrNeedOverride"); if (I != FeaturesVec.end()) { std::vector OverrideFeatures(std::next(I), FeaturesVec.end()); @@ -366,6 +366,12 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector &Features, return true; } +bool RISCVTargetInfo::isValidFeatureName(StringRef Feature) const { + if (Feature.starts_with("__RISCV_TargetAttrNeedOverride")) +return true; + return llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature); +} + bool RISCVTargetInfo::isValidCPUName(StringRef Name) const { bool Is64Bit = getTriple().isArch64Bit(); return llvm::RISCV::parseCPU(Name, Is64Bit); @@ -390,7 +396,7 @@ void RISCVTargetInfo::fillValidTuneCPUList( static void handleFullArchString(StringRef FullArchStr, std::vector &Features) { - Features.push_back("__RISCV_TargetAttrNeedOverride"); + Features.push_back("+__RISCV_TargetAttrNeedOverride"); auto RII = llvm::RISCVISAInfo::parseArchString( FullArchStr, /* EnableExperimentalExtension */ true); if (llvm::errorToBool(RII.takeError())) { diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index bfbdafb682c851..ef8f59185d753c 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -106,6 +106,8 @@ class RISCVTargetInfo : public TargetInfo { bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override; + bool
[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)
wzssyqa wrote: > > @aeubanks The problem is that in your configure, the libclang_rt is placed > > in `/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a`, > > instead of > > `/lib/clang/19/lib/arm-unknown-linux-android/libclang_rt.builtins.a`. > > The point is that both locations were supposed to be accepted, as they were > before - this PR was not supposed to be a policy change that affects that. Yes. After the patch, both locations are accepted. This patch doesn't break it. The current problem is that in some test cases, `-resource-dir` option are missing. For details: 1. with `--sysroot` option, clang will try to find libclang_rt there. In the failure case, it fails to find. 2. then, clang try to look for libclang_rt from `lib/clang/19/lib/arm-unknown-android/libclang_rt.builtin.a`, and failed. 3. clang try to look for libclang_rt from `lib/clang/19/lib/linux/libclang_rt.builtin-arm-android.a`, and success. Thus the file name of libclang_rt is different with the one in test cases. 4. If 3) failed, clang will fallback to `lib/clang/19/lib/arm-unknown-android/libclang_rt.builtin.a`, then test case success. So, we can add `-resource-dir` to skip 3 for test case. https://github.com/llvm/llvm-project/pull/87866 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/76893 >From 169ef33f585b964d9af7a7628919271245f318fc Mon Sep 17 00:00:00 2001 From: wangpc Date: Thu, 4 Jan 2024 13:05:53 +0800 Subject: [PATCH] [RISCV] Add B extension It seems that we have `B` extension again: https://github.com/riscv/riscv-b According to the spec, `B` extension represents the collection of the `Zba`, `Zbb`, `Zbs` extensions. --- clang/test/Driver/riscv-arch.c | 5 - clang/test/Preprocessor/riscv-target-features.c | 12 llvm/docs/RISCVUsage.rst| 1 + llvm/lib/Support/RISCVISAInfo.cpp | 3 +++ llvm/lib/Target/RISCV/RISCVFeatures.td | 8 llvm/test/CodeGen/RISCV/attributes.ll | 4 llvm/unittests/Support/RISCVISAInfoTest.cpp | 6 ++ 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c index 8399b4e97f86d5..8e48ed9160992d 100644 --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -231,11 +231,6 @@ // RV32-STD: error: invalid arch name 'rv32imqc', // RV32-STD: unsupported standard user-level extension 'q' -// RUN: not %clang --target=riscv32-unknown-elf -march=rv32ib -### %s \ -// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-B %s -// RV32-B: error: invalid arch name 'rv32ib', -// RV32-B: unsupported standard user-level extension 'b' - // RUN: not %clang --target=riscv32-unknown-elf -march=rv32xabc -### %s \ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s // RV32X: error: invalid arch name 'rv32xabc', diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index ec7764bb538189..dfdef72cb1e755 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -7,6 +7,7 @@ // CHECK-NOT: __riscv_64e {{.*$}} // CHECK-NOT: __riscv_a {{.*$}} // CHECK-NOT: __riscv_atomic +// CHECK-NOT: __riscv_b {{.*$}} // CHECK-NOT: __riscv_c {{.*$}} // CHECK-NOT: __riscv_compressed {{.*$}} // CHECK-NOT: __riscv_d {{.*$}} @@ -191,6 +192,17 @@ // CHECK-A-EXT: __riscv_a 2001000{{$}} // CHECK-A-EXT: __riscv_atomic 1 +// RUN: %clang --target=riscv32-unknown-linux-gnu \ +// RUN: -march=rv32ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// RUN: %clang --target=riscv64-unknown-linux-gnu \ +// RUN: -march=rv64ib -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// CHECK-B-EXT: __riscv_b 100{{$}} +// CHECK-B-EXT: __riscv_zba 100{{$}} +// CHECK-B-EXT: __riscv_zbb 100{{$}} +// CHECK-B-EXT: __riscv_zbs 100{{$}} + // RUN: %clang --target=riscv32-unknown-linux-gnu \ // RUN: -march=rv32ic -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index 6f5eba263def43..232604788f9972 100644 --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -85,6 +85,7 @@ on support follow. Extension Status = ``A`` Supported + ``B`` Supported ``C`` Supported ``D`` Supported ``F`` Supported diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp index 7a19d24d1ff483..99962501153b0e 100644 --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -52,6 +52,7 @@ static const char *RISCVGImplications[] = { // NOTE: This table should be sorted alphabetically by extension name. static const RISCVSupportedExtension SupportedExtensions[] = { {"a", {2, 1}}, +{"b", {1, 0}}, {"c", {2, 0}}, {"d", {2, 2}}, {"e", {2, 0}}, @@ -1106,6 +1107,7 @@ Error RISCVISAInfo::checkDependency() { return Error::success(); } +static const char *ImpliedExtsB[] = {"zba", "zbb", "zbs"}; static const char *ImpliedExtsD[] = {"f"}; static const char *ImpliedExtsF[] = {"zicsr"}; static const char *ImpliedExtsV[] = {"zvl128b", "zve64d"}; @@ -1181,6 +1183,7 @@ struct ImpliedExtsEntry { // Note: The table needs to be sorted by name. static constexpr ImpliedExtsEntry ImpliedExts[] = { +{{"b"}, {ImpliedExtsB}}, {{"d"}, {ImpliedExtsD}}, {{"f"}, {ImpliedExtsF}}, {{"v"}, {ImpliedExtsV}}, diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td index 794455aa730400..33541be37537df 100644 --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -430,6 +430,14 @@ def HasStdExtZbs : Predicate<"Subtarget->hasStdExtZbs()">, // Bitmanip Extensions for Cryptography Extensions +def FeatureStdExtB +: SubtargetFeature<"b", "HasStdExtB", "true", + "'B' (the collection of the Zba, Zbb, Zbs exten
[clang] 85bc6de - Revert "Use setup_host_tool for clang-ast-dump, fixes 76707"
Author: Timm Bäder Date: 2024-04-11T09:50:03+02:00 New Revision: 85bc6de67ef28cd203da0c5abc1485609bea989c URL: https://github.com/llvm/llvm-project/commit/85bc6de67ef28cd203da0c5abc1485609bea989c DIFF: https://github.com/llvm/llvm-project/commit/85bc6de67ef28cd203da0c5abc1485609bea989c.diff LOG: Revert "Use setup_host_tool for clang-ast-dump, fixes 76707" This reverts commit b4adb42151bbfa80be4cf6d076cbe5edf680693e. The original commit increased local rebuild times a lot. See the discussion in https://github.com/llvm/llvm-project/issues/76707 Added: Modified: clang/lib/Tooling/CMakeLists.txt Removed: diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt index 8b4ab0e2129649..91e6cbdcbc44f7 100644 --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -53,16 +53,14 @@ else() list(APPEND implicitDirs -I ${implicitDir}) endforeach() - setup_host_tool(clang-ast-dump CLANG_AST_DUMP clang_ast_dump_exe clang_ast_dump_target) - include(GetClangResourceDir) get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR}) add_custom_command( COMMENT Generate ASTNodeAPI.json OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json - DEPENDS ${clang_ast_dump_target} clang-resource-headers + DEPENDS clang-ast-dump clang-resource-headers COMMAND - ${clang_ast_dump_exe} + $ # Skip this in debug mode because parsing AST.h is too slow --skip-processing=${skip_expensive_processing} -I ${resource_dir}/include ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)
wzssyqa wrote: Configure cmd ``` cmake ../llvm -G Ninja -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu -DLLVM_USE_LINKER=lld -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" -DLLVM_ENABLE_PROJECTS="mlir;clang;clang-tools-extra;lld" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo ``` Note, in `-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu`, there is no `unknown` aka vendor section. With this configure, `libclang_rt.builtin.a` is present in ``` ./lib/clang/19/lib/aarch64-linux-gnu/ ``` While clang expects it in ``` ./lib/clang/19/lib/aarch64-unknown-linux-gnu/ Note "unknown" ``` The reason is that in `computeTargetTriple`, the line ``` llvm::Triple Target(llvm::Triple::normalize(TargetTriple)); ``` convert the triple to normalize. https://github.com/llvm/llvm-project/pull/88334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add B extension (PR #76893)
kito-cheng wrote: It passed public review[1] and merged into riscv-isa-manual[2], so I think it's time to mark it as 1.0 and moving forward :) [1] https://groups.google.com/a/groups.riscv.org/g/isa-dev/c/KetVUCQkfK4/m/Y3Dbd2pvAAAJ?utm_medium=email&utm_source=footer [2] https://github.com/riscv/riscv-isa-manual/commit/cdb25859bcce5a6edbdc34914c1f86f079b3fddd https://github.com/llvm/llvm-project/pull/76893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg` (PR #88299)
https://github.com/dtcxzyw approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/88299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg` (PR #88299)
@@ -1964,11 +1964,25 @@ Instruction *InstCombinerImpl::visitFPToSI(FPToSIInst &FI) { } Instruction *InstCombinerImpl::visitUIToFP(CastInst &CI) { - return commonCastTransforms(CI); + if (Instruction *R = commonCastTransforms(CI)) +return R; + if (!CI.hasNonNeg() && isKnownNonNegative(CI.getOperand(0), SQ)) { +CI.setNonNeg(); +return &CI; + } + return nullptr; } Instruction *InstCombinerImpl::visitSIToFP(CastInst &CI) { - return commonCastTransforms(CI); + if (Instruction *R = commonCastTransforms(CI)) +return R; + if (isKnownNonNegative(CI.getOperand(0), SQ)) { +auto UI = dtcxzyw wrote: ```suggestion auto *UI = ``` https://github.com/llvm/llvm-project/pull/88299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [libcxx] [lld] [llvm] [openmp] llvm encode decode (PR #87187)
dtcxzyw wrote: Please send this PR to your downstream fork https://github.com/x-codingman/llvm-project. https://github.com/llvm/llvm-project/pull/87187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclc] [libcxx] [lld] [llvm] [openmp] llvm encode decode (PR #87187)
https://github.com/dtcxzyw closed https://github.com/llvm/llvm-project/pull/87187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Integral pointers (PR #84159)
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + FunctionPointer(int IntVal = 0, const Descriptor *Desc = nullptr) tbaederr wrote: Ah sorry, looks like I'm too slow :upside_down_face: https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Integral pointers (PR #84159)
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + FunctionPointer(int IntVal = 0, const Descriptor *Desc = nullptr) tbaederr wrote: Sorry, will fix that. https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Reduced BMI] Remove unreachable decls GMF in redued BMI (PR #88359)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/88359 >From 8913b259eb34db1f1d34d7f53f125c65c58ea353 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Wed, 3 Apr 2024 13:14:07 +0800 Subject: [PATCH] [C++20] [Modules] [Reduced BMI] Remove unreachable decls GMF in reduced BMI Following of https://github.com/llvm/llvm-project/pull/76930 This follows the idea of "only writes what we writes", which I think is the most natural and efficient way to implement this optimization. We start writing the BMI from the first declaration in module purview instead of the global module fragment, so that everything in the GMF untouched won't be written in the BMI naturally. The exception is, as I said in https://github.com/llvm/llvm-project/pull/76930, when we write a declaration we need to write its decl context, and when we write the decl context, we need to write everything from it. So when we see `std::vector`, we basically need to write everything under namespace std. This violates our intention. To fix this, this patch delays the writing of namespace in the GMF. >From my local measurement, the size of the BMI decrease to 90M from 112M for a local modules build. I think this is significant. This feature will be covered under the experimental reduced BMI so that it won't affect any existing users. So I'd like to land this when the CI gets green. Documents will be added seperately. --- .../include/clang/Serialization/ASTBitCodes.h | 4 + clang/include/clang/Serialization/ASTReader.h | 14 ++ clang/include/clang/Serialization/ASTWriter.h | 26 +++- clang/lib/Serialization/ASTReader.cpp | 23 +++ clang/lib/Serialization/ASTReaderDecl.cpp | 9 ++ clang/lib/Serialization/ASTWriter.cpp | 139 +++--- clang/lib/Serialization/ASTWriterDecl.cpp | 27 +++- .../module.glob.frag/cxx20-10-4-ex2.cppm | 58 .../inconsistent-deduction-guide-linkage.cppm | 8 + clang/test/Modules/named-modules-adl-2.cppm | 7 +- clang/test/Modules/named-modules-adl.cppm | 7 +- .../test/Modules/placement-new-reachable.cpp | 9 +- clang/test/Modules/polluted-operator.cppm | 15 +- clang/test/Modules/pr62589.cppm | 4 + clang/test/Modules/preferred_name.cppm| 2 + .../redundant-template-default-arg3.cpp | 10 ++ .../template-function-specialization.cpp | 8 +- 17 files changed, 337 insertions(+), 33 deletions(-) create mode 100644 clang/test/CXX/module/module.glob.frag/cxx20-10-4-ex2.cppm diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index f762116fea956c..500098dd3dab1d 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -698,6 +698,10 @@ enum ASTRecordTypes { /// Record code for an unterminated \#pragma clang assume_nonnull begin /// recorded in a preamble. PP_ASSUME_NONNULL_LOC = 67, + + /// Record code for lexical and visible block for delayed namespace in + /// reduced BMI. + DELAYED_NAMESPACE_LEXICAL_VISIBLE_RECORD = 68, }; /// Record types used within a source manager block. diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index e8b9f28690d9fa..6656c1c58dec9d 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -517,6 +517,20 @@ class ASTReader /// in the chain. DeclUpdateOffsetsMap DeclUpdateOffsets; + using DelayedNamespaceOffsetMapTy = llvm::DenseMap< + serialization::DeclID, + std::pair>; + + /// Mapping from global declaration IDs to the lexical and visible block + /// offset for delayed namespace in reduced BMI. + /// + /// We can't use the existing DeclUpdate mechanism since the DeclUpdate + /// may only be applied in an outer most read. However, we need to know + /// whether or not a DeclContext has external storage during the recursive + /// reading. So we need to apply the offset immediately after we read the + /// namespace as if it is not delayed. + DelayedNamespaceOffsetMapTy DelayedNamespaceOffsetMap; + struct PendingUpdateRecord { Decl *D; serialization::GlobalDeclID ID; diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 214eb3601148b0..443f7703104700 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -201,6 +201,16 @@ class ASTWriter : public ASTDeserializationListener, /// The declarations and types to emit. std::queue DeclTypesToEmit; + /// The delayed namespace to emit. Only meaningful for reduced BMI. + /// + /// In reduced BMI, we want to elide the unreachable declarations in + /// the global module fragment. However, in ASTWriterDecl, when we see + /// a namespace, all the declarations in the namespace would be emitted. + /// So