[libclc] [libclc] Re-use shuffle_decl.inc in OpenCL shuffle2 declaration (PR #140679)
https://github.com/frasercrmck approved this pull request. LGTM, thanks https://github.com/llvm/llvm-project/pull/140679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Reorganize OpenCL builtins (PR #140557)
https://github.com/frasercrmck closed https://github.com/llvm/llvm-project/pull/140557 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream splat op for VectorType (PR #139827)
@@ -1773,6 +1774,38 @@ mlir::LogicalResult CIRToLLVMVecInsertOpLowering::matchAndRewrite( return mlir::success(); } +mlir::LogicalResult CIRToLLVMVecSplatOpLowering::matchAndRewrite( +cir::VecSplatOp op, OpAdaptor adaptor, +mlir::ConversionPatternRewriter &rewriter) const { + // Vector splat can be implemented with an `insertelement` and a + // `shufflevector`, which is better than an `insertelement` for each + // element in the vector. Start with an undef vector. Insert the value into + // the first element. Then use a `shufflevector` with a mask of all 0 to + // fill out the entire vector with that value. + const auto vecTy = mlir::cast(op.getType()); + const mlir::Type llvmTy = typeConverter->convertType(vecTy); + const mlir::Location loc = op.getLoc(); + const mlir::Value poison = rewriter.create(loc, llvmTy); + + const mlir::Value elementValue = adaptor.getValue(); + if (mlir::isa(elementValue.getDefiningOp())) { +// If the splat value is poison, then we can just use poison value +// for the entire vector. +rewriter.replaceOp(op, poison); +return mlir::success(); + } + + const mlir::Value indexValue = + rewriter.create(loc, rewriter.getI64Type(), 0); + const mlir::Value oneElement = rewriter.create( + loc, poison, elementValue, indexValue); + const SmallVector zeroValues(vecTy.getSize(), 0); + const mlir::Value shuffled = rewriter.create( + loc, oneElement, poison, zeroValues); + rewriter.replaceOp(op, shuffled); xlauko wrote: ```suggestion rewriter. replaceOpWithNewOp(op, oneElement, poison, zeroValues); ``` https://github.com/llvm/llvm-project/pull/139827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream splat op for VectorType (PR #139827)
https://github.com/xlauko edited https://github.com/llvm/llvm-project/pull/139827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Upstream splat op for VectorType (PR #139827)
https://github.com/xlauko edited https://github.com/llvm/llvm-project/pull/139827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)
jmmartinez wrote: Ping ! https://github.com/llvm/llvm-project/pull/137665 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Reorganize OpenCL builtins (PR #140557)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` running on `premerge-linux-1` while building `libclc` at step 6 "build-unified-tree". Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/32280 Here is the relevant piece of the build log for the reference ``` Step 6 (build-unified-tree) failure: build (failure) ... 44.748 [4379/58/9684] Linking CXX static library lib/libHLFIRDialect.a 44.966 [4378/58/9685] Generating obj.libclc.dir/clspv64--/clc/lib/generic/integer/clc_rotate.cl.bc 44.971 [4377/58/9686] Generating obj.libclc.dir/clspv64--/clc/lib/generic/math/clc_fdim.cl.bc 44.976 [4376/58/9687] Linking CXX executable bin/mlir-translate 44.983 [4375/58/9688] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_maxmag.cl.bc 44.991 [4374/58/9689] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_exp.cl.bc 44.994 [4373/58/9690] Linking CXX executable bin/clang-repl 44.996 [4372/58/9691] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_ldexp.cl.bc 45.016 [4371/58/9692] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_atanh.cl.bc 45.029 [4370/58/9693] Generating obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc FAILED: tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0 -DCLC_R600 -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/clc/include -mcpu=cedar -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math -MD -MF /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc.d -MT /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc -cl-no-stdinc -emit-llvm -o /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc -x cl /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/ldexp.cl && /etc/cmake/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /build/buildbot/premerge-monolithic-linux/llvm-project/llvm /build/buildbot/premerge-monolithic-linux/llvm-project/libclc /build/buildbot/premerge-monolithic-linux/build /build/buildbot/premerge-monolithic-linux/build/tools/libclc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/ldexp.cl.bc.d /build/buildbot/premerge-monolithic-linux/build/CMakeFiles/d/15e419e5cf412e6112f9fcaec7c9a4899fec59af938d680467007d631db4569e.d In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/lib/generic/math/ldexp.cl:11: In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/clc.h:215: /build/buildbot/premerge-monolithic-linux/llvm-project/libclc/opencl/include/clc/opencl/synchronization/barrier.h:9:38: error: unknown type name 'cl_mem_fence_flags' 9 | _CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags); | ^ 1 error generated. 45.037 [4370/57/9694] Generating obj.libclc.dir/clspv64--/clc/lib/generic/integer/clc_sub_sat.cl.bc 45.041 [4370/56/9695] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_mad24.cl.bc 45.051 [4370/55/9696] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_popcount.cl.bc 45.055 [4370/54/9697] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_asinpi.cl.bc 45.066 [4370/53/9698] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_cbrt.cl.bc 45.068 [4370/52/9699] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_lgamma.cl.bc 45.070 [4370/51/9700] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/integer/clc_hadd.cl.bc 45.076 [4370/50/9701] Generating obj.libclc.dir/tahiti-amdgcn--/clc/lib/generic/math/clc_minmag.cl.bc 45.077 [4370/49/9702] Generating obj.libclc.dir/clspv--/clc/lib/generic/math/clc_atan.cl.bc 45.080 [4370/48/9703] Generating obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc FAILED: tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc /build/buildbot/premerge-monolithic-linux/build/tools/libclc/obj.libclc.dir/cedar-r600--/opencl/lib/generic/math/minmag.cl.bc cd /build/buildbot/premerge-monolithic-linux/build/tools/libclc && /build/buildbot/premerge-monolithic-linux/build/bin/clang-21 -target r600-- -c -fno-builtin -nostdlib -cl-std=CL3.0
[clang] [CIR] Add support for indirect calls (PR #139748)
https://github.com/Lancern updated https://github.com/llvm/llvm-project/pull/139748 >From 71009b450a333d4537d9a84176707656c5bdcea1 Mon Sep 17 00:00:00 2001 From: Sirui Mu Date: Thu, 15 May 2025 23:01:18 +0800 Subject: [PATCH] [CIR] Add support for indirect calls --- .../CIR/Dialect/Builder/CIRBaseBuilder.h | 8 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 57 +-- clang/include/clang/CIR/MissingFeatures.h | 1 - clang/lib/CIR/CodeGen/CIRGenCall.cpp | 35 ++-- clang/lib/CIR/CodeGen/CIRGenCall.h| 11 +++- clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 37 ++-- clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h| 1 + clang/lib/CIR/CodeGen/CIRGenTypes.h | 1 - clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 53 ++--- .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 20 ++- clang/test/CIR/CodeGen/call.cpp | 14 + clang/test/CIR/IR/call.cir| 14 + 12 files changed, 212 insertions(+), 40 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index a63bf4f8858d0..b680e4162a5ce 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -225,6 +225,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { callee.getFunctionType().getReturnType(), operands); } + cir::CallOp createIndirectCallOp(mlir::Location loc, + mlir::Value indirectTarget, + cir::FuncType funcType, + mlir::ValueRange operands) { +return create(loc, indirectTarget, funcType.getReturnType(), + operands); + } + //======// // Cast/Conversion Operators //======// diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e08f372450285..8c82128c43173 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -1798,13 +1798,8 @@ class CIR_CallOpBase extra_traits = []> DeclareOpInterfaceMethods])> { let extraClassDeclaration = [{ /// Get the argument operands to the called function. -mlir::OperandRange getArgOperands() { - return getArgs(); -} - -mlir::MutableOperandRange getArgOperandsMutable() { - return getArgsMutable(); -} +mlir::OperandRange getArgOperands(); +mlir::MutableOperandRange getArgOperandsMutable(); /// Return the callee of this operation mlir::CallInterfaceCallable getCallableForCallee() { @@ -1826,8 +1821,17 @@ class CIR_CallOpBase extra_traits = []> ::mlir::Attribute removeArgAttrsAttr() { return {}; } ::mlir::Attribute removeResAttrsAttr() { return {}; } +bool isIndirect() { return !getCallee(); } +mlir::Value getIndirectCall(); + void setArg(unsigned index, mlir::Value value) { - setOperand(index, value); + if (!isIndirect()) { +setOperand(index, value); +return; + } + + // For indirect call, the operand list is shifted by one. + setOperand(index + 1, value); } }]; @@ -1839,16 +1843,24 @@ class CIR_CallOpBase extra_traits = []> // the upstreaming process moves on. The verifiers is also missing for now, // will add in the future. - dag commonArgs = (ins FlatSymbolRefAttr:$callee, -Variadic:$args); + dag commonArgs = (ins OptionalAttr:$callee, + Variadic:$args); } def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { let summary = "call a function"; let description = [{ -The `cir.call` operation represents a direct call to a function that is -within the same symbol scope as the call. The callee is encoded as a symbol -reference attribute named `callee`. +The `cir.call` operation represents a function call. It could represent +either a direct call or an indirect call. + +If the operation represents a direct call, the callee should be defined +within the same symbol scope as the call. The `callee` attribute contains a +symbol reference to the callee function. All operands of this operation are +arguments to the callee function. + +If the operation represents an indirect call, the `callee` attribute is +empty. The first operand of this operation must be a pointer to the callee +function. The rest operands are arguments to the callee function. Example: @@ -1860,14 +1872,25 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { let results = (outs Optional:$result); let arguments = commonArgs; - let builders = [OpBuilder<(ins "mlir::SymbolRefAttr":$
[clang] [llvm] [mlir] [NVPTX] Unify and extend barrier{.cta} intrinsic support (PR #140615)
https://github.com/durga4github approved this pull request. https://github.com/llvm/llvm-project/pull/140615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check downcasts for the correct type (PR #140689)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/140689 In multiple inheritance/diamond scenarios, we might arrive at the wrong type. >From b8d7be498693a889898a85eed4ce24cbc04f0d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 20 May 2025 09:06:15 +0200 Subject: [PATCH] [clang][bytecode] Check downcasts for the correct type In multiple inheritance/diamond scenarios, we might arrive at the wrong type. --- clang/lib/AST/ByteCode/Compiler.cpp | 9 ++--- clang/lib/AST/ByteCode/Interp.h | 20 +++- clang/lib/AST/ByteCode/Opcodes.td | 2 +- clang/test/AST/ByteCode/records.cpp | 12 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index aa8f009f58bb9..fd2f25d2476c5 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -296,12 +296,15 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_BaseToDerived: { if (!this->delegate(SubExpr)) return false; - unsigned DerivedOffset = collectBaseOffset(SubExpr->getType(), CE->getType()); -return this->emitGetPtrDerivedPop( -DerivedOffset, /*NullOK=*/CE->getType()->isPointerType(), CE); +const Type *TargetType = CE->getType().getTypePtr(); +if (TargetType->isPointerOrReferenceType()) + TargetType = TargetType->getPointeeType().getTypePtr(); +return this->emitGetPtrDerivedPop(DerivedOffset, + /*NullOK=*/CE->getType()->isPointerType(), + TargetType, CE); } case CK_FloatingCast: { diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 9f1a6302eb856..88de615a6dae5 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1643,7 +1643,7 @@ inline bool GetPtrActiveThisField(InterpState &S, CodePtr OpPC, uint32_t Off) { } inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, - bool NullOK) { + bool NullOK, const Type *TargetType) { const Pointer &Ptr = S.Stk.pop(); if (!NullOK && !CheckNull(S, OpPC, Ptr, CSK_Derived)) return false; @@ -1661,6 +1661,24 @@ inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, if (!CheckDowncast(S, OpPC, Ptr, Off)) return false; + const Record *TargetRecord = Ptr.atFieldSub(Off).getRecord(); + assert(TargetRecord); + + if (TargetRecord->getDecl() + ->getTypeForDecl() + ->getAsCXXRecordDecl() + ->getCanonicalDecl() != + TargetType->getAsCXXRecordDecl()->getCanonicalDecl()) { +QualType MostDerivedType = Ptr.getDeclDesc()->getType(); +S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_downcast) +<< MostDerivedType << QualType(TargetType, 0); +return false; + } + + // New pointer should be of the requested type. + assert(Ptr.atFieldSub(Off).getType()->getUnqualifiedDesugaredType() == + TargetType->getUnqualifiedDesugaredType()); + S.Stk.push(Ptr.atFieldSub(Off)); return true; } diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td index 9dddcced8ca38..c8db8da113bd4 100644 --- a/clang/lib/AST/ByteCode/Opcodes.td +++ b/clang/lib/AST/ByteCode/Opcodes.td @@ -325,7 +325,7 @@ def GetMemberPtrBasePop : Opcode { def FinishInitPop : Opcode; def FinishInit: Opcode; -def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool]; } +def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool, ArgTypePtr]; } // [Pointer] -> [Pointer] def GetPtrVirtBasePop : Opcode { diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index c2fe3d9007480..9361d6ddeda70 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1830,3 +1830,15 @@ namespace NullDtor { static_assert(foo() == 10, ""); // both-error {{not an integral constant expression}} \ // both-note {{in call to}} } + +namespace DiamondDowncast { + struct Top {}; + struct Middle1 : Top {}; + struct Middle2 : Top {}; + struct Bottom : Middle1, Middle2 {}; + + constexpr Bottom bottom; + constexpr Top &top1 = (Middle1&)bottom; + constexpr Middle2 &fail = (Middle2&)top1; // both-error {{must be initialized by a constant expression}} \ +// both-note {{cannot cast object of dynamic type 'const Bottom' to type 'Middle2'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [NVPTX] Unify and extend barrier{.cta} intrinsic support (PR #140615)
@@ -102,39 +93,51 @@ def INT_BARRIER0_OR : NVPTXInst<(outs Int32Regs:$dst), (ins Int32Regs:$pred), "}}"), [(set i32:$dst, (int_nvvm_barrier0_or i32:$pred))]>; -def INT_BAR_SYNC : NVPTXInst<(outs), (ins i32imm:$i), "bar.sync \t$i;", - [(int_nvvm_bar_sync imm:$i)]>; - def INT_BAR_WARP_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "bar.warp.sync \t$i;", [(int_nvvm_bar_warp_sync imm:$i)]>, Requires<[hasPTX<60>, hasSM<30>]>; def INT_BAR_WARP_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "bar.warp.sync \t$i;", [(int_nvvm_bar_warp_sync i32:$i)]>, Requires<[hasPTX<60>, hasSM<30>]>; -def INT_BARRIER_SYNC_I : NVPTXInst<(outs), (ins i32imm:$i), "barrier.sync \t$i;", - [(int_nvvm_barrier_sync imm:$i)]>, -Requires<[hasPTX<60>, hasSM<30>]>; -def INT_BARRIER_SYNC_R : NVPTXInst<(outs), (ins Int32Regs:$i), "barrier.sync \t$i;", - [(int_nvvm_barrier_sync i32:$i)]>, -Requires<[hasPTX<60>, hasSM<30>]>; +multiclass BARRIER1 requires = []> { + def _i : BasicNVPTXInst<(outs), (ins i32imm:$i), asmstr, + [(intrinsic imm:$i)]>, + Requires; -def INT_BARRIER_SYNC_CNT_RR : NVPTXInst<(outs), (ins Int32Regs:$id, Int32Regs:$cnt), - "barrier.sync \t$id, $cnt;", - [(int_nvvm_barrier_sync_cnt i32:$id, i32:$cnt)]>, -Requires<[hasPTX<60>, hasSM<30>]>; -def INT_BARRIER_SYNC_CNT_RI : NVPTXInst<(outs), (ins Int32Regs:$id, i32imm:$cnt), - "barrier.sync \t$id, $cnt;", - [(int_nvvm_barrier_sync_cnt i32:$id, imm:$cnt)]>, -Requires<[hasPTX<60>, hasSM<30>]>; -def INT_BARRIER_SYNC_CNT_IR : NVPTXInst<(outs), (ins i32imm:$id, Int32Regs:$cnt), - "barrier.sync \t$id, $cnt;", - [(int_nvvm_barrier_sync_cnt imm:$id, i32:$cnt)]>, -Requires<[hasPTX<60>, hasSM<30>]>; -def INT_BARRIER_SYNC_CNT_II : NVPTXInst<(outs), (ins i32imm:$id, i32imm:$cnt), - "barrier.sync \t$id, $cnt;", - [(int_nvvm_barrier_sync_cnt imm:$id, imm:$cnt)]>, -Requires<[hasPTX<60>, hasSM<30>]>; + def _r : BasicNVPTXInst<(outs), (ins Int32Regs:$i), asmstr, + [(intrinsic i32:$i)]>, + Requires; +} + +multiclass BARRIER2 requires = []> { + def _rr : BasicNVPTXInst<(outs), (ins Int32Regs:$i, Int32Regs:$j), asmstr, + [(intrinsic i32:$i, i32:$j)]>, +Requires; + + def _ri : BasicNVPTXInst<(outs), (ins Int32Regs:$i, i32imm:$j), asmstr, + [(intrinsic i32:$i, imm:$j)]>, +Requires; + + def _ir : BasicNVPTXInst<(outs), (ins i32imm:$i, Int32Regs:$j), asmstr, + [(intrinsic imm:$i, i32:$j)]>, +Requires; + + def _ii : BasicNVPTXInst<(outs), (ins i32imm:$i, i32imm:$j), asmstr, + [(intrinsic imm:$i, imm:$j)]>, +Requires; +} + +// Note the "bar.sync" variants could be renamed to the equivalent corresponding +// "barrier.*.aligned" variants. We use the older syntax for compatibility with +// older versions of the PTX ISA. durga4github wrote: Yes, and thanks for this note! https://github.com/llvm/llvm-project/pull/140615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check downcasts for the correct type (PR #140689)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes In multiple inheritance/diamond scenarios, we might arrive at the wrong type. --- Full diff: https://github.com/llvm/llvm-project/pull/140689.diff 4 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+6-3) - (modified) clang/lib/AST/ByteCode/Interp.h (+19-1) - (modified) clang/lib/AST/ByteCode/Opcodes.td (+1-1) - (modified) clang/test/AST/ByteCode/records.cpp (+12) ``diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index aa8f009f58bb9..fd2f25d2476c5 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -296,12 +296,15 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_BaseToDerived: { if (!this->delegate(SubExpr)) return false; - unsigned DerivedOffset = collectBaseOffset(SubExpr->getType(), CE->getType()); -return this->emitGetPtrDerivedPop( -DerivedOffset, /*NullOK=*/CE->getType()->isPointerType(), CE); +const Type *TargetType = CE->getType().getTypePtr(); +if (TargetType->isPointerOrReferenceType()) + TargetType = TargetType->getPointeeType().getTypePtr(); +return this->emitGetPtrDerivedPop(DerivedOffset, + /*NullOK=*/CE->getType()->isPointerType(), + TargetType, CE); } case CK_FloatingCast: { diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 9f1a6302eb856..88de615a6dae5 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1643,7 +1643,7 @@ inline bool GetPtrActiveThisField(InterpState &S, CodePtr OpPC, uint32_t Off) { } inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, - bool NullOK) { + bool NullOK, const Type *TargetType) { const Pointer &Ptr = S.Stk.pop(); if (!NullOK && !CheckNull(S, OpPC, Ptr, CSK_Derived)) return false; @@ -1661,6 +1661,24 @@ inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, if (!CheckDowncast(S, OpPC, Ptr, Off)) return false; + const Record *TargetRecord = Ptr.atFieldSub(Off).getRecord(); + assert(TargetRecord); + + if (TargetRecord->getDecl() + ->getTypeForDecl() + ->getAsCXXRecordDecl() + ->getCanonicalDecl() != + TargetType->getAsCXXRecordDecl()->getCanonicalDecl()) { +QualType MostDerivedType = Ptr.getDeclDesc()->getType(); +S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_downcast) +<< MostDerivedType << QualType(TargetType, 0); +return false; + } + + // New pointer should be of the requested type. + assert(Ptr.atFieldSub(Off).getType()->getUnqualifiedDesugaredType() == + TargetType->getUnqualifiedDesugaredType()); + S.Stk.push(Ptr.atFieldSub(Off)); return true; } diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td index 9dddcced8ca38..c8db8da113bd4 100644 --- a/clang/lib/AST/ByteCode/Opcodes.td +++ b/clang/lib/AST/ByteCode/Opcodes.td @@ -325,7 +325,7 @@ def GetMemberPtrBasePop : Opcode { def FinishInitPop : Opcode; def FinishInit: Opcode; -def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool]; } +def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool, ArgTypePtr]; } // [Pointer] -> [Pointer] def GetPtrVirtBasePop : Opcode { diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index c2fe3d9007480..9361d6ddeda70 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1830,3 +1830,15 @@ namespace NullDtor { static_assert(foo() == 10, ""); // both-error {{not an integral constant expression}} \ // both-note {{in call to}} } + +namespace DiamondDowncast { + struct Top {}; + struct Middle1 : Top {}; + struct Middle2 : Top {}; + struct Bottom : Middle1, Middle2 {}; + + constexpr Bottom bottom; + constexpr Top &top1 = (Middle1&)bottom; + constexpr Middle2 &fail = (Middle2&)top1; // both-error {{must be initialized by a constant expression}} \ +// both-note {{cannot cast object of dynamic type 'const Bottom' to type 'Middle2'}} +} `` https://github.com/llvm/llvm-project/pull/140689 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle raw string literals containing JSON code (PR #140666)
https://github.com/mydeveloperday approved this pull request. https://github.com/llvm/llvm-project/pull/140666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
DaanDeMeyer wrote: @kadircet Can you land this one as well? (Feel free to give me back the commit bit if that's in your power if you want me to land stuff myself after review) https://github.com/llvm/llvm-project/pull/140600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 32a1b6a - [flang][veclib] Adding AMDLIBM target to fveclib (#140533)
Author: shivaramaarao Date: 2025-05-20T01:38:35-07:00 New Revision: 32a1b6a70b3ec9066dd70ccf538f735a5c58e031 URL: https://github.com/llvm/llvm-project/commit/32a1b6a70b3ec9066dd70ccf538f735a5c58e031 DIFF: https://github.com/llvm/llvm-project/commit/32a1b6a70b3ec9066dd70ccf538f735a5c58e031.diff LOG: [flang][veclib] Adding AMDLIBM target to fveclib (#140533) This commit adds AMDLIBM support to fveclib targets. The support is already present in clang and this patch extends it to flang. Added: Modified: clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/CodeGenOptions.def flang/lib/Frontend/CompilerInvocation.cpp flang/test/Driver/fveclib-codegen.f90 flang/test/Driver/fveclib.f90 Removed: diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index b1ca747e68b89..0bd8d0c85e50a 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -484,7 +484,7 @@ void Flang::addTargetOptions(const ArgList &Args, Triple.getArch() != llvm::Triple::x86_64) D.Diag(diag::err_drv_unsupported_opt_for_target) << Name << Triple.getArchName(); -} else if (Name == "libmvec") { +} else if (Name == "libmvec" || Name == "AMDLIBM") { if (Triple.getArch() != llvm::Triple::x86 && Triple.getArch() != llvm::Triple::x86_64) D.Diag(diag::err_drv_unsupported_opt_for_target) diff --git a/flang/include/flang/Frontend/CodeGenOptions.def b/flang/include/flang/Frontend/CodeGenOptions.def index d9dbd274e83e5..b50dd4fb3abda 100644 --- a/flang/include/flang/Frontend/CodeGenOptions.def +++ b/flang/include/flang/Frontend/CodeGenOptions.def @@ -42,7 +42,7 @@ CODEGENOPT(AliasAnalysis, 1, 0) ///< Enable alias analysis pass CODEGENOPT(Underscoring, 1, 1) ENUM_CODEGENOPT(RelocationModel, llvm::Reloc::Model, 3, llvm::Reloc::PIC_) ///< Name of the relocation model to use. ENUM_CODEGENOPT(DebugInfo, llvm::codegenoptions::DebugInfoKind, 4, llvm::codegenoptions::NoDebugInfo) ///< Level of debug info to generate -ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 3, llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use +ENUM_CODEGENOPT(VecLib, llvm::driver::VectorLibrary, 4, llvm::driver::VectorLibrary::NoLibrary) ///< Vector functions library to use ENUM_CODEGENOPT(FramePointer, llvm::FramePointerKind, 2, llvm::FramePointerKind::None) ///< Enable the usage of frame pointers ENUM_CODEGENOPT(DoConcurrentMapping, DoConcurrentMappingKind, 2, DoConcurrentMappingKind::DCMK_None) ///< Map `do concurrent` to OpenMP diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 238079a09ef3a..b6c37712d0f79 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -201,6 +201,7 @@ static bool parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts, .Case("SLEEF", VectorLibrary::SLEEF) .Case("Darwin_libsystem_m", VectorLibrary::Darwin_libsystem_m) .Case("ArmPL", VectorLibrary::ArmPL) + .Case("AMDLIBM", VectorLibrary::AMDLIBM) .Case("NoLibrary", VectorLibrary::NoLibrary) .Default(std::nullopt); if (!val.has_value()) { diff --git a/flang/test/Driver/fveclib-codegen.f90 b/flang/test/Driver/fveclib-codegen.f90 index 802fff9772bb3..4cbb1e284f18e 100644 --- a/flang/test/Driver/fveclib-codegen.f90 +++ b/flang/test/Driver/fveclib-codegen.f90 @@ -1,6 +1,7 @@ ! test that -fveclib= is passed to the backend ! RUN: %if aarch64-registered-target %{ %flang -S -Ofast -target aarch64-unknown-linux-gnu -fveclib=SLEEF -o - %s | FileCheck %s --check-prefix=SLEEF %} ! RUN: %if x86-registered-target %{ %flang -S -Ofast -target x86_64-unknown-linux-gnu -fveclib=libmvec -o - %s | FileCheck %s %} +! RUN: %if x86-registered-target %{ %flang -S -O3 -ffast-math -target x86_64-unknown-linux-gnu -fveclib=AMDLIBM -o - %s | FileCheck %s --check-prefix=AMDLIBM %} ! RUN: %flang -S -Ofast -fveclib=NoLibrary -o - %s | FileCheck %s --check-prefix=NOLIB subroutine sb(a, b) @@ -10,6 +11,7 @@ subroutine sb(a, b) ! check that we used a vectorized call to powf() ! CHECK: _ZGVbN4vv_powf ! SLEEF: _ZGVnN4vv_powf +! AMDLIBM: amd_vrs4_powf ! NOLIB: powf a(i) = a(i) ** b(i) end do diff --git a/flang/test/Driver/fveclib.f90 b/flang/test/Driver/fveclib.f90 index 1b536b8ad0f18..431a4bfc02522 100644 --- a/flang/test/Driver/fveclib.f90 +++ b/flang/test/Driver/fveclib.f90 @@ -5,6 +5,7 @@ ! RUN: %flang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck -check-prefix CHECK-DARWIN_LIBSYSTEM_M %s ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=SLEEF %s 2>&1 | FileCheck -check-prefix CHECK-SLEEF %s ! RUN: %flang -### -c --target=aarch64-none-none -fveclib=ArmPL %s 2>&1 | FileCheck -check-prefix CHE
[clang] [clang][bytecode] Check downcasts for the correct type (PR #140689)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/140689 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d013556 - [clang][bytecode] Check downcasts for the correct type (#140689)
Author: Timm Baeder Date: 2025-05-20T11:19:24+02:00 New Revision: d01355645b1fece147163e1cfe9f71d9c704860e URL: https://github.com/llvm/llvm-project/commit/d01355645b1fece147163e1cfe9f71d9c704860e DIFF: https://github.com/llvm/llvm-project/commit/d01355645b1fece147163e1cfe9f71d9c704860e.diff LOG: [clang][bytecode] Check downcasts for the correct type (#140689) In multiple inheritance/diamond scenarios, we might arrive at the wrong type. Added: Modified: clang/lib/AST/ByteCode/Compiler.cpp clang/lib/AST/ByteCode/Interp.h clang/lib/AST/ByteCode/Opcodes.td clang/test/AST/ByteCode/records.cpp Removed: diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 36380543e5991..54a4647a604fb 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -296,12 +296,15 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) { case CK_BaseToDerived: { if (!this->delegate(SubExpr)) return false; - unsigned DerivedOffset = collectBaseOffset(SubExpr->getType(), CE->getType()); -return this->emitGetPtrDerivedPop( -DerivedOffset, /*NullOK=*/CE->getType()->isPointerType(), CE); +const Type *TargetType = CE->getType().getTypePtr(); +if (TargetType->isPointerOrReferenceType()) + TargetType = TargetType->getPointeeType().getTypePtr(); +return this->emitGetPtrDerivedPop(DerivedOffset, + /*NullOK=*/CE->getType()->isPointerType(), + TargetType, CE); } case CK_FloatingCast: { diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index bfc6797d13412..70bbfc576925e 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1643,7 +1643,7 @@ inline bool GetPtrActiveThisField(InterpState &S, CodePtr OpPC, uint32_t Off) { } inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, - bool NullOK) { + bool NullOK, const Type *TargetType) { const Pointer &Ptr = S.Stk.pop(); if (!NullOK && !CheckNull(S, OpPC, Ptr, CSK_Derived)) return false; @@ -1661,6 +1661,20 @@ inline bool GetPtrDerivedPop(InterpState &S, CodePtr OpPC, uint32_t Off, if (!CheckDowncast(S, OpPC, Ptr, Off)) return false; + const Record *TargetRecord = Ptr.atFieldSub(Off).getRecord(); + assert(TargetRecord); + + if (TargetRecord->getDecl() + ->getTypeForDecl() + ->getAsCXXRecordDecl() + ->getCanonicalDecl() != + TargetType->getAsCXXRecordDecl()->getCanonicalDecl()) { +QualType MostDerivedType = Ptr.getDeclDesc()->getType(); +S.CCEDiag(S.Current->getSource(OpPC), diag::note_constexpr_invalid_downcast) +<< MostDerivedType << QualType(TargetType, 0); +return false; + } + S.Stk.push(Ptr.atFieldSub(Off)); return true; } diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td index 9dddcced8ca38..c8db8da113bd4 100644 --- a/clang/lib/AST/ByteCode/Opcodes.td +++ b/clang/lib/AST/ByteCode/Opcodes.td @@ -325,7 +325,7 @@ def GetMemberPtrBasePop : Opcode { def FinishInitPop : Opcode; def FinishInit: Opcode; -def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool]; } +def GetPtrDerivedPop : Opcode { let Args = [ArgUint32, ArgBool, ArgTypePtr]; } // [Pointer] -> [Pointer] def GetPtrVirtBasePop : Opcode { diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp index c2fe3d9007480..9361d6ddeda70 100644 --- a/clang/test/AST/ByteCode/records.cpp +++ b/clang/test/AST/ByteCode/records.cpp @@ -1830,3 +1830,15 @@ namespace NullDtor { static_assert(foo() == 10, ""); // both-error {{not an integral constant expression}} \ // both-note {{in call to}} } + +namespace DiamondDowncast { + struct Top {}; + struct Middle1 : Top {}; + struct Middle2 : Top {}; + struct Bottom : Middle1, Middle2 {}; + + constexpr Bottom bottom; + constexpr Top &top1 = (Middle1&)bottom; + constexpr Middle2 &fail = (Middle2&)top1; // both-error {{must be initialized by a constant expression}} \ +// both-note {{cannot cast object of dynamic type 'const Bottom' to type 'Middle2'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Diagnose comparisons of unrelated zero-sized pointers (PR #140695)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/140695.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.h (+8) - (modified) clang/test/AST/ByteCode/cxx11.cpp (+7) ``diff diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 9f1a6302eb856..23d3c088d571d 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1135,6 +1135,14 @@ inline bool CmpHelperEQ(InterpState &S, CodePtr OpPC, CompareFn Fn) { } } + if (LHS.isUnknownSizeArray() && RHS.isUnknownSizeArray()) { +const SourceInfo &Loc = S.Current->getSource(OpPC); +S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_zero_sized) +<< LHS.toDiagnosticString(S.getASTContext()) +<< RHS.toDiagnosticString(S.getASTContext()); +return false; + } + S.Stk.push(BoolT::from(Fn(ComparisonCategoryResult::Unordered))); return true; } diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 88e195c36b583..36a57001ab966 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -233,3 +233,10 @@ namespace IntToPtrCast { constexpr intptr_t i = f((intptr_t)&foo - 10); // both-error{{constexpr variable 'i' must be initialized by a constant expression}} \ // both-note{{reinterpret_cast}} } + +namespace ZeroSizeCmp { + extern void (*start[])(); + extern void (*end[])(); + static_assert(&start != &end, ""); // both-error {{constant expression}} \ + // both-note {{comparison of pointers '&start' and '&end' to unrelated zero-sized objects}} +} `` https://github.com/llvm/llvm-project/pull/140695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Diagnose comparisons of unrelated zero-sized pointers (PR #140695)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/140695 None >From 85be774cdec6ebaac96ca16e753d39237deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 20 May 2025 11:17:46 +0200 Subject: [PATCH] [clang][bytecode] Diagnose comparisons of unrelated zero-sized pointers --- clang/lib/AST/ByteCode/Interp.h | 8 clang/test/AST/ByteCode/cxx11.cpp | 7 +++ 2 files changed, 15 insertions(+) diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 9f1a6302eb856..23d3c088d571d 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -1135,6 +1135,14 @@ inline bool CmpHelperEQ(InterpState &S, CodePtr OpPC, CompareFn Fn) { } } + if (LHS.isUnknownSizeArray() && RHS.isUnknownSizeArray()) { +const SourceInfo &Loc = S.Current->getSource(OpPC); +S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_zero_sized) +<< LHS.toDiagnosticString(S.getASTContext()) +<< RHS.toDiagnosticString(S.getASTContext()); +return false; + } + S.Stk.push(BoolT::from(Fn(ComparisonCategoryResult::Unordered))); return true; } diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 88e195c36b583..36a57001ab966 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -233,3 +233,10 @@ namespace IntToPtrCast { constexpr intptr_t i = f((intptr_t)&foo - 10); // both-error{{constexpr variable 'i' must be initialized by a constant expression}} \ // both-note{{reinterpret_cast}} } + +namespace ZeroSizeCmp { + extern void (*start[])(); + extern void (*end[])(); + static_assert(&start != &end, ""); // both-error {{constant expression}} \ + // both-note {{comparison of pointers '&start' and '&end' to unrelated zero-sized objects}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] 2fb6ff4 - [libclc] Fix header inclusion issues
Author: Fraser Cormack Date: 2025-05-20T10:19:09+01:00 New Revision: 2fb6ff46f62e53e821b37d3ca0a71985969eaf44 URL: https://github.com/llvm/llvm-project/commit/2fb6ff46f62e53e821b37d3ca0a71985969eaf44 DIFF: https://github.com/llvm/llvm-project/commit/2fb6ff46f62e53e821b37d3ca0a71985969eaf44.diff LOG: [libclc] Fix header inclusion issues For some reason these weren't picked up by pre-commit CI. Added: Modified: libclc/clc/include/clc/geometric/clc_cross.h libclc/opencl/include/clc/opencl/clc.h Removed: diff --git a/libclc/clc/include/clc/geometric/clc_cross.h b/libclc/clc/include/clc/geometric/clc_cross.h index 932d8ab0716d3..e5aa913abfa29 100644 --- a/libclc/clc/include/clc/geometric/clc_cross.h +++ b/libclc/clc/include/clc/geometric/clc_cross.h @@ -9,6 +9,8 @@ #ifndef __CLC_GEOMETRIC_CLC_CROSS_H__ #define __CLC_GEOMETRIC_CLC_CROSS_H__ +#include + _CLC_OVERLOAD _CLC_DECL float3 __clc_cross(float3 p0, float3 p1); _CLC_OVERLOAD _CLC_DECL float4 __clc_cross(float4 p0, float4 p1); diff --git a/libclc/opencl/include/clc/opencl/clc.h b/libclc/opencl/include/clc/opencl/clc.h index 0116a12932c9f..5859a00c3158b 100644 --- a/libclc/opencl/include/clc/opencl/clc.h +++ b/libclc/opencl/include/clc/opencl/clc.h @@ -211,9 +211,10 @@ #include #include +#include + /* 6.11.8 Synchronization Functions */ #include -#include /* 6.11.9 Explicit Memory Fence Functions */ #include ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Reject array prvalue operands (PR #140702)
https://github.com/languagelawyer updated https://github.com/llvm/llvm-project/pull/140702 >From df91056b5ccbb0f51945f21cd5b2e5bca31eee7f Mon Sep 17 00:00:00 2001 From: Andrey Erokhin Date: Tue, 20 May 2025 14:58:23 +0500 Subject: [PATCH] [Clang][Sema] Reject array prvalue operands of unary + and *, and binary + and - operators --- .../clang/Basic/DiagnosticSemaKinds.td| 2 ++ clang/lib/Sema/SemaExpr.cpp | 24 +++ clang/test/CXX/expr/p8.cpp| 12 -- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d78a757c72e4a..2d7498a750d18 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7639,6 +7639,8 @@ def warn_param_mismatched_alignment : Warning< def err_objc_object_assignment : Error< "cannot assign to class object (%0 invalid)">; +def err_typecheck_array_prvalue_operand : Error< + "array prvalue is not permitted">; def err_typecheck_invalid_operands : Error< "invalid operands to binary expression (%0 and %1)">, Deferrable; def note_typecheck_invalid_operands_converted : Note< diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d1889100c382e..3e0a80602df68 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11333,6 +11333,13 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, if (!IExp->getType()->isIntegerType()) return InvalidOperands(Loc, LHS, RHS); + if (OriginalOperand Orig(PExp); + Orig.getType()->isArrayType() && Orig.Orig->isPRValue()) { +Diag(Loc, diag::err_typecheck_array_prvalue_operand) +<< PExp->getSourceRange(); +return QualType(); + } + // Adding to a null pointer results in undefined behavior. if (PExp->IgnoreParenCasts()->isNullPointerConstant( Context, Expr::NPC_ValueDependentIsNotNull)) { @@ -11429,6 +11436,18 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, return compType; } + OriginalOperand OrigLHS(LHS.get()), OrigRHS(RHS.get()); + bool LHSArrP = OrigLHS.getType()->isArrayType() && OrigLHS.Orig->isPRValue(); + bool RHSArrP = OrigRHS.getType()->isArrayType() && OrigRHS.Orig->isPRValue(); + if (LHSArrP || RHSArrP) { +auto &&diag = Diag(Loc, diag::err_typecheck_array_prvalue_operand); +if (LHSArrP) + diag << LHS.get()->getSourceRange(); +if (RHSArrP) + diag << RHS.get()->getSourceRange(); +return QualType(); + } + // Either ptr - int or ptr - ptr. if (LHS.get()->getType()->isAnyPointerType()) { QualType lpointee = LHS.get()->getType()->getPointeeType(); @@ -15840,6 +15859,11 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, InputExpr->getType()->isSpecificBuiltinType(BuiltinType::Dependent)) { resultType = Context.DependentTy; } else { +if (Opc == UO_Deref || Opc == UO_Plus) { + if (InputExpr->getType()->isArrayType() && InputExpr->isPRValue()) +return ExprError(Diag(OpLoc, diag::err_typecheck_array_prvalue_operand) + << InputExpr->getSourceRange()); +} switch (Opc) { case UO_PreInc: case UO_PreDec: diff --git a/clang/test/CXX/expr/p8.cpp b/clang/test/CXX/expr/p8.cpp index 471d1c5a30206..f736b88b3db09 100644 --- a/clang/test/CXX/expr/p8.cpp +++ b/clang/test/CXX/expr/p8.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 int a0; const volatile int a1 = 2; @@ -16,4 +15,13 @@ int main() f0(a1); f1(a2); f2(a3); + + using IA = int[]; + void(+IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(*IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } + 0); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } - 0); // expected-error {{array prvalue}} + void(0 + IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(0 - IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } - IA{ 1, 2, 3 }); // expected-error {{array prvalue}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer][NFC] Move PrettyStackTraceLocationContext into dispatchWorkItem (PR #140035)
https://github.com/NagyDonat approved this pull request. LGTM. I'm happy to see that this change simplifies the logic and moves several scattered stacktrace helpers to a common location. https://github.com/llvm/llvm-project/pull/140035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/140699 >From 2b62227227310785e74c71961e36cd0ab7b799d1 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Tue, 20 May 2025 11:44:59 +0200 Subject: [PATCH 1/2] [Clang] Use correct evaluation contexts when instantiating a var without initializer The evaluation context was improperly set up, such that we were trying to setup cleanups for a global var at the point of use, which lead to incorrect diagnostics about the variable not being capturable. Fixes #140632 Fixes #140622 --- clang/docs/ReleaseNotes.rst | 1 + .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 26 ++--- .../CodeGenCXX/cxx1y-variable-template.cpp| 12 +- .../cxx1y-variable-templates_top_level.cpp| 37 +-- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f04cb7b91788c..8e6cf62e11752 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -746,6 +746,7 @@ Bug Fixes to C++ Support - Fixed bug in constant evaluation that would allow using the value of a reference in its own initializer in C++23 mode (#GH131330). - Clang could incorrectly instantiate functions in discarded contexts (#GH140449) +- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index b12085c6f6935..d1f313e9cb487 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6069,22 +6069,20 @@ void Sema::InstantiateVariableInitializer( else if (OldVar->isInline()) Var->setImplicitlyInline(); - if (OldVar->getInit()) { -EnterExpressionEvaluationContext Evaluated( -*this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Var); + ContextRAII SwitchContext(*this, Var->getDeclContext()); -currentEvaluationContext().InLifetimeExtendingContext = -parentEvaluationContext().InLifetimeExtendingContext; -currentEvaluationContext().RebuildDefaultArgOrDefaultInit = -parentEvaluationContext().RebuildDefaultArgOrDefaultInit; -// Instantiate the initializer. -ExprResult Init; + EnterExpressionEvaluationContext Evaluated( + *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Var); + currentEvaluationContext().InLifetimeExtendingContext = + parentEvaluationContext().InLifetimeExtendingContext; + currentEvaluationContext().RebuildDefaultArgOrDefaultInit = + parentEvaluationContext().RebuildDefaultArgOrDefaultInit; -{ - ContextRAII SwitchContext(*this, Var->getDeclContext()); - Init = SubstInitializer(OldVar->getInit(), TemplateArgs, - OldVar->getInitStyle() == VarDecl::CallInit); -} + if (OldVar->getInit()) { +// Instantiate the initializer. +ExprResult Init = +SubstInitializer(OldVar->getInit(), TemplateArgs, + OldVar->getInitStyle() == VarDecl::CallInit); if (!Init.isInvalid()) { Expr *InitExpr = Init.get(); diff --git a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp index 7c0351881f198..885107ee95d88 100644 --- a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp +++ b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s // Check that we keep the 'extern' when we instantiate the definition of this // variable template specialization. @@ -18,6 +18,16 @@ int init_arr(); template template template int Outer::Inner::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() }; int *p = Outer::Inner::arr; +//CHECK : @_ZN8GH1406221gIiEE = linkonce_odr constant %"struct.GH140622::S" zeroinitializer +namespace GH140622 { +template struct S {}; +template constexpr S g; +void test() { +constexpr auto x = 42; +x, g; +} +} + namespace PR35456 { // CHECK: @_ZN7PR354561nILi0EEE = linkonce_odr global i32 0 template int n; diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 1fe0ce9aabf29..aada11dd5f9be 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11 -// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s -// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s +// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only
[clang] 9c33faf - [Clang] Use correct evaluation contexts when instantiating a var without initializer (#140699)
Author: cor3ntin Date: 2025-05-20T14:04:34+02:00 New Revision: 9c33faf8628ae639e6c9b39857e1e413c49e38f0 URL: https://github.com/llvm/llvm-project/commit/9c33faf8628ae639e6c9b39857e1e413c49e38f0 DIFF: https://github.com/llvm/llvm-project/commit/9c33faf8628ae639e6c9b39857e1e413c49e38f0.diff LOG: [Clang] Use correct evaluation contexts when instantiating a var without initializer (#140699) The evaluation context was improperly set up, such that we were trying to set up cleanups for a global variable at the point of use, which led to incorrect diagnostics about the variable not being capturable. Fixes #140632 Fixes #140622 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/CodeGenCXX/cxx1y-variable-template.cpp clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f04cb7b91788c..8e6cf62e11752 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -746,6 +746,7 @@ Bug Fixes to C++ Support - Fixed bug in constant evaluation that would allow using the value of a reference in its own initializer in C++23 mode (#GH131330). - Clang could incorrectly instantiate functions in discarded contexts (#GH140449) +- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622) Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index b12085c6f6935..d1f313e9cb487 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -6069,22 +6069,20 @@ void Sema::InstantiateVariableInitializer( else if (OldVar->isInline()) Var->setImplicitlyInline(); - if (OldVar->getInit()) { -EnterExpressionEvaluationContext Evaluated( -*this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Var); + ContextRAII SwitchContext(*this, Var->getDeclContext()); -currentEvaluationContext().InLifetimeExtendingContext = -parentEvaluationContext().InLifetimeExtendingContext; -currentEvaluationContext().RebuildDefaultArgOrDefaultInit = -parentEvaluationContext().RebuildDefaultArgOrDefaultInit; -// Instantiate the initializer. -ExprResult Init; + EnterExpressionEvaluationContext Evaluated( + *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Var); + currentEvaluationContext().InLifetimeExtendingContext = + parentEvaluationContext().InLifetimeExtendingContext; + currentEvaluationContext().RebuildDefaultArgOrDefaultInit = + parentEvaluationContext().RebuildDefaultArgOrDefaultInit; -{ - ContextRAII SwitchContext(*this, Var->getDeclContext()); - Init = SubstInitializer(OldVar->getInit(), TemplateArgs, - OldVar->getInitStyle() == VarDecl::CallInit); -} + if (OldVar->getInit()) { +// Instantiate the initializer. +ExprResult Init = +SubstInitializer(OldVar->getInit(), TemplateArgs, + OldVar->getInitStyle() == VarDecl::CallInit); if (!Init.isInvalid()) { Expr *InitExpr = Init.get(); diff --git a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp index 7c0351881f198..329b6c0cb86ae 100644 --- a/clang/test/CodeGenCXX/cxx1y-variable-template.cpp +++ b/clang/test/CodeGenCXX/cxx1y-variable-template.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s // Check that we keep the 'extern' when we instantiate the definition of this // variable template specialization. @@ -18,6 +18,16 @@ int init_arr(); template template template int Outer::Inner::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() }; int *p = Outer::Inner::arr; +//CHECK: @_ZN8GH1406221gIiEE = linkonce_odr constant %"struct.GH140622::S" zeroinitializer +namespace GH140622 { +template struct S {}; +template constexpr S g; +void test() { +constexpr auto x = 42; +x, g; +} +} + namespace PR35456 { // CHECK: @_ZN7PR354561nILi0EEE = linkonce_odr global i32 0 template int n; diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 1fe0ce9aabf29..aada11dd5f9be 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11 -// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s -// RUN: %cla
[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/140699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Reject array prvalue operands (PR #140702)
https://github.com/languagelawyer updated https://github.com/llvm/llvm-project/pull/140702 >From f6067249c40ad8423048b718be53e69f74b8607d Mon Sep 17 00:00:00 2001 From: Andrey Erokhin Date: Tue, 20 May 2025 14:58:23 +0500 Subject: [PATCH] [Clang][Sema] Reject array prvalue operands of unary + and *, and binary + and - operators --- .../clang/Basic/DiagnosticSemaKinds.td| 2 ++ clang/lib/Sema/SemaExpr.cpp | 24 +++ clang/test/CXX/expr/p8.cpp| 12 -- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index d78a757c72e4a..e72d62a9a5408 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -6971,6 +6971,8 @@ def err_typecheck_arc_assign_self_class_method : Error< def err_typecheck_arr_assign_enumeration : Error< "fast enumeration variables cannot be modified in ARC by default; " "declare the variable __strong to allow this">; +def err_typecheck_array_prvalue_operand : Error< + "array prvalue is not permitted">; def err_typecheck_arc_assign_externally_retained : Error< "variable declared with 'objc_externally_retained' " "cannot be modified in ARC">; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d1889100c382e..3e0a80602df68 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -11333,6 +11333,13 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, if (!IExp->getType()->isIntegerType()) return InvalidOperands(Loc, LHS, RHS); + if (OriginalOperand Orig(PExp); + Orig.getType()->isArrayType() && Orig.Orig->isPRValue()) { +Diag(Loc, diag::err_typecheck_array_prvalue_operand) +<< PExp->getSourceRange(); +return QualType(); + } + // Adding to a null pointer results in undefined behavior. if (PExp->IgnoreParenCasts()->isNullPointerConstant( Context, Expr::NPC_ValueDependentIsNotNull)) { @@ -11429,6 +11436,18 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, return compType; } + OriginalOperand OrigLHS(LHS.get()), OrigRHS(RHS.get()); + bool LHSArrP = OrigLHS.getType()->isArrayType() && OrigLHS.Orig->isPRValue(); + bool RHSArrP = OrigRHS.getType()->isArrayType() && OrigRHS.Orig->isPRValue(); + if (LHSArrP || RHSArrP) { +auto &&diag = Diag(Loc, diag::err_typecheck_array_prvalue_operand); +if (LHSArrP) + diag << LHS.get()->getSourceRange(); +if (RHSArrP) + diag << RHS.get()->getSourceRange(); +return QualType(); + } + // Either ptr - int or ptr - ptr. if (LHS.get()->getType()->isAnyPointerType()) { QualType lpointee = LHS.get()->getType()->getPointeeType(); @@ -15840,6 +15859,11 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, InputExpr->getType()->isSpecificBuiltinType(BuiltinType::Dependent)) { resultType = Context.DependentTy; } else { +if (Opc == UO_Deref || Opc == UO_Plus) { + if (InputExpr->getType()->isArrayType() && InputExpr->isPRValue()) +return ExprError(Diag(OpLoc, diag::err_typecheck_array_prvalue_operand) + << InputExpr->getSourceRange()); +} switch (Opc) { case UO_PreInc: case UO_PreDec: diff --git a/clang/test/CXX/expr/p8.cpp b/clang/test/CXX/expr/p8.cpp index 471d1c5a30206..f736b88b3db09 100644 --- a/clang/test/CXX/expr/p8.cpp +++ b/clang/test/CXX/expr/p8.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 int a0; const volatile int a1 = 2; @@ -16,4 +15,13 @@ int main() f0(a1); f1(a2); f2(a3); + + using IA = int[]; + void(+IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(*IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } + 0); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } - 0); // expected-error {{array prvalue}} + void(0 + IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(0 - IA{ 1, 2, 3 }); // expected-error {{array prvalue}} + void(IA{ 1, 2, 3 } - IA{ 1, 2, 3 }); // expected-error {{array prvalue}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang] Allow vector and matrix type attributes for sub-byte _BitInt (PR #140253)
https://github.com/MrSidims updated https://github.com/llvm/llvm-project/pull/140253 >From 67935acd84b032209d45bad22db8e1a9e72c1dcd Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Fri, 16 May 2025 06:55:10 -0700 Subject: [PATCH 1/3] [Clang] Allow vector and matrix type attributes for sub-byte _BitInt Signed-off-by: Sidorov, Dmitry --- clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +-- clang/lib/Sema/SemaType.cpp | 4 ++-- clang/test/SemaCXX/ext-int.cpp | 12 ++-- clang/test/SemaCXX/matrix-type.cpp | 3 +-- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index f0bd5a1174020..9f20c07882901 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3257,8 +3257,7 @@ def err_attribute_too_few_arguments : Error< "%0 attribute takes at least %1 argument%s1">; def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">; def err_attribute_invalid_bitint_vector_type : Error< - "'_BitInt' %select{vector|matrix}0 element width must be %select{a power of 2|" - "at least as wide as 'CHAR_BIT'}1">; + "'_BitInt' %select{vector|matrix}0 element width must be a power of 2">; def err_attribute_invalid_matrix_type : Error<"invalid matrix element type %0">; def err_attribute_bad_neon_vector_size : Error< "Neon vector size must be 64 or 128 bits">; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 9ed2326f151a3..28d441234262b 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2321,9 +2321,9 @@ static bool CheckBitIntElementType(Sema &S, SourceLocation AttrLoc, bool ForMatrixType = false) { // Only support _BitInt elements with byte-sized power of 2 NumBits. unsigned NumBits = BIT->getNumBits(); - if (!llvm::isPowerOf2_32(NumBits) || NumBits < 8) + if (!llvm::isPowerOf2_32(NumBits)) return S.Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type) - << ForMatrixType << (NumBits < 8); + << ForMatrixType; return false; } diff --git a/clang/test/SemaCXX/ext-int.cpp b/clang/test/SemaCXX/ext-int.cpp index d974221e774a7..5c566dafed931 100644 --- a/clang/test/SemaCXX/ext-int.cpp +++ b/clang/test/SemaCXX/ext-int.cpp @@ -84,17 +84,9 @@ struct is_same { }; // Reject vector types: -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} -typedef _BitInt(2) __attribute__((vector_size(16))) VecTy; -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} -typedef _BitInt(2) __attribute__((ext_vector_type(32))) OtherVecTy; -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} -typedef _BitInt(4) __attribute__((vector_size(16))) VecTy2; -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} -typedef _BitInt(4) __attribute__((ext_vector_type(32))) OtherVecTy2; -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} +// expected-error@+1{{'_BitInt' vector element width must be a power of 2}} typedef _BitInt(5) __attribute__((vector_size(16))) VecTy3; -// expected-error@+1{{'_BitInt' vector element width must be at least as wide as 'CHAR_BIT'}} +// expected-error@+1{{'_BitInt' vector element width must be a power of 2}} typedef _BitInt(5) __attribute__((ext_vector_type(32))) OtherVecTy3; // expected-error@+1{{'_BitInt' vector element width must be a power of 2}} typedef _BitInt(37) __attribute__((vector_size(16))) VecTy4; diff --git a/clang/test/SemaCXX/matrix-type.cpp b/clang/test/SemaCXX/matrix-type.cpp index bb7a8421ca9e3..186d3b6b35208 100644 --- a/clang/test/SemaCXX/matrix-type.cpp +++ b/clang/test/SemaCXX/matrix-type.cpp @@ -31,8 +31,7 @@ void matrix_unsupported_element_type() { } void matrix_unsupported_bit_int() { - using m1 = _BitInt(2) __attribute__((matrix_type(4, 4))); // expected-error{{'_BitInt' matrix element width must be at least as wide as 'CHAR_BIT'}} - using m2 = _BitInt(7) __attribute__((matrix_type(4, 4))); // expected-error{{'_BitInt' matrix element width must be at least as wide as 'CHAR_BIT'}} + using m2 = _BitInt(7) __attribute__((matrix_type(4, 4))); // expected-error{{'_BitInt' matrix element width must be a power of 2}} using m3 = _BitInt(9) __attribute__((matrix_type(4, 4))); // expected-error{{'_BitInt' matrix element width must be a power of 2}} using m4 = _BitInt(12) __attribute__((matrix_type(4, 4))); // expected-error{{'_BitInt' matrix element width must be a power of 2}} using m5 = _BitInt(8) __attribute__((matrix_type(4, 4))); >From 513b17b19ed9c416e48fe8cf590081ccc0cb2f91 Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Mon, 19 May 2025 06:17:
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
https://github.com/DaanDeMeyer updated https://github.com/llvm/llvm-project/pull/140600 >From 0e6f4f49197748d470c8839e6c3117fad35adbfa Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 19 May 2025 21:39:32 +0200 Subject: [PATCH] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner These mimick the same options from clangd and allow using the check to only check for unused includes or missing includes. --- .../clang-tidy/misc/IncludeCleanerCheck.cpp | 77 +++ .../clang-tidy/misc/IncludeCleanerCheck.h | 4 + clang-tools-extra/docs/ReleaseNotes.rst | 7 +- .../checks/misc/include-cleaner.rst | 11 +++ .../clang-tidy/IncludeCleanerTest.cpp | 58 ++ 5 files changed, 124 insertions(+), 33 deletions(-) diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp index 7638bbc103d16..52a94f3c040aa 100644 --- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp @@ -59,7 +59,9 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, : ClangTidyCheck(Name, Context), IgnoreHeaders( utils::options::parseStringList(Options.get("IgnoreHeaders", ""))), - DeduplicateFindings(Options.get("DeduplicateFindings", true)) { + DeduplicateFindings(Options.get("DeduplicateFindings", true)), + UnusedIncludes(Options.get("UnusedIncludes", true)), + MissingIncludes(Options.get("MissingIncludes", true)) { for (const auto &Header : IgnoreHeaders) { if (!llvm::Regex{Header}.isValid()) configurationDiag("Invalid ignore headers regex '%0'") << Header; @@ -68,12 +70,19 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, HeaderSuffix += "$"; IgnoreHeadersRegex.emplace_back(HeaderSuffix); } + + if (UnusedIncludes == false && MissingIncludes == false) +this->configurationDiag("The check 'misc-include-cleaner' will not " +"perform any analysis because 'UnusedIncludes' and " +"'MissingIncludes' are both false."); } void IncludeCleanerCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "IgnoreHeaders", utils::options::serializeStringList(IgnoreHeaders)); Options.store(Opts, "DeduplicateFindings", DeduplicateFindings); + Options.store(Opts, "UnusedIncludes", UnusedIncludes); + Options.store(Opts, "MissingIncludes", MissingIncludes); } bool IncludeCleanerCheck::isLanguageVersionSupported( @@ -200,39 +209,43 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) { if (!FileStyle) FileStyle = format::getLLVMStyle(); - for (const auto *Inc : Unused) { -diag(Inc->HashLocation, "included header %0 is not used directly") -<< llvm::sys::path::filename(Inc->Spelled, - llvm::sys::path::Style::posix) -<< FixItHint::CreateRemoval(CharSourceRange::getCharRange( - SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1), - SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1))); + if (UnusedIncludes) { +for (const auto *Inc : Unused) { + diag(Inc->HashLocation, "included header %0 is not used directly") + << llvm::sys::path::filename(Inc->Spelled, + llvm::sys::path::Style::posix) + << FixItHint::CreateRemoval(CharSourceRange::getCharRange( + SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1), + SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1))); +} } - tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code, - FileStyle->IncludeStyle); - // Deduplicate insertions when running in bulk fix mode. - llvm::StringSet<> InsertedHeaders{}; - for (const auto &Inc : Missing) { -std::string Spelling = include_cleaner::spellHeader( -{Inc.Missing, PP->getHeaderSearchInfo(), MainFile}); -bool Angled = llvm::StringRef{Spelling}.starts_with("<"); -// We might suggest insertion of an existing include in edge cases, e.g., -// include is present in a PP-disabled region, or spelling of the header -// turns out to be the same as one of the unresolved includes in the -// main file. -if (auto Replacement = -HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"), - Angled, tooling::IncludeDirective::Include)) { - DiagnosticBuilder DB = - diag(SM->getSpellingLoc(Inc.SymRef.RefLocation), - "no header providing \"%0\" is directly included") - << Inc.SymRef.Target.name(); - if (areDiagsSelfContained() || - InsertedHeaders.insert(Replacement->getReplacementText()).second) { -DB << FixItHint::CreateInsertion( -
[clang] [RISCV] Implement intrinsics for XAndesVPackFPH (PR #140007)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/11580 Here is the relevant piece of the build log for the reference ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds. -- Testing: 89697 tests, 88 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90 FAIL: LLVM :: ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s (63104 of 89697) TEST 'LLVM :: ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s' FAILED Exit Code: 1 Command Output (stderr): -- /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc -filetype=obj -triple=x86_64-windows-msvc /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp # RUN: at line 1 + /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-mc -filetype=obj -triple=x86_64-windows-msvc /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp not /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink -noexec /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp 2>&1 | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s # RUN: at line 2 + not /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llvm-jitlink -noexec /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/test/ExecutionEngine/JITLink/x86-64/Output/COFF_directive_alternatename_fail.s.tmp + /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/COFF_directive_alternatename_fail.s -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. Slowest Tests: -- 590.56s: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir 421.06s: Clang :: Driver/fsanitize.c 330.33s: LLVM :: CodeGen/AMDGPU/amdgcn.bitcast.1024bit.ll 325.37s: Clang :: Preprocessor/riscv-target-features.c 291.42s: LLVM :: CodeGen/AMDGPU/memintrinsic-unroll.ll 260.10s: Clang :: Driver/arm-cortex-cpus-1.c 259.64s: Clang :: Driver/arm-cortex-cpus-2.c 253.96s: Clang :: OpenMP/target_update_codegen.cpp 251.49s: Clang :: OpenMP/target_defaultmap_codegen_01.cpp 243.99s: Cla
[clang] [clang-format] Add ApplyAlwaysOnePerLineToTemplateArguments option (PR #137544)
@@ -1521,6 +1523,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.BinPackArguments = true; LLVMStyle.BinPackLongBracedList = true; LLVMStyle.BinPackParameters = FormatStyle::BPPS_BinPack; + LLVMStyle.ApplyAlwaysOnePerLineToTemplateArguments = true; mydeveloperday wrote: what is the current behavior? is this the correct default? https://github.com/llvm/llvm-project/pull/137544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
https://github.com/melver updated https://github.com/llvm/llvm-project/pull/137133 >From b264872c3f28f6cf172b0123087adda9d53dc1b9 Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Wed, 23 Apr 2025 11:31:25 +0200 Subject: [PATCH 1/2] Thread Safety Analysis: Convert CapabilityExpr::CapExpr to hold flags Rather than holding a single bool, switch it to contain flags, which is both more descriptive and simplifies adding more flags in subsequent changes. NFC. --- .../clang/Analysis/Analyses/ThreadSafetyCommon.h | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index e99c5b2466334..6e46a2d721463 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -271,26 +271,28 @@ class CFGWalker { // translateAttrExpr needs it, but that should be moved too. class CapabilityExpr { private: - /// The capability expression and whether it's negated. - llvm::PointerIntPair CapExpr; + static constexpr unsigned FlagNegative = 1u << 0; + + /// The capability expression and flags. + llvm::PointerIntPair CapExpr; /// The kind of capability as specified by @ref CapabilityAttr::getName. StringRef CapKind; public: - CapabilityExpr() : CapExpr(nullptr, false) {} + CapabilityExpr() : CapExpr(nullptr, 0) {} CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg) - : CapExpr(E, Neg), CapKind(Kind) {} + : CapExpr(E, Neg ? FlagNegative : 0), CapKind(Kind) {} // Don't allow implicitly-constructed StringRefs since we'll capture them. template CapabilityExpr(const til::SExpr *, T, bool) = delete; const til::SExpr *sexpr() const { return CapExpr.getPointer(); } StringRef getKind() const { return CapKind; } - bool negative() const { return CapExpr.getInt(); } + bool negative() const { return CapExpr.getInt() & FlagNegative; } CapabilityExpr operator!() const { -return CapabilityExpr(CapExpr.getPointer(), CapKind, !CapExpr.getInt()); +return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative()); } bool equals(const CapabilityExpr &other) const { >From 08b170299096ed4c49a7d52d169510a6ecb567fe Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Thu, 24 Apr 2025 09:02:08 +0200 Subject: [PATCH 2/2] Thread Safety Analysis: Support reentrant capabilities Introduce the `reentrant_capability` attribute, which may be specified alongside the `capability(..)` attribute to denote that the defined capability type is reentrant. Marking a capability as reentrant means that acquiring the same capability multiple times is safe, and does not produce warnings on attempted re-acquisition. The most significant changes required are plumbing to propagate if the attribute is present to a CapabilityExpr, and then introducing a ReentrancyCount to FactEntry that can be incremented while a fact remains in the FactSet. --- clang/docs/ReleaseNotes.rst | 1 + clang/docs/ThreadSafetyAnalysis.rst | 18 + .../clang/Analysis/Analyses/ThreadSafety.h| 4 +- .../Analysis/Analyses/ThreadSafetyCommon.h| 22 +- clang/include/clang/Basic/Attr.td | 7 + .../clang/Basic/DiagnosticSemaKinds.td| 7 +- clang/lib/Analysis/ThreadSafety.cpp | 133 +-- clang/lib/Analysis/ThreadSafetyCommon.cpp | 76 ++-- clang/lib/Sema/AnalysisBasedWarnings.cpp | 8 +- clang/lib/Sema/SemaDeclAttr.cpp | 18 + ...a-attribute-supported-attributes-list.test | 1 + clang/test/Sema/warn-thread-safety-analysis.c | 20 + .../test/SemaCXX/thread-safety-annotations.h | 1 + .../SemaCXX/warn-thread-safety-analysis.cpp | 364 ++ .../SemaCXX/warn-thread-safety-parsing.cpp| 12 + clang/unittests/AST/ASTImporterTest.cpp | 9 + 16 files changed, 624 insertions(+), 77 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f04cb7b91788c..e87f04fe1cdd0 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -443,6 +443,7 @@ Improvements to Clang's diagnostics as function arguments or return value respectively. Note that :doc:`ThreadSafetyAnalysis` still does not perform alias analysis. The feature will be default-enabled with ``-Wthread-safety`` in a future release. +- The :doc:`ThreadSafetyAnalysis` now supports reentrant capabilities. - Clang will now do a better job producing common nested names, when producing common types for ternary operator, template argument deduction and multiple return auto deduction. - The ``-Wsign-compare`` warning now treats expressions with bitwise not(~) and minus(-) as signed integers diff --git a/clang/docs/ThreadSafetyAnalysis.rst b/clang/docs/ThreadSafetyAnalysis.rst index 130069c5659d6..4fc7ff28e9931 100644 --- a/clang/docs/ThreadSafetyAnalysis.rst +++ b/
[clang] [llvm] [RISCV] Add Andes A25/AX25 processor definition (PR #140681)
https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/140681 Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are developed by Andes Technology https://www.andestech.com, a RISC-V IP provider. The overviews for A25/AX25: https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/ https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/ Scheduling model will be implemented in a later PR. >From 98bdcfd0b57b482f31be098e069e610897cc1425 Mon Sep 17 00:00:00 2001 From: Jim Lin Date: Tue, 20 May 2025 10:13:26 +0800 Subject: [PATCH] [RISCV] Add Andes A25/AX25 processor definition Andes A25/AX25 are 32/64bit, 5-stage pipeline, linux-capable CPUs that implement the RV[32|64]IMAFDC_Zba_Zbb_Zbc_Zbs ISA extensions. They are developed by Andes Technology https://www.andestech.com, a RISC-V IP provider. The overviews for A25/AX25: https://www.andestech.com/en/products-solutions/andescore-processors/riscv-a25/ https://www.andestech.com/en/products-solutions/andescore-processors/riscv-ax25/ Scheduling model will be implemented in a later PR. --- clang/test/Driver/riscv-cpus.c| 36 +++ .../test/Misc/target-invalid-cpu-note/riscv.c | 12 --- llvm/docs/ReleaseNotes.md | 1 + llvm/lib/Target/RISCV/RISCVProcessors.td | 32 + 4 files changed, 77 insertions(+), 4 deletions(-) diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c index dacdb03fd09d9..cebf41aa626a7 100644 --- a/clang/test/Driver/riscv-cpus.c +++ b/clang/test/Driver/riscv-cpus.c @@ -699,6 +699,42 @@ // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s // MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7" +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-a25 | FileCheck -check-prefix=MCPU-ANDES-A25 %s +// MCPU-ANDES-A25: "-target-cpu" "andes-a25" +// MCPU-ANDES-A25-SAME: "-target-feature" "+m" +// MCPU-ANDES-A25-SAME: "-target-feature" "+a" +// MCPU-ANDES-A25-SAME: "-target-feature" "+f" +// MCPU-ANDES-A25-SAME: "-target-feature" "+d" +// MCPU-ANDES-A25-SAME: "-target-feature" "+c" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zicsr" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zifencei" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zba" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zbb" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zbc" +// MCPU-ANDES-A25-SAME: "-target-feature" "+zbs" +// MCPU-ANDES-A25-SAME: "-target-abi" "ilp32d" + +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-a25 | FileCheck -check-prefix=MTUNE-ANDES-A25 %s +// MTUNE-ANDES-A25: "-tune-cpu" "andes-a25" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-ax25 | FileCheck -check-prefix=MCPU-ANDES-AX25 %s +// MCPU-ANDES-AX25: "-target-cpu" "andes-ax25" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+m" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+a" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+f" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+d" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+c" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zicsr" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zifencei" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zba" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbb" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbc" +// MCPU-ANDES-AX25-SAME: "-target-feature" "+zbs" +// MCPU-ANDES-AX25-SAME: "-target-abi" "lp64d" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-ax25 | FileCheck -check-prefix=MTUNE-ANDES-AX25 %s +// MTUNE-ANDES-AX25: "-tune-cpu" "andes-ax25" + // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-n45 | FileCheck -check-prefix=MCPU-ANDES-N45 %s // MCPU-ANDES-N45: "-target-cpu" "andes-n45" // MCPU-ANDES-N45-SAME: "-target-feature" "+m" diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c b/clang/test/Misc/target-invalid-cpu-note/riscv.c index b4e83e59d296f..c57bde8aa531a 100644 --- a/clang/test/Misc/target-invalid-cpu-note/riscv.c +++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c @@ -5,7 +5,8 @@ // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32 // RISCV32: error: unknown target CPU 'not-a-cpu' // RISCV32-NEXT: note: valid target CPU values are: -// RISCV32-SAME: {{^}} andes-a45 +// RISCV32-SAME: {{^}} andes-a25 +// RISCV32-SAME: {{^}}, andes-a45 // RISCV32-SAME: {{^}}, andes-n45 // RISCV32-SAME: {{^}}, generic-rv32 // RISCV32-SAME: {{^}}, rocket-rv32 @@ -26,7 +27,8 @@ // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64 // RISCV64: error: unknown target CPU 'not-a-cpu' // RISCV64-NEXT: note: valid target CPU values are: -// RISCV64-SAME: {{^}} andes-ax45 +// RISCV64-SAME: {{^}} andes-ax25 +/
[clang] [clang-format] Add ApplyAlwaysOnePerLineToTemplateArguments option (PR #137544)
https://github.com/mydeveloperday edited https://github.com/llvm/llvm-project/pull/137544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Check downcasts for the correct type (PR #140689)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/15505 Here is the relevant piece of the build log for the reference ``` Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure) ... [250/2500] Copying CXX header __atomic/to_gcc_order.h [251/2500] Generating header errno.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/errno.yaml [252/2500] Generating header uchar.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/uchar.yaml [253/2500] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.strncasecmp.dir/strncasecmp.cpp.obj [254/2500] Generating header string.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/string.yaml [255/2500] Generating header ctype.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/ctype.yaml [256/2500] Generating header time.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/time.yaml [257/2500] Generating header setjmp.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/setjmp.yaml [258/2500] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj [259/2500] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.l64a.dir/l64a.cpp.obj FAILED: libc/src/stdlib/CMakeFiles/libc.src.stdlib.l64a.dir/l64a.cpp.obj /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-z98elllf/./bin/clang++ --target=riscv32-unknown-elf -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-z98elllf/include/riscv32-unknown-unknown-elf --target=riscv32-unknown-elf -march=rv32imafc -mabi=ilp32f -Wno-atomic-alignment "-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, ...)=printf(format)" -D_LIBCPP_PRINT=1 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wno-unnecessary-virtual-specifier -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-z98elllf/runtimes/runtimes-riscv32-unknown-elf-bins=../../../../llvm-project -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= -no-canonical-prefixes -Os -DNDEBUG --target=riscv32-unknown-elf -DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT -DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES)" -fpie -ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT libc/src/stdlib/CMakeFiles/libc.src.stdlib.l64a.dir/l64a.cpp.obj -MF libc/src/stdlib/CMakeFiles/libc.src.stdlib.l64a.dir/l64a.cpp.obj.d -o libc/src/stdlib/CMakeFiles/libc.src.stdlib.l64a.dir/l64a.cpp.obj -c /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/stdlib/l64a.cpp In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/stdlib/l64a.cpp:13: In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/libc_assert.h:25: In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/integer_to_string.h:70: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/big_int.h:35:31: error: use of undeclared identifier 'uint16_t' 35 | template <> struct half_width : cpp::type_identity {}; | ^~~~ /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/big_int.h:35:62: error: use of undeclared identifier 'uint8_t' 35 | template <> struct half_width : cpp::type_identity {}; | ^~~ /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/big_int.h:36:31: error: use of undeclared identifier 'uint32_t' 36 | templ
[clang] [Clang] Fix an inadvertent overwrite of sub-initializers (PR #140714)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Younan Zhang (zyn0217) Changes When using InitChecker with VerifyOnly, we create a new designated initializer to handle anonymous fields. However in the last call to CheckDesignatedInitializer, the subinitializer isn't properly preserved but it gets overwritten by the cloned one. Which causes the initializer to reference the dependent field, breaking assumptions when we initialize the instantiated specialization. Fixes https://github.com/llvm/llvm-project/issues/67173 --- Full diff: https://github.com/llvm/llvm-project/pull/140714.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+1) - (modified) clang/lib/Sema/SemaInit.cpp (+8-4) - (modified) clang/test/SemaTemplate/deduction-guide.cpp (+27) ``diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f04cb7b91788c..6f97cf79c5058 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -690,6 +690,7 @@ Bug Fixes to C++ Support certain differences in qualifiers (this could happen during template argument deduction or when building a ternary operator). (#GH97005) - Fixed type alias CTAD issues involving default template arguments. (#GH134471) +- Fixed CTAD issues when initializing anonymous fields with designated initializers. (#GH67173) - The initialization kind of elements of structured bindings direct-list-initialized from an array is corrected to direct-initialization. - Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 9ee8603ff7811..1f204f8306842 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2791,16 +2791,20 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // initializer list that the child calls see, so that we don't try // to re-process the designator. unsigned OldIndex = Index; -IList->setInit(OldIndex, DIE->getInit()); +auto *OldDIE = +dyn_cast_if_present(IList->getInit(OldIndex)); +if (!OldDIE) + OldDIE = DIE; +IList->setInit(OldIndex, OldDIE->getInit()); CheckSubElementType(Entity, IList, CurrentObjectType, Index, StructuredList, StructuredIndex, /*DirectlyDesignated=*/true); // Restore the designated initializer expression in the syntactic // form of the initializer list. -if (IList->getInit(OldIndex) != DIE->getInit()) - DIE->setInit(IList->getInit(OldIndex)); -IList->setInit(OldIndex, DIE); +if (IList->getInit(OldIndex) != OldDIE->getInit()) + OldDIE->setInit(IList->getInit(OldIndex)); +IList->setInit(OldIndex, OldDIE); return hadError && !prevHadError; } diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index dabd0cf12f77e..c1ce55e1c8029 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -886,3 +886,30 @@ CC c{}; // CHECK-NEXT:`-ClassTemplateSpecialization {{.+}} 'A' } + +namespace GH67173 { + +template struct Vec2d { + struct { +T x; +T y; + }; +}; + +void f() { + Vec2d v{.x = 1, .y = 2}; +} + +// CHECK-LABEL: Dumping GH67173::: +// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit +// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} referenced class depth 0 index 0 T +// CHECK: |-CXXDeductionGuideDecl {{.+}} implicit 'auto (T, T) -> Vec2d' aggregate +// CHECK-NEXT: | |-ParmVarDecl {{.+}} col:27 'T' +// CHECK-NEXT: | `-ParmVarDecl {{.+}} col:27 'T' +// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit used 'auto (int, int) -> GH67173::Vec2d' implicit_instantiation aggregate +// CHECK-NEXT: |-TemplateArgument type 'int' +// CHECK-NEXT: | `-BuiltinType {{.+}} 'int' +// CHECK-NEXT: |-ParmVarDecl {{.+}} 'int' +// CHECK-NEXT: `-ParmVarDecl {{.+}} 'int' + +} `` https://github.com/llvm/llvm-project/pull/140714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix an inadvertent overwrite of sub-initializers (PR #140714)
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/140714 When using InitChecker with VerifyOnly, we create a new designated initializer to handle anonymous fields. However in the last call to CheckDesignatedInitializer, the subinitializer isn't properly preserved but it gets overwritten by the cloned one. Which causes the initializer to reference the dependent field, breaking assumptions when we initialize the instantiated specialization. Fixes https://github.com/llvm/llvm-project/issues/67173 >From ec6c540f17d767b3fd882f60b0757e6e4e35442a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Tue, 20 May 2025 19:19:47 +0800 Subject: [PATCH] [Clang] Fix an inadvertent overwrite of sub-initializers When using InitChecker with VerifyOnly, we create a new designated initializer to handle anonymous fields. However in the last call to CheckDesignatedInitializer, the subinitializer isn't properly preserved but it gets overwritten by the cloned one. Which causes the initializer to reference the dependent field, breaking assumptions when we initialize the instantiated specialization. --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/Sema/SemaInit.cpp | 12 ++--- clang/test/SemaTemplate/deduction-guide.cpp | 27 + 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f04cb7b91788c..6f97cf79c5058 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -690,6 +690,7 @@ Bug Fixes to C++ Support certain differences in qualifiers (this could happen during template argument deduction or when building a ternary operator). (#GH97005) - Fixed type alias CTAD issues involving default template arguments. (#GH134471) +- Fixed CTAD issues when initializing anonymous fields with designated initializers. (#GH67173) - The initialization kind of elements of structured bindings direct-list-initialized from an array is corrected to direct-initialization. - Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 9ee8603ff7811..1f204f8306842 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2791,16 +2791,20 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // initializer list that the child calls see, so that we don't try // to re-process the designator. unsigned OldIndex = Index; -IList->setInit(OldIndex, DIE->getInit()); +auto *OldDIE = +dyn_cast_if_present(IList->getInit(OldIndex)); +if (!OldDIE) + OldDIE = DIE; +IList->setInit(OldIndex, OldDIE->getInit()); CheckSubElementType(Entity, IList, CurrentObjectType, Index, StructuredList, StructuredIndex, /*DirectlyDesignated=*/true); // Restore the designated initializer expression in the syntactic // form of the initializer list. -if (IList->getInit(OldIndex) != DIE->getInit()) - DIE->setInit(IList->getInit(OldIndex)); -IList->setInit(OldIndex, DIE); +if (IList->getInit(OldIndex) != OldDIE->getInit()) + OldDIE->setInit(IList->getInit(OldIndex)); +IList->setInit(OldIndex, OldDIE); return hadError && !prevHadError; } diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index dabd0cf12f77e..c1ce55e1c8029 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -886,3 +886,30 @@ CC c{}; // CHECK-NEXT:`-ClassTemplateSpecialization {{.+}} 'A' } + +namespace GH67173 { + +template struct Vec2d { + struct { +T x; +T y; + }; +}; + +void f() { + Vec2d v{.x = 1, .y = 2}; +} + +// CHECK-LABEL: Dumping GH67173::: +// CHECK-NEXT: FunctionTemplateDecl {{.+}} implicit +// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} referenced class depth 0 index 0 T +// CHECK: |-CXXDeductionGuideDecl {{.+}} implicit 'auto (T, T) -> Vec2d' aggregate +// CHECK-NEXT: | |-ParmVarDecl {{.+}} col:27 'T' +// CHECK-NEXT: | `-ParmVarDecl {{.+}} col:27 'T' +// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} implicit used 'auto (int, int) -> GH67173::Vec2d' implicit_instantiation aggregate +// CHECK-NEXT: |-TemplateArgument type 'int' +// CHECK-NEXT: | `-BuiltinType {{.+}} 'int' +// CHECK-NEXT: |-ParmVarDecl {{.+}} 'int' +// CHECK-NEXT: `-ParmVarDecl {{.+}} 'int' + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/140699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)
@@ -18,6 +18,16 @@ int init_arr(); template template template int Outer::Inner::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() }; int *p = Outer::Inner::arr; +//CHECK: @_ZN8GH1406221gIiEE = linkonce_odr constant %"struct.GH140622::S" zeroinitializer +namespace GH140622 { +template struct S {}; +template constexpr S g; +void test() { +constexpr auto x = 42; shafik wrote: As I pointed out here: https://github.com/llvm/llvm-project/issues/140622#issuecomment-2892633775 this also happens when the local is *const*, so it is worth testing that case and the non const/constexpr case. https://github.com/llvm/llvm-project/pull/140699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)
https://github.com/shafik commented: It would also be nice to get a reduction for: https://github.com/llvm/llvm-project/issues/140632 and see if we can add a test for that if it looks significantly different from the other cases. https://github.com/llvm/llvm-project/pull/140699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Clang][Driver][fveclib] Fix target parsing for -fveclib=AMDLIBM option (PR #140544)
RKSimon wrote: @rohitaggarwal007 please can you edit the summary to briefly describe the fix https://github.com/llvm/llvm-project/pull/140544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add clang driver option -fpartition-static-data-sections (PR #124991)
https://github.com/mingmingl-llvm ready_for_review https://github.com/llvm/llvm-project/pull/124991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Re-use shuffle_decl.inc in OpenCL shuffle2 declaration (PR #140679)
frasercrmck wrote: Sorry, just merged #140557 so you'll have to fix the conflicts before merging. https://github.com/llvm/llvm-project/pull/140679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)
@@ -115,9 +115,22 @@ class CheckerRegistry { public: /// Adds a checker to the registry. Use this non-templated overload when your /// checker requires custom initialization. - void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn, + void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn, + StringRef FullName, StringRef DebugName, StringRef Desc, + StringRef DocsUri, bool IsHidden); + + /// Adds a checker to the registry. This overload doesn't take a `DebugName` + /// (which usually looks like `DivZeroChecker`), so it uses the user-facing + /// `FullName` (which usually looks like ``core.DivideZero`) as a debug name. + /// THIS IS DEPRECATED and is only provided to preserve compatibility with + /// legacy plugins. + /// TODO: Eventually remove this from the codebase. NagyDonat wrote: Ok, I will remove this method variant from the codebase (I'll need to update a unit test). Unfortunately this "no `DebugName`, we need to pass the `FullName` issue" also affects the templated overload below this one, and _that one_ is used by a dozen unit tests, so modifying it would be bothersome (I would like to skip updating it, but even if I do it perhaps it should be in a separate commit). https://github.com/llvm/llvm-project/pull/139256 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fixed issue #128882: don't warn if 1st argument to 'getcwd' is NULL (PR #135720)
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/135720 >From cfd32680ac4a534b4060d8cc3549edfe45e721bf Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Mon, 14 Apr 2025 20:58:24 -0400 Subject: [PATCH 1/2] Fixed issue #128882: don't warn if 1st argument to 'getcwd' is NULL --- .../lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 1 - clang/test/Analysis/errno-stdlibraryfunctions.c| 3 --- 2 files changed, 4 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index 9c0b79ab58618..34bab80307a04 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -2663,7 +2663,6 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( .Case({ArgumentCondition(1, WithinRange, Range(1, SizeMax)), IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg) -.ArgConstraint(NotNull(ArgNo(0))) .ArgConstraint( BufferSize(/*Buffer*/ ArgNo(0), /*BufSize*/ ArgNo(1))) .ArgConstraint( diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c b/clang/test/Analysis/errno-stdlibraryfunctions.c index 657aa37a42670..0bc82b595eed8 100644 --- a/clang/test/Analysis/errno-stdlibraryfunctions.c +++ b/clang/test/Analysis/errno-stdlibraryfunctions.c @@ -105,9 +105,6 @@ void errno_getcwd(char *Buf, size_t Sz) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} clang_analyzer_eval(Path == NULL); // expected-warning{{TRUE}} if (errno) {} // no warning - } else if (Path == NULL) { -clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} -if (errno) {} // no warning } else { clang_analyzer_eval(Path == Buf); // expected-warning{{TRUE}} if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}} >From 039952f6517c6e732fb5ce578291a35668c46c7b Mon Sep 17 00:00:00 2001 From: Balazs Benics Date: Tue, 20 May 2025 12:05:00 +0200 Subject: [PATCH 2/2] Add NotNull constaints to arg 0 for the summary Cases --- .../Checkers/StdLibraryFunctionsChecker.cpp| 9 ++--- clang/test/Analysis/errno-stdlibraryfunctions.c| 10 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index 54583ce54a45e..8ee616f5ed37e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -2651,13 +2651,16 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( addToFunctionSummaryMap( "getcwd", Signature(ArgTypes{CharPtrTy, SizeTy}, RetType{CharPtrTy}), Summary(NoEvalCall) -.Case({ArgumentCondition(1, WithinRange, Range(1, SizeMax)), +.Case({NotNull(ArgNo(0)), + ArgumentCondition(1, WithinRange, Range(1, SizeMax)), ReturnValueCondition(BO_EQ, ArgNo(0))}, ErrnoMustNotBeChecked, GenericSuccessMsg) -.Case({ArgumentCondition(1, WithinRange, SingleValue(0)), +.Case({NotNull(ArgNo(0)), + ArgumentCondition(1, WithinRange, SingleValue(0)), IsNull(Ret)}, ErrnoNEZeroIrrelevant, "Assuming that argument 'size' is 0") -.Case({ArgumentCondition(1, WithinRange, Range(1, SizeMax)), +.Case({NotNull(ArgNo(0)), + ArgumentCondition(1, WithinRange, Range(1, SizeMax)), IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg) .ArgConstraint( diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c b/clang/test/Analysis/errno-stdlibraryfunctions.c index 0bc82b595eed8..84809751e1eee 100644 --- a/clang/test/Analysis/errno-stdlibraryfunctions.c +++ b/clang/test/Analysis/errno-stdlibraryfunctions.c @@ -8,6 +8,7 @@ #include "Inputs/errno_var.h" #include "Inputs/std-c-library-functions-POSIX.h" +#include "Inputs/system-header-simulator-for-malloc.h" #define NULL ((void *) 0) @@ -105,12 +106,21 @@ void errno_getcwd(char *Buf, size_t Sz) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} clang_analyzer_eval(Path == NULL); // expected-warning{{TRUE}} if (errno) {} // no warning + } else if (Path == NULL) { +clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} +if (errno) {} // no warning } else { clang_analyzer_eval(Path == Buf); // expected-warning{{TRUE}} if (errno) {} // expected-warning{{An undefined value may be read from
[clang] [KeyInstr][Clang] Add Clang option -g[no-]key-instructions (PR #134627)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` running on `fuchsia-debian-64-us-central1-b-1` while building `clang` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/15511 Here is the relevant piece of the build log for the reference ``` Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure) ... Passed : 46015 (97.92%) Expectedly Failed:27 (0.06%) [1368/1370] Linking CXX executable unittests/Transforms/Scalar/ScalarTests [1369/1370] Running the LLVM regression tests llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/ld.lld llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/lld-link llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/ld64.lld llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/wasm-ld -- Testing: 59213 tests, 60 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. FAIL: LLVM :: tools/dsymutil/X86/op-convert-offset.test (52232 of 59213) TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' FAILED Exit Code: 1 Command Output (stdout): -- warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-19 17:22:56.276800899) and debug map (2022-07-12 20:49:30.0) warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-19 17:22:56.276800899) and debug map (2022-07-12 20:49:30.0) warning: cann't read address attribute value. note: while processing op-convert-offset1.c -- Command Output (stderr): -- /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 23 + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 24 + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 25 + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-3i9o13c4/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-b
[clang] [Clang][AArch64]Add FP8 ACLE macros implementation (PR #140591)
@@ -1046,6 +1082,29 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasSVEB16B16 = true; HasSMEB16B16 = true; } + +if (Feature == "+fp8") + HasFP8 = true; +if (Feature == "+fp8fma") paulwalker-arm wrote: `fp8...` feature extensions should also set `HasFP8`? https://github.com/llvm/llvm-project/pull/140591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Add FP8 ACLE macros implementation (PR #140591)
@@ -1046,6 +1082,29 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasSVEB16B16 = true; HasSMEB16B16 = true; } + +if (Feature == "+fp8") + HasFP8 = true; +if (Feature == "+fp8fma") + HasFP8FMA = true; +if (Feature == "+fp8dot2") + HasFP8DOT2 = true; +if (Feature == "+fp8dot4") + HasFP8DOT4 = true; +if (Feature == "+ssve-fp8dot2") + HasSSVE_FP8DOT2 = true; paulwalker-arm wrote: This and the other `SSVE` features should also set `HasSME2`? https://github.com/llvm/llvm-project/pull/140591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR][NFC] Eliminate ArgInfo structure (PR #140612)
@@ -72,16 +68,15 @@ class RequiredArgs { class CIRGenFunctionInfo final : public llvm::FoldingSetNode, - private llvm::TrailingObjects { - using ArgInfo = CIRGenFunctionInfoArgInfo; - + private llvm::TrailingObjects { Lancern wrote: It would be nice if we have some comment here to indicate that `CanQualType` refers to the argument type. https://github.com/llvm/llvm-project/pull/140612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR][NFC] Eliminate ArgInfo structure (PR #140612)
https://github.com/Lancern edited https://github.com/llvm/llvm-project/pull/140612 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Do not emit lifetime intrinsics for coro promise alloca (PR #140548)
NewSigma wrote: After further consideration, I think this is not a satisfactory solution to the issue. I may revisit it if I develop a concrete plan. Apologies for any inconvenience. https://github.com/llvm/llvm-project/pull/140548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ARM][AArch64] Add missing Neon Types (PR #126945)
https://github.com/davemgreen updated https://github.com/llvm/llvm-project/pull/126945 >From 410d78202cac8221048a83ea466b59cb6e78ea87 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Wed, 12 Feb 2025 14:31:47 + Subject: [PATCH 1/2] Add missing Neon Types The AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors __mfp8 is defined in the ACLE https://arm-software.github.io/acle/main/acle.html#data-types I'm not sure whether __mfp8 should be defined for A32. For now I have left it as it is. --- .../clang/Basic/AArch64SVEACLETypes.def | 36 + clang/include/clang/Basic/LangOptions.def | 1 + clang/include/clang/Basic/Specifiers.h| 6 + clang/include/clang/Basic/TokenKinds.def | 6 + clang/include/clang/Sema/DeclSpec.h | 6 + clang/lib/AST/ASTContext.cpp | 12 +- clang/lib/Basic/IdentifierTable.cpp | 5 +- clang/lib/Basic/LangOptions.cpp | 3 + clang/lib/Parse/ParseDecl.cpp | 13 ++ clang/lib/Parse/ParseTentative.cpp| 8 ++ clang/lib/Sema/DeclSpec.cpp | 9 ++ clang/lib/Sema/SemaTemplateVariadic.cpp | 4 + clang/lib/Sema/SemaType.cpp | 7 + clang/test/AST/ast-dump-aarch64-neon-types.c | 128 ++ 14 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 clang/test/AST/ast-dump-aarch64-neon-types.c diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 6a6f51c95ebd0..dc5f39362eccf 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -201,6 +201,42 @@ SVE_OPAQUE_TYPE(__SVCount_t, __SVCount_t, SveCount, SveCountTy) SVE_SCALAR_TYPE(__mfp8, __mfp8, MFloat8, MFloat8Ty, 8) +// Unlike the SVE types above, the Neon vector types are parsed as keywords and +// mapped to the equivalent __attribute__(neon_vector_type(...)) vector type. +// They are not builtin types. +#ifndef NEON_VECTOR_TYPE +#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) +#endif +NEON_VECTOR_TYPE(__Int8x8_t, CharTy, 8, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int16x4_t, ShortTy, 16, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int32x2_t, IntTy, 32, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint8x8_t, CharTy, 8, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint16x4_t, UnsignedShortTy, 16, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint32x2_t, UnsignedIntTy, 32, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Float16x4_t, Float16Ty, 16, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Float32x2_t, FloatTy, 32, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Poly8x8_t, CharTy, 8, 8, VectorKind::NeonPoly) +NEON_VECTOR_TYPE(__Poly16x4_t, UnsignedShortTy, 16, 4, VectorKind::NeonPoly) +NEON_VECTOR_TYPE(__Bfloat16x4_t, BFloat16Ty, 16, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int8x16_t, CharTy, 8, 16, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int16x8_t, ShortTy, 16, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int32x4_t, IntTy, 32, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Int64x2_t, LongLongTy, 64, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint8x16_t, CharTy, 8, 16, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint16x8_t, UnsignedShortTy, 16, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint32x4_t, UnsignedIntTy, 32, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Uint64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Float16x8_t, Float16Ty, 16, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Float32x4_t, FloatTy, 32, 4, VectorKind::Neon) +NEON_VECTOR_TYPE(__Float64x2_t, DoubleTy, 64, 2, VectorKind::Neon) +NEON_VECTOR_TYPE(__Poly8x16_t, CharTy, 8, 16, VectorKind::NeonPoly) +NEON_VECTOR_TYPE(__Poly16x8_t, UnsignedShortTy, 16, 8, VectorKind::NeonPoly) +NEON_VECTOR_TYPE(__Poly64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::NeonPoly) +NEON_VECTOR_TYPE(__Bfloat16x8_t, BFloat16Ty, 16, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Mfloat8x8_t, MFloat8Ty, 8, 8, VectorKind::Neon) +NEON_VECTOR_TYPE(__Mfloat8x16_t, MFloat8Ty, 16, 8, VectorKind::Neon) + +#undef NEON_VECTOR_TYPE #undef SVE_VECTOR_TYPE #undef SVE_VECTOR_TYPE_MFLOAT #undef SVE_VECTOR_TYPE_BFLOAT diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 930c1c06d1a76..68499469e899c 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -463,6 +463,7 @@ COMPATIBLE_VALUE_LANGOPT(FunctionAlignment, 5, 0, "Default alignment for functio COMPATIBLE_VALUE_LANGOPT(LoopAlignment, 32, 0, "Default alignment for loops") LANGOPT(FixedPoint, 1, 0, "fixed point types") +LANGOPT(ACLE, 1, 0, "Arm C Language Extensi
[clang] 838ddc2 - [CIR] Add support for indirect calls (#139748)
Author: Sirui Mu Date: 2025-05-20T18:11:19+08:00 New Revision: 838ddc28f222ae244626a827a433fd9235546d3d URL: https://github.com/llvm/llvm-project/commit/838ddc28f222ae244626a827a433fd9235546d3d DIFF: https://github.com/llvm/llvm-project/commit/838ddc28f222ae244626a827a433fd9235546d3d.diff LOG: [CIR] Add support for indirect calls (#139748) This PR adds support for indirect calls to the `cir.call` operation. Added: Modified: clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h clang/include/clang/CIR/Dialect/IR/CIROps.td clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/CodeGen/CIRGenCall.cpp clang/lib/CIR/CodeGen/CIRGenCall.h clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h clang/lib/CIR/CodeGen/CIRGenTypes.h clang/lib/CIR/Dialect/IR/CIRDialect.cpp clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp clang/test/CIR/CodeGen/call.cpp clang/test/CIR/IR/call.cir Removed: diff --git a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h index a63bf4f8858d0..b680e4162a5ce 100644 --- a/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h +++ b/clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h @@ -225,6 +225,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder { callee.getFunctionType().getReturnType(), operands); } + cir::CallOp createIndirectCallOp(mlir::Location loc, + mlir::Value indirectTarget, + cir::FuncType funcType, + mlir::ValueRange operands) { +return create(loc, indirectTarget, funcType.getReturnType(), + operands); + } + //======// // Cast/Conversion Operators //======// diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index d3411973129a4..8267df92e3187 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -1843,13 +1843,8 @@ class CIR_CallOpBase extra_traits = []> DeclareOpInterfaceMethods])> { let extraClassDeclaration = [{ /// Get the argument operands to the called function. -mlir::OperandRange getArgOperands() { - return getArgs(); -} - -mlir::MutableOperandRange getArgOperandsMutable() { - return getArgsMutable(); -} +mlir::OperandRange getArgOperands(); +mlir::MutableOperandRange getArgOperandsMutable(); /// Return the callee of this operation mlir::CallInterfaceCallable getCallableForCallee() { @@ -1871,8 +1866,17 @@ class CIR_CallOpBase extra_traits = []> ::mlir::Attribute removeArgAttrsAttr() { return {}; } ::mlir::Attribute removeResAttrsAttr() { return {}; } +bool isIndirect() { return !getCallee(); } +mlir::Value getIndirectCall(); + void setArg(unsigned index, mlir::Value value) { - setOperand(index, value); + if (!isIndirect()) { +setOperand(index, value); +return; + } + + // For indirect call, the operand list is shifted by one. + setOperand(index + 1, value); } }]; @@ -1884,16 +1888,24 @@ class CIR_CallOpBase extra_traits = []> // the upstreaming process moves on. The verifiers is also missing for now, // will add in the future. - dag commonArgs = (ins FlatSymbolRefAttr:$callee, -Variadic:$args); + dag commonArgs = (ins OptionalAttr:$callee, + Variadic:$args); } def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { let summary = "call a function"; let description = [{ -The `cir.call` operation represents a direct call to a function that is -within the same symbol scope as the call. The callee is encoded as a symbol -reference attribute named `callee`. +The `cir.call` operation represents a function call. It could represent +either a direct call or an indirect call. + +If the operation represents a direct call, the callee should be defined +within the same symbol scope as the call. The `callee` attribute contains a +symbol reference to the callee function. All operands of this operation are +arguments to the callee function. + +If the operation represents an indirect call, the `callee` attribute is +empty. The first operand of this operation must be a pointer to the callee +function. The rest operands are arguments to the callee function. Example: @@ -1905,14 +1917,25 @@ def CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> { let results = (outs Optional:$result); let arguments = commonArgs; - let builders = [OpBuilder<(i
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
https://github.com/erichkeane approved this pull request. I'm happy as-is. Please give Aaron a chance to poke if he wants to. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,103 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + SourceLocation Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, + [](Expr *Arg) { return Arg->isTypeDependent(); })); + + if (Args.size() == 0) { erichkeane wrote: Ah, thats unfortunate. But yes, I think that seems to be the way it is. Its a little odd we don't actually print the 'right' thing for the 'at least' function, but I see this is far from the first. SGMT. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, erichkeane wrote: Yep, I would expect that to be enough to get it. Looks like we must handle it elsewhere for these, I wasn't sure! https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Add (fast) normalize to CLC; add half overloads (PR #139759)
arsenm wrote: > I wasn't sure if this was necessary so this commit replaces the vector2 > versions of the constants with the vector3/vector4 ones. The OpenCL-CTS seems > okay with it. If this is incorrect then it's not very difficult to split them > back out again. Does it pass with -cl-denorms-are-zero? https://github.com/llvm/llvm-project/pull/139759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Modules] Don't fail when an unused textual header is missing. (PR #138227)
ilya-biryukov wrote: Here's a reproducer for our breakage: ```cpp // RUN: rm -rf %t // RUN: split-file %s %t // // First, build a module with a header. // // RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/modules1.map -fmodule-name=a -emit-module -xc++ -fmodules-embed-all-files -o %t/a.pcm %t/modules1.map // RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/modules1.map -fmodule-map-file=%t/modules2.map -fmodule-name=b -emit-module \ // RUN: -fmodule-file=%t/a.pcm -xc++ -fmodules-embed-all-files -o %t/b.pcm %t/modules2.map // // Remove the header and check we can still build the code that finds it in a PCM. // // RUN: rm %t/foo.h // RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/modules2.map -fmodule-file=%t/b.pcm -fsyntax-only %t/use.cpp //--- modules1.map module a { module foo { header "foo.h" export * } export * } //--- modules2.map module all_textual { module foo { textual header "foo.h" export * } module wrap_foo { textual header "wrap_foo.h" export * } export * } module b { module wrap_foo { private header "wrap_foo.h" export * } export * } //--- foo.h #ifndef FOO_H #define FOO_H void foo(); #endif //--- wrap_foo.h #include "foo.h" //--- use.cpp #include "wrap_foo.h" void test() { foo(); } ``` It previously built fine because the `all_textual.foo` and its parent module used to be marked as unavailable because `foo.h` could not be found here: https://github.com/llvm/llvm-project/blob/09fd8f0093b8ff489d76285d893be152e4ca4c24/clang/lib/Lex/ModuleMap.cpp#L326 and therefore it made us pick the module `b.wrap_foo` later when resolving `wrap_foo.h` instead of `all_textual.wrap_foo` based on the code here: https://github.com/llvm/llvm-project/blob/09fd8f0093b8ff489d76285d893be152e4ca4c24/clang/lib/Lex/ModuleMap.cpp#L618 After the change, we no longer mark `all_textual` as unavailable and pick `all_textual.wrap_foo`, which causes us to reprocess the header. I know what we do is cheesy and we might need to reconsider how to approach it, but this is a breaking change and it would be great to find a resolution for it before committing to the new behavior. Could we revert this while we discuss the potential ways out of it? https://github.com/llvm/llvm-project/pull/138227 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Optimize classify() further (PR #140735)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/140735 >From a1979e88d05ed198700b90c3b5530d451cde9c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 20 May 2025 12:35:30 +0200 Subject: [PATCH] [clang][bytecode] Optimize classify() further Try to do as few checks as possible. Check for builtin types only once, then look at the BuiltinType Kind. For integers, we cache the int and long size, since those are used a lot and the ASTContext::getIntWidth() call is costly. --- clang/lib/AST/ByteCode/Context.cpp | 128 +++-- clang/lib/AST/ByteCode/Context.h | 3 + 2 files changed, 87 insertions(+), 44 deletions(-) diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp index c70a5259b77e2..6b8f4e31e4ff9 100644 --- a/clang/lib/AST/ByteCode/Context.cpp +++ b/clang/lib/AST/ByteCode/Context.cpp @@ -21,7 +21,12 @@ using namespace clang; using namespace clang::interp; -Context::Context(ASTContext &Ctx) : Ctx(Ctx), P(new Program(*this)) {} +Context::Context(ASTContext &Ctx) : Ctx(Ctx), P(new Program(*this)) { + this->IntWidth = Ctx.getTargetInfo().getIntWidth(); + this->LongWidth = Ctx.getTargetInfo().getLongWidth(); + assert(Ctx.getTargetInfo().getCharWidth() == 8 && + "We're assuming 8 bit chars"); +} Context::~Context() {} @@ -216,55 +221,91 @@ bool Context::evaluateCharRange(State &Parent, const Expr *SizeExpr, const LangOptions &Context::getLangOpts() const { return Ctx.getLangOpts(); } -std::optional Context::classify(QualType T) const { - if (T->isBooleanType()) -return PT_Bool; - - if (T->isSignedIntegerOrEnumerationType()) { -switch (Ctx.getIntWidth(T)) { -case 64: - return PT_Sint64; -case 32: - return PT_Sint32; -case 16: - return PT_Sint16; -case 8: - return PT_Sint8; -default: - return PT_IntAPS; -} +static PrimType integralTypeToPrimTypeS(unsigned BitWidth) { + switch (BitWidth) { + case 64: +return PT_Sint64; + case 32: +return PT_Sint32; + case 16: +return PT_Sint16; + case 8: +return PT_Sint8; + default: +return PT_IntAPS; } + llvm_unreachable("Unhandled BitWidth"); +} + +static PrimType integralTypeToPrimTypeU(unsigned BitWidth) { + switch (BitWidth) { + case 64: +return PT_Uint64; + case 32: +return PT_Uint32; + case 16: +return PT_Uint16; + case 8: +return PT_Uint8; + default: +return PT_IntAP; + } + llvm_unreachable("Unhandled BitWidth"); +} + +std::optional Context::classify(QualType T) const { - if (T->isUnsignedIntegerOrEnumerationType()) { -switch (Ctx.getIntWidth(T)) { -case 64: - return PT_Uint64; -case 32: - return PT_Uint32; -case 16: - return PT_Uint16; -case 8: - return PT_Uint8; -case 1: - // Might happen for enum types. + if (const auto *BT = dyn_cast(T.getCanonicalType())) { +auto Kind = BT->getKind(); +if (Kind == BuiltinType::Bool) return PT_Bool; -default: - return PT_IntAP; -} +if (Kind == BuiltinType::NullPtr) + return PT_Ptr; +if (Kind == BuiltinType::BoundMember) + return PT_MemberPtr; + +// Just trying to avoid the ASTContext::getIntWidth call below. +if (Kind == BuiltinType::Int) + return integralTypeToPrimTypeS(this->IntWidth); +if (Kind == BuiltinType::UInt) + return integralTypeToPrimTypeU(this->IntWidth); +if (Kind == BuiltinType::Long) + return integralTypeToPrimTypeS(this->LongWidth); +if (Kind == BuiltinType::ULong) + return integralTypeToPrimTypeU(this->LongWidth); +if (Kind == BuiltinType::SChar || Kind == BuiltinType::Char_S) + return integralTypeToPrimTypeS(8); +if (Kind == BuiltinType::UChar || Kind == BuiltinType::Char_U || +Kind == BuiltinType::Char8) + return integralTypeToPrimTypeU(8); + +if (BT->isSignedInteger()) + return integralTypeToPrimTypeS(Ctx.getIntWidth(T)); +if (BT->isUnsignedInteger()) + return integralTypeToPrimTypeU(Ctx.getIntWidth(T)); + +if (BT->isFloatingPoint()) + return PT_Float; } - if (T->isNullPtrType()) + if (T->isPointerOrReferenceType()) return PT_Ptr; - if (T->isRealFloatingType()) -return PT_Float; + if (T->isMemberPointerType()) +return PT_MemberPtr; - if (T->isFunctionPointerType() || T->isFunctionReferenceType() || - T->isFunctionType() || T->isBlockPointerType()) -return PT_Ptr; + if (const auto *BT = T->getAs()) { +if (BT->isSigned()) + return integralTypeToPrimTypeS(BT->getNumBits()); +return integralTypeToPrimTypeU(BT->getNumBits()); + } - if (T->isPointerOrReferenceType() || T->isObjCObjectPointerType()) -return PT_Ptr; + if (const auto *ET = T->getAs()) { +const auto *D = ET->getDecl(); +if (!D->isComplete()) + return std::nullopt; +return classify(D->getIntegerType()); + } if (const auto *AT = T->getAs
[clang-tools-extra] [clangd] Add tweak to override pure virtuals (PR #139348)
https://github.com/marcogmaia edited https://github.com/llvm/llvm-project/pull/139348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [NVPTX] Unify and extend barrier{.cta} intrinsic support (PR #140615)
https://github.com/AlexMaclean updated https://github.com/llvm/llvm-project/pull/140615 >From babb28ef1c935f0d0cfb3b40f62be860be027010 Mon Sep 17 00:00:00 2001 From: Alex Maclean Date: Thu, 15 May 2025 18:12:11 + Subject: [PATCH 1/5] [NVPTX] Unify and extend barrier{.cta} intrinsic support --- llvm/include/llvm/IR/IntrinsicsNVVM.td| 37 +++-- llvm/lib/IR/AutoUpgrade.cpp | 18 +++ llvm/lib/Target/NVPTX/NVPTXInstrInfo.td | 28 llvm/lib/Target/NVPTX/NVPTXIntrinsics.td | 71 .../Transforms/IPO/AttributorAttributes.cpp | 3 +- .../Assembler/auto_upgrade_nvvm_intrinsics.ll | 22 +++ llvm/test/CodeGen/NVPTX/barrier.ll| 153 +++--- llvm/test/CodeGen/NVPTX/named-barriers.ll | 36 +++-- .../CodeGen/NVPTX/noduplicate-syncthreads.ll | 6 +- 9 files changed, 275 insertions(+), 99 deletions(-) diff --git a/llvm/include/llvm/IR/IntrinsicsNVVM.td b/llvm/include/llvm/IR/IntrinsicsNVVM.td index a95c739f1331d..f648815b06ab8 100644 --- a/llvm/include/llvm/IR/IntrinsicsNVVM.td +++ b/llvm/include/llvm/IR/IntrinsicsNVVM.td @@ -128,6 +128,12 @@ // * llvm.nvvm.swap.lo.hi.b64 --> llvm.fshl(x, x, 32) // * llvm.nvvm.atomic.load.inc.32 --> atomicrmw uinc_wrap // * llvm.nvvm.atomic.load.dec.32 --> atomicrmw udec_wrap +// * llvm.nvvm.barrier0 --> llvm.nvvm.barrier.cta.sync.aligned.all(0) +// * llvm.nvvm.barrier.n --> llvm.nvvm.barrier.cta.sync.aligned.all(x) +// * llvm.nvvm.bar.sync --> llvm.nvvm.barrier.cta.sync.aligned.all(x) +// * llvm.nvvm.barrier --> llvm.nvvm.barrier.cta.sync.aligned(x, y) +// * llvm.nvvm.barrier.sync --> llvm.nvvm.barrier.cta.sync.all(x) +// * llvm.nvvm.barrier.sync.cnt --> llvm.nvvm.barrier.cta.sync(x, y) def llvm_global_ptr_ty : LLVMQualPointerType<1>; // (global)ptr def llvm_shared_ptr_ty : LLVMQualPointerType<3>; // (shared)ptr @@ -1263,18 +1269,6 @@ let TargetPrefix = "nvvm" in { defm int_nvvm_atomic_cas_gen_i : PTXAtomicWithScope3; // Bar.Sync - - // The builtin for "bar.sync 0" is called __syncthreads. Unlike most of the - // intrinsics in this file, this one is a user-facing API. - def int_nvvm_barrier0 : ClangBuiltin<"__syncthreads">, - Intrinsic<[], [], [IntrConvergent, IntrNoCallback]>; - // Synchronize all threads in the CTA at barrier 'n'. - def int_nvvm_barrier_n : ClangBuiltin<"__nvvm_bar_n">, - Intrinsic<[], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; - // Synchronize 'm', a multiple of warp size, (arg 2) threads in - // the CTA at barrier 'n' (arg 1). - def int_nvvm_barrier : ClangBuiltin<"__nvvm_bar">, - Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; def int_nvvm_barrier0_popc : ClangBuiltin<"__nvvm_bar0_popc">, Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; def int_nvvm_barrier0_and : ClangBuiltin<"__nvvm_bar0_and">, @@ -1282,16 +1276,21 @@ let TargetPrefix = "nvvm" in { def int_nvvm_barrier0_or : ClangBuiltin<"__nvvm_bar0_or">, Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; - def int_nvvm_bar_sync : NVVMBuiltin, - Intrinsic<[], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; def int_nvvm_bar_warp_sync : NVVMBuiltin, Intrinsic<[], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; - // barrier.sync id[, cnt] - def int_nvvm_barrier_sync : NVVMBuiltin, - Intrinsic<[], [llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; - def int_nvvm_barrier_sync_cnt : NVVMBuiltin, - Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], [IntrConvergent, IntrNoCallback]>; + // barrier{.cta}.sync{.aligned} a{, b}; + // barrier{.cta}.arrive{.aligned}a, b; + let IntrProperties = [IntrConvergent, IntrNoCallback] in { +foreach align = ["", "_aligned"] in { + def int_nvvm_barrier_cta_sync # align # _all : + Intrinsic<[], [llvm_i32_ty]>; + def int_nvvm_barrier_cta_sync # align : + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty]>; + def int_nvvm_barrier_cta_arrive # align : + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty]>; +} + } // barrier.cluster.[wait, arrive, arrive.relaxed] def int_nvvm_barrier_cluster_arrive : diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 9091e7585f9d9..18f6f2bf9ed11 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -1349,6 +1349,10 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn, else if (Name == "clz.ll" || Name == "popc.ll" || Name == "h2f" || Name == "swap.lo.hi.b64") Expand = true; + else if (Name == "barrier0" || Name == "barrier.n" || + Name == "bar.sync" || Name == "barrier" || + Name == "barrier.sync" || Name == "barrier.sync.cnt") +Expand = true; else if (Name.consume_front("max.") || Name.consume
[clang] [llvm] [mlir] [NVPTX] Unify and extend barrier{.cta} intrinsic support (PR #140615)
@@ -240,6 +240,47 @@ def BF16RT : RegTyInfo; def F16X2RT : RegTyInfo; def BF16X2RT : RegTyInfo; +// This class provides a basic wrapper around an NVPTXInst that abstracts the +// specific syntax of most PTX instructions. It automatically handles the +// construction of the asm string based on the provided dag arguments. +// For example, the following asm-strings would be computed: +// +// * BasicFlagsNVPTXInst<(outs Int32Regs:$dst), +// (ins Int32Regs:$a, Int32Regs:$b), (ins), +// "add.s32">; +// ---> "add.s32 \t$dst, $a, $b;" +// +// * BasicFlagsNVPTXInst<(outs Int32Regs:$d), +// (ins Int32Regs:$a, Int32Regs:$b, Hexu32imm:$c), +// (ins PrmtMode:$mode), +// "prmt.b32${mode}">; +// ---> "prmt.b32${mode} \t$dst, $a, $b, $c;" AlexMaclean wrote: Fixed! https://github.com/llvm/llvm-project/pull/140615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Update -Wimplicit-void-ptr-cast for null pointer constants (PR #138271)
AaronBallman wrote: > > Just to confirm: is it intended that `char *s = NULL;` now generates this > > warning? I mean, the C library may define `NULL` as `((void*)0)`, and `char > > *s = ((void*)0);` is clearly not C++-compatible. However, when compiling > > this code in C++, `NULL` may expand to something that IS actually okay in > > C++ (like `0`, `nullptr` or `__null`). So this warning may be a bit too > > noisy overall? > > https://gcc.godbolt.org/z/hnMfsPjsa > > Hmmm, semi-intended. It's intended to diagnose `void foo(void *ptr) { char *s > = ptr; }`, but a null pointer constant initialization, regardless of form > (`nullptr`, `(void *)0`, `__null`, etc) should not be diagnosed. So I think I > need to be more clever here; I'll work on a fix (thought it likely won't be > until tomorrow at this point). Thank you for bringing this up! https://github.com/llvm/llvm-project/pull/140724 should address this concern https://github.com/llvm/llvm-project/pull/138271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C] Don't diagnose null pointer macros in -Wimplicit-void-ptr-cast (PR #140724)
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/140724 This silences the diagnostic when the right-hand side is a null pointer constant that comes from a macro expansion, such as NULL. However, we do not limit to just NULL because other custom macros may expand to an implicit void * cast in C while expanding to something else in C++. >From a5e8f77597ecc8ae56f947de5ef236d88e1581d1 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 20 May 2025 08:49:33 -0400 Subject: [PATCH] [C] Don't diagnose null pointer macros in -Wimplicit-void-ptr-cast This silences the diagnostic when the right-hand side is a null pointer constant that comes from a macro expansion, such as NULL. However, we do not limit to just NULL because other custom macros may expand to an implicit void * cast in C while expanding to something else in C++. --- clang/lib/Sema/SemaExpr.cpp | 9 +++-- clang/test/Sema/implicit-void-ptr-cast.c | 22 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b18e83b605e4f..6b04f8150b0a1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -9966,8 +9966,13 @@ AssignConvertType Sema::CheckSingleAssignmentConstraints(QualType LHSType, // If there is a conversion of some kind, check to see what kind of // pointer conversion happened so we can diagnose a C++ compatibility // diagnostic if the conversion is invalid. This only matters if the RHS - // is some kind of void pointer. - if (Kind != CK_NoOp && !getLangOpts().CPlusPlus) { + // is some kind of void pointer. We have a carve-out when the RHS is from + // a macro expansion because the use of a macro may indicate different + // code between C and C++. Consider: char *s = NULL; where NULL is + // defined as (void *)0 in C (which would be invalid in C++), but 0 in + // C++, which is valid in C++. + if (Kind != CK_NoOp && !getLangOpts().CPlusPlus && + !RHS.get()->getBeginLoc().isMacroID()) { QualType CanRHS = RHS.get()->getType().getCanonicalType().getUnqualifiedType(); QualType CanLHS = LHSType.getCanonicalType().getUnqualifiedType(); diff --git a/clang/test/Sema/implicit-void-ptr-cast.c b/clang/test/Sema/implicit-void-ptr-cast.c index a469c49c36b49..3c3e153d1dbda 100644 --- a/clang/test/Sema/implicit-void-ptr-cast.c +++ b/clang/test/Sema/implicit-void-ptr-cast.c @@ -59,4 +59,26 @@ void more(void) { b3 = (char *)0; b3 = nullptr; b3 = 0; + + // Note that we explicitly silence the diagnostic if the RHS is from a macro + // expansion. This allows for things like NULL expanding to different token + // sequences depending on language mode, but applies to any macro that + // expands to a valid null pointer constant. +#if defined(__cplusplus) + #define NULL 0 +#else + #define NULL ((void *)0) +#endif + #define SOMETHING_NOT_SPELLED_NULL nullptr + #define SOMETHING_THAT_IS_NOT_NULL (void *)12 + + char *ptr1 = NULL; // Ok + char *ptr2 = SOMETHING_NOT_SPELLED_NULL; // Ok + char *ptr3 = SOMETHING_THAT_IS_NOT_NULL; // c-warning {{implicit conversion when initializing 'char *' with an expression of type 'void *' is not permitted in C++}} \ + cxx-error {{cannot initialize a variable of type 'char *' with an rvalue of type 'void *'}} + + ptr1 = NULL; // Ok + ptr2 = SOMETHING_NOT_SPELLED_NULL; // Ok + ptr3 = SOMETHING_THAT_IS_NOT_NULL; // c-warning {{implicit conversion when assigning to 'char *' from type 'void *' is not permitted in C++}} \ +cxx-error {{assigning to 'char *' from incompatible type 'void *'}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Add FP8 ACLE macros implementation (PR #140591)
@@ -1046,6 +1082,29 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasSVEB16B16 = true; HasSMEB16B16 = true; } + +if (Feature == "+fp8") + HasFP8 = true; +if (Feature == "+fp8fma") paulwalker-arm wrote: I don't fully understand the effect of setting these bools and how the dependencies in `AArch64Features.td` correspond to setting the feature macros. What I'm mainly after is consistency and so for the SME2 extensions you're setting `HasSME2` as well. So I guess the question is why that is necessary? If it's not, then perhaps the way to go is to remove those rather than adding the ones I suggest. The most important part to verify is that all the feature macros a user would expect to be defined by a specific +feat are in fact defined. If that is managed by `AArch64Features.td` then great, if not then that would explain why the key feature dependencies are duplicated here. https://github.com/llvm/llvm-project/pull/140591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add ApplyAlwaysOnePerLineToTemplateArguments option (PR #137544)
https://github.com/mydeveloperday commented: What is the current behaviour vs the default you have introduced? https://github.com/llvm/llvm-project/pull/137544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, + [](Expr *Arg) { return Arg->isTypeDependent(); })); + + if (Args.size() == 0) { +Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args_at_least) +<< 0 << 1 << 0 << 0 << TheCall->getSourceRange(); +return ExprError(); + } + + auto FuncT = Args[0]->getType(); + + if (auto *MPT = FuncT->getAs()) { +if (Args.size() < 2) { + Diag(TheCall->getBeginLoc(), +diag::err_typecheck_call_too_few_args_at_least) + << 0 << 2 << 1 << 0 << TheCall->getSourceRange(); erichkeane wrote: Same here, we do the /*whatever=*/ pattern here. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
https://github.com/erichkeane commented: Couple of nits, else I'm reasonably ok with this. Interested to hear what @AaronBallman has to say, else I think this is beneficial. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); erichkeane wrote: Don't use auto here. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, Tok.isOneOf( #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait, #include "clang/Basic/TransformTypeTraits.def" - tok::kw___is_abstract, - tok::kw___is_aggregate, - tok::kw___is_arithmetic, - tok::kw___is_array, - tok::kw___is_assignable, - tok::kw___is_base_of, - tok::kw___is_bounded_array, - tok::kw___is_class, - tok::kw___is_complete_type, - tok::kw___is_compound, - tok::kw___is_const, - tok::kw___is_constructible, - tok::kw___is_convertible, - tok::kw___is_convertible_to, - tok::kw___is_destructible, - tok::kw___is_empty, - tok::kw___is_enum, - tok::kw___is_floating_point, - tok::kw___is_final, - tok::kw___is_function, - tok::kw___is_fundamental, - tok::kw___is_integral, - tok::kw___is_interface_class, + tok::kw___is_convertible, // Last use in libc++ was removed in 925a11a erichkeane wrote: I'm missing something, what happened to the ones on the LHS here? https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, erichkeane wrote: Is this enforced earlier? Why can't type dependent args make it here? https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, + [](Expr *Arg) { return Arg->isTypeDependent(); })); + + if (Args.size() == 0) { +Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args_at_least) +<< 0 << 1 << 0 << 0 << TheCall->getSourceRange(); erichkeane wrote: These 4 need some sort of comments showing what they mean. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
@@ -68,12 +70,19 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, HeaderSuffix += "$"; IgnoreHeadersRegex.emplace_back(HeaderSuffix); } + + if (UnusedIncludes == false && MissingIncludes == false) +this->configurationDiag("The check 'misc-include-cleaner' will not " vbvictor wrote: This behavior should be checked in tests (write small file same as `clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-wrong-config.cpp`) https://github.com/llvm/llvm-project/pull/140600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] suggest headers on undeclared errors (PR #140247)
@@ -14,6 +14,8 @@ #include "clang/Basic/DiagnosticParse.h" #include "clang/Parse/Parser.h" #include "clang/Sema/ParsedTemplate.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" AaronBallman wrote: This seems like a layering violation, though not a circular dependency. Parser currently does not link against tooling. In your patch, you link tooling into Sema which Parser then picks up transitively. Tooling does not currently link in Parser or Sema, hence no circular dependency. I kind of think the standard library stuff needs to be lifted into AST. It does seem to rely on `Decl.h` internally, so it can't be lifted into Basic. CC @erichkeane for other opinions https://github.com/llvm/llvm-project/pull/140247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
https://github.com/DaanDeMeyer updated https://github.com/llvm/llvm-project/pull/140600 >From 900e6b24fb244d9034cdf81f337dd457a451b915 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Mon, 19 May 2025 21:39:32 +0200 Subject: [PATCH] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner These mimick the same options from clangd and allow using the check to only check for unused includes or missing includes. --- .../clang-tidy/misc/IncludeCleanerCheck.cpp | 77 +++ .../clang-tidy/misc/IncludeCleanerCheck.h | 4 + clang-tools-extra/docs/ReleaseNotes.rst | 7 +- .../checks/misc/include-cleaner.rst | 11 +++ .../misc/include-cleaner-wrong-config.cpp | 13 .../clang-tidy/IncludeCleanerTest.cpp | 58 ++ 6 files changed, 137 insertions(+), 33 deletions(-) create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner-wrong-config.cpp diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp index 7638bbc103d16..52a94f3c040aa 100644 --- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp @@ -59,7 +59,9 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, : ClangTidyCheck(Name, Context), IgnoreHeaders( utils::options::parseStringList(Options.get("IgnoreHeaders", ""))), - DeduplicateFindings(Options.get("DeduplicateFindings", true)) { + DeduplicateFindings(Options.get("DeduplicateFindings", true)), + UnusedIncludes(Options.get("UnusedIncludes", true)), + MissingIncludes(Options.get("MissingIncludes", true)) { for (const auto &Header : IgnoreHeaders) { if (!llvm::Regex{Header}.isValid()) configurationDiag("Invalid ignore headers regex '%0'") << Header; @@ -68,12 +70,19 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name, HeaderSuffix += "$"; IgnoreHeadersRegex.emplace_back(HeaderSuffix); } + + if (UnusedIncludes == false && MissingIncludes == false) +this->configurationDiag("The check 'misc-include-cleaner' will not " +"perform any analysis because 'UnusedIncludes' and " +"'MissingIncludes' are both false."); } void IncludeCleanerCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "IgnoreHeaders", utils::options::serializeStringList(IgnoreHeaders)); Options.store(Opts, "DeduplicateFindings", DeduplicateFindings); + Options.store(Opts, "UnusedIncludes", UnusedIncludes); + Options.store(Opts, "MissingIncludes", MissingIncludes); } bool IncludeCleanerCheck::isLanguageVersionSupported( @@ -200,39 +209,43 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) { if (!FileStyle) FileStyle = format::getLLVMStyle(); - for (const auto *Inc : Unused) { -diag(Inc->HashLocation, "included header %0 is not used directly") -<< llvm::sys::path::filename(Inc->Spelled, - llvm::sys::path::Style::posix) -<< FixItHint::CreateRemoval(CharSourceRange::getCharRange( - SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1), - SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1))); + if (UnusedIncludes) { +for (const auto *Inc : Unused) { + diag(Inc->HashLocation, "included header %0 is not used directly") + << llvm::sys::path::filename(Inc->Spelled, + llvm::sys::path::Style::posix) + << FixItHint::CreateRemoval(CharSourceRange::getCharRange( + SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1), + SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1))); +} } - tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code, - FileStyle->IncludeStyle); - // Deduplicate insertions when running in bulk fix mode. - llvm::StringSet<> InsertedHeaders{}; - for (const auto &Inc : Missing) { -std::string Spelling = include_cleaner::spellHeader( -{Inc.Missing, PP->getHeaderSearchInfo(), MainFile}); -bool Angled = llvm::StringRef{Spelling}.starts_with("<"); -// We might suggest insertion of an existing include in edge cases, e.g., -// include is present in a PP-disabled region, or spelling of the header -// turns out to be the same as one of the unresolved includes in the -// main file. -if (auto Replacement = -HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"), - Angled, tooling::IncludeDirective::Include)) { - DiagnosticBuilder DB = - diag(SM->getSpellingLoc(Inc.SymRef.RefLocation), - "no header providing \"%0\" is directly included") - << Inc.SymRef.Target.name(); -
[clang] [Clang] Fix parsing of expressions of the form (T())[/*...*/] (PR #140053)
https://github.com/cor3ntin converted_to_draft https://github.com/llvm/llvm-project/pull/140053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
@@ -0,0 +1,13 @@ +// RUN: %check_clang_tidy %s misc-include-cleaner %t \ +// RUN: -config='{CheckOptions: \ +// RUN: {"misc-include-cleaner.UnusedIncludes": false,\ +// RUN: "misc-include-cleaner.MissingIncludes": false,\ +// RUN: }}' -- -fno-delayed-template-parsing + +// CHECK-MESSAGES: warning: The check 'misc-include-cleaner' will not perform any analysis because 'UnusedIncludes' and 'MissingIncludes' are both false. [clang-tidy-config] + +void g() { +int p_local0 = 42; +// CHECK-FIXES-NOT: int const p_local0 = 42; + } + vbvictor wrote: Please add a newline https://github.com/llvm/llvm-project/pull/140600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
@@ -0,0 +1,13 @@ +// RUN: %check_clang_tidy %s misc-include-cleaner %t \ +// RUN: -config='{CheckOptions: \ +// RUN: {"misc-include-cleaner.UnusedIncludes": false,\ +// RUN: "misc-include-cleaner.MissingIncludes": false,\ +// RUN: }}' -- -fno-delayed-template-parsing + +// CHECK-MESSAGES: warning: The check 'misc-include-cleaner' will not perform any analysis because 'UnusedIncludes' and 'MissingIncludes' are both false. [clang-tidy-config] + +void g() { vbvictor wrote: And maybe this unrelated code should be deleted https://github.com/llvm/llvm-project/pull/140600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen] Expose the extensibility of PassConfig to plugins (PR #139059)
@@ -119,6 +119,9 @@ addPassesToGenerateCode(CodeGenTargetMachineImpl &TM, PassManagerBase &PM, PM.add(PassConfig); PM.add(&MMIWP); + for (auto& C : *TargetMachine::TargetPassConfigCallbacks) Tcc100 wrote: This is same syntax as most of the callbacks in the code base use. Do you think not using auto would be better in this case? https://github.com/llvm/llvm-project/pull/139059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] suggest headers on undeclared errors (PR #140247)
@@ -14,6 +14,8 @@ #include "clang/Basic/DiagnosticParse.h" #include "clang/Parse/Parser.h" #include "clang/Sema/ParsedTemplate.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" cor3ntin wrote: Sure, but we want to rewrite anyway. The implementation (StandardLibrary.cpp) seems fairly inefficient. We should try to TableGen a trie and store version information in there, have some support for typo correction, etc https://github.com/llvm/llvm-project/pull/140247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen] Expose the extensibility of PassConfig to plugins (PR #139059)
@@ -72,6 +74,10 @@ namespace yaml { struct MachineFunctionInfo; } // namespace yaml +class TargetMachine; +using PassConfigCallback = +std::function; Tcc100 wrote: I think this should be a owning reference, similar to the other callback vectors. https://github.com/llvm/llvm-project/pull/139059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, Tok.isOneOf( #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait, #include "clang/Basic/TransformTypeTraits.def" - tok::kw___is_abstract, - tok::kw___is_aggregate, - tok::kw___is_arithmetic, - tok::kw___is_array, - tok::kw___is_assignable, - tok::kw___is_base_of, - tok::kw___is_bounded_array, - tok::kw___is_class, - tok::kw___is_complete_type, - tok::kw___is_compound, - tok::kw___is_const, - tok::kw___is_constructible, - tok::kw___is_convertible, - tok::kw___is_convertible_to, - tok::kw___is_destructible, - tok::kw___is_empty, - tok::kw___is_enum, - tok::kw___is_floating_point, - tok::kw___is_final, - tok::kw___is_function, - tok::kw___is_fundamental, - tok::kw___is_integral, - tok::kw___is_interface_class, + tok::kw___is_convertible, // Last use in libc++ was removed in 925a11a philnik777 wrote: That's a different patch. Not sure how it ended up here. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Add UnusedIncludes/MissingIncludes options to misc-include-cleaner (PR #140600)
https://github.com/vbvictor edited https://github.com/llvm/llvm-project/pull/140600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,101 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + auto Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, philnik777 wrote: I'm not sure whether dependent arguments can make it here, but I haven't been able to get any here. Should I remove the assertion? https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [analyzer][NFC] Introduce framework for checker families (PR #139256)
https://github.com/NagyDonat updated https://github.com/llvm/llvm-project/pull/139256 From 3bead14691a29482705c76951eaed176bfbfc996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Don=C3=A1t=20Nagy?= Date: Thu, 8 May 2025 18:46:41 +0200 Subject: [PATCH 01/12] [analyzer][NFC] Introduce framework for checker families The checker classes (i.e. classes derived from `CheckerBase` via the utility template `Checker<...>`) act as intermediates between the user and the analyzer engine, so they have two interfaces: - On the frontend side, they have a public name, can be enabled or disabled, can accept checker options and can be reported as the source of bug reports. - On the backend side, they can handle various checker callbacks and they "leave a mark" on the `ExplodedNode`s that are created by them. (These `ProgramPointTag` marks are internal: they appear in debug logs and can be queried by checker logic; but the user doesn't see them.) In a significant majority of the checkers there is 1:1 correspondence between these sides, but there are also many checker classes where several related user-facing checkers share the same backend class. Historically each of these "multi-part checker" classes had its own hacks to juggle its multiple names, which led to lots of ugliness like lazy initialization of `mutable std::unique_ptr` members and redundant data members (when a checker used its custom `CheckNames` array and ignored the inherited single `Name`). My recent commit 27099982da2f5a6c2d282d6b385e79d080669546 tried to unify and standardize these existing solutions to get rid of some of the technical debt, but it still used enum values to identify the checker parts within a "multi-part" checker class, which led to some ugliness. This commit introduces a new framework which takes a more direct, object-oriented approach: instead of identifying checker parts with `{parent checker object, index of part}` pairs, the parts of a multi-part checker become stand-alone objects that store their own name (and enabled/disabled status) as a data member. This is implemented by separating the functionality of `CheckerBase` into two new classes: `CheckerFrontend` and `CheckerBackend`. The name `CheckerBase` is kept (as a class derived from both `CheckerFrontend` and `CheckerBackend`), so "simple" checkers that use `CheckerBase` and `Checker<...>` continues to work without changes. However we also get first-class support for the "many frontends - one backend" situation: - The class `CheckerFamily<...>` works exactly like `Checker<...>` but inherits from `CheckerBackend` instead of `CheckerBase`, so it won't have a superfluous single `Name` member. - Classes deriving from `CheckerFamily` can freely own multiple `CheckerFrontend` data members, which are enabled within the registration methods corresponding to their name and can be used to initialize the `BugType`s that they can emit. In this scheme each `CheckerFamily` needs to override the pure virtual method `ProgramPointTag::getTagDescription()` which returns a string which represents that class for debugging purposes. (Previously this used the name of one arbitrary sub-checker, which was passable for debugging purposes, but not too elegant.) I'm planning to implement follow-up commits that convert all the "multi-part" checkers to this `CheckerFamily` framework. --- clang/include/clang/Analysis/ProgramPoint.h | 4 +- .../Core/BugReporter/BugReporter.h| 7 +- .../StaticAnalyzer/Core/BugReporter/BugType.h | 44 +++--- .../clang/StaticAnalyzer/Core/Checker.h | 132 ++ .../StaticAnalyzer/Core/CheckerManager.h | 80 --- .../Checkers/DivZeroChecker.cpp | 34 +++-- .../Checkers/ObjCSelfInitChecker.cpp | 2 +- .../Checkers/VirtualCallChecker.cpp | 29 ++-- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 4 +- clang/lib/StaticAnalyzer/Core/Checker.cpp | 14 +- .../StaticAnalyzer/Core/CheckerManager.cpp| 22 +-- 11 files changed, 180 insertions(+), 192 deletions(-) diff --git a/clang/include/clang/Analysis/ProgramPoint.h b/clang/include/clang/Analysis/ProgramPoint.h index c40aa3d8ffb72..d81b8e845cb48 100644 --- a/clang/include/clang/Analysis/ProgramPoint.h +++ b/clang/include/clang/Analysis/ProgramPoint.h @@ -40,8 +40,8 @@ class ProgramPointTag { ProgramPointTag(void *tagKind = nullptr) : TagKind(tagKind) {} virtual ~ProgramPointTag(); - /// The description of this program point which will be displayed when the - /// ExplodedGraph is dumped in DOT format for debugging. + /// The description of this program point which will be dumped for debugging + /// purposes. Do not use in user-facing output! virtual StringRef getTagDescription() const = 0; /// Used to implement 'isKind' in subclasses. diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 8e1d25b3
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/116709 >From e0bb550672326e21a556ac727f2e2a6ef65f0469 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 1 Oct 2024 11:08:02 +0200 Subject: [PATCH 1/2] [Clang] Add __builtin_invoke and recognize std::invoke as a builtin --- clang/include/clang/Basic/Builtins.td | 6 + clang/include/clang/Sema/Sema.h | 9 + clang/lib/Parse/ParseDeclCXX.cpp | 24 +-- clang/lib/Sema/SemaChecking.cpp | 97 +++ clang/lib/Sema/SemaExprCXX.cpp| 105 ++-- clang/test/CodeGenCXX/builtin-invoke.cpp | 61 +++ clang/test/SemaCXX/builtin-invoke.cpp | 133 +++ libcxx/include/__type_traits/invoke.h | 155 ++ .../__type_traits/is_core_convertible.h | 11 ++ 9 files changed, 499 insertions(+), 102 deletions(-) create mode 100644 clang/test/CodeGenCXX/builtin-invoke.cpp create mode 100644 clang/test/SemaCXX/builtin-invoke.cpp diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index 187d3b5ed24a7..58cc35088c40a 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -4272,6 +4272,12 @@ def MoveIfNsoexcept : CxxLibBuiltin<"utility"> { let Namespace = "std"; } +def Invoke : Builtin { + let Spellings = ["__builtin_invoke"]; + let Attributes = [CustomTypeChecking, Constexpr]; + let Prototype = "void(...)"; +} + def Annotation : Builtin { let Spellings = ["__builtin_annotation"]; let Attributes = [NoThrow, CustomTypeChecking]; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 5ec67087aeea4..22d66e8688906 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2594,6 +2594,8 @@ class Sema final : public SemaBase { SourceLocation BuiltinLoc, SourceLocation RParenLoc); + ExprResult BuiltinInvoke(CallExpr *TheCall); + static StringRef GetFormatStringTypeName(FormatStringType FST); static FormatStringType GetFormatStringType(StringRef FormatFlavor); static FormatStringType GetFormatStringType(const FormatAttr *Format); @@ -15220,11 +15222,18 @@ class Sema final : public SemaBase { SourceLocation Loc); QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind, SourceLocation Loc); + + QualType BuiltinRemoveCVRef(QualType BaseType, SourceLocation Loc) { +return BuiltinRemoveReference(BaseType, UTTKind::RemoveCVRef, Loc); + } + QualType BuiltinChangeCVRQualifiers(QualType BaseType, UTTKind UKind, SourceLocation Loc); QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind, SourceLocation Loc); + bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT); + /// Ensure that the type T is a literal type. /// /// This routine checks whether the type @p T is a literal type. If @p T is an diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 316bc30edf1f0..aeb1112bad8b4 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1611,29 +1611,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, Tok.isOneOf( #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait, #include "clang/Basic/TransformTypeTraits.def" - tok::kw___is_abstract, - tok::kw___is_aggregate, - tok::kw___is_arithmetic, - tok::kw___is_array, - tok::kw___is_assignable, - tok::kw___is_base_of, - tok::kw___is_bounded_array, - tok::kw___is_class, - tok::kw___is_complete_type, - tok::kw___is_compound, - tok::kw___is_const, - tok::kw___is_constructible, - tok::kw___is_convertible, - tok::kw___is_convertible_to, - tok::kw___is_destructible, - tok::kw___is_empty, - tok::kw___is_enum, - tok::kw___is_floating_point, - tok::kw___is_final, - tok::kw___is_function, - tok::kw___is_fundamental, - tok::kw___is_integral, - tok::kw___is_interface_class, + tok::kw___is_convertible, // Last use in libc++ was removed in 925a11a tok::kw___is_literal, tok::kw___is_lvalue_expr, tok::kw___is_lvalue_reference, diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index a960b9931ddfd..26579de25bdf0 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2368,6 +2368,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, return BuiltinShuffleVector(TheCall); // TheCall will be freed by the smart pointer here, but that's fine, s
[clang] [Clang][Sema] Reject array prvalue operands (PR #140702)
AaronBallman wrote: > > Is this going to break behavior in C? > > Array **prvalues** is C++11+ exclusive thing. Compound literals are lvalues > in C Ah, good point, I wasn't remembering that C and C++ are different in how they handle compound literals. And you can return a pointer to an array in C, but that's still an lvalue. > Anyway, here is a check: > > ```shell > $ build/bin/clang -fsyntax-only test.c > test.c:2:3: warning: expression result unused [-Wunused-value] > 2 | *((int []){ 1, 2, 3}); > | ^ > test.c:3:24: warning: expression result unused [-Wunused-value] > 3 | ((int []){ 1, 2, 3}) + 0; > | ^ ~ > 2 warnings generated. > ``` Thank you! https://github.com/llvm/llvm-project/pull/140702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CodeGen] Expose the extensibility of PassConfig to plugins (PR #139059)
Tcc100 wrote: I added a test case and some docs, which tuned out to be more challenging than expected, since I couldn't find any test case for the plugin system. The lit test in this PR requires the current llvm headers, which are not provided by the lit system, thus, it currently only works if you provide the absolute path in your system. I'd appreciate any pointers on how to implement this correctly. https://github.com/llvm/llvm-project/pull/139059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,103 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + SourceLocation Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, + [](Expr *Arg) { return Arg->isTypeDependent(); })); + + if (Args.size() == 0) { +Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args_at_least) +<< /*callee_type=*/0 << /*min_arg_count=*/1 << /*actual_arg_count=*/0 +<< /*is_non_object=*/0 << TheCall->getSourceRange(); +return ExprError(); + } + + auto FuncT = Args[0]->getType(); + + if (auto *MPT = FuncT->getAs()) { +if (Args.size() < 2) { + Diag(TheCall->getBeginLoc(), + diag::err_typecheck_call_too_few_args_at_least) + << /*callee_type=*/0 << /*min_arg_count=*/2 << /*actual_arg_count=*/1 + << /*is_non_object=*/0 << TheCall->getSourceRange(); + return ExprError(); +} + +auto *MemPtrClass = MPT->getQualifier()->getAsType(); +auto ObjectT = Args[1]->getType(); + + +if (MPT->isMemberDataPointer() && Args.size() != 2) { + Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_many_args) + << 0 << 2 << Args.size() << 0 << TheCall->getSourceRange(); erichkeane wrote: Here too. https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
@@ -5406,6 +5408,103 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, RParenLoc, CurFPFeatureOverrides()); } +ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) { + SourceLocation Loc = TheCall->getBeginLoc(); + auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs()); + assert(llvm::none_of(Args, + [](Expr *Arg) { return Arg->isTypeDependent(); })); + + if (Args.size() == 0) { erichkeane wrote: Instead of all of these separate diagnostics, is there a reason we can't just use `Sema::checkArgCountAtLeast` and friends? This one looks like a 'at least 1'. 5427 looks like `Sema::checkArgCountAtMost`, and 5440 `Sema::checkArgCount`. WDYT? https://github.com/llvm/llvm-project/pull/116709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] suggest headers on undeclared errors (PR #140247)
cor3ntin wrote: We already do have some typo correction https://compiler-explorer.com/z/Ede9rzsn5 I would expect the feature to be plugged into the same place such that: - If we find a name that is an exact match through lookup - Otherwise, if there is a name that matches exactly (respecting namespace qualifier) in the known standard names, suggest that - Otherwise offer typo correction, merging lookup results and standard names (or the first best suggestion of the two) https://github.com/llvm/llvm-project/pull/140247 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -3943,7 +3948,8 @@ static void emitScanBasedDirective( PrivScope.Privatize(); CGF.CGM.getOpenMPRuntime().emitReduction( CGF, S.getEndLoc(), Privates, LHSs, RHSs, ReductionOps, - {/*WithNowait=*/true, /*SimpleReduction=*/true, OMPD_unknown}); + {/*WithNowait=*/true, /*SimpleReduction=*/true, + /*IsPrivateVarReduction */ false, OMPD_unknown}); chandraghale wrote: Done !! https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -5748,7 +5754,7 @@ void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) { } CGM.getOpenMPRuntime().emitReduction( *this, ParentDir.getEndLoc(), Privates, LHSs, RHSs, ReductionOps, - {/*WithNowait=*/true, /*SimpleReduction=*/true, OMPD_simd}); + {/*WithNowait=*/true, /*SimpleReduction=*/true, false, OMPD_simd}); chandraghale wrote: Done !! https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)
Avimitin wrote: I still get compiler error for the above case, but with additional error message: ```text fatal error: error in backend: Invalid size request on a scalable vector. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /nix/store/n44qhrqxb3qnbylypsfq75jl2lfsvbp6-clang-21.0.0-unstable-2025-03-23/bin/clang @/tmp/nix-shell.9YUR38/cc-params.lXn6o1 1. parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'test.c'. 4. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@utf8_count_SWAR_popc_bithack_autovec' ``` And here is the debug files: [test.c.txt](https://github.com/user-attachments/files/20348260/test.c.txt) [test.sh.txt](https://github.com/user-attachments/files/20348266/test.sh.txt) https://github.com/llvm/llvm-project/pull/133031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -3943,7 +3948,8 @@ static void emitScanBasedDirective( PrivScope.Privatize(); CGF.CGM.getOpenMPRuntime().emitReduction( CGF, S.getEndLoc(), Privates, LHSs, RHSs, ReductionOps, - {/*WithNowait=*/true, /*SimpleReduction=*/true, OMPD_unknown}); + {/*WithNowait=*/true, /*SimpleReduction=*/true, + /*IsPrivateVarReduction */ false, OMPD_unknown}); alexey-bataev wrote: ```suggestion /*IsPrivateVarReduction=*/false, OMPD_unknown}); ``` https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -1481,6 +1482,8 @@ void CodeGenFunction::EmitOMPReductionClauseFinal( Privates.append(C->privates().begin(), C->privates().end()); LHSExprs.append(C->lhs_exprs().begin(), C->lhs_exprs().end()); RHSExprs.append(C->rhs_exprs().begin(), C->rhs_exprs().end()); +IsPrivate.append(C->private_var_reduction_flags().begin(), + C->private_var_reduction_flags().end()); alexey-bataev wrote: What if there is a mix of private and non-private reductions in a single construct? IsPrivateVarReduction flag is set for all reduced value, not matter if they are private or not https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)
@@ -5748,7 +5754,7 @@ void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) { } CGM.getOpenMPRuntime().emitReduction( *this, ParentDir.getEndLoc(), Privates, LHSs, RHSs, ReductionOps, - {/*WithNowait=*/true, /*SimpleReduction=*/true, OMPD_simd}); + {/*WithNowait=*/true, /*SimpleReduction=*/true, false, OMPD_simd}); alexey-bataev wrote: ```suggestion {/*WithNowait=*/true, /*SimpleReduction=*/true, /*IsPrivateVarReduction=*/false, OMPD_simd}); ``` https://github.com/llvm/llvm-project/pull/134709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][OpenMP][LoopTransformations] Fix incorrect number of generated loops for Tile and Reverse directives (PR #140532)
alexey-bataev wrote: Do we need the number of generated loops at all? Is it used anywhere? Maybe it worth it to remove it? https://github.com/llvm/llvm-project/pull/140532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Add FP8 ACLE macros implementation (PR #140591)
@@ -1046,6 +1082,29 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector &Features, HasSVEB16B16 = true; HasSMEB16B16 = true; } + +if (Feature == "+fp8") + HasFP8 = true; +if (Feature == "+fp8fma") CarolineConcatto wrote: I could. I am not sure I should reproduce the same we have in lib/Target/AArch64/AArch64Features.td also here. Is that what you are suggestion here? At first glance it does not look like this is a representation of what we have in lib/Target/AArch64/AArch64Features.td https://github.com/llvm/llvm-project/pull/140591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Add FP8 ACLE macros implementation (PR #140591)
@@ -744,3 +744,34 @@ // CHECK-SMEB16B16: __ARM_FEATURE_SME2 1 // CHECK-SMEB16B16: __ARM_FEATURE_SME_B16B16 1 // CHECK-SMEB16B16: __ARM_FEATURE_SVE_B16B16 1 +// +// RUN: %clang --target=aarch64 -march=armv9-a+fp8 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FP8 %s +// CHECK-FP8: __ARM_FEATURE_FP8 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+fp8fma -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FP8FMA %s +// CHECK-FP8FMA: __ARM_FEATURE_FP8FMA 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+fp8dot2 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FP8DOT2 %s +// CHECK-FP8DOT2: __ARM_FEATURE_FP8DOT2 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+fp8dot4 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FP8DOT4 %s +// CHECK-FP8DOT4: __ARM_FEATURE_FP8DOT4 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+ssve-fp8dot2 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SSVE-FP8DOT2 %s +// CHECK-SSVE-FP8DOT2: __ARM_FEATURE_SSVE_FP8DOT2 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+ssve-fp8dot4 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SSVE-FP8DOT4 %s +// CHECK-SSVE-FP8DOT4: __ARM_FEATURE_SSVE_FP8DOT4 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+ssve-fp8fma -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SSVE-FP8FMA %s +// CHECK-SSVE-FP8FMA: __ARM_FEATURE_SSVE_FP8FMA 1 + +// RUN: %clang --target=aarch64 -march=armv9-a+sme-f8f32 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SMEF8F32 %s +// CHECK-SMEF8F32: __ARM_FEATURE_LOCALLY_STREAMING 1 CarolineConcatto wrote: Do you mean for the sme-f8f32 and sme-f8f16? If so I was just reproducing what was done for sme-b16b16 and sme-f16f16. https://github.com/llvm/llvm-project/pull/140591 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits