[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits
@@ -366,9 +387,15 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); } - // Ignore empty records. - if (isEmptyRecord(getContext(), Ty, true)) -return ABIArgInfo::ge

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits
@@ -588,7 +615,8 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy, bool isVariadic, // Otherwise this is an AAPCS variant. - if (isEmptyRecord(getContext(), RetTy, true)) + if (isEmptyRecord(getContext(), RetTy, true) || + getContext().getTypeSize(RetTy)

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-28 Thread Eli Friedman via cfe-commits
@@ -366,9 +387,15 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); } - // Ignore empty records. - if (isEmptyRecord(getContext(), Ty, true)) -return ABIArgInfo::ge

[clang] [AArch64] Match GCC behaviour for zero-size structs (PR #124760)

2025-01-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/124760 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][SME] Account for C++ lambdas in SME builtin diagnostics (PR #124750)

2025-01-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Please add some tests for lambdas with streaming attributes, for example: ``` void f() { auto x = []__arm_locally_streaming {}; x(); } ``` https://github.com/llvm/llvm-project/pull/124750 ___ cfe-commits mailing list cfe-commits@l

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/119423 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AArch64] Match GCC behaviour for zero-size structs (PR #124760)

2025-01-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The likelihood of anyone actually tripping over this outside a synthetic testcase is very low; you need a combination of unusual constructs to hit this. So I'm not really worried about documentation/ABI compat flags. https://github.com/llvm/llvm-project/pull/124760 __

[clang] [NFC] Avoid potential nullptr deref by using castAs<> (PR #123395)

2025-01-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/123395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang] Implement pragma clang section on COFF targets (PR #112714)

2025-01-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/112714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang] Implement pragma clang section on COFF targets (PR #112714)

2025-01-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/112714 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Return larger CXX records in memory (PR #120670)

2025-01-29 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: You can cherry-pick this to the 20.x branch if you want; we can still land fixes like this for a few weeks after the branch is created. https://github.com/llvm/llvm-project/pull/120670 ___ cfe-commits mailing list cfe-commits@list

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-29 Thread Eli Friedman via cfe-commits
@@ -1144,6 +1144,12 @@ Arm and AArch64 Support * FUJITSU-MONAKA (fujitsu-monaka) +- The AArch64 calling convention for empty structs in C++ mode was changed to efriedma-quic wrote: I assume this is supposed to mention AArch32/AAPCS32? https://github.com/l

[clang] [llvm] [clang][llvm][aarch64][win] Add a clang flag and module attribute for import call optimization, and remove LLVM flag (PR #122831)

2025-01-29 Thread Eli Friedman via cfe-commits
@@ -945,7 +944,7 @@ void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) { // If import call optimization is enabled, emit the appropriate section. // We do this whether or not we recorded any import calls. - if (EnableImportCallOptimization && TT.isOSBinFormatCOFF()) { +

[clang] [llvm] [clang][llvm][aarch64][win] Add a clang flag and module attribute for import call optimization, and remove LLVM flag (PR #122831)

2025-01-29 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/122831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][llvm][aarch64][win] Add a clang flag and module attribute for import call optimization, and remove LLVM flag (PR #122831)

2025-01-29 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM with one minor comment. https://github.com/llvm/llvm-project/pull/122831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [ARM] Empty structs are 1-byte for C++ ABI (PR #124762)

2025-01-29 Thread Eli Friedman via cfe-commits
@@ -1144,6 +1144,12 @@ Arm and AArch64 Support * FUJITSU-MONAKA (fujitsu-monaka) +- The AArch64 calling convention for empty structs in C++ mode was changed to + pass them as if they have a size of 1 byte, matching the AAPCS64 + specification and GCC's implementation. The

[clang] [clang][SME] Account for C++ lambdas in SME builtin diagnostics (PR #124750)

2025-01-29 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. https://github.com/llvm/llvm-project/pull/124750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Implement gcc_struct attribute on Itanium targets (PR #71148)

2025-01-13 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu -fms-layout-compatibility=microsoft %s +// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu %s +// RUN: %clang_cc1 -emi

[clang] [clang] Implement gcc_struct attribute on Itanium targets (PR #71148)

2025-01-13 Thread Eli Friedman via cfe-commits
@@ -997,6 +997,9 @@ def warn_npot_ms_struct : Warning< "data types with sizes that aren't a power of two">, DefaultError, InGroup; +def err_itanium_layout_unimplemented : Error< + "Itanium-compatible layout for the Microsoft C++ ABI is not yet supported">; ---

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-13 Thread Eli Friedman via cfe-commits
@@ -66,6 +66,17 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) { } } +bool IntrinsicInst::canAccessFPEnvironment(Intrinsic::ID IID) { + switch (IID) { +#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ +case Intrinsic::INTR

[clang] [libclang] Add API to query more information about base classes. (PR #120300)

2025-01-14 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The 32-bit Arm failures are fixed by 7aec7caca30f800811b76ba94291645494788a4f . The other failures appear to be unrelated. https://github.com/llvm/llvm-project/pull/120300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-14 Thread Eli Friedman via cfe-commits
@@ -66,6 +66,12 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) { } } +bool IntrinsicInst::canAccessFPEnvironment(LLVMContext &C, Intrinsic::ID IID) { + AttributeList Attrs = Intrinsic::getAttributes(C, IID); + MemoryEffects ME = Attrs.getMemoryEffects();

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Eli Friedman via cfe-commits
@@ -1060,236 +1061,358 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-15 Thread Eli Friedman via cfe-commits
@@ -1060,236 +1061,358 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type, return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true); } -const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset( -ASTContext &Ctx, const

[clang] [clang] Emit @llvm.assume before streaming_compatible functions when the streaming mode is known (PR #121917)

2025-01-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The two issues are sort of tied together: if the intrinsic isn't IntrNoMem, I suspect the assumption cache stops cooperating. But anyway, I guess the question is really whether we want these constructs represented explicitly in IR, to try to leverage the AssumptionCache, o

[clang] [compiler-rt] [Clang] Adjust pointer-overflow sanitizer for N3322 (PR #120719)

2025-01-08 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM I don't see any reason to mess with the runtime bits: we try to keep them stable where we can. https://github.com/llvm/llvm-project/pull/120719 ___ cfe-commits mailing list cfe-commits

[clang] Remove the `CustomEntry` escape hatch from builtin TableGen (PR #120861)

2025-01-08 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/120861 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Allow packing fields into tail padding of record fields (PR #122197)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -803,10 +804,16 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { if (!AppendField(Field, Layout.getFieldOffset(FieldNo), EltInit, AllowOverwrite)) return false; - // After emitting a non-empty field

[clang] Allow packing fields into tail padding of record fields (PR #122197)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -389,14 +389,28 @@ void CGRecordLowering::accumulateFields(bool isNonVirtualBaseType) { // Empty fields have no storage. ++Field; } else { - // Use base subobject layout for the potentially-overlapping field, - // as it is done in RecordLayoutBuild

[clang] Allow packing fields into tail padding of record fields (PR #122197)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -389,14 +389,28 @@ void CGRecordLowering::accumulateFields(bool isNonVirtualBaseType) { // Empty fields have no storage. ++Field; } else { - // Use base subobject layout for the potentially-overlapping field, - // as it is done in RecordLayoutBuild

[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2025-01-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I think you're looking for -DLLVM_RUNTIME_TARGETS ? https://github.com/llvm/llvm-project/pull/109164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2025-01-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I think you need to do some target-specific stuff to get the builtins library to build... see, for example, https://reviews.llvm.org/D42958 . https://github.com/llvm/llvm-project/pull/109164 ___ cfe-commits mailing list cfe-commit

[clang] [AArch64][Clang] Add support for __arm_agnostic("sme_za_state") (PR #121788)

2025-01-10 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/121788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libclang] Add API to query more information about base classes. (PR #120300)

2025-01-10 Thread Eli Friedman via cfe-commits
@@ -3771,6 +3771,12 @@ CINDEX_LINKAGE enum CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T); */ CINDEX_LINKAGE unsigned clang_isVirtualBase(CXCursor); +/** + * Returns the offset in bits of a CX_CXXBaseSpecifier relative to the parent + * class. + */ +CINDEX_LINKAG

[clang] [libclang] Allow using PrintingPolicy with types (PR #122386)

2025-01-10 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/122386 >From 2f6e9acc324802854132ff1b48693a47a8466fa4 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 17 Dec 2024 17:46:09 -0800 Subject: [PATCH] [libclang] Allow using PrintingPolicy with types This allo

[clang] [libclang/python] Add python bindings for PrintingPolicy (PR #120494)

2025-01-08 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/120494 >From 13a9c0b88afae7a5f48a66e86357f7284fdace95 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 17 Dec 2024 15:25:00 -0800 Subject: [PATCH] [libclang/python] Add python bindings for PrintingPolicy T

[clang] [compiler-rt] [llvm] [ASan] Add metadata to renamed instructions so ASan doesn't use the i… (PR #119387)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -137,6 +137,10 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, Alloca = new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(), ArraySize, Name, AllocaInsertPt->getIterator()); + if (Alloca->getName

[clang] [libclang/python] Add python bindings for PrintingPolicy (PR #120494)

2025-01-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Still failing the same way. Should I go ahead and merge anyway, or is there someone who can look into this? https://github.com/llvm/llvm-project/pull/120494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -14585,11 +14585,18 @@ void Sema::CheckAddressOfPackedMember(Expr *rhs) { _2, _3, _4)); } +static ExprResult UsualUnaryConversionsNoPromoteInt(Sema &S, Expr *E) { + // Don't promote integer types + if (QualType Ty = E->getType(); S.getASTContext().is

[clang] [clang] Restrict use of scalar types in vector builtins (PR #119423)

2025-01-08 Thread Eli Friedman via cfe-commits
@@ -14604,57 +14611,63 @@ bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { } bool Sema::BuiltinElementwiseMath(CallExpr *TheCall, bool FPOnly) { - QualType Res; - if (BuiltinVectorMath(TheCall, Res, FPOnly)) -return true; - TheCall->setType(Res);

[clang] [llvm] [clang] Implement pragma clang section on COFF targets (PR #112714)

2025-01-14 Thread Eli Friedman via cfe-commits
@@ -1,4 +1,5 @@ ;RUN: llc -mtriple=armv7-eabi %s -o - | FileCheck %s +;RUN: llc -mtriple=armv7-msvc %s -o - | FileCheck %s efriedma-quic wrote: That's fine. But the CHECK lines in the new test don't look right (`nobits` etc. are ELF-specific). https://github.

[clang] 7aec7ca - Add explicit triple to test_type.py.

2025-01-14 Thread Eli Friedman via cfe-commits
Author: Eli Friedman Date: 2025-01-14T14:49:45-08:00 New Revision: 7aec7caca30f800811b76ba94291645494788a4f URL: https://github.com/llvm/llvm-project/commit/7aec7caca30f800811b76ba94291645494788a4f DIFF: https://github.com/llvm/llvm-project/commit/7aec7caca30f800811b76ba94291645494788a4f.diff

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-15 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: LGTM with one minor comment https://github.com/llvm/llvm-project/pull/122735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-15 Thread Eli Friedman via cfe-commits
@@ -86,6 +86,35 @@ IRBuilderBase::createCallHelper(Function *Callee, ArrayRef Ops, return CI; } +CallInst *IRBuilderBase::CreateCall(FunctionType *FTy, Value *Callee, +ArrayRef Args, +ArrayRef OpBundles

[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-01-15 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/122735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Support constexpr alignment of __builtin_assume_aligned. (PR #127223)

2025-02-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: This is not the right fix. After we check the constant expression in Sema, we should create a ConstantExpr containing the the evaluated value, so we don't need to re-evaluate it later. https://github.com/llvm/llvm-project/pull/127223

[clang] [clang] Lower modf builtin using `llvm.modf` intrinsic (PR #126750)

2025-02-13 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic requested changes to this pull request. Hang on... I need to think a little more about the interaction with snan in strictfp mode. https://github.com/llvm/llvm-project/pull/126750 ___ cfe-commits mailing list cfe-commi

[clang] [clang] Add `__builtin_sincospi` that lowers to `llvm.sincospi.*` (PR #127065)

2025-02-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: How does this interact with strictfp? Do we need a constrained version of sincospi which raises appropriate exceptions? https://github.com/llvm/llvm-project/pull/127065 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http

[clang] [clang] Lower modf builtin using `llvm.modf` intrinsic (PR #126750)

2025-02-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Referring to the C standard and implementations, I think modf does in fact raise an fp exception when the operand is an snan. So to handle this, we need different lowering in strictfp mode, probably to a "constrained" intrinsic. https://github.com/llvm/llvm-project/pull/1

[clang] [clang] Lower modf builtin using `llvm.modf` intrinsic (PR #126750)

2025-02-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > when -fno-math-errno is set What does -fno-math-errno have to do with anything? modf never sets errno anyway. https://github.com/llvm/llvm-project/pull/126750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://li

[clang] [clang] Lower modf builtin using `llvm.modf` intrinsic (PR #126750)

2025-02-11 Thread Eli Friedman via cfe-commits
@@ -859,6 +859,24 @@ static void emitSincosBuiltin(CodeGenFunction &CGF, const CallExpr *E, StoreCos->setMetadata(LLVMContext::MD_noalias, AliasScopeList); } +static llvm::Value *emitModfBuiltin(CodeGenFunction &CGF, const CallExpr *E, +l

[clang] [clang] Lower modf builtin using `llvm.modf` intrinsic (PR #126750)

2025-02-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Can you just move the modf handling into the section for non-math intrinsics? It's not a "math intrinsic" in this context: it doesn't set errno or raise exceptions. https://github.com/llvm/llvm-project/pull/126750 ___ cfe-commit

[clang] [Clang][NFC] Extend cmplx range tests for #131129 (PR #131447)

2025-03-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > I can experiment with --filter-out, but I'd prefer to do that as a followup. If you want, you can run the IR through "opt -passes=mem2reg" or something... we just don't want to run the full optimization pipeline because that leads to a bunch of spurious changes to clang

[clang] [HLSL] error on out of bounds vector accesses (PR #128952)

2025-03-19 Thread Eli Friedman via cfe-commits
@@ -14054,6 +14054,23 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) { << TRange << Op->getSourceRange(); } +void Sema::CheckVectorAccess(const Expr *BaseExpr, const Expr *IndexExpr) { + const auto *VTy = BaseExpr->getType()->getAs(); + if (!VTy)

[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)

2025-03-19 Thread Eli Friedman via cfe-commits
@@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) { x.arr[1] = b; return x; } + +struct s8_t { + char a; +}; + +// AVR-NOT: {{.*}} signext +// TINY-NOT: {{.*}} signext efriedma-quic wrote: Can you rewrite this test to avoid "NOT"? Something like `//

[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)

2025-03-19 Thread Eli Friedman via cfe-commits
@@ -135,7 +135,8 @@ class AVRTargetCodeGenInfo : public TargetCodeGenInfo { if (GV->isDeclaration()) return; const auto *FD = dyn_cast_or_null(D); -if (!FD) return; +if (!FD) efriedma-quic wrote: Please don't reformat code that isn't rele

[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)

2025-03-20 Thread Eli Friedman via cfe-commits
@@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) { x.arr[1] = b; return x; } + +struct s8_t { + char a; +}; + +// AVR: define {{.*}} i8 @foob(i8 {{.*}}) +// TINY define {{.*}} i8 @foob(i8 {{.*}}) efriedma-quic wrote: ```suggestion // AVR: define {{

[clang] [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (PR #131976)

2025-03-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/131976 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-21 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The RISCV builtins are generated code; riscv_vector_builtin_cg.inc is 87000 lines. There's an open bug about this: #88368. https://github.com/llvm/llvm-project/pull/132252 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] [Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers (PR #130734)

2025-03-21 Thread Eli Friedman via cfe-commits
@@ -42,6 +42,11 @@ Potentially Breaking Changes C/C++ Language Potentially Breaking Changes --- +- Some old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))`` are treated efriedma-quic wrote: I think it

[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)

2025-03-24 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: https://llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches https://llvm.org/docs/HowToReleaseLLVM.html#release-patch-rules . https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commit

[clang] [Docs] Document freestanding requirements (PR #132232)

2025-03-24 Thread Eli Friedman via cfe-commits
@@ -1073,6 +1073,28 @@ inputs. Here is some example of ``$``-prefixed options: Language and Target-Independent Features +Freestanding Builds +--- +Passing the ``-ffreestanding`` flag causes Clang to build for a freestand

[clang] [llvm] [llvm:ir] Add support for constant data exceeding 4GiB (PR #126481)

2025-03-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/126481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] IR: Store the default subtarget info in named metadata instead of the context. (PR #98673)

2025-03-14 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Sorry, I meant to get back to this sooner. I'm not sure it makes sense to distinguish between "compile-time" and "link-time" in the sense this patch is doing: whether an instrumentation pass runs at compile-time or link-time is more a matter of what's convenient for a giv

[clang] Move const qualification of array to its elements (PR #131366)

2025-03-14 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Non-canonical types, are, as the name suggests, non-canonical: they can have all kinds of type sugar, and type qualifiers at all levels. Please don't try to change that; just fix getCommonSugaredType so it can tolerate a const qualifier in this position. https://github.c

[clang] [clang] Allow constexpr-unknown values pre C++23 (PR #129646)

2025-03-14 Thread Eli Friedman via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: efriedma-quic wrote: Reduced testcase for the microsoft-abi-member-pointers.cpp failure: ``` constinit int &b = b; ``` This should produce an error; clang -std=c++23 currently accepts it. https://github.com/llvm/llvm-project/pull/129646 _

[clang] [clang] Allow constexpr-unknown values pre C++23 (PR #129646)

2025-03-14 Thread Eli Friedman via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: efriedma-quic wrote: The other test changes look mostly okay, but worth investigating to see if we can improve the diagnostic notes for illegal uses of constexpr-unknown variables. https://github.com/llvm/llvm-project/pull/129646 _

[clang] [Clang][NFC] Extend cmplx range tests for #131129 (PR #131447)

2025-03-17 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: This is a lot of tests... do we really need every combination of type/operator/flag? I guess it makes sure we don't have gaps, but thousands of lines of tests seems excessive. https://github.com/llvm/llvm-project/pull/131447 ___

[clang] [Clang][NFC] Extend cmplx range tests for #131129 (PR #131447)

2025-03-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/131447 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Change placeholder from `undef` to `poison` (PR #131533)

2025-03-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/131533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen][NFC] Run mem2reg and sroa on complex range tests (PR #131925)

2025-04-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Running both mem2reg and sroa is redunant; just run sroa. If the undefs are getting introduced by sroa, that's fine; they'll go away when we fix sroa. https://github.com/llvm/llvm-project/pull/131925 ___ cfe-commits mailing list

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Eli Friedman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] [llvm] [Clang][NVVM] Support `-f[no-]cuda-prec-sqrt` and propagate precision flag to `NVVMReflect` (PR #134244)

2025-04-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: At first glance, it seems like a good idea to allow people to choose how their square roots are lowered on a per-function level: some code cares about precise square roots, some doesn't, and you should be able to make choices on a case-by-case basis. But looking at the co

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Clang][NVVM] Support `-f[no-]cuda-prec-sqrt` and propagate precision flag to `NVVMReflect` (PR #134244)

2025-04-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Why is this a module flag, instead of a function attribute? https://github.com/llvm/llvm-project/pull/134244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [llvm:ir] Add support for constant data exceeding 4GiB (PR #126481)

2025-04-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Code formatter returned issues; please fix (https://github.com/llvm/llvm-project/pull/126481#issuecomment-2649368078) https://github.com/llvm/llvm-project/pull/126481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers (PR #130734)

2025-04-05 Thread Eli Friedman via cfe-commits
@@ -42,6 +42,11 @@ Potentially Breaking Changes C/C++ Language Potentially Breaking Changes --- +- Some old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))`` are treated efriedma-quic wrote: Well, no, b

[clang] [Docs] Document freestanding requirements (PR #132232)

2025-04-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: -ffreestanding currently has the following effects: - Disables builtins recognition (-fno-builtins) - Sets `__STDC_HOSTED__` to 0. - Disables unwind tables (-fno-asynchronous-unwind-tables -fno-unwind-tables) (refer to df50259f9856ae98b5a1b34c4c955074aff3c566) Maybe we shou

[clang] [Clang][NFC] Code cleanup in CGBuiltin.cpp (PR #132060)

2025-04-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The timing of this is sort of unfortunate with #132252; the merge conflict there is going to be very painful. @jthackray , thoughts? https://github.com/llvm/llvm-project/pull/132060 ___ cfe-commits mailing list cfe-commits@lists.

[clang] Allow direct dispatch for the ObjFW runtime (PR #126382)

2025-04-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/126382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)

2025-04-04 Thread Eli Friedman via cfe-commits
Mateusz =?utf-8?q?Mikuła?= , Mateusz =?utf-8?q?Mikuła?= , Mateusz =?utf-8?q?Mikuła?= , Mateusz =?utf-8?q?Mikuła?= Message-ID: In-Reply-To: https://github.com/efriedma-quic commented: Please split this into multiple pull requests; some of these probably need different reviewers, and GitHub doe

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 >From 2873bb1aee5470ecd7fa66c1f255bfe8b26dbc68 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 17 Mar 2025 11:20:21 -0700 Subject: [PATCH] [clang] fix constexpr-unknown handling of self-references.

[clang] [Docs] Document freestanding requirements (PR #132232)

2025-03-26 Thread Eli Friedman via cfe-commits
@@ -1073,6 +1073,29 @@ inputs. Here is some example of ``$``-prefixed options: Language and Target-Independent Features +Freestanding Builds +--- +Passing the ``-ffreestanding`` flag causes Clang to build for a freestand

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > Do you intend to backport this change to 20? The weird behavior only shows up if you refer to a reference variable inside its own initializer, as far as I can tell. Maybe not worth backporting, even if it is a regression, because people shouldn't be writing code like th

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
@@ -3629,17 +3644,17 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, Result = VD->getEvaluatedValue(); - // C++23 [expr.const]p8 - // ... For such an object that is not usable in constant expressions, the - // dynamic type of the object is constexpr-un

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-26 Thread Eli Friedman via cfe-commits
@@ -177,3 +177,50 @@ namespace extern_reference_used_as_unknown { int y; constinit int& g = (x,y); // expected-warning {{left operand of comma operator has no effect}} } + +namespace uninit_reference_used { + int y; + constexpr int &r = r; // expected-error {{must be ini

[clang] [Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers (PR #130734)

2025-03-27 Thread Eli Friedman via cfe-commits
@@ -64,21 +64,27 @@ class CGBuilderTy : public CGBuilderBaseTy { Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine &Name) { const llvm::DataLayout &DL = BB->getDataLayout(); -llvm::GetElementPtrInst *

[clang] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-03-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/132990 Usually, in constant evaluation, references which are local to the evaluation have to be initialized before they're accessed. However, there's one funny special case: the initializer of a reference can r

[clang] [Clang][CodeGen] Do not set inbounds flag for struct GEP with null base pointers (PR #130734)

2025-03-27 Thread Eli Friedman via cfe-commits
@@ -42,6 +42,11 @@ Potentially Breaking Changes C/C++ Language Potentially Breaking Changes --- +- Some old-style offsetof idioms like ``((int)(&(((struct S *)0)->field)))`` are treated efriedma-quic wrote: I was think

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-09 Thread Eli Friedman via cfe-commits
@@ -7653,8 +7653,11 @@ ExprResult Sema::TemporaryMaterializationConversion(Expr *E) { // In C++98, we don't want to implicitly create an xvalue. // FIXME: This means that AST consumers need to deal with "prvalues" that // denote materialized temporaries. Maybe we should

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Respect -fwrapv-pointer when emitting struct GEPs (PR #134269)

2025-04-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/134269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AArch64] Change the coercion type of structs with pointer members. (PR #135064)

2025-04-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic edited https://github.com/llvm/llvm-project/pull/135064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AArch64] Change the coercion type of structs with pointer members. (PR #135064)

2025-04-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: The general idea here makes sense. https://github.com/llvm/llvm-project/pull/135064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [AArch64] Change the coercion type of structs with pointer members. (PR #135064)

2025-04-09 Thread Eli Friedman via cfe-commits
@@ -485,6 +485,24 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadicFn, } Size = llvm::alignTo(Size, Alignment); +// If the Aggregate is made up of pointers, use an array of pointers for the +// coerced type. This prevents having

[clang] Mark CXX module initializer with PACBTI attributes (PR #133716)

2025-04-10 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -triple thumbv8.1m.main-unknown-none-eabi -emit-module-interface -target-feature +pacbti -mbranch-target-enforce -std=c++20 %s -o %t.pcm efriedma-quic wrote: I don't think we need all the combinations here in RUN lines; we v

[clang] [clang][CodeGen] Add range metadata for atomic load of boolean type. #131476 (PR #133546)

2025-04-10 Thread Eli Friedman via cfe-commits
Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= Message-ID: In-Reply-To: efriedma-quic wrote: I don't really understand what the new version of the patch is doing... instcombine can infer `nuw` on `trunc` if the operan

[clang] Mark CXX module initializer with PACBTI attributes (PR #133716)

2025-04-10 Thread Eli Friedman via cfe-commits
@@ -447,6 +447,8 @@ llvm::Function *CodeGenModule::CreateGlobalInitOrCleanUpFunction( if (Linkage == llvm::GlobalVariable::InternalLinkage) SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); + else +getTargetCodeGenInfo().setTargetAttributes(nullptr, Fn, *this);

[clang] [Clang][CodeGen][X86] don't coerce int128 into `{i64,i64}` for SysV-like ABIs (PR #135230)

2025-04-10 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: There isn't any reason we can't do this... but it doesn't really solve the issue in general. And there are a lot of other ways to trip over this. CC @dblaike @hvdijk @jmorse Do we want to try to handle _BitInt, or a struct containing an i128? https://github.com/llvm/ll

<    11   12   13   14   15   16   17   18   19   20   >