[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)

2025-04-29 Thread Eli Friedman via cfe-commits
@@ -4820,6 +4820,9 @@ bool CodeGenFunction::isUnderlyingBasePointerConstantNull(const Expr *E) { const Expr *UnderlyingBaseExpr = E->IgnoreParens(); while (auto *BaseMemberExpr = dyn_cast(UnderlyingBaseExpr)) UnderlyingBaseExpr = BaseMemberExpr->getBase()->IgnoreParens

[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)

2025-04-29 Thread Eli Friedman via cfe-commits
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, else elemTy = CGF.ConvertTypeForMem(elementType); - if (CGF.getLangOpts().PointerOverflowDefined) + if (CGF.getLangOpts().PointerOverflowDefined || + CGF.isUnderlyingBasePointerConstan

[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)

2025-04-29 Thread Eli Friedman via cfe-commits
@@ -2,16 +2,20 @@ // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s -class A { +class A { + // expected-note@-1 {{candidate constructor}} +#if __cplusplus >= 201103L // C++11 or later + // expec

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Not sure if anyone has mentioned this elsewhere, but there's a significant problem with the type of the returned function pointer: a normal function pointer doesn't necessarily have the correct calling convention. In practice, this is likely to cause problems on Windows.

[clang] [llvm] [TargetVerifier][AMDGPU] Add TargetVerifier. (PR #123609)

2025-04-21 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I don't think it makes sense to have a target-specific "verifier": verification sets the limits of what optimizations are allowed to do. And that determination needs to be target-independent, or else target-independent optimizations can't exist. Target-specific intrinsic

[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-21 Thread Eli Friedman via cfe-commits
=?utf-8?q?Théo?= de Magalhaes Message-ID: In-Reply-To: https://github.com/efriedma-quic closed https://github.com/llvm/llvm-project/pull/136062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] [CLANG][MS-STRUCT] bitfield padding warning presents padding to exact bit count (PR #136062)

2025-04-21 Thread Eli Friedman via cfe-commits
=?utf-8?q?Th=C3=A9o?= de Magalhaes Message-ID: In-Reply-To: https://github.com/efriedma-quic approved this pull request. Oh, I see, I missed the nesting. LGTM https://github.com/llvm/llvm-project/pull/136062 ___ cfe-commits mailing list cfe-commits

[clang] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)

2025-02-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I'm not really happy with that... but if the semantics were never properly defined in the first place, I guess this isn't making things worse. Not sure if marking the allocas themselves is actually the right approach long-term. It seems like there's a distinction between

[clang] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)

2025-02-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Adding metadata to an instruction should never be required for correctness: optimizations are not required to preserve metadata on instructions, so this "fix" will just break again later. If we need two different kinds of alloca in coroutine functions, we need a different

[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2025-02-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: `-std=gnu99` etc. sets LangOpts.GNUMode... but we don't want to base the ABI on that; it's not an ABI flag. The ABI should only be based on the triple, and flags specifically intended to modify the ABI. I think we should just use the GNU-compatible ABI by default. Unless

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

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

[clang] [clang][CodeGen] Propagate `volatile` qualifier in derived-to-base conversion (PR #127824)

2025-02-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Should the result type of the ImplicitCastExpr be volatile in the AST? https://github.com/llvm/llvm-project/pull/127824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [llvm] [win][x64] Unwind v2 3/n: Add support for emitting unwind v2 information (equivalent to MSVC /d2epilogunwind) (PR #129142)

2025-02-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > we can't have epilogs in chained unwind tables, since they are only for > additional savereg codes. How do epilogs work in chained unwind tables? Do the epilog opcodes from the original table get ignored? If they do get ignored, can you specify different opcodes in th

[clang] [llvm] [win][x64] Unwind v2 3/n: Add support for emitting unwind v2 information (equivalent to MSVC /d2epilogunwind) (PR #129142)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -500,7 +500,8 @@ MCSymbol *MCStreamer::emitLineTableLabel() { MCSymbol *MCStreamer::emitCFILabel() { // Return a dummy non-null value so that label fields appear filled in when // generating textual assembly. - return (MCSymbol *)1; + static size_t DummyLabelValue = 0;

[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -51,18 +51,18 @@ namespace disabled_dtor { union disable_dtor { T val; template -disable_dtor(U &&...u) : val(forward(u)...) {} +disable_dtor(U &&...u) : val(forward(u)...) {} // expected-error {{attempt to use a deleted function}} efriedm

[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace t1{ +template struct VSX { + ~VSX() { static_assert(sizeof(T) != 4, ""); } // expected-error {{static assertion failed due to requirement 'sizeof(int) != 4':}} \ +

[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -5451,10 +5451,31 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, NumInitializers * sizeof(CXXCtorInitializer*)); Constructor->setCtorInitializers(baseOrMemberInitializers); +SourceLocation Location = Constructor->getLo

[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -5451,10 +5451,23 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, NumInitializers * sizeof(CXXCtorInitializer*)); Constructor->setCtorInitializers(baseOrMemberInitializers); +SourceLocation Location = Constructor->getLo

[clang] [Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitializer` (PR #128409)

2025-02-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Here's a testcase that's should generate a diagnostic, but doesn't without this patch: ``` int &ff(); int &x = ff(); constinit int &z = x; ``` Some related testcases are a little weird... consider the following: ``` extern int &x; int &z = x; ``` There's a gap between ch

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-06 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/129952 >From 9ac636ee137248cafe38f4d2e016cfb885142dff Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 5 Mar 2025 14:20:21 -0800 Subject: [PATCH 1/3] [clang] Reject constexpr-unknown values as constant exp

[clang] [Clang][CodeGen] Bail out on constexpr unknown values in ConstantEmitter (PR #127525)

2025-03-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > That said, this patch might be worth having in that branch AS WELL to cover > any other missed cases. I would be OK having this patch HERE only on that > branch or replaced with an assert in main. #128409 should cover all the cases this patch would cover. I'm a little

[clang] [Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitializer` (PR #128409)

2025-03-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Opened #129844 with a case that still fails. Other entry-points to constant evaluation need similar treatment to EvaluateAsInitializer. https://github.com/llvm/llvm-project/pull/128409 ___ cfe-commits mailing list cfe-commits@lis

[clang] [Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitializer` (PR #128409)

2025-03-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: And the check for allowConstexprUnknown() isn't catching all the relevant cases; opened #129845. https://github.com/llvm/llvm-project/pull/128409 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-06 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/129952 >From 9ac636ee137248cafe38f4d2e016cfb885142dff Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 5 Mar 2025 14:20:21 -0800 Subject: [PATCH 1/2] [clang] Reject constexpr-unknown values as constant exp

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-06 Thread Eli Friedman via cfe-commits
@@ -154,3 +154,26 @@ int g() { static_assert(f(arr) == 5); } } + +namespace GH128409 { + int &ff(); + int &x = ff(); // nointerpreter-note {{declared here}} + constinit int &z = x; // expected-error {{variable does not have a constant initializer}} +

[clang] [llvm] [analysis] Software Bill of Mitigations (PR #130103)

2025-03-06 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: This needs a higher-level description of the overall goal, and why you've picked the specific instrumentation points you've chosen. https://github.com/llvm/llvm-project/pull/130103 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: /cherry-pick 42d49a77241df73a17cb442973702fc460e7fb90 https://github.com/llvm/llvm-project/pull/129952 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

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

[clang] [Clang][CodeGen] Fix demangler invariant comment assertion (PR #130522)

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

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

2025-03-11 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I somehow thought we had already done something about this, but I can't find any reference to it. Anyway, if we're going to support this as an extension, I don't want to bury it in CGBuilder.h. We should decide exactly when we want it to trigger, an

[clang] [Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitializer` (PR #128409)

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

[clang] [Sema] Instantiate destructors for initialized anonymous union fields (PR #128866)

2025-02-27 Thread Eli Friedman via cfe-commits
@@ -5451,10 +5451,23 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, NumInitializers * sizeof(CXXCtorInitializer*)); Constructor->setCtorInitializers(baseOrMemberInitializers); +SourceLocation Location = Constructor->getLo

[clang] [llvm] [win][x64] Unwind v2 3/n: Add support for emitting unwind v2 information (equivalent to MSVC /d2epilogunwind) (PR #129142)

2025-02-28 Thread Eli Friedman via cfe-commits
@@ -500,7 +500,8 @@ MCSymbol *MCStreamer::emitLineTableLabel() { MCSymbol *MCStreamer::emitCFILabel() { // Return a dummy non-null value so that label fields appear filled in when // generating textual assembly. - return (MCSymbol *)1; + static size_t DummyLabelValue = 0;

[clang] [llvm] [win][x64] Unwind v2 3/n: Add support for emitting unwind v2 information (equivalent to MSVC /d2epilogunwind) (PR #129142)

2025-02-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: So if an unwind table has an epilog opcode, and you chain another unwind table to it, the chained unwind table inherits the epilog opcode? You could use that. The primary unwind table ends at the first epilog, you mark it with an "atend" epilog opcode. The next region sta

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

2025-03-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Just ran into some related code: see 3d0a540857edbd510e329f40581f6b2c1968ccca . Maybe using IgnoreParenCasts() like that code does is appropriate. (I don't really like using IgnoreParenCasts() because there's such a big variety of casts, but it's probably okay in this co

[clang] [Clang][WIP] Constant Expressions inside of gcc'asm strings (PR #131003)

2025-03-13 Thread Eli Friedman via cfe-commits
@@ -2586,10 +2586,11 @@ static void UpdateAsmCallInst(llvm::CallBase &Result, bool HasSideEffect, // Slap the source location of the inline asm into a !srcloc metadata on the // call. - if (const auto *gccAsmStmt = dyn_cast(&S)) -Result.setMetadata("srcloc", -

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/129952 Perform the check for constexpr-unknown values in the same place we perform checks for other values which don't count as constant expressions. While I'm here, also fix a rejects-valid with a reference tha

[clang] [clang] Reject constexpr-unknown values as constant expressions more consistently (PR #129952)

2025-03-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/129952 >From 9ac636ee137248cafe38f4d2e016cfb885142dff Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 5 Mar 2025 14:20:21 -0800 Subject: [PATCH] [clang] Reject constexpr-unknown values as constant express

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

2025-03-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > We only perform this optimization in addrspace(0). I'd still prefer to get this right for all address-spaces, so we don't need to revisit later. But really, I'm more concerned about the "happens to get folded" part: there isn't a stable set of values that get constant-

[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 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/126750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

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

[clang] [Clang][CodeGen] Bail out on constexpr unknown values in ConstantEmitter (PR #127525)

2025-02-21 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > Clang rejects the following case after modifying evaluateValue to treat > constexpr-unknown value as invalid I don't see the connection. At least, there isn't any obvious connection: the testcase doesn't require constexpr-unknown. Maybe you need to "reject" the value

[clang] [WebAssembly] Generate invokes with llvm.wasm.(re)throw (PR #128105)

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

[clang] [llvm] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)

2025-02-24 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I think if we're trying to automatically identify whether an alloca has one of two lifetimes, and one of those lifetimes isn't a subset of the other, we're guaranteed to run into trouble again, eventually. We have to pick the right lifetime 100% of the time... but without

[clang] [Clang] Treat constexpr-unknown value as invalid in `evaluateValue` (PR #128409)

2025-02-24 Thread Eli Friedman via cfe-commits
@@ -2587,6 +2587,9 @@ APValue *VarDecl::evaluateValueImpl(SmallVectorImpl &Notes, !Notes.empty()) Result = false; + if (Eval->Evaluated.allowConstexprUnknown()) +Result = false; efriedma-quic wrote: I think this check should be inside `Evaluat

[clang] [Clang] Treat constexpr-unknown value as invalid in `evaluateValue` (PR #128409)

2025-02-24 Thread Eli Friedman via cfe-commits
@@ -3628,8 +3628,6 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, if (AllowConstexprUnknown) { if (!Result) Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base); -else - Result->setConstexprUnknown(); efr

[clang] [Clang][CodeGen] Bail out on constexpr unknown values in ConstantEmitter (PR #127525)

2025-02-24 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I'm worried this is just scratching the surface... it looks like there's a whole class of issues involving constexpr-unknown leaking out of constant evaluation, and this is just addressing one specific case. If we can't take https://github.com/llvm/llvm-project/pull/12840

[clang] [HLSL] Make memory representation of boolean vectors in HLSL, vectors of i32. Add support for boolean swizzling. (PR #123977)

2025-02-24 Thread Eli Friedman via cfe-commits
@@ -1984,6 +1984,15 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM, return Res; } + // In HLSL bool vectors are stored in memory as a vector of i32 + if (destType->isExtVectorBoolType() && CGM.getContext().getLangOpts().HLSL) { e

[clang] [Clang] Treat constexpr-unknown value as invalid in `evaluateValue` (PR #128409)

2025-02-24 Thread Eli Friedman via cfe-commits
@@ -122,9 +122,9 @@ namespace CaseStatements { } extern int &Recurse1; -int &Recurse2 = Recurse1; // expected-note {{declared here}} +int &Recurse2 = Recurse1; // pre-cxx23-note {{declared here}} efriedma-quic wrote: I'd guess you just need to generate a note

[clang] [Clang][CodeGen] Bail out on constexpr unknown values in ConstantEmitter (PR #127525)

2025-02-20 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Does it even make sense for evaluateValue to return a constexpr-unknown value? If I'm following correctly, we can't actually do anything useful with such a result: we don't actually know what the value is. It would make things simpler if we kept su

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

2025-02-25 Thread Eli Friedman via cfe-commits
@@ -617,15 +617,15 @@ class ConstantDataSequential : public ConstantData { /// If this is a sequential container of integers (of any size), return the /// specified element in the low bits of a uint64_t. - uint64_t getElementAsInteger(unsigned i) const; + uint64_t getEle

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

2025-02-25 Thread Eli Friedman via cfe-commits
@@ -644,7 +644,7 @@ class ConstantDataSequential : public ConstantData { Type *getElementType() const; /// Return the number of elements in the array or vector. - unsigned getNumElements() const; + uint64_t getNumElements() const; efriedma-quic wrote: A

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

2025-03-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM. (I'll merge once the premerge checks come back.) https://github.com/llvm/llvm-project/pull/126481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

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

2025-03-31 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] [Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (PR #130990)

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

[clang] [Clang] Always verify LLVM IR inputs (PR #134396)

2025-04-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Might as well do it for bitcode too? That wouldn't impact LTO scenarios, I think: in LTO, the IR is directly loaded by lld/the LTO plugin. https://github.com/llvm/llvm-project/pull/134396 ___ cfe-commits mailing list cfe-commits@

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

2025-04-04 Thread Eli Friedman via cfe-commits
@@ -793,6 +793,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) { } CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, ModuleInits, GuardAddr); +getTargetCodeGenInfo().setTargetAttributes(nullptr,

[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

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

[clang] [CLANG-CL] ignores wpadded (PR #130182)

2025-04-04 Thread Eli Friedman via cfe-commits
=?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes Message-ID: In-Reply-To: https://github.c

[clang] [Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (PR #130990)

2025-04-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > The ubsan handler cannot be eliminated because inaccessiblemem: readwrite > indicates that it has externally observable side effects. That is not how things work. For example: ``` $ echo "declare void @g() define void @f() nounwind { call void @g() memory(argmem: read,

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

2025-03-28 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 1/2] [clang] fix constexpr-unknown handling of self-referen

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

2025-04-02 Thread Eli Friedman via cfe-commits
Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= Message-ID: In-Reply-To: @@ -590,6 +590,29 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest, llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr); Load->setAtomic(Order, Scope); Load->set

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

2025-04-02 Thread Eli Friedman via cfe-commits
Jan =?utf-8?q?Górski?= , Jan =?utf-8?q?Górski?= Message-ID: In-Reply-To: @@ -590,6 +590,29 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest, llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr); Load->setAtomic(Order, Scope); Load->set

[clang] [Clang][NFC] Add threadsafe macro helper (PR #134139)

2025-04-02 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I don't understand what you're planning. Currently, the only thing the POSIXThreads LangOption does is control `_REENTRANT` or equivalent. If you provide a separate option to control the macro, the POSIXThreads option doesn't do anything at all. https://github.com/llvm/

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

2025-04-03 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > most of them are safe What's the distinguishing factor here? Do you consider it "safe" to mark inbounds if the pointer is immediately dereferenced? Or does the pointer have to refer to a known successful allocation? Or something else? https://github.com/llvm/llvm-pro

[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

2025-04-03 Thread Eli Friedman via cfe-commits
@@ -1491,7 +1491,10 @@ void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest, "Invalid complex expression to emit"); ComplexExprEmitter Emitter(*this); ComplexPairTy Val = Emitter.Visit(const_cast(E)); - Emitter.EmitStoreOfComplex(Val, dest,

[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

2025-04-03 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: There's a comment in CodeGenFunction::EmitReturnBlock that says: ``` // FIXME: We are at an unreachable point, there is no reason to emit the block // unless it has uses. However, we still need a place to put the debug // region.end for now. ```

[clang] [MS][clang] Fix crash on deletion of array of pointers (PR #134088)

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

[clang] [llvm] [clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (PR #132489)

2025-04-03 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I think you also need to fix the backends so if they see thread_pointer intrinsic with the wrong address-space, they don't crash. https://github.com/llvm/llvm-project/pull/132489 ___ cfe-commits mailing list

[clang] [llvm] [HLSL] Run finalize linkage pass for all targets (PR #134260)

2025-04-03 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I'm not sure I understand why we're changing the linkage of functions in an IR pass, instead of just setting the correct linkage in the first place. Is there some form of linker involved? If there is, should the linker fix the linkage? By conventio

[clang] [CLANG-CL] ignores wpadded (PR #130182)

2025-04-03 Thread Eli Friedman via cfe-commits
=?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes , =?utf-8?q?Théo?= De Magalhaes Message-ID: In-Reply-To: efriedma-quic wr

[clang] [Clang] Fix unnecessary extra return block emmited during function epilog after musttail call (PR #134282)

2025-04-03 Thread Eli Friedman via cfe-commits
@@ -3897,6 +3897,13 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, return; } + // If there is no valid insert point, we won't emit a return. + // The insert point could be null if we have already emitted a return + // (e.g. if musttail) + if (

[clang] [CIR] Upstream support for address of and dereference (PR #134317)

2025-04-03 Thread Eli Friedman via cfe-commits
@@ -193,8 +334,23 @@ LValue CIRGenFunction::emitUnaryOpLValue(const UnaryOperator *e) { switch (op) { case UO_Deref: { -cgm.errorNYI(e->getSourceRange(), "UnaryOp dereference"); -return LValue(); +QualType t = e->getSubExpr()->getType()->getPointeeType(); +

[clang] [llvm] [clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (PR #132489)

2025-04-03 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I'm mostly concerned about the case where the lowered node has the wrong type. For example, AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN always creates a value with the pointer width of addrspace 0, but address spaces exist which don't have the native pointer width (arm

[clang] [Clang] Always verify LLVM IR inputs (PR #134396)

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/134396 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Handle CC attrs for UEFI (PR #138935)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -581,8 +581,11 @@ CodeGenTypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, } FunctionType::ExtInfo einfo; - bool IsWindows = getContext().getTargetInfo().getTriple().isOSWindows(); - einfo = einfo.withCallingConv(getCallingConventionForDecl(MD, IsWindo

[clang] [Clang][AArch64] Add pessimistic vscale_range for sve/sme (PR #137624)

2025-05-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I really don't want the dependency chain that involves clang converting the target feature list to an LLVM attribute string, then grabbing the attribute out of the llvm::Function to parse it back into a feature list. That ties together the target info and codegen in a wei

[clang] [Clang][CodeGen] Add workaround for old glibc `__PTR_ALIGN` macro (PR #137851)

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

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -7613,6 +7613,9 @@ def import_call_optimization : Flag<["-"], "import-call-optimization">, "by the Windows kernel to enable import call optimization">, MarshallingInfoFlag>; +def replaceable_function: Joined<["-"], "loader-replaceable-function=">, + Marsh

[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

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

[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

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

[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -4661,3 +4661,109 @@ AsmPrinter::getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr, return std::make_tuple(Base, 0, BranchLabel, codeview::JumpTableEntrySize::Int32); } + +void AsmPrinter::emitCOFFReplaceableFunctionData(Module &M)

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [llvm] Add support for Windows hot-patching (PR #138972)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,251 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [Clang][CodeGen] Enable pointer overflow check for GCC workaround (PR #137849)

2025-05-07 Thread Eli Friedman via cfe-commits
@@ -4169,10 +4169,10 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, // The index is not pointer-sized. // The pointer type is not byte-sized. // - if (BinaryOperator::isNullPointerArithmeticExtension(CGF.getContext(), -

[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-05-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: These days, there's very high demand for "secure" C/C++. From this perspective, this optimization is a security threat: if you write code that does an undefined write to "this", you have a lurking security vulnerability could be exposed with any change to optimization heu

[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

2025-05-08 Thread Eli Friedman via cfe-commits
@@ -9125,9 +9126,25 @@ bool LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) { assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) && "lvalue compound literal in c++?"); - // Defer visiting the literal until the lvalue-to-rvalue con

[clang] [Clang][CodeGen] Enable pointer overflow check for GCC workaround (PR #137849)

2025-05-08 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/137849 ___ 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-05-06 Thread Eli Friedman via cfe-commits
@@ -486,6 +486,39 @@ 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] [AArch64] Change the coercion type of structs with pointer members. (PR #135064)

2025-05-06 Thread Eli Friedman via cfe-commits
@@ -486,6 +486,39 @@ 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] [AArch64] Change the coercion type of structs with pointer members. (PR #135064)

2025-05-06 Thread Eli Friedman via cfe-commits
@@ -486,6 +486,39 @@ 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] [clang] fix constexpr-unknown handling of self-references. (PR #132990)

2025-05-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/132990 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,

[clang] [llvm] [clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (PR #132489)

2025-05-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Please update LangRef with the new overload and verifier rule. https://github.com/llvm/llvm-project/pull/132489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [llvm] [clang][IR] Overload @llvm.thread.pointer to support non-AS0 targets (PR #132489)

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

[clang] [llvm] Add support for Windows Secure Hot-Patching (PR #138972)

2025-05-20 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: It looks like my previous comments about ConstantExpr never got resolved? Specifically, what happens if you have an instruction where an operand is a ConstantExpr GEP of a global, or something like that. https://github.com/llvm/llvm-project/pull/138

<    13   14   15   16   17   18   19   20   21   >