[clang] [llvm] [AArch64][SelectionDAG] Add CodeGen support for scalar FEAT_CPA (PR #105669)
@@ -2602,6 +2605,100 @@ SDValue DAGCombiner::foldSubToAvg(SDNode *N, const SDLoc &DL) { return SDValue(); } +/// Try to fold a pointer arithmetic node. +/// This needs to be done separately from normal addition, because pointer +/// addition is not commutative. +/// This function was adapted from DAGCombiner::visitPTRADD() from the Morello +/// project, which is based on CHERI. +SDValue DAGCombiner::visitPTRADD(SDNode *N) { + SDValue N0 = N->getOperand(0); + SDValue N1 = N->getOperand(1); + EVT PtrVT = N0.getValueType(); + EVT IntVT = N1.getValueType(); + SDLoc DL(N); + + // fold (ptradd undef, y) -> undef + if (N0.isUndef()) +return N0; + + // fold (ptradd x, undef) -> undef + if (N1.isUndef()) +return DAG.getUNDEF(PtrVT); + + // fold (ptradd x, 0) -> x + if (isNullConstant(N1)) +return N0; + + if (N0.getOpcode() == ISD::PTRADD && + !reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1)) { +SDValue X = N0.getOperand(0); +SDValue Y = N0.getOperand(1); +SDValue Z = N1; +bool N0OneUse = N0.hasOneUse(); +bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y); +bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z); +bool ZOneUse = Z.hasOneUse(); + +// (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if: +// * x is a null pointer; or +// * y is a constant and z has one use; or +// * y is a constant and (ptradd x, y) has one use; or +// * (ptradd x, y) and z have one use and z is not a constant. +if (isNullConstant(X) || (YIsConstant && ZOneUse) || +(YIsConstant && N0OneUse) || (N0OneUse && ZOneUse && !ZIsConstant)) { + SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z}); + + // Calling visit() can replace the Add node with ISD::DELETED_NODE if + // there aren't any users, so keep a handle around whilst we visit it. + HandleSDNode ADDHandle(Add); + + SDValue VisitedAdd = visit(Add.getNode()); + if (VisitedAdd) { +// If visit() returns the same node, it means the SDNode was RAUW'd, and +// therefore we have to load the new value to perform the checks whether +// the reassociation fold is profitable. +if (VisitedAdd.getNode() == Add.getNode()) + Add = ADDHandle.getValue(); +else + Add = VisitedAdd; + } ritter-x2a wrote: Is there a reason why this needs to be done by directly calling `visit` here and cleaning up after it, instead of calling `AddToWorklist(Add.getNode())` so that the Combiner's worklist algorithm takes care of processing the new node next? That seems to be the way it's done in the other combiner rules. https://github.com/llvm/llvm-project/pull/105669 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Simplify string comparisons (NFC) (PR #137756)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/137756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ace8cea - [ARM][Driver] Ensure NEON is enabled and disabled correctly (#137595)
Author: Jack Styles Date: 2025-04-29T08:28:10+01:00 New Revision: ace8ceab736f7e265b206b583d218a7554bee864 URL: https://github.com/llvm/llvm-project/commit/ace8ceab736f7e265b206b583d218a7554bee864 DIFF: https://github.com/llvm/llvm-project/commit/ace8ceab736f7e265b206b583d218a7554bee864.diff LOG: [ARM][Driver] Ensure NEON is enabled and disabled correctly (#137595) In #130623 support was added for `+nosimd` in the clang driver. Following this PR, it was discovered that, if NEON is disabled in the command line, it did not disable features that depend on this, such as Crypto or AES. To achieve this, This PR does the following: - Ensure that disabling NEON (e.g., via +nosimd) also disables dependent features like Crypto and AES. - Update the driver to automatically enable NEON when enabling features that require it (e.g., AES). This fixes inconsistent behavior where features relying on NEON could be enabled without NEON itself being active, or where disabling NEON left dependent features incorrectly enabled. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-features.c clang/test/Driver/arm-mfpu.c clang/test/Preprocessor/arm-target-features.c Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3105d8b481560..0fc46fe10b585 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -608,6 +608,8 @@ Arm and AArch64 Support - The ``+nosimd`` attribute is now fully supported for ARM. Previously, this had no effect when being used with ARM targets, however this will now disable NEON instructions being generated. The ``simd`` option is also now printed when the ``--print-supported-extensions`` option is used. +- When a feature that depends on NEON (``simd``) is used, NEON is now automatically enabled. +- When NEON is disabled (``+nosimd``), all features that depend on NEON will now be disabled. - Support for __ptrauth type qualifier has been added. diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index 5084058b3fef0..b6b1c2e28a96c 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -781,6 +781,22 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, if (FPUKind == llvm::ARM::FK_FPV5_D16 || FPUKind == llvm::ARM::FK_FPV5_SP_D16) Features.push_back("-mve.fp"); + // If SIMD has been disabled and the selected FPU supports NEON, then features + // that rely on NEON instructions should also be disabled. + bool HasSimd = false; + const auto ItSimd = + llvm::find_if(llvm::reverse(Features), +[](const StringRef F) { return F.contains("neon"); }); + const bool FPUSupportsNeon = (llvm::ARM::FPUNames[FPUKind].NeonSupport == +llvm::ARM::NeonSupportLevel::Neon) || + (llvm::ARM::FPUNames[FPUKind].NeonSupport == +llvm::ARM::NeonSupportLevel::Crypto); + if (ItSimd != Features.rend()) +HasSimd = ItSimd->starts_with("+"); + if (!HasSimd && FPUSupportsNeon) +Features.insert(Features.end(), +{"-sha2", "-aes", "-crypto", "-dotprod", "-bf16", "-imm8"}); + // For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes // Rather than replace within the feature vector, determine whether each // algorithm is enabled and append this to the end of the vector. @@ -791,6 +807,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, // FIXME: this needs reimplementation after the TargetParser rewrite bool HasSHA2 = false; bool HasAES = false; + bool HasBF16 = false; + bool HasDotprod = false; + bool HasI8MM = false; const auto ItCrypto = llvm::find_if(llvm::reverse(Features), [](const StringRef F) { return F.contains("crypto"); @@ -803,12 +822,25 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, llvm::find_if(llvm::reverse(Features), [](const StringRef F) { return F.contains("crypto") || F.contains("aes"); }); - const bool FoundSHA2 = ItSHA2 != Features.rend(); - const bool FoundAES = ItAES != Features.rend(); - if (FoundSHA2) -HasSHA2 = ItSHA2->take_front() == "+"; - if (FoundAES) -HasAES = ItAES->take_front() == "+"; + const auto ItBF16 = + llvm::find_if(llvm::reverse(Features), +[](const StringRef F) { return F.contains("bf16"); }); + const auto ItDotprod = + llvm::find_if(llvm::reverse(Features), +[](const StringRef F) { return F.contains("dotprod"); }); + const auto ItI8MM = + llvm::find_if(llvm::reverse(Features), +[](const StringRef F) { return F.contains("i8mm"); }); + if (ItSHA2 != Features.rend()) +HasSHA2 = ItSHA2->starts_with("+"
[clang] [clang][bytecode] Start implementing builtin_is_within_lifetime (PR #137765)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/137765.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+49) - (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+33) ``diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 34baae1986c35..2804985cb867b 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -2184,6 +2184,50 @@ static bool interp__builtin_object_size(InterpState &S, CodePtr OpPC, return true; } +static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC, + const CallExpr *Call) { + + if (!S.inConstantContext()) +return false; + + const Pointer &Ptr = S.Stk.peek(); + + auto Error = [&](int Diag) { +bool CalledFromStd = false; +const auto *Callee = S.Current->getCallee(); +if (Callee && Callee->isInStdNamespace()) { + const IdentifierInfo *Identifier = Callee->getIdentifier(); + CalledFromStd = Identifier && Identifier->isStr("is_within_lifetime"); +} +S.CCEDiag(CalledFromStd + ? S.Current->Caller->getSource(S.Current->getRetPC()) + : S.Current->getSource(OpPC), + diag::err_invalid_is_within_lifetime) +<< (CalledFromStd ? "std::is_within_lifetime" + : "__builtin_is_within_lifetime") +<< Diag; +return false; + }; + + if (Ptr.isZero()) +return Error(0); + if (Ptr.isOnePastEnd()) +return Error(1); + + bool Result = true; + if (!Ptr.isActive()) { +Result = false; + } else { +if (!CheckLive(S, OpPC, Ptr, AK_Read)) + return false; +if (!CheckMutable(S, OpPC, Ptr)) + return false; + } + + pushInteger(S, Result, Call->getType()); + return true; +} + bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, uint32_t BuiltinID) { if (!S.getASTContext().BuiltinInfo.isConstantEvaluated(BuiltinID)) @@ -2693,6 +2737,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, return false; break; + case Builtin::BI__builtin_is_within_lifetime: +if (!interp__builtin_is_within_lifetime(S, OpPC, Call)) + return false; +break; + default: S.FFDiag(S.Current->getLocation(OpPC), diag::note_invalid_subexpr_in_const_expr) diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index a4c8ec4856ecc..a7fbb1c6743d8 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1697,3 +1697,36 @@ namespace Invalid { static_assert(test() == 0); // both-error {{not an integral constant expression}} \ // both-note {{in call to}} } + +#if __cplusplus >= 202002L +namespace WithinLifetime { + constexpr int a = 10; + static_assert(__builtin_is_within_lifetime(&a)); + + consteval int IsActive(bool ReadB) { +union { + int a, b; +} A; +A.a = 10; +if (ReadB) + return __builtin_is_within_lifetime(&A.b); +return __builtin_is_within_lifetime(&A.a); + } + static_assert(IsActive(false)); + static_assert(!IsActive(true)); + + static_assert(__builtin_is_within_lifetime((void*)nullptr)); // both-error {{not an integral constant expression}} \ + // both-note {{'__builtin_is_within_lifetime' cannot be called with a null pointer}} + + constexpr int i = 2; + constexpr int arr[2]{}; + void f() { +__builtin_is_within_lifetime(&i + 1); // both-error {{call to consteval function '__builtin_is_within_lifetime' is not a constant expression}} \ + // both-note {{'__builtin_is_within_lifetime' cannot be called with a one-past-the-end pointer}} \ + // both-warning {{expression result unused}} +__builtin_is_within_lifetime(arr + 2); // both-error {{call to consteval function '__builtin_is_within_lifetime' is not a constant expression}} \ + // both-note {{'__builtin_is_within_lifetime' cannot be called with a one-past-the-end pointer}} \ + // both-warning {{expression result unused}} + } +} +#endif `` https://github.com/llvm/llvm-project/pull/137765 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ff66d34 - [Driver] Simplify string comparisons (NFC) (#137756)
Author: Kazu Hirata Date: 2025-04-29T00:30:59-07:00 New Revision: ff66d34286b07ba864029776d097e66306cc53ef URL: https://github.com/llvm/llvm-project/commit/ff66d34286b07ba864029776d097e66306cc53ef DIFF: https://github.com/llvm/llvm-project/commit/ff66d34286b07ba864029776d097e66306cc53ef.diff LOG: [Driver] Simplify string comparisons (NFC) (#137756) Added: Modified: clang/lib/Driver/ToolChains/Flang.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index a8b4688aed09c..e9d5a844ab073 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -159,7 +159,7 @@ void Flang::addCodegenOptions(const ArgList &Args, for (const auto &arg : Args.getAllArgValues(options::OPT_frepack_arrays_contiguity_EQ)) -if (arg.compare("whole") != 0 && arg.compare("innermost") != 0) { +if (arg != "whole" && arg != "innermost") { getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument) << "-frepack-arrays-contiguity=" << arg; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ARM][Driver] Fix i8mm feature string (PR #137771)
https://github.com/Stylie777 closed https://github.com/llvm/llvm-project/pull/137771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bb9fa77 - [ARM][Driver] Fix i8mm feature string (#137771)
Author: Jack Styles Date: 2025-04-29T10:32:50+01:00 New Revision: bb9fa77c8410e539d1eefdfe76c192db44bdc520 URL: https://github.com/llvm/llvm-project/commit/bb9fa77c8410e539d1eefdfe76c192db44bdc520 DIFF: https://github.com/llvm/llvm-project/commit/bb9fa77c8410e539d1eefdfe76c192db44bdc520.diff LOG: [ARM][Driver] Fix i8mm feature string (#137771) #137595 changed the behaviour for SIMD on ARM to ensure it is enabled and disabled correctly depending on the options used by the user. In this, the functionality to disable all features that depend on SIMD was added. However, there was a spelling error for the i8mm feature, which caused the `+nosimd` command to fail. This fixes the error, and allows the command to work again. Added: Modified: clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-features.c Removed: diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index b6b1c2e28a96c..5f58d42061e0a 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -795,7 +795,7 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D, HasSimd = ItSimd->starts_with("+"); if (!HasSimd && FPUSupportsNeon) Features.insert(Features.end(), -{"-sha2", "-aes", "-crypto", "-dotprod", "-bf16", "-imm8"}); +{"-sha2", "-aes", "-crypto", "-dotprod", "-bf16", "-i8mm"}); // For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes // Rather than replace within the feature vector, determine whether each diff --git a/clang/test/Driver/arm-features.c b/clang/test/Driver/arm-features.c index 830bd54198e99..18e0525aa6235 100644 --- a/clang/test/Driver/arm-features.c +++ b/clang/test/Driver/arm-features.c @@ -105,3 +105,13 @@ // RUN: %clang -target arm-none-none-eabi -march=armv8-r+bf16 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s // RUN: %clang -target arm-none-none-eabi -march=armv8-r+i8mm -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-ENABLED-WITH-FEATURE %s // CHECK-NEON-ENABLED-WITH-FEATURE: "-target-feature" "+neon" + +// Check that disabling NEON disables all features associated with this +// RUN: %clang -target arm-none-none-eabi -march=armv8-a+nosimd -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES %s +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-neon" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-dotprod" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-bf16" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-i8mm" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-crypto" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-sha2" +// CHECK-NEON-DISABLED-DISABLES-ALL-DEPENDENCIES: "-target-feature" "-aes" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
@@ -1257,6 +1259,26 @@ inline bool isX86_64ExtendedReg(MCRegister Reg) { return false; } +inline const TargetRegisterClass * +constrainRegClassToNonRex2(const TargetRegisterClass *RC) { fzou1 wrote: I wrote it based on canUseApxExtendedReg function. Updated. https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules][deps] Optimize in-process timestamping of PCMs (PR #137363)
@@ -59,19 +60,46 @@ class InProcessModuleCache : public ModuleCache { InMemoryModuleCache InMemory; public: - InProcessModuleCache(ModuleCacheMutexes &Mutexes) : Mutexes(Mutexes) {} + InProcessModuleCache(ModuleCacheEntries &Entries) : Entries(Entries) {} void prepareForGetLock(StringRef Filename) override {} std::unique_ptr getLock(StringRef Filename) override { -auto &Mtx = [&]() -> std::shared_mutex & { - std::lock_guard Lock(Mutexes.Mutex); - auto &Mutex = Mutexes.Map[Filename]; - if (!Mutex) -Mutex = std::make_unique(); - return *Mutex; +auto &CompilationMutex = [&]() -> std::shared_mutex & { + std::lock_guard Lock(Entries.Mutex); + auto &Entry = Entries.Map[Filename]; + if (!Entry) +Entry = std::make_unique(); + return Entry->CompilationMutex; }(); -return std::make_unique(Mtx); +return std::make_unique(CompilationMutex); + } + + std::time_t getModuleTimestamp(StringRef Filename) override { +auto &Timestamp = [&]() -> std::atomic & { + std::lock_guard Lock(Entries.Mutex); + auto &Entry = Entries.Map[Filename]; + if (!Entry) +Entry = std::make_unique(); + return Entry->Timestamp; +}(); + +return Timestamp.load(); + } + + void updateModuleTimestamp(StringRef Filename) override { +// Note: This essentially replaces FS contention with mutex contention. +auto &Timestamp = [&]() -> std::atomic & { + std::lock_guard Lock(Entries.Mutex); + auto &Entry = Entries.Map[Filename]; + if (!Entry) +Entry = std::make_unique(); + return Entry->Timestamp; +}(); + +std::time_t Expected = 0; +std::time_t Now = llvm::sys::toTimeT(std::chrono::system_clock::now()); +Timestamp.compare_exchange_weak(Expected, Now); Bigcheese wrote: This has different semantics than the file system version. This will keep the oldest time, and the filesystem version keeps the newest time. Not sure if that's a problem though. https://github.com/llvm/llvm-project/pull/137363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fmin & fmax to CLC library (PR #134218)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/134218 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 4609b6a - [libclc] Move fmin & fmax to CLC library (#134218)
Author: Fraser Cormack Date: 2025-04-29T10:51:24+01:00 New Revision: 4609b6a3e76e604463bab2a303c6da737f303237 URL: https://github.com/llvm/llvm-project/commit/4609b6a3e76e604463bab2a303c6da737f303237 DIFF: https://github.com/llvm/llvm-project/commit/4609b6a3e76e604463bab2a303c6da737f303237.diff LOG: [libclc] Move fmin & fmax to CLC library (#134218) This is an alternative to #128506 which doesn't attempt to change the codegen for fmin and fmax on their way to the CLC library. The amdgcn and r600 custom definitions of fmin/fmax are now converted to custom definitions of __clc_fmin and __clc_fmax. For simplicity, the CLC library doesn't provide vector/scalar versions of these builtins. The OpenCL layer wraps those up to the vector/vector versions. The only codegen change is that non-standard vector/scalar overloads of fmin/fmax have been removed. We were currently (accidentally, presumably) providing overloads with mixed elment types such as fmin(double2, float), fmax(half4, double), etc. The only vector/scalar overloads in the OpenCL spec are those with scalars of the same element type as the vector in the first argument. Added: libclc/clc/include/clc/math/clc_fmax.h libclc/clc/include/clc/math/clc_fmin.h libclc/clc/include/clc/shared/binary_decl_with_scalar_second_arg.inc libclc/clc/include/clc/shared/binary_def_with_scalar_second_arg.inc libclc/clc/lib/amdgcn/math/clc_fmax.cl libclc/clc/lib/amdgcn/math/clc_fmin.cl libclc/clc/lib/generic/math/clc_fmax.cl libclc/clc/lib/generic/math/clc_fmin.cl libclc/clc/lib/r600/math/clc_fmax.cl libclc/clc/lib/r600/math/clc_fmin.cl Modified: libclc/amdgcn/lib/SOURCES libclc/clc/lib/amdgcn/SOURCES libclc/clc/lib/generic/SOURCES libclc/clc/lib/r600/SOURCES libclc/generic/lib/math/fmax.cl libclc/generic/lib/math/fmin.cl libclc/r600/lib/SOURCES Removed: libclc/amdgcn/lib/math/fmax.cl libclc/amdgcn/lib/math/fmin.cl libclc/r600/lib/math/fmax.cl libclc/r600/lib/math/fmin.cl diff --git a/libclc/amdgcn/lib/SOURCES b/libclc/amdgcn/lib/SOURCES index 6c6e77db0d84b..213f62cc73a74 100644 --- a/libclc/amdgcn/lib/SOURCES +++ b/libclc/amdgcn/lib/SOURCES @@ -1,6 +1,4 @@ cl_khr_int64_extended_atomics/minmax_helpers.ll -math/fmax.cl -math/fmin.cl mem_fence/fence.cl synchronization/barrier.cl workitem/get_global_offset.cl diff --git a/libclc/amdgcn/lib/math/fmax.cl b/libclc/amdgcn/lib/math/fmax.cl deleted file mode 100644 index 8d3bf0495390f..0 --- a/libclc/amdgcn/lib/math/fmax.cl +++ /dev/null @@ -1,53 +0,0 @@ -//===--===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#include -#include - -_CLC_DEF _CLC_OVERLOAD float fmax(float x, float y) -{ - /* fcanonicalize removes sNaNs and flushes denormals if not enabled. -* Otherwise fmax instruction flushes the values for comparison, -* but outputs original denormal */ - x = __builtin_canonicalizef(x); - y = __builtin_canonicalizef(y); - return __builtin_fmaxf(x, y); -} -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, fmax, float, float) - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEF _CLC_OVERLOAD double fmax(double x, double y) -{ - x = __builtin_canonicalize(x); - y = __builtin_canonicalize(y); - return __builtin_fmax(x, y); -} -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, fmax, double, double) - -#endif -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEF _CLC_OVERLOAD half fmax(half x, half y) -{ - if (isnan(x)) - return y; - if (isnan(y)) - return x; - return (y < x) ? x : y; -} -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, fmax, half, half) - -#endif - -#define __CLC_BODY <../../../generic/lib/math/fmax.inc> -#include diff --git a/libclc/amdgcn/lib/math/fmin.cl b/libclc/amdgcn/lib/math/fmin.cl deleted file mode 100644 index 689401323105d..0 --- a/libclc/amdgcn/lib/math/fmin.cl +++ /dev/null @@ -1,53 +0,0 @@ -//===--===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#include -#include - -_CLC_DEF _CLC_OVERLOAD float fmin(float x, float y) -{ - /* fcanonicalize removes sNaNs and flushes denormals if not enabled. -* Otherwise fmin instruction flushes the values for comparis
[libclc] [libclc] Move fmin & fmax to CLC library (PR #134218)
frasercrmck wrote: I'll merge this as it's just a code move and there's no change to codegen. https://github.com/llvm/llvm-project/pull/134218 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Flang][Sanitizer] Support sanitizer flag for Flang Driver. (PR #137759)
kiranchandramohan wrote: Is enabling the flag sufficient? Is there additional work in the Frontend to make this flag and its options useful? https://github.com/llvm/llvm-project/pull/137759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][analyzer] replace Stmt* with ConstCFGElement in SymbolConjured (reland) (PR #137355)
https://github.com/fangyi-zhou edited https://github.com/llvm/llvm-project/pull/137355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][analyzer] replace Stmt* with ConstCFGElement in SymbolConjured (reland) (PR #137355)
fangyi-zhou wrote: @steakhal https://github.com/llvm/llvm-project/pull/137355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang-format: Add -disable-format option (PR #137617)
philnik777 wrote: > > Can't you just run the `llvm-include-order` clang-tidy check instead? > > Does that take `IncludeBlocks` and `IncludeCategories` from `.clang-format` > into account? I don't think so, but it shouldn't be impossible to teach clang-tidy. https://github.com/llvm/llvm-project/pull/137617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)
@@ -1660,6 +1660,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">; def err_omp_missing_comma : Error< "missing ',' after %0">; def err_omp_expected_context_selector : Error<"expected valid context selector in %0">; +def err_omp_unknown_clause +: Error<"expected an OpenMP clause">; +def warn_omp_default_deprecated : Warning<"'default' clause for" ravurvi20 wrote: Most of the deprecated clauses have their own warning messages without operands. https://github.com/llvm/llvm-project/pull/128640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` running on `suse-gary-m68k-cross` while building `llvm` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/9322 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llc -mattr=+egpr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llc -mattr=+egpr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-objdump --no-print-imm-hex -dr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-objdump --no-print-imm-hex -dr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llc -mattr=+egpr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llc -mattr=+egpr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-objdump --no-print-imm-hex -dr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/llvm-objdump --no-print-imm-hex -dr /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/FileCheck /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i:
[clang] [llvm] [clang][amdgpu] Add builtins for raw/struct buffer lds load (PR #137678)
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tahiti -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu bonaire -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu carrizo -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1200 -S -verify -o - %s +// REQUIRES: amdgpu-registered-target + +typedef unsigned int v4u32 __attribute__((ext_vector_type(4))); + +void test_amdgcn_struct_buffer_load_lds(v4u32 rsrc, __local void* lds, int index, int offset, int soffset, int x) { arsenm wrote: This should just work https://github.com/llvm/llvm-project/pull/137678 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 78d95cc - [libclc] Move fract to the CLC library (#137785)
Author: Fraser Cormack Date: 2025-04-29T13:58:13+01:00 New Revision: 78d95cc54455755eaac43d956baed6a3612bc72c URL: https://github.com/llvm/llvm-project/commit/78d95cc54455755eaac43d956baed6a3612bc72c DIFF: https://github.com/llvm/llvm-project/commit/78d95cc54455755eaac43d956baed6a3612bc72c.diff LOG: [libclc] Move fract to the CLC library (#137785) The builtin was already vectorized so there's no difference to codegen for non-SPIR-V targets. Added: libclc/clc/include/clc/math/clc_fract.h libclc/clc/lib/generic/math/clc_fract.cl libclc/clc/lib/generic/math/clc_fract.inc Modified: libclc/clc/lib/generic/SOURCES libclc/generic/include/clc/math/fract.h libclc/generic/lib/math/fract.cl Removed: libclc/generic/include/clc/math/fract.inc libclc/generic/lib/math/fract.inc diff --git a/libclc/generic/include/clc/math/fract.inc b/libclc/clc/include/clc/math/clc_fract.h similarity index 57% rename from libclc/generic/include/clc/math/fract.inc rename to libclc/clc/include/clc/math/clc_fract.h index 72e65d4409041..8ea47d47d914f 100644 --- a/libclc/generic/include/clc/math/fract.inc +++ b/libclc/clc/include/clc/math/clc_fract.h @@ -6,6 +6,15 @@ // //===--===// -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr); +#ifndef __CLC_MATH_CLC_FRACT_H__ +#define __CLC_MATH_CLC_FRACT_H__ + +#define __CLC_FUNCTION __clc_fract +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_FRACT_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 4c81a152290a9..dafc69e1d83a4 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -46,6 +46,7 @@ math/clc_fmax.cl math/clc_fmin.cl math/clc_floor.cl math/clc_fmod.cl +math/clc_fract.cl math/clc_frexp.cl math/clc_hypot.cl math/clc_ldexp.cl diff --git a/libclc/clc/lib/generic/math/clc_fract.cl b/libclc/clc/lib/generic/math/clc_fract.cl new file mode 100644 index 0..7db43ef878710 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.cl @@ -0,0 +1,17 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/libclc/clc/lib/generic/math/clc_fract.inc b/libclc/clc/lib/generic/math/clc_fract.inc new file mode 100644 index 0..31d32399e3f03 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.inc @@ -0,0 +1,38 @@ +//===--===// +// +// 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 +// +//===--===// + +#if __CLC_FPSIZE == 64 +#define MIN_CONSTANT 0x1.fp-1 +#elif __CLC_FPSIZE == 32 +#define MIN_CONSTANT 0x1.fep-1f +#elif __CLC_FPSIZE == 16 +#define MIN_CONSTANT 0x1.ffcp-1h +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x, + private __CLC_GENTYPE *iptr) { + *iptr = __clc_floor(x); + __CLC_GENTYPE r = __clc_fmin(x - *iptr, MIN_CONSTANT); + r = __clc_isinf(x) ? __CLC_FP_LIT(0.0) : r; + r = __clc_isnan(x) ? x : r; + return r; +} + +#define FRACT_DEF(addrspace) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract( \ + __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \ +__CLC_GENTYPE private_iptr; \ +__CLC_GENTYPE ret = __clc_fract(x, &private_iptr); \ +*iptr = private_iptr; \ +return ret; \ + } + +FRACT_DEF(local); +FRACT_DEF(global); + +#undef MIN_CONSTANT diff --git a/libclc/generic/include/clc/math/fract.h b/libclc/generic/include/clc/math/fract.h index 75bce83575b02..8443d4968c985 100644 --- a/libclc/generic/include/clc/math/fract.h +++ b/libclc/generic/include/clc/math/fract.h @@ -6,5 +6,7 @@ // //===--
[clang] [llvm] [clang][amdgpu] Add builtins for raw/struct buffer lds load (PR #137678)
@@ -163,7 +163,10 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b64, "V2UiQbiiIi", "n") BUILTIN(__builtin_amdgcn_raw_buffer_load_b96, "V3UiQbiiIi", "n") BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n") +TARGET_BUILTIN(__builtin_amdgcn_raw_buffer_load_lds, "vV4Uiv*3IUiiiIiIi", "t", "vmem-to-lds-load-insts") arsenm wrote: We don't want the non-pointer form spreading, every user should migrate to using real pointers https://github.com/llvm/llvm-project/pull/137678 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fract to the CLC library (PR #137785)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/137785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Support the OpenCL generic addrspace feature by default (PR #137636)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/137636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Support the OpenCL generic addrspace feature by default (PR #137636)
@@ -146,3 +146,8 @@ #pragma OPENCL EXTENSION cl_khr_subgroups: enable // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}} +#ifdef __opencl_c_generic_address_space +#error "Incorrect __opencl_c_generic_address_space define" arsenm wrote: It's not a real error so it doesn't really matter https://github.com/llvm/llvm-project/pull/137636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/137234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ppc64le-linux-multistage` running on `ppc64le-clang-multistage-test` while building `llvm` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/9147 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 1 Command Output (stderr): -- /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/test/CodeGen/X86/apx/
[libclc] [libclc][NFC] Remove unary_builtin.inc (PR #137656)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/137656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add test for QualTypes in template class NNS (PR #137804)
https://github.com/hahnjo created https://github.com/llvm/llvm-project/pull/137804 Recently commit dc17429ae6 removed some code related to template arguments in `NestedNameSpecifier::print` that would not pass on the `TemplateParameterList`. This would cause `printIntegral` to add type suffixes for the `unsigned` parameter, but only for the prefix. Add a regression test to prevent such problems from coming back. >From 53a3c9837ed56fdc7720c45395c8070dbeff02fe Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 29 Apr 2025 14:25:05 +0200 Subject: [PATCH] [clang] Add test for QualTypes in template class NNS Recently commit dc17429ae6 removed some code related to template arguments in NestedNameSpecifier::print that would not pass on the TemplateParameterList. This would cause printIntegral to add type suffixes for the unsigned parameter, but only for the prefix. Add a regression test to prevent such problems from coming back. --- clang/unittests/Tooling/QualTypeNamesTest.cpp | 96 +++ 1 file changed, 96 insertions(+) diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index dc81f0188b4fc..bcf7d8935f792 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -265,6 +265,102 @@ TEST(QualTypeNameTest, InlineNamespace) { TypeNameVisitor::Lang_CXX11); } +TEST(QualTypeNameTest, TemplatedClass) { + std::unique_ptr AST = + tooling::buildASTFromCode("template struct A {\n" +" template struct B {};\n" +"};\n" +"template struct A<1>;\n" +"template struct A<2u>;\n" +"template struct A<1>::B<3>;\n" +"template struct A<2u>::B<4u>;\n"); + + auto &Context = AST->getASTContext(); + auto &Policy = Context.getPrintingPolicy(); + auto getFullyQualifiedName = [&](QualType QT) { +return TypeName::getFullyQualifiedName(QT, Context, Policy); + }; + + auto *A = Context.getTranslationUnitDecl() +->lookup(&Context.Idents.get("A")) +.find_first(); + ASSERT_NE(A, nullptr); + + // A has two explicit instantiations: A<1> and A<2u> + auto ASpec = A->spec_begin(); + ASSERT_NE(ASpec, A->spec_end()); + auto *A1 = *ASpec; + ASpec++; + ASSERT_NE(ASpec, A->spec_end()); + auto *A2 = *ASpec; + + // Their type names follow the records. + QualType A1RecordTy = Context.getRecordType(A1); + EXPECT_EQ(getFullyQualifiedName(A1RecordTy), "A<1>"); + QualType A2RecordTy = Context.getRecordType(A2); + EXPECT_EQ(getFullyQualifiedName(A2RecordTy), "A<2U>"); + + // getTemplateSpecializationType() gives types that print the integral + // argument directly. + TemplateArgument Args1[] = { + {Context, llvm::APSInt::getUnsigned(1u), Context.UnsignedIntTy}}; + QualType A1TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A), Args1, Args1, A1RecordTy); + EXPECT_EQ(A1TemplateSpecTy.getAsString(), "A<1>"); + + TemplateArgument Args2[] = { + {Context, llvm::APSInt::getUnsigned(2u), Context.UnsignedIntTy}}; + QualType A2TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A), Args2, Args2, A2RecordTy); + EXPECT_EQ(A2TemplateSpecTy.getAsString(), "A<2>"); + + // Find A<1>::B and its specialization B<3>. + auto *A1B = + A1->lookup(&Context.Idents.get("B")).find_first(); + ASSERT_NE(A1B, nullptr); + auto A1BSpec = A1B->spec_begin(); + ASSERT_NE(A1BSpec, A1B->spec_end()); + auto *A1B3 = *A1BSpec; + QualType A1B3RecordTy = Context.getRecordType(A1B3); + EXPECT_EQ(getFullyQualifiedName(A1B3RecordTy), "A<1>::B<3>"); + + // Construct A<1>::B<3> and check name. + TemplateArgument Args3[] = { + {Context, llvm::APSInt::getUnsigned(3u), Context.UnsignedIntTy}}; + QualType A1B3TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A1B), Args3, Args3, A1B3RecordTy); + EXPECT_EQ(A1B3TemplateSpecTy.getAsString(), "B<3>"); + + NestedNameSpecifier *A1Nested = NestedNameSpecifier::Create( + Context, nullptr, A1TemplateSpecTy.getTypePtr()); + QualType A1B3ElaboratedTy = Context.getElaboratedType( + ElaboratedTypeKeyword::None, A1Nested, A1B3TemplateSpecTy); + EXPECT_EQ(A1B3ElaboratedTy.getAsString(), "A<1>::B<3>"); + + // Find A<2u>::B and its specialization B<4u>. + auto *A2B = + A2->lookup(&Context.Idents.get("B")).find_first(); + ASSERT_NE(A2B, nullptr); + auto A2BSpec = A2B->spec_begin(); + ASSERT_NE(A2BSpec, A2B->spec_end()); + auto *A2B4 = *A2BSpec; + QualType A2B4RecordTy = Context.getRecordType(A2B4); + EXPECT_EQ(getFullyQualifiedName(A2B4RecordTy), "A<2U>::B<4U>"); + + // Construct A<2>::B<4> and check name. + TemplateArgument Args4[] = { + {Context, llvm::APSInt::getUnsigned(4u), Context.UnsignedIntTy}}; + QualType A2
[clang] [clang] Add test for QualTypes in template class NNS (PR #137804)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Jonas Hahnfeld (hahnjo) Changes Recently commit dc17429ae6 removed some code related to template arguments in `NestedNameSpecifier::print` that would not pass on the `TemplateParameterList`. This would cause `printIntegral` to add type suffixes for the `unsigned` parameter, but only for the prefix. Add a regression test to prevent such problems from coming back. --- Full diff: https://github.com/llvm/llvm-project/pull/137804.diff 1 Files Affected: - (modified) clang/unittests/Tooling/QualTypeNamesTest.cpp (+96) ``diff diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index dc81f0188b4fc..bcf7d8935f792 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -265,6 +265,102 @@ TEST(QualTypeNameTest, InlineNamespace) { TypeNameVisitor::Lang_CXX11); } +TEST(QualTypeNameTest, TemplatedClass) { + std::unique_ptr AST = + tooling::buildASTFromCode("template struct A {\n" +" template struct B {};\n" +"};\n" +"template struct A<1>;\n" +"template struct A<2u>;\n" +"template struct A<1>::B<3>;\n" +"template struct A<2u>::B<4u>;\n"); + + auto &Context = AST->getASTContext(); + auto &Policy = Context.getPrintingPolicy(); + auto getFullyQualifiedName = [&](QualType QT) { +return TypeName::getFullyQualifiedName(QT, Context, Policy); + }; + + auto *A = Context.getTranslationUnitDecl() +->lookup(&Context.Idents.get("A")) +.find_first(); + ASSERT_NE(A, nullptr); + + // A has two explicit instantiations: A<1> and A<2u> + auto ASpec = A->spec_begin(); + ASSERT_NE(ASpec, A->spec_end()); + auto *A1 = *ASpec; + ASpec++; + ASSERT_NE(ASpec, A->spec_end()); + auto *A2 = *ASpec; + + // Their type names follow the records. + QualType A1RecordTy = Context.getRecordType(A1); + EXPECT_EQ(getFullyQualifiedName(A1RecordTy), "A<1>"); + QualType A2RecordTy = Context.getRecordType(A2); + EXPECT_EQ(getFullyQualifiedName(A2RecordTy), "A<2U>"); + + // getTemplateSpecializationType() gives types that print the integral + // argument directly. + TemplateArgument Args1[] = { + {Context, llvm::APSInt::getUnsigned(1u), Context.UnsignedIntTy}}; + QualType A1TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A), Args1, Args1, A1RecordTy); + EXPECT_EQ(A1TemplateSpecTy.getAsString(), "A<1>"); + + TemplateArgument Args2[] = { + {Context, llvm::APSInt::getUnsigned(2u), Context.UnsignedIntTy}}; + QualType A2TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A), Args2, Args2, A2RecordTy); + EXPECT_EQ(A2TemplateSpecTy.getAsString(), "A<2>"); + + // Find A<1>::B and its specialization B<3>. + auto *A1B = + A1->lookup(&Context.Idents.get("B")).find_first(); + ASSERT_NE(A1B, nullptr); + auto A1BSpec = A1B->spec_begin(); + ASSERT_NE(A1BSpec, A1B->spec_end()); + auto *A1B3 = *A1BSpec; + QualType A1B3RecordTy = Context.getRecordType(A1B3); + EXPECT_EQ(getFullyQualifiedName(A1B3RecordTy), "A<1>::B<3>"); + + // Construct A<1>::B<3> and check name. + TemplateArgument Args3[] = { + {Context, llvm::APSInt::getUnsigned(3u), Context.UnsignedIntTy}}; + QualType A1B3TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A1B), Args3, Args3, A1B3RecordTy); + EXPECT_EQ(A1B3TemplateSpecTy.getAsString(), "B<3>"); + + NestedNameSpecifier *A1Nested = NestedNameSpecifier::Create( + Context, nullptr, A1TemplateSpecTy.getTypePtr()); + QualType A1B3ElaboratedTy = Context.getElaboratedType( + ElaboratedTypeKeyword::None, A1Nested, A1B3TemplateSpecTy); + EXPECT_EQ(A1B3ElaboratedTy.getAsString(), "A<1>::B<3>"); + + // Find A<2u>::B and its specialization B<4u>. + auto *A2B = + A2->lookup(&Context.Idents.get("B")).find_first(); + ASSERT_NE(A2B, nullptr); + auto A2BSpec = A2B->spec_begin(); + ASSERT_NE(A2BSpec, A2B->spec_end()); + auto *A2B4 = *A2BSpec; + QualType A2B4RecordTy = Context.getRecordType(A2B4); + EXPECT_EQ(getFullyQualifiedName(A2B4RecordTy), "A<2U>::B<4U>"); + + // Construct A<2>::B<4> and check name. + TemplateArgument Args4[] = { + {Context, llvm::APSInt::getUnsigned(4u), Context.UnsignedIntTy}}; + QualType A2B4TemplateSpecTy = Context.getTemplateSpecializationType( + TemplateName(A2B), Args4, Args4, A2B4RecordTy); + EXPECT_EQ(A2B4TemplateSpecTy.getAsString(), "B<4>"); + + NestedNameSpecifier *A2Nested = NestedNameSpecifier::Create( + Context, nullptr, A2TemplateSpecTy.getTypePtr()); + QualType A2B4ElaboratedTy = Context.getElaboratedType( + ElaboratedTypeKeyword::None, A2Nested, A2B4TemplateSpecTy); + EXPECT_EQ(A2B4ElaboratedTy.getAsString(),
[clang] [clang] Add test for QualTypes in template class NNS (PR #137804)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/137804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
https://github.com/Naghasan created https://github.com/llvm/llvm-project/pull/137805 The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. The motivation for the header is to provide a stable binding for applications or library (such as SYCL) and allows non SPIR-V targets to provide an implementation (via libclc or similar to how it is done for gpuintrin.h). >From c01ab8cf9a84858a6a881a362ce68b077efddd64 Mon Sep 17 00:00:00 2001 From: Victor Lomuller Date: Mon, 28 Apr 2025 16:20:09 +0100 Subject: [PATCH] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. --- clang/include/clang/Basic/BuiltinsSPIRV.td| 9 + .../clang/Basic/DiagnosticSemaKinds.td| 10 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/Basic/Targets/SPIR.cpp | 6 +- clang/lib/Basic/Targets/SPIR.h| 6 +- clang/lib/CodeGen/CGBuiltin.cpp | 6 +- clang/lib/CodeGen/TargetBuiltins/SPIR.cpp | 14 ++ clang/lib/Headers/CMakeLists.txt | 16 ++ clang/lib/Headers/__clang_spirv_builtins.h| 176 ++ clang/lib/Sema/SemaChecking.cpp | 6 +- clang/lib/Sema/SemaDeclAttr.cpp | 4 +- clang/lib/Sema/SemaSPIRV.cpp | 105 +++ .../Builtins/generic_cast_to_ptr_explicit.c | 33 clang/test/Headers/spirv_functions.cpp| 25 +++ .../BuiltIns/generic_cast_to_ptr_explicit.c | 25 +++ 15 files changed, 433 insertions(+), 13 deletions(-) create mode 100644 clang/lib/Headers/__clang_spirv_builtins.h create mode 100644 clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c create mode 100644 clang/test/Headers/spirv_functions.cpp create mode 100644 clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Victor Lomuller (Naghasan) Changes The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. The motivation for the header is to provide a stable binding for applications or library (such as SYCL) and allows non SPIR-V targets to provide an implementation (via libclc or similar to how it is done for gpuintrin.h). --- Patch is 28.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137805.diff 15 Files Affected: - (modified) clang/include/clang/Basic/BuiltinsSPIRV.td (+9) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+9-1) - (modified) clang/lib/AST/ASTContext.cpp (+5) - (modified) clang/lib/Basic/Targets/SPIR.cpp (+4-2) - (modified) clang/lib/Basic/Targets/SPIR.h (+1-5) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+3-3) - (modified) clang/lib/CodeGen/TargetBuiltins/SPIR.cpp (+14) - (modified) clang/lib/Headers/CMakeLists.txt (+16) - (added) clang/lib/Headers/__clang_spirv_builtins.h (+176) - (modified) clang/lib/Sema/SemaChecking.cpp (+5-1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+3-1) - (modified) clang/lib/Sema/SemaSPIRV.cpp (+105) - (added) clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c (+33) - (added) clang/test/Headers/spirv_functions.cpp (+25) - (added) clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c (+25) ``diff diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}0 argument">; + // errors of expect.with.probability def err_probability_not_constant_float : Error< "probability argument to __builtin_expect_with_probability must be constant " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c95e733f30494..51438c22f52fe 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10054,6 +10054,11 @@ bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const { if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin && BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) return true; + // Allow redecl custom type checking builtin for SPIR-V. + if (getTargetInfo().getTriple().isSPIROrSPIRV() && + BuiltinInfo.isTSBuiltin(FD->getBuiltinID()) && + BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) +return true; return BuiltinInfo.canBeRedeclared(FD->getBu
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Victor Lomuller (Naghasan) Changes The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. The motivation for the header is to provide a stable binding for applications or library (such as SYCL) and allows non SPIR-V targets to provide an implementation (via libclc or similar to how it is done for gpuintrin.h). --- Patch is 28.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137805.diff 15 Files Affected: - (modified) clang/include/clang/Basic/BuiltinsSPIRV.td (+9) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+9-1) - (modified) clang/lib/AST/ASTContext.cpp (+5) - (modified) clang/lib/Basic/Targets/SPIR.cpp (+4-2) - (modified) clang/lib/Basic/Targets/SPIR.h (+1-5) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+3-3) - (modified) clang/lib/CodeGen/TargetBuiltins/SPIR.cpp (+14) - (modified) clang/lib/Headers/CMakeLists.txt (+16) - (added) clang/lib/Headers/__clang_spirv_builtins.h (+176) - (modified) clang/lib/Sema/SemaChecking.cpp (+5-1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+3-1) - (modified) clang/lib/Sema/SemaSPIRV.cpp (+105) - (added) clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c (+33) - (added) clang/test/Headers/spirv_functions.cpp (+25) - (added) clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c (+25) ``diff diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}0 argument">; + // errors of expect.with.probability def err_probability_not_constant_float : Error< "probability argument to __builtin_expect_with_probability must be constant " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c95e733f30494..51438c22f52fe 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10054,6 +10054,11 @@ bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const { if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin && BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) return true; + // Allow redecl custom type checking builtin for SPIR-V. + if (getTargetInfo().getTriple().isSPIROrSPIRV() && + BuiltinInfo.isTSBuiltin(FD->getBuiltinID()) && + BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) +return true; return BuiltinInfo.canBeRedeclared(FD->getBuil
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Victor Lomuller (Naghasan) Changes The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. The motivation for the header is to provide a stable binding for applications or library (such as SYCL) and allows non SPIR-V targets to provide an implementation (via libclc or similar to how it is done for gpuintrin.h). --- Patch is 28.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137805.diff 15 Files Affected: - (modified) clang/include/clang/Basic/BuiltinsSPIRV.td (+9) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+9-1) - (modified) clang/lib/AST/ASTContext.cpp (+5) - (modified) clang/lib/Basic/Targets/SPIR.cpp (+4-2) - (modified) clang/lib/Basic/Targets/SPIR.h (+1-5) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+3-3) - (modified) clang/lib/CodeGen/TargetBuiltins/SPIR.cpp (+14) - (modified) clang/lib/Headers/CMakeLists.txt (+16) - (added) clang/lib/Headers/__clang_spirv_builtins.h (+176) - (modified) clang/lib/Sema/SemaChecking.cpp (+5-1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+3-1) - (modified) clang/lib/Sema/SemaSPIRV.cpp (+105) - (added) clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c (+33) - (added) clang/test/Headers/spirv_functions.cpp (+25) - (added) clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c (+25) ``diff diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}0 argument">; + // errors of expect.with.probability def err_probability_not_constant_float : Error< "probability argument to __builtin_expect_with_probability must be constant " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c95e733f30494..51438c22f52fe 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10054,6 +10054,11 @@ bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const { if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin && BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) return true; + // Allow redecl custom type checking builtin for SPIR-V. + if (getTargetInfo().getTriple().isSPIROrSPIRV() && + BuiltinInfo.isTSBuiltin(FD->getBuiltinID()) && + BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) +return true; return BuiltinInfo.canBeRedeclared(FD->getBuiltinID(
[clang] 1e31f4b - [AMDGPU] Support the OpenCL generic addrspace feature by default (#137636)
Author: Fraser Cormack Date: 2025-04-29T14:14:00+01:00 New Revision: 1e31f4b5eb96de3080810340c9083138a34587b8 URL: https://github.com/llvm/llvm-project/commit/1e31f4b5eb96de3080810340c9083138a34587b8 DIFF: https://github.com/llvm/llvm-project/commit/1e31f4b5eb96de3080810340c9083138a34587b8.diff LOG: [AMDGPU] Support the OpenCL generic addrspace feature by default (#137636) This feature should be supported on AMDGCN architectures with flat addressing. Added: Modified: clang/lib/Basic/Targets/AMDGPU.h clang/test/Misc/amdgcn.languageOptsOpenCL.cl clang/test/Misc/r600.languageOptsOpenCL.cl Removed: diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 63b0d4b6e5fc0..8ea544ba28b10 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -318,6 +318,9 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { Opts["__opencl_c_images"] = true; Opts["__opencl_c_3d_image_writes"] = true; Opts["cl_khr_3d_image_writes"] = true; + + Opts["__opencl_c_generic_address_space"] = + GPUKind >= llvm::AMDGPU::GK_GFX700; } } diff --git a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl index 186cdae0494c6..50c78d70b83d9 100644 --- a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl +++ b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl @@ -155,3 +155,11 @@ #endif #pragma OPENCL EXTENSION cl_amd_media_ops2: enable +#if (__OPENCL_C_VERSION__ >= 300) +#ifndef __opencl_c_generic_address_space +#error "Missing __opencl_c_generic_address_space define" +#else +#error "Incorrect __opencl_c_generic_address_space define" +#endif +#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable +#endif diff --git a/clang/test/Misc/r600.languageOptsOpenCL.cl b/clang/test/Misc/r600.languageOptsOpenCL.cl index 600c49f4ed692..27a7691d53575 100644 --- a/clang/test/Misc/r600.languageOptsOpenCL.cl +++ b/clang/test/Misc/r600.languageOptsOpenCL.cl @@ -146,3 +146,8 @@ #pragma OPENCL EXTENSION cl_khr_subgroups: enable // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}} +#ifdef __opencl_c_generic_address_space +#error "Incorrect __opencl_c_generic_address_space define" +#endif +#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable +// expected-warning@-1{{OpenCL extension '__opencl_c_generic_address_space' unknown or does not require pragma - ignoring}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Support the OpenCL generic addrspace feature by default (PR #137636)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/137636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions h,cpp,c -- clang/lib/Headers/__clang_spirv_builtins.h clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c clang/test/Headers/spirv_functions.cpp clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c clang/lib/AST/ASTContext.cpp clang/lib/Basic/Targets/SPIR.cpp clang/lib/Basic/Targets/SPIR.h clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/TargetBuiltins/SPIR.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaSPIRV.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e526e0b62..85309186b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -99,7 +99,7 @@ static Value *EmitTargetArchBuiltinExpr(CodeGenFunction *CGF, case llvm::Triple::spirv: case llvm::Triple::spirv32: case llvm::Triple::spirv64: - if (CGF->getTarget().getTriple().getOS() != llvm::Triple::OSType::AMDHSA) +if (CGF->getTarget().getTriple().getOS() != llvm::Triple::OSType::AMDHSA) return CGF->EmitSPIRVBuiltinExpr(BuiltinID, E); return CGF->EmitAMDGPUBuiltinExpr(BuiltinID, E); default: diff --git a/clang/lib/Headers/__clang_spirv_builtins.h b/clang/lib/Headers/__clang_spirv_builtins.h index 0b23fc87b..e344ed525 100644 --- a/clang/lib/Headers/__clang_spirv_builtins.h +++ b/clang/lib/Headers/__clang_spirv_builtins.h @@ -37,7 +37,7 @@ // if we do not intent to use the backend. So instead of use target macros, rely // on a __has_builtin test. #if (__has_builtin(__builtin_spirv_generic_cast_to_ptr_explicit)) -#define __SPIRV_BUILTIN_ALIAS(builtin) \ +#define __SPIRV_BUILTIN_ALIAS(builtin) \ __attribute__((clang_builtin_alias(builtin))) #else #define __SPIRV_BUILTIN_ALIAS(builtin) @@ -85,8 +85,9 @@ __spirv_GenericCastToPtrExplicit_ToLocal(__generic const volatile void *, int) __SPIRV_NOEXCEPT; extern __SPIRV_overloadable __SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) -__private void *__spirv_GenericCastToPtrExplicit_ToPrivate(__generic void *, - int) __SPIRV_NOEXCEPT; +__private void * +__spirv_GenericCastToPtrExplicit_ToPrivate(__generic void *, + int) __SPIRV_NOEXCEPT; extern __SPIRV_overloadable __SPIRV_BUILTIN_ALIAS(__builtin_spirv_generic_cast_to_ptr_explicit) __private const void * @@ -110,7 +111,8 @@ __spirv_GenericCastToPtr_ToGlobal(__generic void *p, int) __SPIRV_NOEXCEPT { return (__global void *)p; } static __SPIRV_overloadable __SPIRV_inline __global const void * -__spirv_GenericCastToPtr_ToGlobal(__generic const void *p, int) __SPIRV_NOEXCEPT { +__spirv_GenericCastToPtr_ToGlobal(__generic const void *p, + int) __SPIRV_NOEXCEPT { return (__global const void *)p; } static __SPIRV_overloadable __SPIRV_inline __global volatile void * @@ -128,7 +130,8 @@ __spirv_GenericCastToPtr_ToLocal(__generic void *p, int) __SPIRV_NOEXCEPT { return (__local void *)p; } static __SPIRV_overloadable __SPIRV_inline __local const void * -__spirv_GenericCastToPtr_ToLocal(__generic const void *p, int) __SPIRV_NOEXCEPT { +__spirv_GenericCastToPtr_ToLocal(__generic const void *p, + int) __SPIRV_NOEXCEPT { return (__local const void *)p; } static __SPIRV_overloadable __SPIRV_inline __local volatile void * diff --git a/clang/lib/Sema/SemaSPIRV.cpp b/clang/lib/Sema/SemaSPIRV.cpp index 9282d02bc..d5b37e0b8 100644 --- a/clang/lib/Sema/SemaSPIRV.cpp +++ b/clang/lib/Sema/SemaSPIRV.cpp @@ -117,13 +117,16 @@ static bool checkGenericCastToPtr(Sema &SemaRef, CallExpr *Call) { LangAS AddrSpace; switch (static_cast(StorageClass)) { case spirv::StorageClass::CrossWorkgroup: -AddrSpace = SemaRef.LangOpts.isSYCL() ? LangAS::sycl_global : LangAS::opencl_global; +AddrSpace = +SemaRef.LangOpts.isSYCL() ? LangAS::sycl_global : LangAS::opencl_global; break; case spirv::StorageClass::Workgroup: -AddrSpace = SemaRef.LangOpts.isSYCL() ? LangAS::sycl_local : LangAS::opencl_local; +AddrSpace = +SemaRef.LangOpts.isSYCL() ? LangAS::sycl_local : LangAS::opencl_local; break; case spirv::StorageClass::Function: -AddrSpace = SemaRef.LangOpts.isSYCL() ? LangAS::sycl_private : LangAS::opencl_private; +AddrSpace = SemaRef.LangOpts.isSYCL() ? LangAS::sycl_private + : LangAS::opencl_private; break; default: llvm_unreachable("Invalid builtin function"); `` http
[libclc] 837d5a7 - [libclc][NFC] Remove unary_builtin.inc (#137656)
Author: Fraser Cormack Date: 2025-04-29T14:17:17+01:00 New Revision: 837d5a740f120eb077aa8808809c057fa38d91f3 URL: https://github.com/llvm/llvm-project/commit/837d5a740f120eb077aa8808809c057fa38d91f3 DIFF: https://github.com/llvm/llvm-project/commit/837d5a740f120eb077aa8808809c057fa38d91f3.diff LOG: [libclc][NFC] Remove unary_builtin.inc (#137656) We had two ways of achieving the same thing. This commit removes unary_builtin.inc in favour of the approach combining gentype.inc with unary_def.inc. There is no change to the codegen for any target. Added: Modified: libclc/clc/lib/generic/math/clc_ceil.cl libclc/clc/lib/generic/math/clc_fabs.cl libclc/clc/lib/generic/math/clc_floor.cl libclc/clc/lib/generic/math/clc_rint.cl libclc/clc/lib/generic/math/clc_round.cl libclc/clc/lib/generic/math/clc_trunc.cl libclc/generic/lib/math/acos.cl libclc/generic/lib/math/acosh.cl libclc/generic/lib/math/acospi.cl libclc/generic/lib/math/asin.cl libclc/generic/lib/math/asinh.cl libclc/generic/lib/math/asinpi.cl libclc/generic/lib/math/atan.cl libclc/generic/lib/math/atanh.cl libclc/generic/lib/math/atanpi.cl libclc/generic/lib/math/ceil.cl libclc/generic/lib/math/fabs.cl libclc/generic/lib/math/floor.cl libclc/generic/lib/math/log1p.cl libclc/generic/lib/math/rint.cl libclc/generic/lib/math/round.cl libclc/generic/lib/math/trunc.cl Removed: libclc/clc/include/clc/math/unary_builtin.inc diff --git a/libclc/clc/include/clc/math/unary_builtin.inc b/libclc/clc/include/clc/math/unary_builtin.inc deleted file mode 100644 index 790eaec5341d5..0 --- a/libclc/clc/include/clc/math/unary_builtin.inc +++ /dev/null @@ -1,32 +0,0 @@ -//===--===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===--===// - -#include -#include - -#ifndef __CLC_BUILTIN -#define __CLC_BUILTIN __CLC_XCONCAT(__clc_, __CLC_FUNCTION) -#endif - -_CLC_DEFINE_UNARY_BUILTIN(float, __CLC_FUNCTION, __CLC_BUILTIN, float) - -#ifdef cl_khr_fp64 - -#pragma OPENCL EXTENSION cl_khr_fp64 : enable - -_CLC_DEFINE_UNARY_BUILTIN(double, __CLC_FUNCTION, __CLC_BUILTIN, double) - -#endif - -#ifdef cl_khr_fp16 - -#pragma OPENCL EXTENSION cl_khr_fp16 : enable - -_CLC_DEFINE_UNARY_BUILTIN(half, __CLC_FUNCTION, __CLC_BUILTIN, half) - -#endif diff --git a/libclc/clc/lib/generic/math/clc_ceil.cl b/libclc/clc/lib/generic/math/clc_ceil.cl index 975b51185d58c..c4df638d5ce26 100644 --- a/libclc/clc/lib/generic/math/clc_ceil.cl +++ b/libclc/clc/lib/generic/math/clc_ceil.cl @@ -8,7 +8,8 @@ #include -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_ceil -#define __CLC_BUILTIN __builtin_elementwise_ceil -#include +#define FUNCTION __clc_ceil +#define __CLC_FUNCTION(x) __builtin_elementwise_ceil +#define __CLC_BODY + +#include diff --git a/libclc/clc/lib/generic/math/clc_fabs.cl b/libclc/clc/lib/generic/math/clc_fabs.cl index 90841afefdfb9..f684c1e76bbbd 100644 --- a/libclc/clc/lib/generic/math/clc_fabs.cl +++ b/libclc/clc/lib/generic/math/clc_fabs.cl @@ -8,7 +8,8 @@ #include -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_fabs -#define __CLC_BUILTIN __builtin_elementwise_abs -#include +#define FUNCTION __clc_fabs +#define __CLC_FUNCTION(x) __builtin_elementwise_abs +#define __CLC_BODY + +#include diff --git a/libclc/clc/lib/generic/math/clc_floor.cl b/libclc/clc/lib/generic/math/clc_floor.cl index 2b80e5b3a178e..0626ba36f3ea8 100644 --- a/libclc/clc/lib/generic/math/clc_floor.cl +++ b/libclc/clc/lib/generic/math/clc_floor.cl @@ -8,7 +8,8 @@ #include -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_floor -#define __CLC_BUILTIN __builtin_elementwise_floor -#include +#define FUNCTION __clc_floor +#define __CLC_FUNCTION(x) __builtin_elementwise_floor +#define __CLC_BODY + +#include diff --git a/libclc/clc/lib/generic/math/clc_rint.cl b/libclc/clc/lib/generic/math/clc_rint.cl index d0852bcf77163..2188a7d901f01 100644 --- a/libclc/clc/lib/generic/math/clc_rint.cl +++ b/libclc/clc/lib/generic/math/clc_rint.cl @@ -8,7 +8,8 @@ #include -#undef __CLC_FUNCTION -#define __CLC_FUNCTION __clc_rint -#define __CLC_BUILTIN __builtin_elementwise_rint -#include +#define FUNCTION __clc_rint +#define __CLC_FUNCTION(x) __builtin_elementwise_rint +#define __CLC_BODY + +#include diff --git a/libclc/clc/lib/generic/math/clc_round.cl b/libclc/clc/lib/generic/math/clc_round.cl index 981949090c694..e784dbeaf3fab 100644 --- a/libclc/clc/lib/generic/math/clc_round.cl +++ b/libclc/clc/lib/generic/math/clc_round.cl @@ -8,7 +8,8 @@ #include -#undef __CLC_F
[libclc] [libclc][NFC] Remove unary_builtin.inc (PR #137656)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/137656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add test for QualTypes in template class NNS (PR #137804)
https://github.com/mizvekov approved this pull request. https://github.com/llvm/llvm-project/pull/137804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
Naghasan wrote: Sorry I can't assign reviewers, @JonChesterfield @jhuber6 as you are involved in gpuintrin.h, I'd welcome feedbacks here (feel free to ping other relevant persons) For the SPIR-V side of thing @VyacheslavLevytskyy @farzonl I appreciate your feedbacks as well :) FYI @tahonermann https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fract to the CLC library (PR #137785)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions h,cl,inc -- libclc/clc/lib/generic/math/clc_fract.cl libclc/clc/lib/generic/math/clc_fract.inc libclc/generic/include/clc/math/fract.h libclc/generic/lib/math/fract.cl libclc/clc/include/clc/math/clc_fract.h `` View the diff from clang-format here. ``diff diff --git a/libclc/clc/lib/generic/math/clc_fract.cl b/libclc/clc/lib/generic/math/clc_fract.cl index 1a0c5ab7a..7db43ef87 100644 --- a/libclc/clc/lib/generic/math/clc_fract.cl +++ b/libclc/clc/lib/generic/math/clc_fract.cl @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #define __CLC_BODY #include `` https://github.com/llvm/llvm-project/pull/137785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
https://github.com/fzou1 closed https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fract to the CLC library (PR #137785)
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/137785 >From f9a265e0d9bcecb80d25b97c394d7b9aa68d27ea Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 29 Apr 2025 11:43:00 +0100 Subject: [PATCH 1/2] [libclc] Move fract to the CLC library The builtin was already vectorized so there's no difference to codegen for non-SPIR-V targets. --- .../include/clc/math/clc_fract.h} | 15 +-- libclc/clc/lib/generic/SOURCES| 1 + libclc/clc/lib/generic/math/clc_fract.cl | 17 libclc/clc/lib/generic/math/clc_fract.inc | 38 + libclc/generic/include/clc/math/fract.h | 4 +- libclc/generic/lib/math/fract.cl | 4 +- libclc/generic/lib/math/fract.inc | 41 --- 7 files changed, 74 insertions(+), 46 deletions(-) rename libclc/{generic/include/clc/math/fract.inc => clc/include/clc/math/clc_fract.h} (57%) create mode 100644 libclc/clc/lib/generic/math/clc_fract.cl create mode 100644 libclc/clc/lib/generic/math/clc_fract.inc delete mode 100644 libclc/generic/lib/math/fract.inc diff --git a/libclc/generic/include/clc/math/fract.inc b/libclc/clc/include/clc/math/clc_fract.h similarity index 57% rename from libclc/generic/include/clc/math/fract.inc rename to libclc/clc/include/clc/math/clc_fract.h index 72e65d4409041..8ea47d47d914f 100644 --- a/libclc/generic/include/clc/math/fract.inc +++ b/libclc/clc/include/clc/math/clc_fract.h @@ -6,6 +6,15 @@ // //===--===// -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr); +#ifndef __CLC_MATH_CLC_FRACT_H__ +#define __CLC_MATH_CLC_FRACT_H__ + +#define __CLC_FUNCTION __clc_fract +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_FRACT_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 4c81a152290a9..dafc69e1d83a4 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -46,6 +46,7 @@ math/clc_fmax.cl math/clc_fmin.cl math/clc_floor.cl math/clc_fmod.cl +math/clc_fract.cl math/clc_frexp.cl math/clc_hypot.cl math/clc_ldexp.cl diff --git a/libclc/clc/lib/generic/math/clc_fract.cl b/libclc/clc/lib/generic/math/clc_fract.cl new file mode 100644 index 0..1a0c5ab7a8d47 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.cl @@ -0,0 +1,17 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/libclc/clc/lib/generic/math/clc_fract.inc b/libclc/clc/lib/generic/math/clc_fract.inc new file mode 100644 index 0..31d32399e3f03 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.inc @@ -0,0 +1,38 @@ +//===--===// +// +// 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 +// +//===--===// + +#if __CLC_FPSIZE == 64 +#define MIN_CONSTANT 0x1.fp-1 +#elif __CLC_FPSIZE == 32 +#define MIN_CONSTANT 0x1.fep-1f +#elif __CLC_FPSIZE == 16 +#define MIN_CONSTANT 0x1.ffcp-1h +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x, + private __CLC_GENTYPE *iptr) { + *iptr = __clc_floor(x); + __CLC_GENTYPE r = __clc_fmin(x - *iptr, MIN_CONSTANT); + r = __clc_isinf(x) ? __CLC_FP_LIT(0.0) : r; + r = __clc_isnan(x) ? x : r; + return r; +} + +#define FRACT_DEF(addrspace) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract( \ + __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \ +__CLC_GENTYPE private_iptr; \ +__CLC_GENTYPE ret = __clc_fract(x, &private_iptr); \ +*iptr = private_iptr; \ +return ret; \ + } + +FRACT_DEF(local); +FRACT_DEF(global); + +#undef MIN_CONSTANT diff --git a/libclc/generic/include/cl
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `ml-opt-rel-x86-64` running on `ml-opt-rel-x86-64-b2` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/17441 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /b/ml-opt-rel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /b/ml-opt-rel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-rel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC + /b/ml-opt-rel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /b/ml-opt-rel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /b/ml-opt-rel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /b/ml-opt-rel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX + /b/ml-opt-rel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 7 + /b/ml-opt-rel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' ld.lld /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so # RUN: at line 8 + ld.lld /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so /b/ml-opt-rel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.script: line 7: ld.lld: command not found -- ``` https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `ml-opt-devrel-x86-64` running on `ml-opt-devrel-x86-64-b2` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/17658 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /b/ml-opt-devrel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /b/ml-opt-devrel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC + /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /b/ml-opt-devrel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /b/ml-opt-devrel-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 7 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/ml-opt-devrel-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o ld.lld /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so # RUN: at line 8 + ld.lld /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so /b/ml-opt-devrel-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.script: line 7: ld.lld: command not found -- ``` https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `ml-opt-dev-x86-64` running on `ml-opt-dev-x86-64-b1` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/17687 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /b/ml-opt-dev-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /b/ml-opt-dev-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-dev-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /b/ml-opt-dev-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /b/ml-opt-dev-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /b/ml-opt-dev-x86-64-b1/build/bin/llc -mattr=+egpr /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /b/ml-opt-dev-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /b/ml-opt-dev-x86-64-b1/build/bin/llvm-objdump --no-print-imm-hex -dr /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 7 + /b/ml-opt-dev-x86-64-b1/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' ld.lld /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so # RUN: at line 8 + ld.lld /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.so /b/ml-opt-dev-x86-64-b1/build/test/CodeGen/X86/apx/Output/tls.ll.script: line 7: ld.lld: command not found -- ``` https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
https://github.com/Naghasan updated https://github.com/llvm/llvm-project/pull/137805 >From 90725e8f74295bfd9169e03e73af54c2cf4616ea Mon Sep 17 00:00:00 2001 From: Victor Lomuller Date: Mon, 28 Apr 2025 16:20:09 +0100 Subject: [PATCH] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. --- clang/include/clang/Basic/BuiltinsSPIRV.td| 9 + .../clang/Basic/DiagnosticSemaKinds.td| 10 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/Basic/Targets/SPIR.cpp | 6 +- clang/lib/Basic/Targets/SPIR.h| 6 +- clang/lib/CodeGen/CGBuiltin.cpp | 4 +- clang/lib/CodeGen/TargetBuiltins/SPIR.cpp | 14 ++ clang/lib/Headers/CMakeLists.txt | 16 ++ clang/lib/Headers/__clang_spirv_builtins.h| 179 ++ clang/lib/Sema/SemaChecking.cpp | 6 +- clang/lib/Sema/SemaDeclAttr.cpp | 4 +- clang/lib/Sema/SemaSPIRV.cpp | 108 +++ .../Builtins/generic_cast_to_ptr_explicit.c | 33 clang/test/Headers/spirv_functions.cpp| 25 +++ .../BuiltIns/generic_cast_to_ptr_explicit.c | 25 +++ 15 files changed, 438 insertions(+), 12 deletions(-) create mode 100644 clang/lib/Headers/__clang_spirv_builtins.h create mode 100644 clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c create mode 100644 clang/test/Headers/spirv_functions.cpp create mode 100644 clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}0 argument">; + // errors of expect.with.probability def err_probability_not_constant_float : Error< "probability argument to __builtin_expect_with_probability must be constant " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c95e733f30494..51438c22f52fe 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10054,6 +10054,11 @@ bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const { if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin && BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) return true; + // Allow redecl custom type checking builtin for SPIR-V. + if (getTargetInfo().getTriple().isSPIROrSPIRV() && + BuiltinIn
[libclc] [libclc] Optimize generic CLC fmin/fmax (PR #128506)
arsenm wrote: > I don't suppose the recent > [clarifications](https://github.com/llvm/llvm-project/commit/363b05944f92) to > `llvm.minnum` and `llvm.maxnum` change anything here? It depends on whether the conformance test is fixed to match the fuzzy language of the spec or not. If the decision is fmin/fmax should match the IEEE behavior, the implementation directly maps to llvm.minnum/llvm.maxnum. If the decision is the conformance test continues doing what it has been doing, it should directly map to llvm.minimumnum/maximumnum. In either case, we should not have code using canonicalizes https://github.com/llvm/llvm-project/pull/128506 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move fract to the CLC library (PR #137785)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/137785 The builtin was already vectorized so there's no difference to codegen for non-SPIR-V targets. >From f9a265e0d9bcecb80d25b97c394d7b9aa68d27ea Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 29 Apr 2025 11:43:00 +0100 Subject: [PATCH] [libclc] Move fract to the CLC library The builtin was already vectorized so there's no difference to codegen for non-SPIR-V targets. --- .../include/clc/math/clc_fract.h} | 15 +-- libclc/clc/lib/generic/SOURCES| 1 + libclc/clc/lib/generic/math/clc_fract.cl | 17 libclc/clc/lib/generic/math/clc_fract.inc | 38 + libclc/generic/include/clc/math/fract.h | 4 +- libclc/generic/lib/math/fract.cl | 4 +- libclc/generic/lib/math/fract.inc | 41 --- 7 files changed, 74 insertions(+), 46 deletions(-) rename libclc/{generic/include/clc/math/fract.inc => clc/include/clc/math/clc_fract.h} (57%) create mode 100644 libclc/clc/lib/generic/math/clc_fract.cl create mode 100644 libclc/clc/lib/generic/math/clc_fract.inc delete mode 100644 libclc/generic/lib/math/fract.inc diff --git a/libclc/generic/include/clc/math/fract.inc b/libclc/clc/include/clc/math/clc_fract.h similarity index 57% rename from libclc/generic/include/clc/math/fract.inc rename to libclc/clc/include/clc/math/clc_fract.h index 72e65d4409041..8ea47d47d914f 100644 --- a/libclc/generic/include/clc/math/fract.inc +++ b/libclc/clc/include/clc/math/clc_fract.h @@ -6,6 +6,15 @@ // //===--===// -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr); +#ifndef __CLC_MATH_CLC_FRACT_H__ +#define __CLC_MATH_CLC_FRACT_H__ + +#define __CLC_FUNCTION __clc_fract +#define __CLC_BODY + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_FRACT_H__ diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 4c81a152290a9..dafc69e1d83a4 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -46,6 +46,7 @@ math/clc_fmax.cl math/clc_fmin.cl math/clc_floor.cl math/clc_fmod.cl +math/clc_fract.cl math/clc_frexp.cl math/clc_hypot.cl math/clc_ldexp.cl diff --git a/libclc/clc/lib/generic/math/clc_fract.cl b/libclc/clc/lib/generic/math/clc_fract.cl new file mode 100644 index 0..1a0c5ab7a8d47 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.cl @@ -0,0 +1,17 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/libclc/clc/lib/generic/math/clc_fract.inc b/libclc/clc/lib/generic/math/clc_fract.inc new file mode 100644 index 0..31d32399e3f03 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fract.inc @@ -0,0 +1,38 @@ +//===--===// +// +// 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 +// +//===--===// + +#if __CLC_FPSIZE == 64 +#define MIN_CONSTANT 0x1.fp-1 +#elif __CLC_FPSIZE == 32 +#define MIN_CONSTANT 0x1.fep-1f +#elif __CLC_FPSIZE == 16 +#define MIN_CONSTANT 0x1.ffcp-1h +#endif + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x, + private __CLC_GENTYPE *iptr) { + *iptr = __clc_floor(x); + __CLC_GENTYPE r = __clc_fmin(x - *iptr, MIN_CONSTANT); + r = __clc_isinf(x) ? __CLC_FP_LIT(0.0) : r; + r = __clc_isnan(x) ? x : r; + return r; +} + +#define FRACT_DEF(addrspace) \ + _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract( \ + __CLC_GENTYPE x, addrspace __CLC_GENTYPE *iptr) { \ +__CLC_GENTYPE private_iptr; \ +__CLC_GENTYPE ret = __clc_fract(x, &private_iptr); \ +*iptr = private_iptr; \ +return ret; \ + } + +FRACT_
[clang] [clang] Remove FEM_Indeterminable (PR #137661)
AaronBallman wrote: > > > > @zahiraam @AaronBallman a different option would be to add a signed vs > > > > unsigned storage option to the `OPTION` and `BENIGN_ENUM_LANGOPT` > > > > macros so we can store negative enumerations safely > > > > > > > > > I think I would prefer this solution. We need to be able to set the > > > evaluation method to a value (-1) when it can't be known from the target > > > or when the value of `ffp-eval-method` is inconsistent with the target. > > > > > > Could we shift all the values, so `FEM_Indeterminable` is `0`? > > I don't think so. In practice on Linux systems, they use > `__FLT_EVAL_METHOD__` to control the type of `float_t` and `double_t`. Things > like this: Oh shoot, I forgot this was tied to `__FLT_EVAL_METHOD__` https://github.com/llvm/llvm-project/pull/137661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)
https://github.com/ShashwathiNavada updated https://github.com/llvm/llvm-project/pull/125643 >From 0aebcd7119fbcd51154c5d9706752e8ff3f041bc Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:16:09 -0600 Subject: [PATCH 01/10] Adding diagnostics for unsupported option --- clang/lib/Frontend/CompilerInvocation.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 11fd6ab7f52a7..ac8d8be572012 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1897,6 +1897,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.setInlining(CodeGenOptions::NormalInlining); } +// -mcmodel option. +if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) +{ +llvm::StringRef modelName = A->getValue(); +if(modelName=="tiny" && !T.isARM()) + Diags.Report(diag::err_drv_unsupported_option_argument_for_target) + << A->getSpelling()getValue(); if(modelName=="tiny" && !T.isARM()) - Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() From 689dc3a3472ff8270ee9631b235e776f5fa1a27f Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:49:37 -0600 Subject: [PATCH 03/10] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1242073ea6746..15d382620d279 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,13 +1896,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - - // -mcmodel option. - if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)){ + + // -mcmodel option. + if (const llvm::opt::Arg *A = + Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { llvm::StringRef modelName = A->getValue(); -if(modelName=="tiny" && !T.isARM()) +if (modelName == "tiny" && !T.isARM()) { Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() << modelName << T.getTriple(); + << A->getSpelling() << modelName << T.getTriple(); +} } // PIC defaults to -fno-direct-access-external-data while non-PIC defaults to >From 28fcb0ee20645cd1d30dd15bfd7f6eff402ba2b9 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 01:01:00 -0600 Subject: [PATCH 04/10] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 15d382620d279..f858ec2234cb5 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,7 +1896,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - + // -mcmodel option. if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { >From 843d4ccf4c41a78397e14eb5d9459a4921325741 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 21:39:44 +0530 Subject: [PATCH 05/10] Addressed build fail --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f858ec2234cb5..48f66931a
[clang] [Clang][AArch64] Add fp8 variants for untyped NEON intrinsics (PR #128019)
paulwalker-arm wrote: > @paulwalker-arm the reasoning behind creating separate records, is that > mfloat type is not available for aarch32 architectures and therefore all > intrinsics using it need to be gated behind `ArchGuard = > "defined(__aarch64__)"` . I see. How practical would it be for NEONEmitter to infer the ArchGuard based on the type? I'm assuming ArchGuard is either unset of set to what we need for all the cases we care about. This is not a firm ask but it would be nice to reuse the existing definitions if possible. https://github.com/llvm/llvm-project/pull/128019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)
https://github.com/ShashwathiNavada edited https://github.com/llvm/llvm-project/pull/125643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)
https://github.com/ShashwathiNavada updated https://github.com/llvm/llvm-project/pull/125643 >From 0aebcd7119fbcd51154c5d9706752e8ff3f041bc Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:16:09 -0600 Subject: [PATCH 01/11] Adding diagnostics for unsupported option --- clang/lib/Frontend/CompilerInvocation.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 11fd6ab7f52a7..ac8d8be572012 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1897,6 +1897,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.setInlining(CodeGenOptions::NormalInlining); } +// -mcmodel option. +if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) +{ +llvm::StringRef modelName = A->getValue(); +if(modelName=="tiny" && !T.isARM()) + Diags.Report(diag::err_drv_unsupported_option_argument_for_target) + << A->getSpelling()getValue(); if(modelName=="tiny" && !T.isARM()) - Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() From 689dc3a3472ff8270ee9631b235e776f5fa1a27f Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:49:37 -0600 Subject: [PATCH 03/11] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1242073ea6746..15d382620d279 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,13 +1896,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - - // -mcmodel option. - if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)){ + + // -mcmodel option. + if (const llvm::opt::Arg *A = + Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { llvm::StringRef modelName = A->getValue(); -if(modelName=="tiny" && !T.isARM()) +if (modelName == "tiny" && !T.isARM()) { Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() << modelName << T.getTriple(); + << A->getSpelling() << modelName << T.getTriple(); +} } // PIC defaults to -fno-direct-access-external-data while non-PIC defaults to >From 28fcb0ee20645cd1d30dd15bfd7f6eff402ba2b9 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 01:01:00 -0600 Subject: [PATCH 04/11] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 15d382620d279..f858ec2234cb5 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,7 +1896,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - + // -mcmodel option. if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { >From 843d4ccf4c41a78397e14eb5d9459a4921325741 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 21:39:44 +0530 Subject: [PATCH 05/11] Addressed build fail --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f858ec2234cb5..48f66931a
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ppc64le-linux-test-suite` running on `ppc64le-clang-test-suite` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/12600 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 1 Command Output (stderr): -- /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -mattr=+egpr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llvm-objdump --no-print-imm-hex -dr /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /home/buildbots/llvm-external-buildbots/workers/ppc64
[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)
https://github.com/ShashwathiNavada updated https://github.com/llvm/llvm-project/pull/125643 >From 0aebcd7119fbcd51154c5d9706752e8ff3f041bc Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:16:09 -0600 Subject: [PATCH 01/12] Adding diagnostics for unsupported option --- clang/lib/Frontend/CompilerInvocation.cpp | 9 + 1 file changed, 9 insertions(+) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 11fd6ab7f52a7..ac8d8be572012 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1897,6 +1897,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Opts.setInlining(CodeGenOptions::NormalInlining); } +// -mcmodel option. +if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) +{ +llvm::StringRef modelName = A->getValue(); +if(modelName=="tiny" && !T.isARM()) + Diags.Report(diag::err_drv_unsupported_option_argument_for_target) + << A->getSpelling()getValue(); if(modelName=="tiny" && !T.isARM()) - Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() From 689dc3a3472ff8270ee9631b235e776f5fa1a27f Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 00:49:37 -0600 Subject: [PATCH 03/12] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1242073ea6746..15d382620d279 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,13 +1896,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - - // -mcmodel option. - if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)){ + + // -mcmodel option. + if (const llvm::opt::Arg *A = + Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { llvm::StringRef modelName = A->getValue(); -if(modelName=="tiny" && !T.isARM()) +if (modelName == "tiny" && !T.isARM()) { Diags.Report(diag::err_drv_unsupported_option_argument_for_target) - << A->getSpelling() << modelName << T.getTriple(); + << A->getSpelling() << modelName << T.getTriple(); +} } // PIC defaults to -fno-direct-access-external-data while non-PIC defaults to >From 28fcb0ee20645cd1d30dd15bfd7f6eff402ba2b9 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 01:01:00 -0600 Subject: [PATCH 04/12] minor changes --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 15d382620d279..f858ec2234cb5 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1896,7 +1896,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, } else { Opts.setInlining(CodeGenOptions::NormalInlining); } - + // -mcmodel option. if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) { >From 843d4ccf4c41a78397e14eb5d9459a4921325741 Mon Sep 17 00:00:00 2001 From: ShashwathiNavada Date: Tue, 4 Feb 2025 21:39:44 +0530 Subject: [PATCH 05/12] Addressed build fail --- clang/lib/Frontend/CompilerInvocation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f858ec2234cb5..48f66931a
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` running on `gribozavr4` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/24594 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llc -mattr=+egpr /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llc -mattr=+egpr /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-objdump --no-print-imm-hex -dr /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-objdump --no-print-imm-hex -dr /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llc -mattr=+egpr /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llc -mattr=+egpr /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-objdump --no-print-imm-hex -dr /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-objdump --no-print-imm-hex -dr /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck /b/1/clang-x86_64-debian-fast/llvm.src/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 7 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o ld.lld /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.so # RUN: at line 8 + ld.lld /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o -o /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.tmp.so /b/1/clang-x86_64-debian-fast/llvm.obj/test/CodeGen/X86/apx/Output/tls.ll.script: line 7: ld.lld: command not found --
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-debian-cpp20` running on `clang-debian-cpp20` while building `llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/108/builds/12234 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llc -mattr=+egpr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llc -mattr=+egpr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-objdump --no-print-imm-hex -dr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/FileCheck /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-objdump --no-print-imm-hex -dr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/FileCheck /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llc -mattr=+egpr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llc -mattr=+egpr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-objdump --no-print-imm-hex -dr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/FileCheck /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/FileCheck /vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-objdump --no-print-imm-hex -dr /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp.o echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 7 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o ld
[clang] [HLSL] Allow non `.hlsl` files as source files (PR #137378)
https://github.com/s-perron closed https://github.com/llvm/llvm-project/pull/137378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
fzou1 wrote: Sorry. The test failure had been fixed in https://github.com/llvm/llvm-project/pull/137794. https://github.com/llvm/llvm-project/pull/136660 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cc0cf72 - [HLSL] Allow non `.hlsl` files as source files (#137378)
Author: Steven Perron Date: 2025-04-29T09:28:29-04:00 New Revision: cc0cf7253967af4aa3dce2a5de186f766564747b URL: https://github.com/llvm/llvm-project/commit/cc0cf7253967af4aa3dce2a5de186f766564747b DIFF: https://github.com/llvm/llvm-project/commit/cc0cf7253967af4aa3dce2a5de186f766564747b.diff LOG: [HLSL] Allow non `.hlsl` files as source files (#137378) Changes the driver to assume input file with an unknown extension are HLSL source files instead of object files. Fixes https://github.com/llvm/llvm-project/issues/137370 Added: clang/test/Driver/dxc_I.test Modified: clang/lib/Driver/Driver.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 2b8c6e35263b1..a648cc928afdc 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3001,6 +3001,8 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, Ty = types::TY_CXX; else if (CCCIsCPP() || CCGenDiagnostics) Ty = types::TY_C; +else if (IsDXCMode()) + Ty = types::TY_HLSL; else Ty = types::TY_Object; } diff --git a/clang/test/Driver/dxc_I.test b/clang/test/Driver/dxc_I.test new file mode 100644 index 0..c78382375b2b1 --- /dev/null +++ b/clang/test/Driver/dxc_I.test @@ -0,0 +1,4 @@ +// RUN: %clang_dxc -Tlib_6_3 -### %s 2>&1 | FileCheck %s + +// Make sure a non `.hlsl` file is considered an HLSL source file in dxc mode. +// CHECK: "-x" "hlsl" "{{.*}}dxc_I.test" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add test for QualTypes in template class NNS (PR #137804)
https://github.com/vgvassilev approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/137804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)
@@ -29,6 +29,8 @@ MODULE_PASS("amdgpu-printf-runtime-binding", AMDGPUPrintfRuntimeBindingPass()) MODULE_PASS("amdgpu-remove-incompatible-functions", AMDGPURemoveIncompatibleFunctionsPass(*this)) MODULE_PASS("amdgpu-sw-lower-lds", AMDGPUSwLowerLDSPass(*this)) MODULE_PASS("amdgpu-unify-metadata", AMDGPUUnifyMetadataPass()) +MODULE_PASS("amdgpu-expand-feature-predicates", +AMDGPUExpandFeaturePredicatesPass(*this)) jhuber6 wrote: I forget if these passes run in order, but shouldn't this run as soon as possible? https://github.com/llvm/llvm-project/pull/134016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] db2315a - [clang] Merge gtest binaries into AllClangUnitTests (#134196)
Author: Reid Kleckner Date: 2025-04-29T06:32:03-07:00 New Revision: db2315afa8db1153e3b85d452cd14d5a1b957350 URL: https://github.com/llvm/llvm-project/commit/db2315afa8db1153e3b85d452cd14d5a1b957350 DIFF: https://github.com/llvm/llvm-project/commit/db2315afa8db1153e3b85d452cd14d5a1b957350.diff LOG: [clang] Merge gtest binaries into AllClangUnitTests (#134196) This reduces the size of the clang/unittests build directory by 64% and my overall build dir size by 5%. Static linking is the real driving factor here, but even if the default build configuration used shared libraries, I don't see why we should be building so many unit test binaries. To make the project more approachable for new contributors, I'm attempting to make the build a bit less resource-intensive. Build directory size is a common complaint, and this is low-hanging fruit. I've noticed that incremental builds leave behind the old, stale gtest binaries, and lit will keep running them. This mostly doesn't matter unless they use shared libraries, which will eventually stop working after successive builds. You can clean up the old test binaries with this command in the build directory: $ find tools/clang/unittests/ -iname '*Tests' -type f | xargs rm ... or you can simply clean the build directory in a more holistic way. - Co-authored-by: Petr Hosek Added: Modified: clang/lib/CodeGen/BackendUtil.cpp clang/unittests/CMakeLists.txt clang/unittests/Driver/ModuleCacheTest.cpp clang/unittests/Frontend/OutputStreamTest.cpp clang/unittests/Interpreter/CMakeLists.txt clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt clang/unittests/Parse/CMakeLists.txt Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index f7eb853beb23c..2271f011b3a05 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -304,7 +304,7 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) { .Case("kernel", llvm::CodeModel::Kernel) .Case("medium", llvm::CodeModel::Medium) .Case("large", llvm::CodeModel::Large) - .Case("default", ~1u) + .Cases("default", "", ~1u) .Default(~0u); assert(CodeModel != ~0u && "invalid code model!"); if (CodeModel == ~1u) @@ -617,7 +617,8 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { return; TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr, Options, RM, CM, OptLevel)); - TM->setLargeDataThreshold(CodeGenOpts.LargeDataThreshold); + if (TM) +TM->setLargeDataThreshold(CodeGenOpts.LargeDataThreshold); } bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses, diff --git a/clang/unittests/CMakeLists.txt b/clang/unittests/CMakeLists.txt index f3823ba309420..b4114d419b75c 100644 --- a/clang/unittests/CMakeLists.txt +++ b/clang/unittests/CMakeLists.txt @@ -15,11 +15,11 @@ if(CLANG_BUILT_STANDALONE) endif() endif() -# add_clang_unittest(test_name file1.cpp file2.cpp) +# add_distinct_clang_unittest(test_name file1.cpp file2.cpp) # # Will compile the list of files together and link against the clang # Produces a binary named 'basename(test_name)'. -function(add_clang_unittest test_name) +function(add_distinct_clang_unittest test_name) cmake_parse_arguments(ARG "" "" @@ -47,6 +47,34 @@ function(add_clang_unittest test_name) target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS}) endfunction() +set(doc_opts BRIEF_DOCS "" FULL_DOCS "") +define_property(GLOBAL PROPERTY CLANG_UNITTEST_SRCS ${doc_opts}) +define_property(GLOBAL PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS ${doc_opts}) +define_property(GLOBAL PROPERTY CLANG_UNITTEST_CLANG_LIBS ${doc_opts}) +define_property(GLOBAL PROPERTY CLANG_UNITTEST_LINK_LIBS ${doc_opts}) + +# add_clang_unittest(test_name file1.cpp file2.cpp) +# +# Adds unittests to the combined AllClangUnitTests binary. The unittest binary +# is defined after adding all unittest subdirectories. +function(add_clang_unittest test_name) + cmake_parse_arguments(ARG +"" +"" +"CLANG_LIBS;LINK_LIBS;LLVM_COMPONENTS" +${ARGN}) + + file(RELATIVE_PATH src_prefix "${CMAKE_CURRENT_FUNCTION_LIST_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + set(srcs_prefixed) + foreach(src ${ARG_UNPARSED_ARGUMENTS}) +set(srcs_prefixed ${srcs_prefixed} "${src_prefix}/${src}") + endforeach() + set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_SRCS ${srcs_prefixed}) + set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_CLANG_LIBS ${ARG_CLANG_LIBS}) + set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LINK_LIBS ${ARG_LINK_LIBS}) + set_property(GLOBAL APPEND PROPERTY CLANG_UNITTEST_LLVM_COMPONENTS ${ARG_LLVM_COMPON
[libclc] [libclc] Support the generic address space (PR #137183)
@@ -23,4 +23,20 @@ #define _CLC_DEF __attribute__((always_inline)) #endif +#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \ +(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \ + defined(__opencl_c_generic_address_space)) +#define _CLC_GENERIC_AS_SUPPORTED 1 +// Note that we hard-code the assumption that a non-distinct address space means +// that the target maps the generic address space to the private address space. +#ifdef __CLC_DISTINCT_GENERIC_ADDRSPACE__ +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 +#else +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif +#else arsenm wrote: I mean something like ``` #define __libclc_generic_addrspace_val 0 #define __libclc_private_addrspace_val 5 #if __libclc_private_addrspace_val == __libclc_generic_addrspace_val // ... #endif ``` https://github.com/llvm/llvm-project/pull/137183 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)
https://github.com/rnk closed https://github.com/llvm/llvm-project/pull/134196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() const { + if (getTriple().isSPIRV()) +return {{&BuiltinStrings, BuiltinInfos}}; farzonl wrote: I don't understand why this change (in SPIR.cpp and SPIR.h) is necessesary. The existing code accomplished the same thing with method overriding. The original code also had some defensive programming safety to me. We went from a compile time enforcement of SPIRVTargetInfo== BuiltinsSPIRV.td to now a runtime enforcement. The problem with that is the next guy that comes along and makes a change might assume the builtins so far are SPIRV and thats why you are checking the triple, then add a new SPIR flavor builtin that would not be valid for SPIRV. https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() const { + if (getTriple().isSPIRV()) farzonl wrote: if you are using this to extend the builtins to spirv32/spirv64 I have concerns that not all builtins will be valid for those targets. For example `__builtin_spirv_reflect` is only valid when targeting spirv because thats the target that enables GLSL extentions. It is not valid for spirv32/64 because there is no equivalent opencl extention. To expose across all targets without exposing builtins that break could be tricky and might require special codegen to emulate the behavior of other targets. It might be simpler to just do a new tablegen file for spirv32/spriv64. https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] df267d7 - [C] Add new -Wimplicit-int-enum-cast to -Wc++-compat (#137658)
Author: Aaron Ballman Date: 2025-04-29T07:06:08-04:00 New Revision: df267d77f6cc06608d2fabc2139cabbd99007381 URL: https://github.com/llvm/llvm-project/commit/df267d77f6cc06608d2fabc2139cabbd99007381 DIFF: https://github.com/llvm/llvm-project/commit/df267d77f6cc06608d2fabc2139cabbd99007381.diff LOG: [C] Add new -Wimplicit-int-enum-cast to -Wc++-compat (#137658) This introduces a new diagnostic group to diagnose implicit casts from int to an enumeration type. In C, this is valid, but it is not compatible with C++. Additionally, this moves the "implicit conversion from enum type to different enum type" diagnostic from `-Wenum-conversion` to a new group `-Wimplicit-enum-enum-cast`, which is a more accurate home for it. `-Wimplicit-enum-enum-cast` is also under `-Wimplicit-int-enum-cast`, as it is the same incompatibility (the enumeration on the right-hand is promoted to `int`, so it's an int -> enum conversion). Fixes #37027 Added: clang/test/Sema/implicit-int-enum-conversion.c Modified: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaChecking.cpp clang/test/Misc/warning-flags-enabled.c Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 0fc46fe10b585..fd873a302a308 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -150,6 +150,15 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Wimplicit-int-enum-cast``, grouped under ``-Wc++-compat``, which + diagnoses implicit conversion from integer types to an enumeration type in C, + which is not compatible with C++. #GH37027 +- Split "implicit conversion from enum type to diff erent enum type" diagnostic + from ``-Wenum-conversion`` into its own diagnostic group, + ``-Wimplicit-enum-enum-cast``, which is grouped under both + ``-Wenum-conversion`` and ``-Wimplicit-int-enum-cast``. This conversion is an + int-to-enum conversion because the enumeration on the right-hand side is + promoted to ``int`` before the assignment. C2y Feature Support ^^^ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 31e2cfa7ab485..97ed38d71ed51 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -103,10 +103,12 @@ def AnonEnumEnumConversion : DiagGroup<"anon-enum-enum-conversion", [DeprecatedAnonEnumEnumConversion]>; def EnumEnumConversion : DiagGroup<"enum-enum-conversion", [DeprecatedEnumEnumConversion]>; +def ImplicitEnumEnumCast : DiagGroup<"implicit-enum-enum-cast">; def EnumFloatConversion : DiagGroup<"enum-float-conversion", [DeprecatedEnumFloatConversion]>; def EnumConversion : DiagGroup<"enum-conversion", [EnumEnumConversion, +ImplicitEnumEnumCast, EnumFloatConversion, EnumCompareConditional]>; def DeprecatedOFast : DiagGroup<"deprecated-ofast">; @@ -157,7 +159,10 @@ def : DiagGroup<"c2x-compat", [C23Compat]>; def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; -def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit]>; +def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast", + [ImplicitEnumEnumCast]>; +def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit, +ImplicitIntToEnumCast]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..2e148e01d6e5e 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4310,7 +4310,10 @@ def warn_impcast_string_literal_to_bool : Warning< InGroup, DefaultIgnore; def warn_impcast_ diff erent_enum_types : Warning< "implicit conversion from enumeration type %0 to diff erent enumeration type " - "%1">, InGroup; + "%1">, InGroup; +def warn_impcast_int_to_enum : Warning< + "implicit conversion from %0 to enumeration type %1 is invalid in C++">, + InGroup, DefaultIgnore; def warn_impcast_bool_to_null_pointer : Warning< "initialization of pointer of type %0
[clang] [C] Add new -Wimplicit-int-enum-cast to -Wc++-compat (PR #137658)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/137658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Diagnose declarations hidden in C++ (PR #137368)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137368 >From e8234c9f374783f3b3fde586464037f52eda2f77 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 25 Apr 2025 13:16:39 -0400 Subject: [PATCH 1/3] [C] Diagnose declarations hidden in C++ This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped under -Wc++-compat, that diagnoses declarations which are valid in C but invalid in C++ due to the type being at the wrong scope. e.g., struct S { struct T { int x; } t; }; struct T t; // Valid C, invalid C++ This is implementing the other half of #21898 --- clang/docs/ReleaseNotes.rst | 12 clang/include/clang/AST/DeclBase.h| 6 +- clang/include/clang/Basic/DiagnosticGroups.td | 5 +- .../clang/Basic/DiagnosticSemaKinds.td| 4 ++ clang/include/clang/Sema/Sema.h | 1 + clang/lib/AST/DeclBase.cpp| 11 +++ clang/lib/Sema/SemaDecl.cpp | 33 + clang/test/Sema/decl-hidden-in-c++.c | 68 +++ 8 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/decl-hidden-in-c++.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6ecb97825ab8d..262c863c602d0 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -150,6 +150,18 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Wc++-hidden-decl``, grouped under ``-Wc++-compat``, which diagnoses + use of tag types which are visible in C but not visible in C++ due to scoping + rules. e.g., + + .. code-block:: c + +struct S { + struct T { +int x; + } t; +}; +struct T t; // Invalid C++, valid C, now diagnosed C2y Feature Support ^^^ diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 2fb9d5888bce4..375e9e2592502 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -2239,10 +2239,14 @@ class DeclContext { return DC && this->getPrimaryContext() == DC->getPrimaryContext(); } - /// Determine whether this declaration context encloses the + /// Determine whether this declaration context semantically encloses the /// declaration context DC. bool Encloses(const DeclContext *DC) const; + /// Determine whether this declaration context lexically encloses the + /// declaration context DC. + bool LexicallyEncloses(const DeclContext *DC) const; + /// Find the nearest non-closure ancestor of this context, /// i.e. the innermost semantic parent of this context which is not /// a closure. A context may be its own non-closure ancestor. diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 31e2cfa7ab485..47b24d5d6c112 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -154,10 +154,13 @@ def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">; def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; +def HiddenCppDecl : DiagGroup<"c++-hidden-decl">; def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; -def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit]>; +def CXXCompat: DiagGroup<"c++-compat", + [ImplicitVoidPtrCast, DefaultConstInit, + HiddenCppDecl]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 7090cbe7acbe6..4be5654e6a63f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -496,6 +496,10 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup, DefaultIgnore; +def warn_decl_hidden_in_cpp : Warning< + "%select{struct|union|enum}0 defined within a struct or union is not visible " + "in C++">, InGroup, DefaultIgnore; + def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "|" // ReservedIdentifierStatus::NotReserved diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 0c77c5b5ca30a..7bad162afa66f 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3536,6 +3536,7 @@ class Sema final : public SemaBase { }
[clang] [llvm] [clang][amdgpu] Add builtins for raw/struct buffer lds load (PR #137678)
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tahiti -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu bonaire -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu carrizo -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -S -verify -o - %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1200 -S -verify -o - %s +// REQUIRES: amdgpu-registered-target + +typedef unsigned int v4u32 __attribute__((ext_vector_type(4))); + +void test_amdgcn_struct_buffer_load_lds(v4u32 rsrc, __local void* lds, int index, int offset, int soffset, int x) { JonChesterfield wrote: Or see the other test cases in this PR. I'm not claiming multiple test lines in one test never works, I'm claiming merging these does not work. Please feel free to apply the patch and try it. I don't want to stall the intrinsics on debugging through clang's verify implementation quirks. https://github.com/llvm/llvm-project/pull/137678 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-nvptx-nvidia-win` running on `as-builder-8` while building `llvm` at step 7 "test-build-unified-tree-check-llvm". Full details are available at: https://lab.llvm.org/buildbot/#/builders/54/builds/8678 Here is the relevant piece of the build log for the reference ``` Step 7 (test-build-unified-tree-check-llvm) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stdout): -- # RUN: at line 1 c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe -mattr=+egpr C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe' -mattr=+egpr 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # RUN: at line 2 c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-objdump.exe --no-print-imm-hex -dr C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o | c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll --check-prefix=TLSDESC # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-objdump.exe' --no-print-imm-hex -dr 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' --check-prefix=TLSDESC # RUN: at line 3 echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-mc.exe -filetype=obj -triple=x86_64 - -o C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o # executed command: echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-mc.exe' -filetype=obj -triple=x86_64 - -o 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o' # RUN: at line 5 c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe -mattr=+egpr C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll -mtriple=x86_64 -filetype=obj -o C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o -x86-enable-apx-for-relocation=true # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llc.exe' -mattr=+egpr 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' -mtriple=x86_64 -filetype=obj -o 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' -x86-enable-apx-for-relocation=true # RUN: at line 6 c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-objdump.exe --no-print-imm-hex -dr C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o | c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll --check-prefix=GOTTPOFF_APXRELAX # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-objdump.exe' --no-print-imm-hex -dr 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 7 echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | c:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\bin\llvm-mc.exe -filetype=obj -triple=x86_64 - -o C:\buildbot\as-builder-8\llvm-nvptx-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o # executed command: echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' # executed command: 'c:\buildbot\as-builder-8\llvm-n
[libclc] [libclc] Move fract to the CLC library (PR #137785)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/137785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137234 >From 56a3f3cd282e9bd5ef9014e4125380e0d9685121 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 24 Apr 2025 14:17:42 -0400 Subject: [PATCH 01/15] [C] Diagnose use of C++ keywords in C This adds a new diagnostic group, -Widentifier-is-c++-keyword, which is off by default and grouped under -Wc++-compat. The diagnostic catches use of C++ keywords in C code. This change additionally fixes an issue with -Wreserved-identifier not diagnosing use of reserved identifiers in function parameter lists. Partially fixes #21898 --- clang/docs/ReleaseNotes.rst | 3 + clang/include/clang/Basic/DiagnosticGroups.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 3 + clang/include/clang/Basic/IdentifierTable.h | 11 +- clang/lib/Basic/IdentifierTable.cpp | 27 +++ clang/lib/Sema/SemaDecl.cpp | 23 ++ clang/test/Sema/c++-keyword-in-c.c| 213 ++ 7 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 clang/test/Sema/c++-keyword-in-c.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d1f24fb23d44d..57b604335fcdd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -143,6 +143,9 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Widentifier-is-c++-keyword``, grouped under ``-Wc++-compat``, which + diagnoses when a C++ keyword is used as an identifier in C. Partially + addresses #GH21898. C2y Feature Support ^^^ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 6441b8049ed8d..84e590a857398 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -155,8 +155,9 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; +def CppKeywordInC : DiagGroup<"identifier-is-c++-keyword">; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; -def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast]>; +def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, CppKeywordInC]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; def GNUCaseRange : DiagGroup<"gnu-case-range">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 8ff170520aafe..50a960313349a 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -496,6 +496,9 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup, DefaultIgnore; +def warn_identifier_is_cpp_keyword : Warning< + "identifier %0 conflicts with a C++ keyword">, + InGroup, DefaultIgnore; def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "|" // ReservedIdentifierStatus::NotReserved diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 1275b056227b5..05c989c1b07d9 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -444,13 +444,18 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { } bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; } - /// Return true if this token is a keyword in the specified language. + /// Return true if this identifier uses a keyword token and is a keyword in + /// the specified language. bool isKeyword(const LangOptions &LangOpts) const; - /// Return true if this token is a C++ keyword in the specified - /// language. + /// Return true if this identifier uses a keyword token and is a C++ keyword + /// in the specified language. bool isCPlusPlusKeyword(const LangOptions &LangOpts) const; + /// Returns true if the name of this identifier matches a keyword given the + /// specified language options. + bool isNameKeyword(const LangOptions &LangOpts) const; + /// Get and set FETokenInfo. The language front-end is allowed to associate /// arbitrary metadata with this token. void *getFETokenInfo() const { return FETokenInfo; } diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 16151c94464f9..412f0af40861a 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -343,6 +343,14 @@ static KeywordStatus getTokenKwStatus(const LangOptions &LangOpts, } } +static KeywordStatus getNameKwStatus(const LangOptions &LangOpts, + StringRef Name)
[clang] clang-format: Add -disable-format option (PR #137617)
DaanDeMeyer wrote: > Can't you just run the `llvm-include-order` clang-tidy check instead? Does that take `IncludeBlocks` and `IncludeCategories` from `.clang-format` into account? https://github.com/llvm/llvm-project/pull/137617 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
arsenm wrote: In practice this should be a single use of an internal function and should not require this hint. Is this papering over a different issue? https://github.com/llvm/llvm-project/pull/137769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-cmake-x86_64-avx512-linux` running on `avx512-intel64` while building `llvm` at step 7 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/15286 Here is the relevant piece of the build log for the reference ``` Step 7 (ninja check 1) failure: stage 1 checked (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stderr): -- /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llc -mattr=+egpr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o # RUN: at line 1 + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llc -mattr=+egpr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-objdump --no-print-imm-hex -dr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC # RUN: at line 2 + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-objdump --no-print-imm-hex -dr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=TLSDESC echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o # RUN: at line 3 + echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp1.o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llc -mattr=+egpr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true # RUN: at line 5 + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llc -mattr=+egpr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll -mtriple=x86_64 -filetype=obj -o /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o -x86-enable-apx-for-relocation=true /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-objdump --no-print-imm-hex -dr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 6 + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-objdump --no-print-imm-hex -dr /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/test/CodeGen/X86/apx/Output/tls.ll.tmp.o + /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/CodeGen/X86/apx/tls.ll --check-prefix=GOTTPOFF_APXRELAX echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/llvm-mc -filetype=obj -triple=x86_64 - -o /localdisk2
[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
@@ -6107,6 +6109,44 @@ static bool isFromSystemHeader(SourceManager &SM, const Decl *D) { SM.isInSystemMacro(D->getLocation()); } +constexpr unsigned countCPlusPlusKeywords() { + unsigned Ret = 0; +#define MODULES_KEYWORD(NAME) +#define KEYWORD(NAME, FLAGS) ++Ret; +#define CXX_KEYWORD_OPERATOR(NAME, TOK) ++Ret; +#include "clang/Basic/TokenKinds.def" + return Ret; +} + +static bool isKeywordInCPlusPlus(const Sema &S, const IdentifierInfo *II) { + if (!II) +return false; + + // Build a static map of identifiers for all of the keywords in C++ that are + // not keywords in C. This allows us to do pointer comparisons instead of + // string comparisons when deciding whether the given identifier is a keyword + // or not. Note, this treats all keywords as being enabled, regardless of the + // setting of other language options. It intentionally disables the modules + // keywords because those are conditional keywords, so may be safe to use. + static auto Keywords = [&S] { +std::array Ret; +unsigned Idx = 0; +#define MODULES_KEYWORD(NAME) +#define KEYWORD(NAME, FLAGS) \ + Ret[Idx++] = reinterpret_cast( \ + &S.getPreprocessor().getIdentifierTable().get(#NAME)); +#define CXX_KEYWORD_OPERATOR(NAME, TOK) \ + Ret[Idx++] = reinterpret_cast( \ + &S.getPreprocessor().getIdentifierTable().get(#NAME)); +#include "clang/Basic/TokenKinds.def" +assert(Idx == Ret.size() && "expected to fill every member!"); +llvm::sort(Ret); +return Ret; + }(); + + return llvm::binary_search(Keywords, reinterpret_cast(II)); AaronBallman wrote: Good suggestion, I've gone ahead with those changes. https://github.com/llvm/llvm-project/pull/137234 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` running on `linaro-lldb-aarch64-ubuntu` while building `llvm` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/16860 Here is the relevant piece of the build log for the reference ``` Step 6 (test) failure: build (failure) ... PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAttach.py (1207 of 2152) PASS: lldb-api :: tools/lldb-server/TestGdbRemoteCompletion.py (1208 of 2152) UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteFork.py (1209 of 2152) UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkNonStop.py (1210 of 2152) UNSUPPORTED: lldb-api :: tools/lldb-server/TestGdbRemoteForkResume.py (1211 of 2152) PASS: lldb-api :: tools/lldb-server/TestGdbRemoteExitCode.py (1212 of 2152) PASS: lldb-api :: tools/lldb-server/TestGdbRemoteHostInfo.py (1213 of 2152) PASS: lldb-api :: tools/lldb-server/TestGdbRemoteModuleInfo.py (1214 of 2152) PASS: lldb-api :: tools/lldb-server/TestGdbRemoteAuxvSupport.py (1215 of 2152) UNRESOLVED: lldb-api :: tools/lldb-dap/variables/TestDAP_variables.py (1216 of 2152) TEST 'lldb-api :: tools/lldb-dap/variables/TestDAP_variables.py' FAILED Script: -- /usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/variables -p TestDAP_variables.py -- Exit Code: 1 Command Output (stdout): -- lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision bd6addc032b1ea764494e2de135b5b2c46ee6aca) clang revision bd6addc032b1ea764494e2de135b5b2c46ee6aca llvm revision bd6addc032b1ea764494e2de135b5b2c46ee6aca Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc'] -- Command Output (stderr): -- UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_darwin_dwarf_missing_obj (TestDAP_variables.TestDAP_variables) (requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_darwin_dwarf_missing_obj_with_symbol_ondemand_enabled (TestDAP_variables.TestDAP_variables) (requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) = DEBUG ADAPTER PROTOCOL LOGS = 1745927725.626282930 --> (stdin/stdout) {"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1} 1745927725.628283978 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision bd6addc032b1ea764494e2de135b5b2c46ee6aca)\n clang revision bd6addc032b1ea764494e2de135b5b2c46ee6aca\n llvm revision bd6addc032b1ea764494e2de135b5b2c46ee6aca","completionTriggerCharacters":["."," ","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++ Catch"},{"default":false,"filter":"cpp_throw","label":"C++ Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBr
[clang] [clang] Remove dead incremental Parser code (PR #102450)
hahnjo wrote: > > As far as I can tell, -fincremental-extensions should set the language > > option IncrementalExtensions which in turn is the default for > > Preprocessor::IncrementalProcessing. > > It is true that it is the default, but it's possible for clients to have one > without the other. This is the case in Swift in particular (see #65683). > > > The few tests we have with -fincremental-extensions pass with this change. > > I couldn't think of a great way to test this at the time. If anyone has any > ideas though... 😅. Otherwise we could add a comment here to explain why it's > needed? If I understand correctly, you are manually calling `Preprocessor::enableIncrementalProcessing`? This should be added as a unittest because right now it is not exercised at all... https://github.com/llvm/llvm-project/pull/102450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix crash with -ast-dump=json (PR #137324)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/137324 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2f97695 - [C] Diagnose declarations hidden in C++ (#137368)
Author: Aaron Ballman Date: 2025-04-29T07:58:00-04:00 New Revision: 2f976956e5ccef566418853015fb6b31257aa69f URL: https://github.com/llvm/llvm-project/commit/2f976956e5ccef566418853015fb6b31257aa69f DIFF: https://github.com/llvm/llvm-project/commit/2f976956e5ccef566418853015fb6b31257aa69f.diff LOG: [C] Diagnose declarations hidden in C++ (#137368) This introduces a new diagnostic, -Wc++-hidden-decl, which is grouped under -Wc++-compat, that diagnoses declarations which are valid in C but invalid in C++ due to the type being at the wrong scope. e.g., ``` struct S { struct T { int x; } t; }; struct T t; // Valid C, invalid C++ ``` This is implementing the other half of #21898 Added: clang/test/Sema/decl-hidden-in-c++.c Modified: clang/docs/ReleaseNotes.rst clang/include/clang/AST/DeclBase.h clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/AST/DeclBase.cpp clang/lib/Sema/SemaDecl.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 61e08b15e810b..bc68bb8b70b3d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -150,6 +150,18 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Wc++-hidden-decl``, grouped under ``-Wc++-compat``, which diagnoses + use of tag types which are visible in C but not visible in C++ due to scoping + rules. e.g., + + .. code-block:: c + +struct S { + struct T { +int x; + } t; +}; +struct T t; // Invalid C++, valid C, now diagnosed - Added ``-Wimplicit-int-enum-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from integer types to an enumeration type in C, which is not compatible with C++. #GH37027 diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 2fb9d5888bce4..375e9e2592502 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -2239,10 +2239,14 @@ class DeclContext { return DC && this->getPrimaryContext() == DC->getPrimaryContext(); } - /// Determine whether this declaration context encloses the + /// Determine whether this declaration context semantically encloses the /// declaration context DC. bool Encloses(const DeclContext *DC) const; + /// Determine whether this declaration context lexically encloses the + /// declaration context DC. + bool LexicallyEncloses(const DeclContext *DC) const; + /// Find the nearest non-closure ancestor of this context, /// i.e. the innermost semantic parent of this context which is not /// a closure. A context may be its own non-closure ancestor. diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 97ed38d71ed51..fc1ce197ef134 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -156,13 +156,14 @@ def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">; def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; +def HiddenCppDecl : DiagGroup<"c++-hidden-decl">; def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">; def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; def ImplicitIntToEnumCast : DiagGroup<"implicit-int-enum-cast", [ImplicitEnumEnumCast]>; def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit, -ImplicitIntToEnumCast]>; +ImplicitIntToEnumCast, HiddenCppDecl]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 2e148e01d6e5e..ad5bf26be2590 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -496,6 +496,10 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup, DefaultIgnore; +def warn_decl_hidden_in_cpp : Warning< + "%select{struct|union|enum}0 defined within a struct or union is not visible " + "in C++">, InGroup, DefaultIgnore; + def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "|" // ReservedIdentifierStatus::NotReserved diff --git a/clang/include/clang/Sema/
[clang] [C] Diagnose declarations hidden in C++ (PR #137368)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/137368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [X86][APX] Suppress EGPR/NDD instructions for relocations (PR #136660)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-nvptx64-nvidia-win` running on `as-builder-8` while building `llvm` at step 7 "test-build-unified-tree-check-llvm". Full details are available at: https://lab.llvm.org/buildbot/#/builders/155/builds/8781 Here is the relevant piece of the build log for the reference ``` Step 7 (test-build-unified-tree-check-llvm) failure: test (failure) TEST 'LLVM :: CodeGen/X86/apx/tls.ll' FAILED Exit Code: 127 Command Output (stdout): -- # RUN: at line 1 c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llc.exe -mattr=+egpr C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llc.exe' -mattr=+egpr 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' -mtriple=x86_64 --relocation-model=pic -enable-tlsdesc -filetype=obj -o 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # RUN: at line 2 c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-objdump.exe --no-print-imm-hex -dr C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll --check-prefix=TLSDESC # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-objdump.exe' --no-print-imm-hex -dr 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' --check-prefix=TLSDESC # RUN: at line 3 echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-mc.exe -filetype=obj -triple=x86_64 - -o C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o # executed command: echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-mc.exe' -filetype=obj -triple=x86_64 - -o 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o' # RUN: at line 5 c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llc.exe -mattr=+egpr C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll -mtriple=x86_64 -filetype=obj -o C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o -x86-enable-apx-for-relocation=true # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llc.exe' -mattr=+egpr 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' -mtriple=x86_64 -filetype=obj -o 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' -x86-enable-apx-for-relocation=true # RUN: at line 6 c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-objdump.exe --no-print-imm-hex -dr C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll --check-prefix=GOTTPOFF_APXRELAX # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-objdump.exe' --no-print-imm-hex -dr 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp.o' # executed command: 'c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\filecheck.exe' 'C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\llvm-project\llvm\test\CodeGen\X86\apx\tls.ll' --check-prefix=GOTTPOFF_APXRELAX # RUN: at line 7 echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i: .zero 4;j: .zero 4' | c:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\bin\llvm-mc.exe -filetype=obj -triple=x86_64 - -o C:\buildbot\as-builder-8\llvm-nvptx64-nvidia-win\build\test\CodeGen\X86\apx\Output\tls.ll.tmp1.o # executed command: echo '.tbss; .globl b,c,d,e,f,g,h,i,j; b: .zero 4;c: .zero 4;d: .zero 4;e: .zero 4;f: .zero 4;g: .zero 4;h: .zero 4;i:
[clang] [C] Diagnose use of C++ keywords in C (PR #137234)
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137234 >From 56a3f3cd282e9bd5ef9014e4125380e0d9685121 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 24 Apr 2025 14:17:42 -0400 Subject: [PATCH 01/15] [C] Diagnose use of C++ keywords in C This adds a new diagnostic group, -Widentifier-is-c++-keyword, which is off by default and grouped under -Wc++-compat. The diagnostic catches use of C++ keywords in C code. This change additionally fixes an issue with -Wreserved-identifier not diagnosing use of reserved identifiers in function parameter lists. Partially fixes #21898 --- clang/docs/ReleaseNotes.rst | 3 + clang/include/clang/Basic/DiagnosticGroups.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 3 + clang/include/clang/Basic/IdentifierTable.h | 11 +- clang/lib/Basic/IdentifierTable.cpp | 27 +++ clang/lib/Sema/SemaDecl.cpp | 23 ++ clang/test/Sema/c++-keyword-in-c.c| 213 ++ 7 files changed, 279 insertions(+), 4 deletions(-) create mode 100644 clang/test/Sema/c++-keyword-in-c.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d1f24fb23d44d..57b604335fcdd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -143,6 +143,9 @@ C Language Changes - Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which diagnoses implicit conversion from ``void *`` to another pointer type as being incompatible with C++. (#GH17792) +- Added ``-Widentifier-is-c++-keyword``, grouped under ``-Wc++-compat``, which + diagnoses when a C++ keyword is used as an identifier in C. Partially + addresses #GH21898. C2y Feature Support ^^^ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 6441b8049ed8d..84e590a857398 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -155,8 +155,9 @@ def C99Compat : DiagGroup<"c99-compat">; def C23Compat : DiagGroup<"c23-compat">; def : DiagGroup<"c2x-compat", [C23Compat]>; +def CppKeywordInC : DiagGroup<"identifier-is-c++-keyword">; def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">; -def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast]>; +def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, CppKeywordInC]>; def ExternCCompat : DiagGroup<"extern-c-compat">; def KeywordCompat : DiagGroup<"keyword-compat">; def GNUCaseRange : DiagGroup<"gnu-case-range">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 8ff170520aafe..50a960313349a 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -496,6 +496,9 @@ def warn_unused_lambda_capture: Warning<"lambda capture %0 is not " "%select{used|required to be captured for this use}1">, InGroup, DefaultIgnore; +def warn_identifier_is_cpp_keyword : Warning< + "identifier %0 conflicts with a C++ keyword">, + InGroup, DefaultIgnore; def warn_reserved_extern_symbol: Warning< "identifier %0 is reserved because %select{" "|" // ReservedIdentifierStatus::NotReserved diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index 1275b056227b5..05c989c1b07d9 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -444,13 +444,18 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { } bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; } - /// Return true if this token is a keyword in the specified language. + /// Return true if this identifier uses a keyword token and is a keyword in + /// the specified language. bool isKeyword(const LangOptions &LangOpts) const; - /// Return true if this token is a C++ keyword in the specified - /// language. + /// Return true if this identifier uses a keyword token and is a C++ keyword + /// in the specified language. bool isCPlusPlusKeyword(const LangOptions &LangOpts) const; + /// Returns true if the name of this identifier matches a keyword given the + /// specified language options. + bool isNameKeyword(const LangOptions &LangOpts) const; + /// Get and set FETokenInfo. The language front-end is allowed to associate /// arbitrary metadata with this token. void *getFETokenInfo() const { return FETokenInfo; } diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 16151c94464f9..412f0af40861a 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -343,6 +343,14 @@ static KeywordStatus getTokenKwStatus(const LangOptions &LangOpts, } } +static KeywordStatus getNameKwStatus(const LangOptions &LangOpts, + StringRef Name)
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
https://github.com/Naghasan updated https://github.com/llvm/llvm-project/pull/137805 >From 020a804188b13ef881dcf1cbd81a5e11e4803d62 Mon Sep 17 00:00:00 2001 From: Victor Lomuller Date: Mon, 28 Apr 2025 16:20:09 +0100 Subject: [PATCH] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding The patch introduce __builtin_spirv_generic_cast_to_ptr_explicit which is lowered to the llvm.spv.generic.cast.to.ptr.explicit intrinsic. The patch also introduces a new header defining its SPIR-V friendly equivalent (__spirv_GenericCastToPtrExplicit_ToGlobal, __spirv_GenericCastToPtrExplicit_ToLocal and __spirv_GenericCastToPtrExplicit_ToPrivate). The functions are declared as aliases to the new builtin allowing C-like languages to have a definition to rely on as well as gaining proper front-end diagnostics. --- clang/include/clang/Basic/BuiltinsSPIRV.td| 9 + .../clang/Basic/DiagnosticSemaKinds.td| 10 +- clang/lib/AST/ASTContext.cpp | 5 + clang/lib/Basic/Targets/SPIR.cpp | 2 +- clang/lib/Basic/Targets/SPIR.h| 4 +- clang/lib/CodeGen/CGBuiltin.cpp | 4 +- clang/lib/CodeGen/TargetBuiltins/SPIR.cpp | 14 ++ clang/lib/Headers/CMakeLists.txt | 16 ++ clang/lib/Headers/__clang_spirv_builtins.h| 179 ++ clang/lib/Sema/SemaChecking.cpp | 6 +- clang/lib/Sema/SemaDeclAttr.cpp | 4 +- clang/lib/Sema/SemaSPIRV.cpp | 108 +++ .../Builtins/generic_cast_to_ptr_explicit.c | 33 clang/test/Headers/spirv_functions.cpp| 25 +++ .../BuiltIns/generic_cast_to_ptr_explicit.c | 25 +++ 15 files changed, 436 insertions(+), 8 deletions(-) create mode 100644 clang/lib/Headers/__clang_spirv_builtins.h create mode 100644 clang/test/CodeGenSPIRV/Builtins/generic_cast_to_ptr_explicit.c create mode 100644 clang/test/Headers/spirv_functions.cpp create mode 100644 clang/test/SemaSPIRV/BuiltIns/generic_cast_to_ptr_explicit.c diff --git a/clang/include/clang/Basic/BuiltinsSPIRV.td b/clang/include/clang/Basic/BuiltinsSPIRV.td index cc0c2f960f8d2..bbb2abba2e256 100644 --- a/clang/include/clang/Basic/BuiltinsSPIRV.td +++ b/clang/include/clang/Basic/BuiltinsSPIRV.td @@ -8,6 +8,12 @@ include "clang/Basic/BuiltinsBase.td" +class SPIRVBuiltin Attr> : Builtin { + let Spellings = ["__builtin_spirv_"#NAME]; + let Prototype = prototype; + let Attributes = !listconcat([NoThrow], Attr); +} + def SPIRVDistance : Builtin { let Spellings = ["__builtin_spirv_distance"]; let Attributes = [NoThrow, Const]; @@ -37,3 +43,6 @@ def SPIRVFaceForward : Builtin { let Attributes = [NoThrow, Const, CustomTypeChecking]; let Prototype = "void(...)"; } + +def generic_cast_to_ptr_explicit +: SPIRVBuiltin<"void*(void*, int)", [NoThrow, Const, CustomTypeChecking]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4c96142e28134..8f088d4d0d0f8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4609,7 +4609,7 @@ def err_attribute_preferred_name_arg_invalid : Error< "argument %0 to 'preferred_name' attribute is not a typedef for " "a specialization of %1">; def err_attribute_builtin_alias : Error< - "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">; + "%0 attribute can only be applied to a ARM, HLSL, SPIR-V or RISC-V builtin">; // called-once attribute diagnostics. def err_called_once_attribute_wrong_type : Error< @@ -12740,6 +12740,14 @@ def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; +// SPIR-V builtins diagnostics +def err_spirv_builtin_generic_cast_invalid_arg : Error< + "expecting a pointer argument to the generic address space">; +def err_spirv_enum_not_int : Error< + "%0{storage class} argument for SPIR-V builtin is not a 32-bits integer">; +def err_spirv_enum_not_valid : Error< + "invalid value for %select{storage class}0 argument">; + // errors of expect.with.probability def err_probability_not_constant_float : Error< "probability argument to __builtin_expect_with_probability must be constant " diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c95e733f30494..51438c22f52fe 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -10054,6 +10054,11 @@ bool ASTContext::canBuiltinBeRedeclared(const FunctionDecl *FD) const { if (LangOpts.HLSL && FD->getBuiltinID() != Builtin::NotBuiltin && BuiltinInfo.hasCustomTypechecking(FD->getBuiltinID())) return true; + // Allow redecl custom type checking builtin for SPIR-V. + if (getTargetInfo().getTriple().isSPIROrSPIRV() && + BuiltinInf
[libclc] [libclc] Move fdim to CLC library; simplify (PR #137811)
https://github.com/frasercrmck created https://github.com/llvm/llvm-project/pull/137811 This commit moves the fdim builtin to the CLC library. It simultaneously simplifies the codegen, unifying it between scalar and vector and avoiding bithacking for vector types. >From a20d00150430c7e5c24b69401526d44a41ab7886 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Tue, 29 Apr 2025 12:28:08 +0100 Subject: [PATCH] [libclc] Move fdim to CLC library; simplify This commit moves the fdim builtin to the CLC library. It simultaneously simplifies the codegen, unifying it between scalar and vector and avoiding bithacking for vector types. --- libclc/clc/include/clc/math/clc_fdim.h | 20 ++ libclc/clc/include/clc/math/gentype.inc | 4 ++ libclc/clc/lib/generic/SOURCES | 1 + libclc/clc/lib/generic/math/clc_fdim.cl | 18 ++ libclc/clc/lib/generic/math/clc_fdim.inc | 15 + libclc/generic/include/clc/math/fdim.h | 2 +- libclc/generic/lib/math/fdim.cl | 5 +- libclc/generic/lib/math/fdim.inc | 82 8 files changed, 62 insertions(+), 85 deletions(-) create mode 100644 libclc/clc/include/clc/math/clc_fdim.h create mode 100644 libclc/clc/lib/generic/math/clc_fdim.cl create mode 100644 libclc/clc/lib/generic/math/clc_fdim.inc delete mode 100644 libclc/generic/lib/math/fdim.inc diff --git a/libclc/clc/include/clc/math/clc_fdim.h b/libclc/clc/include/clc/math/clc_fdim.h new file mode 100644 index 0..4477d1ecb7d31 --- /dev/null +++ b/libclc/clc/include/clc/math/clc_fdim.h @@ -0,0 +1,20 @@ +//===--===// +// +// 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 +// +//===--===// + +#ifndef __CLC_MATH_CLC_FDIM_H__ +#define __CLC_MATH_CLC_FDIM_H__ + +#define __CLC_BODY +#define __CLC_FUNCTION __clc_fdim + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION + +#endif // __CLC_MATH_CLC_FDIM_H__ diff --git a/libclc/clc/include/clc/math/gentype.inc b/libclc/clc/include/clc/math/gentype.inc index 0c7dd5b220b9c..196d2e96922eb 100644 --- a/libclc/clc/include/clc/math/gentype.inc +++ b/libclc/clc/include/clc/math/gentype.inc @@ -57,6 +57,8 @@ #define __CLC_CONVERT_UINTN __CLC_XCONCAT(__clc_convert_, __CLC_UINTN) #define __CLC_CONVERT_ULONGN __CLC_XCONCAT(__clc_convert_, __CLC_ULONGN) +#define __CLC_CONVERT_BIT_INTN __CLC_XCONCAT(__clc_convert_, __CLC_BIT_INTN) + // See definitions of __CLC_S_GENTYPE/__CLC_U_GENTYPE below, which depend on the // specific size of floating-point type. These are the signed and unsigned // integers of the same bitwidth and element count as the GENTYPE. They match @@ -329,6 +331,8 @@ #undef __CLC_CONVERT_UINTN #undef __CLC_CONVERT_ULONGN +#undef __CLC_CONVERT_BIT_INTN + #undef __CLC_ULONGN #undef __CLC_UINTN #undef __CLC_USHORTN diff --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES index 4c81a152290a9..289f7eed83342 100644 --- a/libclc/clc/lib/generic/SOURCES +++ b/libclc/clc/lib/generic/SOURCES @@ -41,6 +41,7 @@ math/clc_exp2.cl math/clc_expm1.cl math/clc_exp_helper.cl math/clc_fabs.cl +math/clc_fdim.cl math/clc_fma.cl math/clc_fmax.cl math/clc_fmin.cl diff --git a/libclc/clc/lib/generic/math/clc_fdim.cl b/libclc/clc/lib/generic/math/clc_fdim.cl new file mode 100644 index 0..4e76448cde88f --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fdim.cl @@ -0,0 +1,18 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include +#include +#include +#include +#include +#include +#include + +#define __CLC_BODY +#include diff --git a/libclc/clc/lib/generic/math/clc_fdim.inc b/libclc/clc/lib/generic/math/clc_fdim.inc new file mode 100644 index 0..712818bb0a305 --- /dev/null +++ b/libclc/clc/lib/generic/math/clc_fdim.inc @@ -0,0 +1,15 @@ +//===--===// +// +// 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 +// +//===--===// + +_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fdim(__CLC_GENTYPE x, +__CLC_GENTYPE y) { + return __clc_select( + __builtin_elementwise_max(x - y, (__CLC_GENTYPE)__CLC_FP_LIT(0.0)),
[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)
https://github.com/paulwalker-arm updated https://github.com/llvm/llvm-project/pull/130973 >From 32a2805a41dc3ff02bff9df26f4665923445b488 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 20 Mar 2025 14:58:51 + Subject: [PATCH 1/4] Add SROA tests for casts between fixed and scalable types. --- .../scalable-vectors-with-known-vscale.ll | 363 ++ llvm/test/Transforms/SROA/scalable-vectors.ll | 223 ++- 2 files changed, 585 insertions(+), 1 deletion(-) create mode 100644 llvm/test/Transforms/SROA/scalable-vectors-with-known-vscale.ll diff --git a/llvm/test/Transforms/SROA/scalable-vectors-with-known-vscale.ll b/llvm/test/Transforms/SROA/scalable-vectors-with-known-vscale.ll new file mode 100644 index 0..03afc9d609488 --- /dev/null +++ b/llvm/test/Transforms/SROA/scalable-vectors-with-known-vscale.ll @@ -0,0 +1,363 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -passes='sroa' -S | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG +; RUN: opt < %s -passes='sroa' -S | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64" + +; This test checks that SROA runs mem2reg on scalable vectors. + +define @alloca_nxv16i1( %pg) vscale_range(1) { +; CHECK-LABEL: @alloca_nxv16i1( +; CHECK-NEXT:ret [[PG:%.*]] +; + %pg.addr = alloca + store %pg, ptr %pg.addr + %1 = load , ptr %pg.addr + ret %1 +} + +define @alloca_nxv16i8( %vec) vscale_range(1) { +; CHECK-LABEL: @alloca_nxv16i8( +; CHECK-NEXT:ret [[VEC:%.*]] +; + %vec.addr = alloca + store %vec, ptr %vec.addr + %1 = load , ptr %vec.addr + ret %1 +} + +; Test scalable alloca that can't be promoted. Mem2Reg only considers +; non-volatile loads and stores for promotion. +define @unpromotable_alloca( %vec) vscale_range(1) { +; CHECK-LABEL: @unpromotable_alloca( +; CHECK-NEXT:[[VEC_ADDR:%.*]] = alloca , align 16 +; CHECK-NEXT:store volatile [[VEC:%.*]], ptr [[VEC_ADDR]], align 16 +; CHECK-NEXT:[[TMP1:%.*]] = load volatile , ptr [[VEC_ADDR]], align 16 +; CHECK-NEXT:ret [[TMP1]] +; + %vec.addr = alloca + store volatile %vec, ptr %vec.addr + %1 = load volatile , ptr %vec.addr + ret %1 +} + +; Test we bail out when using an alloca of a fixed-length vector (VLS) that was +; bitcasted to a scalable vector. +define @cast_alloca_to_svint32_t( %type.coerce) vscale_range(1) { +; CHECK-LABEL: @cast_alloca_to_svint32_t( +; CHECK-NEXT:[[TYPE:%.*]] = alloca <16 x i32>, align 64 +; CHECK-NEXT:[[TYPE_ADDR:%.*]] = alloca <16 x i32>, align 64 +; CHECK-NEXT:store [[TYPE_COERCE:%.*]], ptr [[TYPE]], align 16 +; CHECK-NEXT:[[TYPE1:%.*]] = load <16 x i32>, ptr [[TYPE]], align 64 +; CHECK-NEXT:store <16 x i32> [[TYPE1]], ptr [[TYPE_ADDR]], align 64 +; CHECK-NEXT:[[TMP1:%.*]] = load <16 x i32>, ptr [[TYPE_ADDR]], align 64 +; CHECK-NEXT:[[TMP2:%.*]] = load , ptr [[TYPE_ADDR]], align 16 +; CHECK-NEXT:ret [[TMP2]] +; + %type = alloca <16 x i32> + %type.addr = alloca <16 x i32> + store %type.coerce, ptr %type + %type1 = load <16 x i32>, ptr %type + store <16 x i32> %type1, ptr %type.addr + %1 = load <16 x i32>, ptr %type.addr + %2 = load , ptr %type.addr + ret %2 +} + +; When casting from VLA to VLS via memory check we bail out when producing a +; GEP where the element type is a scalable vector. +define @cast_alloca_from_svint32_t() vscale_range(1) { +; CHECK-LABEL: @cast_alloca_from_svint32_t( +; CHECK-NEXT:[[RETVAL_COERCE:%.*]] = alloca , align 16 +; CHECK-NEXT:store <16 x i32> zeroinitializer, ptr [[RETVAL_COERCE]], align 16 +; CHECK-NEXT:[[TMP1:%.*]] = load , ptr [[RETVAL_COERCE]], align 16 +; CHECK-NEXT:ret [[TMP1]] +; + %retval = alloca <16 x i32> + store <16 x i32> zeroinitializer, ptr %retval + %retval.coerce = alloca + call void @llvm.memcpy.p0.p0.i64(ptr align 16 %retval.coerce, ptr align 16 %retval, i64 64, i1 false) + %1 = load , ptr %retval.coerce + ret %1 +} + +; Test we bail out when using an alloca of a fixed-length vector (VLS) that was +; bitcasted to a scalable vector. +define void @select_load_alloca_to_svdouble_t() vscale_range(1) { +; CHECK-LABEL: @select_load_alloca_to_svdouble_t( +; CHECK-NEXT:[[Z:%.*]] = alloca <16 x half>, align 32 +; CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 0, 0 +; CHECK-NEXT:[[COND:%.*]] = select i1 [[CMP]], ptr [[Z]], ptr null +; CHECK-NEXT:[[VAL:%.*]] = load , ptr [[COND]], align 16 +; CHECK-NEXT:ret void +; + %z = alloca <16 x half> + %cmp = icmp eq i32 0, 0 + %cond = select i1 %cmp, ptr %z, ptr null + %val = load , ptr %cond, align 16 + ret void +} + +define void @select_store_alloca_to_svdouble_t( %val) vscale_range(1) { +; CHECK-LABEL: @select_store_alloca_to_svdouble_t( +; CHECK-NEXT:[[Z:%.*]] = alloca <16 x half>, align 32 +; CHECK-NEXT:[[CMP
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() const { + if (getTriple().isSPIRV()) +return {{&BuiltinStrings, BuiltinInfos}}; Naghasan wrote: Oh, that's a left over of my initial prototype in intel/llvm sorry. For historical reasons `spir` / `spir64` is also used there, so had to hack a bit to allow proper testing there. The change should be moving it to `BaseSPIRVTargetInfo` to only enable `spirv`, `spirv32` and `spirv64`. I updated the PR. https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = { static_assert(std::size(BuiltinInfos) == NumBuiltins); llvm::SmallVector -SPIRVTargetInfo::getTargetBuiltins() const { - return {{&BuiltinStrings, BuiltinInfos}}; +BaseSPIRTargetInfo::getTargetBuiltins() const { + if (getTriple().isSPIRV()) +return {{&BuiltinStrings, BuiltinInfos}}; farzonl wrote: Ok we might have a hierarchy problem then how do we say a builtin is valid for `spirv` but not `spirv32` or `spriv64` and vice versa. see https://github.com/llvm/llvm-project/pull/137805#discussion_r2066520947 https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
https://github.com/farzonl edited https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
@@ -5837,12 +5838,13 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64(); bool IsARM = S.Context.getTargetInfo().getTriple().isARM(); bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV(); + bool IsSPIRV = S.Context.getTargetInfo().getTriple().isSPIRV(); bool IsHLSL = S.Context.getLangOpts().HLSL; if ((IsAArch64 && !S.ARM().SveAliasValid(BuiltinID, AliasName)) || (IsARM && !S.ARM().MveAliasValid(BuiltinID, AliasName) && !S.ARM().CdeAliasValid(BuiltinID, AliasName)) || (IsRISCV && !S.RISCV().isAliasValid(BuiltinID, AliasName)) || - (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) { + (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL && !IsSPIRV)) { farzonl wrote: This shouldn't impact HLSL's ability to target SPIRV will it? More specifically will this impact HLSL's use of SPIRV builtins? https://github.com/llvm/llvm-project/pull/137805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/137773 If a member or base initializer of a constructor turns out to be invalid, mark the entire constructor as invalid. >From eaa78a369c3a1577b040b6b3e78d6812af6f1348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 29 Apr 2025 11:11:08 +0200 Subject: [PATCH] [clang] Mark constructors with invalid initializers as invalid If a member or base initializer of a constructor turns out to be invalid, mark the entire constructor as invalid. --- clang/lib/Parse/ParseDeclCXX.cpp | 4 +++- clang/test/SemaCXX/class-base-member-init.cpp | 2 +- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp | 4 ++-- clang/test/SemaCXX/constexpr-subobj-initialization.cpp | 8 clang/test/SemaCXX/constructor-initializer.cpp | 10 +++--- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 51fe0663a8d1a..7212ac8daea23 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -4064,8 +4064,10 @@ void Parser::ParseConstructorInitializer(Decl *ConstructorDecl) { MemInitResult MemInit = ParseMemInitializer(ConstructorDecl); if (!MemInit.isInvalid()) MemInitializers.push_back(MemInit.get()); -else +else { + ConstructorDecl->setInvalidDecl(); AnyErrors = true; +} if (Tok.is(tok::comma)) ConsumeToken(); diff --git a/clang/test/SemaCXX/class-base-member-init.cpp b/clang/test/SemaCXX/class-base-member-init.cpp index a6bb4410a81c8..cf297328c1f83 100644 --- a/clang/test/SemaCXX/class-base-member-init.cpp +++ b/clang/test/SemaCXX/class-base-member-init.cpp @@ -86,7 +86,7 @@ namespace test5 { decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(Base(1))' (aka 'test5::Base')}} decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}} } -A(float) : decltype(A())(3) { +A(float) : decltype(A())(3) { // expected-error {{constructor for 'A' creates a delegation cycle}} } }; } diff --git a/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp b/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp index 7a6d7cb353158..474ad587bacc6 100644 --- a/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp +++ b/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp @@ -535,9 +535,9 @@ namespace InvalidBaseClass { }; class InBetween : public F{}; - class E : public InBetween { + class E : public InBetween { // expected-note 2{{candidate constructor}} public: constexpr E() : F{3} {} // expected-error {{not a direct or virtual base}} }; - static_assert(__builtin_bit_cast(char, E()) == 0); // expected-error {{not an integral constant expression}} + static_assert(__builtin_bit_cast(char, E()) == 0); // expected-error {{no matching constructor}} } diff --git a/clang/test/SemaCXX/constexpr-subobj-initialization.cpp b/clang/test/SemaCXX/constexpr-subobj-initialization.cpp index f0252df1e2ce1..f0abe09d23bf4 100644 --- a/clang/test/SemaCXX/constexpr-subobj-initialization.cpp +++ b/clang/test/SemaCXX/constexpr-subobj-initialization.cpp @@ -16,17 +16,17 @@ struct Bar : Foo { constexpr Bar bar; // expected-error {{must be initialized by a constant expression}} struct Base {}; -struct A : Base { // expected-note-re {{constructor of base class '{{.*}}Base' is not called}} +struct A : Base { // expected-note 2{{candidate constructor}} constexpr A() : value() {} // expected-error {{member initializer 'value' does not name a non-static data member or base class}} }; -constexpr A a; // expected-error {{must be initialized by a constant expression}} +constexpr A a; // expected-error {{no matching constructor}} -struct B : Base { // expected-note-re {{constructor of base class '{{.*}}Base' is not called}} +struct B : Base { // expected-note 2{{candidate constructor}} constexpr B() : {} // expected-error {{expected class member or base class name}} }; -constexpr B b; // expected-error {{must be initialized by a constant expression}} +constexpr B b; // expected-error {{no matching constructor}} } // namespace baseclass_uninit diff --git a/clang/test/SemaCXX/constructor-initializer.cpp b/clang/test/SemaCXX/constructor-initializer.cpp index 96be8dda97735..c8b1cfbae65ce 100644 --- a/clang/test/SemaCXX/constructor-initializer.cpp +++ b/clang/test/SemaCXX/constructor-initializer.cpp @@ -2,16 +2,20 @@ // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s -class A { +class A { + // expected-note@-1 {{candidate constructor}} +#if __cplusplus >= 201103L // C++11 or later + // expected-note@-3 {{candidate constructor}} +#endif int m; public: A() : A::m(17) { } // expected-err
[clang-tools-extra] [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (PR #137286)
carlosgalvezp wrote: /cherry-pick 014ab736dc741f24c007f9861e24b31faba0e1e7 https://github.com/llvm/llvm-project/pull/137286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (PR #137286)
https://github.com/carlosgalvezp milestoned https://github.com/llvm/llvm-project/pull/137286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 014ab73 - [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (#137286)
Author: Carlos Galvez Date: 2025-04-29T11:13:30+02:00 New Revision: 014ab736dc741f24c007f9861e24b31faba0e1e7 URL: https://github.com/llvm/llvm-project/commit/014ab736dc741f24c007f9861e24b31faba0e1e7 DIFF: https://github.com/llvm/llvm-project/commit/014ab736dc741f24c007f9861e24b31faba0e1e7.diff LOG: [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (#137286) …dy.py Currently, run_clang_tidy.py does not correctly display the list of checks picked up from the top-level .clang-tidy file. The reason for that is that we are passing an empty string as input file. However, that's not how we are supposed to use clang-tidy to list checks. Per https://github.com/llvm/llvm-project/commit/65eccb463df7fe511c813ee6a1794c80d7489ff2, we simply should not pass any file at all - the internal code of clang-tidy will pass a "dummy" file if that's the case and get the .clang-tidy file from the current working directory. Fixes #136659 Co-authored-by: Carlos Gálvez Added: Modified: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py clang-tools-extra/docs/ReleaseNotes.rst Removed: diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py index f1b934f7139e9..8741147a4f8a3 100755 --- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -87,7 +87,7 @@ def find_compilation_database(path: str) -> str: def get_tidy_invocation( -f: str, +f: Optional[str], clang_tidy_binary: str, checks: str, tmpdir: Optional[str], @@ -147,7 +147,8 @@ def get_tidy_invocation( start.append(f"--warnings-as-errors={warnings_as_errors}") if allow_no_checks: start.append("--allow-no-checks") -start.append(f) +if f: +start.append(f) return start @@ -490,7 +491,7 @@ async def main() -> None: try: invocation = get_tidy_invocation( -"", +None, clang_tidy_binary, args.checks, None, diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index ba3774307e392..8f61839af2c80 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -103,6 +103,9 @@ Improvements to clang-tidy - Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take effect when passed via the `.clang-tidy` file. +- Fixed bug in :program:`run_clang_tidy.py` where the program would not + correctly display the checks enabled by the top-level `.clang-tidy` file. + New checks ^^ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (PR #137286)
carlosgalvezp wrote: /cherry-pick [014ab73](https://github.com/llvm/llvm-project/commit/014ab736dc741f24c007f9861e24b31faba0e1e7) https://github.com/llvm/llvm-project/pull/137286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Do not pass any file when listing checks in run_clang_ti… (PR #137286)
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/137286 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits