[clang] [Sema] Don't call isNonConstantStorage on incomplete variable types (PR #161590)

2025-10-01 Thread Eli Friedman via cfe-commits
@@ -14918,52 +14918,57 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) { } // Apply section attributes and pragmas to global variables. - if (GlobalStorage && var->isThisDeclarationADefinition() && - !inTemplateInstantiation()) { -PragmaStack *Stack

[clang] [libcxx] [clang] [libc++] fix _Atomic c11 compare exchange does not update expected results (PR #78707)

2025-09-30 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I think the current state addresses my concerns, yes. I'd like to make one final pass over it, though; please git-clang-format and rebase the patch. https://github.com/llvm/llvm-project/pull/78707 ___ cfe-commits mailing list cfe

[clang] [clang] Implement __builtin_stdc_rotate_left, __builtin_stdc_rotate_right (PR #160259)

2025-09-27 Thread Eli Friedman via cfe-commits
@@ -3679,6 +3679,35 @@ the arguments. Both arguments and the result have the bitwidth specified by the name of the builtin. These builtins can be used within constant expressions. +``__builtin_stdc_rotate_left`` and ``__builtin_stdc_rotate_right`` +---

[clang] [Clang] Fix Codegen UO real/imag crash on scalar with type promotion (PR #160609)

2025-09-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: For very old clang code, we were less rigorous about test checks; these days we'd very rarely approve -emit-llvm-only tests. Especially since we have update_cc_test_checks.py. It probably makes sense to change the test to an update_cc_test_checks.py test, just so nobody

[clang] [clang] Implement __builtin_stdc_rotate_left, __builtin_stdc_rotate_right (PR #160259)

2025-09-24 Thread Eli Friedman via cfe-commits
@@ -3642,6 +3642,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_rotateleft16: case Builtin::BI__builtin_rotateleft32: case Builtin::BI__builtin_rotateleft64: + case Builtin::BI__builtin_stdc_rotate_left: -

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

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

[clang] [clang] Add missing readonly/readnone annotations (PR #158424)

2025-09-23 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If you want me to merge for you, please let me know. https://github.com/llvm/llvm-project/pull/158424 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add missing readonly/readnone annotations (PR #158424)

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

[clang] [clang][fatlto] Only run sanitzer passes in prelink pipelines (PR #160213)

2025-09-23 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Why do we want to run sanitizer passes prelink? Wouldn't it be more effective to run them postlink? https://github.com/llvm/llvm-project/pull/160213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/c

[clang] [llvm] [clang][SPARC] Pass 16-aligned structs with the correct alignment in CC (PR #155829)

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

[clang] [Clang] Enable -fextend-variable-liveness at -Og (PR #118026)

2025-09-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: There's a corresponding intrinsic llvm.fake.use (FAKE_USE in MIR), which isn't used by anything else. Possibly there's a bug in the implementation of that intrinsic. https://github.com/llvm/llvm-project/pull/118026 ___ cfe-commi

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

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

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

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

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

2025-09-18 Thread Eli Friedman via cfe-commits
@@ -405,6 +405,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { // parameters. Do this in whatever block we're currently in; it's // important to do this before we enter the return block or return // edges will be *really* confused. +

[clang] Fix __builtin_object_size calculation for references of unknown origin in C++23 (PR #157778)

2025-09-17 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: In any context where the standard requires constant evaluation, we have to return false, probably. (This corresponds, roughly, to Info.InConstantContext. I don't think we have a bit that precisely corresponds, though.) We probably do want to fold in tryEvaluateObjectSize

[clang] [clang] Add missing readonly/readnone annotations (PR #158424)

2025-09-17 Thread Eli Friedman via cfe-commits
@@ -3011,6 +3016,37 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, } assert(ArgNo == FI.arg_size()); + ArgNo = 0; + if (AddedPotentialArgAccess && MemAttrForPtrArgs) { +llvm::SmallSet ArgsToSkip; +if (IRFunctionArgs.hasSRetArg()) { + ArgsToSk

[clang] Fix __builtin_object_size calculation for references of unknown origin in C++23 (PR #157778)

2025-09-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Try the following with -std=c++23 -Winvalid-constexpr: ``` constexpr int f(int &a) { return 1 / (__builtin_object_size(&a, 0) - 4); } int a[2]; static_assert(f(a[0]) == 0); ``` https://github.com/llvm/llvm-project/pull/157778 __

[clang] [llvm] [FMV][AArch64] Allow user to override version priority. (PR #150267)

2025-09-15 Thread Eli Friedman via cfe-commits
@@ -348,6 +350,76 @@ entry: ret i32 %call } +declare i32 @test_explicit_priority._Mmops() #18 +declare i32 @test_explicit_priority._Msve2() #19 +declare i32 @test_explicit_priority._Msve() #20 +declare i32 @test_explicit_priority.default() #0 + +define weak_odr ptr @test_exp

[clang] [clang] fix incorrect assumption about function type 's ExtInfo (PR #157925)

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

[clang] [flang] [llvm] [polly] Import and Export `getXXXPluginInfo` from embedded plugin such as Polly (PR #156440)

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

[clang] [PowerPC] fix float ABI selection on ppcle (PR #154773)

2025-09-12 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Can you unify the test with clang/test/CodeGen/PowerPC/ppc-sfvarargs.c, since it's testing basically the same thing? https://github.com/llvm/llvm-project/pull/154773 ___ cfe-commits mailing list cfe-commits@

[clang] [llvm] [clang] Regenerate test checks including TBAA semantics (NFC) (PR #154347)

2025-09-12 Thread Eli Friedman via cfe-commits
@@ -1,15 +1,17 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 // RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future \

[clang] [llvm] [clang] Regenerate test checks including TBAA semantics (NFC) (PR #154347)

2025-09-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I don't have time to look more now... but please do an extra pass and call out any tests with potentially interesting changes. https://github.com/llvm/llvm-project/pull/154347 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[clang] [llvm] Add metadata for const C/C++ scalar types to track initial values of escaped alloca (PR #157676)

2025-09-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > Since there are multiple store operations to immutable alloca here, the > optimization will conservatively not be performed at all. In the trivial case I showed, you can find all the stores. More generally, other optimizations can hide stores, so iterating over the use

[clang] [Clang] Assume unaligned in maksed load / store builtins (PR #156063)

2025-09-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Deferencing a pointer, __builtin_memcpy, and most other operations that involve accessing pointers, currently assume pointers are naturally aligned. The exact representation of this in LLVM IR varies, but the fundamental assumption is that you're following normal C/C++ st

[clang] [llvm] [clang] Regenerate test checks including TBAA semantics (NFC) (PR #154347)

2025-09-12 Thread Eli Friedman via cfe-commits
@@ -1,15 +1,17 @@ -// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 // RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future \

[clang] [llvm] Add metadata for const C/C++ scalar types to track initial values of escaped alloca (PR #157676)

2025-09-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Consider: ``` void f(int*); void g() { for (int i = 0; i < 10; ++i) { const int j = i; f(&j); } } ``` There's "one store"... but consider what happens if the loop is unrolled. - There's also more subtle issues; we don't guarantee "one store" actually rema

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

2025-09-11 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: This is roughly what I expected. But it looks like there are some build failures on the bot. https://github.com/llvm/llvm-project/pull/156643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

2025-09-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Instead of creating a separate cleanup stack and adding special deferred handling for that cleanup stack, can we just skip creating the scope in the first place? We have `LexicalScope ForScope(*this, S.getSourceRange());`; can we replace that with s

[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

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

[clang] [llvm] [SPIRV] Add OpInf support for isinf hlsl intrinsic (PR #156570)

2025-09-04 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Given the current definition of "ninf", there is no way to legally check if a value produced by an "ninf" instruction is infinity: even if the bitpattern looks like an infinity, it's actually poison. If that's causing problems for you, we might need to revisit the definit

[clang] [llvm] [clang] Polymorphic Cleanup type is moved despite not being POD types (PR #156607)

2025-09-04 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. I've reviewed other changes here recently (#152866). The code is playing some weird games with memory allocation, using an std::vector as an arena. Probably there's some better way to write this. Strictly speaking, it's undefined

[clang] [CodeGen] Fix cleanup attribute for C89 for-loop init variables (PR #156643)

2025-09-03 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: "End of the function" is not really correct. It's still the end of the scope... just the scope in question is different. This matters if you have, for example, a nested loop. Probably need to change CodeGenFunction::EmitForStmt to push the scope at

[clang] [llvm] [clang][SPARC] Pass 16-aligned 16-byte structs as i128 in CC (PR #155829)

2025-09-03 Thread Eli Friedman via cfe-commits
@@ -275,10 +276,14 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const { // Try to use the original type for coercion. llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType(); + // We use a pair of i64 for 9-16 byte aggregate with 8 byte a

[clang] [llvm] [SPIRV] Add OpInf support for isinf hlsl intrinsic (PR #156570)

2025-09-03 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Is there some reason clang can't just generate a call to `llvm.is.fpclass`? https://github.com/llvm/llvm-project/pull/156570 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

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

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

2025-09-02 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Sorry, forgot this was still open. https://github.com/llvm/llvm-project/pull/151053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

2025-09-01 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/151053 >From 43e441c0559294f0e4d85cf67bea480140b2e9d1 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 28 Jul 2025 15:47:33 -0700 Subject: [PATCH 1/2] [clang] Followup for constexpr-unknown potential consta

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-28 Thread Eli Friedman via cfe-commits
@@ -1480,6 +1480,14 @@ class DeclRefExpr final return DeclRefExprBits.IsImmediateEscalating; } + bool isOverflowBehaviorDiscarded() const { efriedma-quic wrote: I guess that makes sense. But the number of bits we have available in Expr is really limi

[clang] [Arm64EC][clang] Implement varargs support in clang. (PR #152411)

2025-08-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/152411 >From 9b8fdaf87ceb1478e5c4a0324de99b5ce375b175 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 6 Aug 2025 16:31:03 -0700 Subject: [PATCH 1/2] [Arm64EC][clang] Implement varargs support in clang. Th

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-28 Thread Eli Friedman via cfe-commits
@@ -550,6 +550,39 @@ explicit ``overflow_behavior`` attribute. // [-Wimplicit-overflow-behavior-conversion-pedantic] } +Format String Functions +=== + +When overflow behavior types are used with format string functions (printf-famil

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-28 Thread Eli Friedman via cfe-commits
@@ -12504,6 +12514,14 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, IntRange TargetRange = IntRange::forTargetOfCanonicalType(Context, Target); if (LikelySourceRange->Width > TargetRange.Width) { +// Check if target is a wrapping OBT -

[clang] [llvm] [clang][SPARC] Pass 16-aligned 16-byte structs as i128 in CC (PR #155829)

2025-08-28 Thread Eli Friedman via cfe-commits
@@ -275,10 +276,14 @@ SparcV9ABIInfo::classifyType(QualType Ty, unsigned SizeLimit) const { // Try to use the original type for coercion. llvm::Type *CoerceTy = CB.isUsableType(StrTy) ? StrTy : CB.getType(); + // We use a pair of i64 for 9-16 byte aggregate with 8 byte a

[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-08-28 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Not every inline asm, only inline asm statements that specifically have an "unwind" clobber (or in Rust, may_unwind). Which is pretty rare, in practice: I've never seen anyone use it in clang, and it isn't even available on stable in Rust. Accurately detecting whether th

[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

2025-08-27 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,14 @@ +; RUN: llc < %s -mtriple=armv7 | FileCheck %s --check-prefix=armv7 +; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefix=aarch64 efriedma-quic wrote: You can't put aarch64 testcases in llvm/test/CodeGen/ARM/. They have to be in llvm/

[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

2025-08-27 Thread Eli Friedman via cfe-commits
@@ -4248,6 +4248,39 @@ assignment can happen automatically. to a variable, have its address taken, or passed into or returned from a function, because doing so violates bounds safety conventions. +.. _builtin_stack_address-doc: + +``__builtin_stack_address`` +-

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -12504,6 +12514,14 @@ void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC, IntRange TargetRange = IntRange::forTargetOfCanonicalType(Context, Target); if (LikelySourceRange->Width > TargetRange.Width) { +// Check if target is a wrapping OBT -

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -405,6 +405,9 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { argTy = PT->getPointeeType(); } + if (const auto *OBT = argTy->getAs()) +argTy = OBT->getUnderlyingType(); efriedma-quic wrote: Probably the documentation should mentio

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -3189,16 +3227,21 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, // Note that signed integer inc/dec with width less than int can't // overflow because of promotion rules; we're just eliding a few steps // here. -} els

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -1480,6 +1480,14 @@ class DeclRefExpr final return DeclRefExprBits.IsImmediateEscalating; } + bool isOverflowBehaviorDiscarded() const { efriedma-quic wrote: Is there some description of what this bit is supposed to mean? As far as I can tell, it

[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -199,6 +233,19 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { if (!Op.mayHaveIntegerOverflow()) return true; + const UnaryOperator *UO = dyn_cast(Op.E); + if (UO && Ctx.isUnaryOverflowPatternExcluded(UO)) +return true; + + c

[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

2025-08-26 Thread Eli Friedman via cfe-commits
@@ -14389,6 +14389,36 @@ Semantics: Note this intrinsic is only verified on AArch64 and ARM. +'``llvm.stackaddress``' Intrinsic +^ + +Syntax: +""" + +:: + + declare ptr @llvm.stackaddress() + +Overview: +" + +The '``llvm.stacka

[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

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

[clang] [llvm] [Clang] Add `__builtin_stack_address` (PR #148281)

2025-08-26 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: The backend code looks like what I expect. Needs a backend regression test for some non-SPARC target. https://github.com/llvm/llvm-project/pull/148281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] fix crash in codegen caused by deferred asm diagnostics under -fopenmp (PR #147163)

2025-08-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: My understanding of deferred diagnostics is that the primary use is to allow including headers that contain inline functions, and don't properly mark device vs. host. So when you parse the function, it's unknown whether the function is actually going to be used, which wou

[clang] [clang] Remove hasValue() check in `RecordExprEvaluator::VisitCXXConstructExpr()` (PR #154610)

2025-08-24 Thread Eli Friedman via cfe-commits
@@ -11045,10 +11045,6 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E, bool ZeroInit = E->requiresZeroInitialization(); if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) { -// If we've already performed zero-initiali

[clang] [Clang][CodeGen] Preserve alignment information for pointer arithmetics (PR #152575)

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

[clang] [llvm] [NVPTX] Change the alloca address space in NVPTXLowerAlloca (PR #154814)

2025-08-22 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Modifying the datalayout feels really strange, and I'm sort of worried it'll have unintended consequences, especially if there's only one target doing it. Maybe you can just skip modifying the datalayout? The passes that run after createNVPTXLower

[clang] [Clang] Fix incorrect return type for `__builtin_shufflevector` (PR #154817)

2025-08-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. I expect this doesn't have much effect in most cases; we have a bunch of implicit conversions between vector types, so probably in most cases the vector gets converted to the right type before anyone actually tries to use it. LGTM h

[clang] [llvm] Singleton hack of fixing static initialisation order ficaso (PR #154541)

2025-08-20 Thread Eli Friedman via cfe-commits
@@ -30,18 +30,18 @@ constexpr StringRef AssumptionAttrKey = "llvm.assume"; /// A set of known assumption strings that are accepted without warning and /// which can be recommended as typo correction. -LLVM_ABI extern StringSet<> KnownAssumptionStrings; +LLVM_ABI extern StringS

[clang] [llvm] Singleton hack of fixing static initialisation order ficaso (PR #154541)

2025-08-20 Thread Eli Friedman via cfe-commits
@@ -160,7 +160,7 @@ inlineCostFeatureToMlFeature(InlineCostFeatureIndex Feature) { return static_cast(static_cast(Feature)); } -LLVM_ABI extern std::vector FeatureMap; +LLVM_ABI extern std::vector &getFeatureMap(); efriedma-quic wrote: ```suggestion LLVM_A

[clang] [clang][CodeGen] add addr space cast if needed when storing ptrs (PR #154380)

2025-08-20 Thread Eli Friedman via cfe-commits
@@ -2209,6 +2209,18 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, } } + // When storing a pointer, perform address space cast if needed. efriedma-quic wrote: Yes, that sounds right. https://github.com/llvm/llvm-project/

[clang] [AArch64][Clang] Limit variadic onstack args to 8 bytes on Arm64EC. (PR #154578)

2025-08-20 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Duplicate of #152411? https://github.com/llvm/llvm-project/pull/154578 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CodeGen] add addr space cast if needed when storing ptrs (PR #154380)

2025-08-20 Thread Eli Friedman via cfe-commits
@@ -2209,6 +2209,18 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr, } } + // When storing a pointer, perform address space cast if needed. efriedma-quic wrote: Types in IRGen should match types in the AST. So if an lvalue

[clang] [libcxx] Elide suspension points via [[clang::coro_await_suspend_destroy]] (PR #152623)

2025-08-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: git-clang-format uses the "--lines" option to clang-format restrict formatting updates. If that isn't working correctly, please file a bug. You can ignore the bot after that. https://github.com/llvm/llvm-project/pull/152623 ___

[clang] [llvm] [X86][APX] Remove CF feature from APXF and Diamond Rapids (PR #153751)

2025-08-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, right, I guess x86 doesn't ever disable instructions in the assembler... other architectures usually do. There might be other edge cases where things get weird, like, if you do runtime CPU detection. But I don't care enough to argue further. Please at least leave a

[clang] [clang][RISCV] Fix crash on VLS calling convention (PR #145489)

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

[clang] [llvm] [X86][APX] Remove CF feature from APXF and Diamond Rapids (PR #153751)

2025-08-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > We usually use Tuningxxx due to hardware defects, which implies some hardware > preform good while some bad. But here the problem is we haven't fully address > regression to make it a net profit for performance. I don't really see a difference between the two: if there's

[clang] Fix Issue where libclang Does Not Include Standard Compiler Specific Headers (PR #153746)

2025-08-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If we're going to explicitly add a flag for the resource dir, we should use the flag `-resource-dir`, not try to emulate it with -I. There are other relevant bits in the resource directory, like cfi_ignorelist.txt. We have code in libclang which is supposed to handle this

[clang] [llvm] [X86][APX] Remove CF feature from APXF and Diamond Rapids (PR #153751)

2025-08-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: "CF" is a hardware feature; it's incredibly confusing to just pretend it doesn't exist because it's slow. If you need to adjust codegen, add a separate feature TuningSlowCF or something. https://github.com/llvm/llvm-project/pull/153751

[clang] [Clang][NFC] Avoid repeating copy of std::string in lambda implementation (PR #153863)

2025-08-15 Thread Eli Friedman via cfe-commits
@@ -204,8 +204,9 @@ class FullDependencyConsumer : public DependencyConsumer { std::optional Provided, std::vector Requires) override { ModuleName = Provided ? Provided->ModuleName : ""; -llvm::transform(Requires, std::back_inserter(NamedModuleDeps), -

[clang] [DebugInfo] When referencing structured bindings use the reference's location, not the binding's declaration's location (PR #153637)

2025-08-14 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Really, the AST design is weird: we're not supposed to do any computation when you reference parts of the binding. We represent it as an expression just to reduce the code required to handle bindings. As such, the set of expressions actually allowed in a binding are quit

[clang] [win][arm64ec] XFAIL x64 intrinsic tests on Arm64EC (PR #153474)

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

[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

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

[clang] [AArch64][FMV] Enable PAuth and BTI hardening of resolver functions (PR #141573)

2025-08-14 Thread Eli Friedman via cfe-commits
@@ -4652,6 +4659,7 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) { "", Resolver, &getModule()); GIF->setName(ResolverName); SetCommonAttributes(FD, GIF); +SetResolverAttrs(cast(Resolver)); ---

[clang] [clang][WebAssembly] Handle casted function pointers with different number of arguments (PR #153168)

2025-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Really, I think the biggest problem with this approach is that it special-cases compile-time casts, and treats them differently from runtime casts. That might be just barely sufficient for specific cases from glib, but it's not comprehensive, and it

[clang] [clang] Add an ABI_EXTENSION concept that is testable under -pedantic… (PR #153506)

2025-08-13 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I'm fine with this for the branch, sure. https://github.com/llvm/llvm-project/pull/153506 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][PAC] ptrauth_qualifier must be considered a feature (PR #153291)

2025-08-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Can we just drop the check from `__has_extension` handling? It looks like that check dates back to the introduction of __has_extension (d5d410faa8cfbbf4e2ffc2f8aa470491a77fd843). But it's a terrible idea for a lot of reasons: it adds a semantic effect to a flag which othe

[clang] [clang][PAC] ptrauth_qualifier must be considered a feature (PR #153291)

2025-08-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > No, ptrauth is not a feature, it is an extension and should be reported as > such. The real bug here is that you're missing an extension warning when > `__ptrauth` is used I thought our general policy was that we don't trigger pedantic warnings for reserved keywords (li

[clang] [WIP] [clang] Align cleanup structs to prevent SIGBUS on sparc32 (PR #152866)

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

[clang] [Arm64EC][clang] Implement varargs support in clang. (PR #152411)

2025-08-08 Thread Eli Friedman via cfe-commits
@@ -132,6 +132,10 @@ class ABIInfo { virtual llvm::FixedVectorType * getOptimalVectorMemoryType(llvm::FixedVectorType *T, const LangOptions &Opt) const; + + /// Used by Arm64EC calling convention code to call into x86 calling + /// convention

[clang] [Arm64EC][clang] Implement varargs support in clang. (PR #152411)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -1409,6 +1409,12 @@ class WinX86_64ABIInfo : public ABIInfo { return isX86VectorCallAggregateSmallEnough(NumMembers); } + ABIArgInfo classifyArgForArm64ECVarArg(QualType Ty) const override { efriedma-quic wrote: classifyArgForArm64ECVarArg is exclus

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -563,8 +563,11 @@ bool Pointer::hasSameBase(const Pointer &A, const Pointer &B) { if (A.isTypeidPointer() && B.isTypeidPointer()) return true; - if (A.isIntegralPointer() || B.isIntegralPointer()) + if (A.isIntegralPointer() || B.isIntegralPointer()) { +if (A.i

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

2025-08-07 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/151053 >From 43e441c0559294f0e4d85cf67bea480140b2e9d1 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 28 Jul 2025 15:47:33 -0700 Subject: [PATCH 1/2] [clang] Followup for constexpr-unknown potential consta

[clang] [llvm] Trying to fix undefined symbol error caused by iterator variable (PR #141507)

2025-08-07 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Still waiting for an answer: > The reason I'm suspicious of the getDeclareMapperVarRef check is that > SemaOpenMP::ActOnOMPIteratorExpr creates the variable (VarDecl::Create) > regardless. So what's supposed to happen for variables where > getDeclareMapperVarRef is false?

[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -6324,10 +6324,20 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, SetLLVMFunctionAttributesForDefinition(D, Fn); + auto getPriority = [this](auto *Attr) -> int { +int priority = Attr->DefaultPriority; +Expr *E = Attr->getPriority(); +if (

[clang] [Clang][CodeGen] Preserve alignment information for pointer arithmetics (PR #152575)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -4184,29 +4184,14 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { } /// Emit pointer + index arithmetic. -static Value *emitPointerArithmetic(CodeGenFunction &CGF, -const BinOpInfo &op, -

[clang] [Clang][CodeGen] Preserve alignment information for pointer arithmetics (PR #152575)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -1381,6 +1432,13 @@ static Address EmitPointerWithAlignment(const Expr *E, LValueBaseInfo *BaseInfo, if (CE->getCastKind() == CK_AddressSpaceConversion) Addr = CGF.Builder.CreateAddrSpaceCast( Addr, CGF.ConvertType(E->getType()), ElemTy); +

[clang] [Clang][CodeGen] Preserve alignment information for pointer arithmetics (PR #152575)

2025-08-07 Thread Eli Friedman via cfe-commits
@@ -4309,16 +4292,39 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, // future proof. llvm::Type *elemTy; if (elementType->isVoidType() || elementType->isFunctionType()) -elemTy = CGF.Int8Ty; +elemTy = Int8Ty; else -elemTy = CGF.ConvertTypeFor

[clang] [flang] [llvm] [IR] Remove size argument from lifetime intrinsics (PR #150248)

2025-08-07 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM, assuming there aren't any non-trivial changes to the regression tests. (I looked at the code changes, but I skimmed the test changes.) https://github.com/llvm/llvm-project/pull/150248 ___

[clang] [Arm64EC][clang] Implement varargs support in clang. (PR #152411)

2025-08-06 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/152411 The clang side of the calling convention code for arm64 vs. arm64ec is close enough that this isn't really noticeable in most cases, but the rule for choosing whether to pass a struct directly or indirect

[clang] [clang] Followup for constexpr-unknown potential constant expressions. (PR #151053)

2025-08-06 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Ping https://github.com/llvm/llvm-project/pull/151053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix crash in dynamic_cast final class optimization (PR #152076)

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

[clang] [clang] Fix crash in dynamic_cast final class optimization (PR #152076)

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

[clang] [clang] Fix crash in dynamic_cast final class optimization (PR #152076)

2025-08-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I think I'd prefer to split the pointer authentication changes into a separate patch; I'm not sure I'm comfortable reviewing that bit. Other changes look fine. https://github.com/llvm/llvm-project/pull/152076 _

[clang] [clang] Fix crash in dynamic_cast final class optimization (PR #152076)

2025-08-05 Thread Eli Friedman via cfe-commits
@@ -2294,6 +2294,18 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr, DestRecordTy->getAsCXXRecordDecl()->isEffectivelyFinal() && CGM.getCXXABI().shouldEmitExactDynamicCast(DestRecordTy); + std::optional ExactCastInfo; + if

[clang] [clang] Fix crash in dynamic_cast final class optimization (PR #152076)

2025-08-05 Thread Eli Friedman via cfe-commits
@@ -1722,41 +1728,95 @@ llvm::Value *ItaniumCXXABI::emitExactDynamicCast( if (!Offset) Offset = PathOffset; else if (Offset != PathOffset) { - // Base appears in at least two different places. Find the most-derived - // object and see if it's a DestDecl.

[clang] [clang] Introduce elementwise ctlz/cttz builtins (PR #131995)

2025-08-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > > We don't currently have a definition of what it means to "use" a value in a > > way that would cause undefined behavior with poison. > > Which means stating it produces undefined behavior less accurate? We have to document semantics that describe the behavior with all

[clang] Fix missing clang changes for #151983 (PR #152066)

2025-08-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: LGTM, thanks https://github.com/llvm/llvm-project/pull/152066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Respect [[gnu::error]] on functions passed to [[gnu::cleanup]] (PR #152082)

2025-08-05 Thread Eli Friedman via cfe-commits
@@ -624,8 +624,15 @@ namespace { CallArgList Args; Args.add(RValue::get(Arg), CGF.getContext().getPointerType(Var.getType())); - auto Callee = CGCallee::forDirect(CleanupFn); - CGF.EmitCall(FnInfo, Callee, ReturnValueSlot(), Args); + bo

  1   2   3   4   5   6   7   8   9   10   >