[clang] [lld] [llvm] [LTO] enable `ObjCARCContractPass` only on optimized build (PR #101114)

2024-07-30 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Is there some way we can avoid the additional domtree construction? Particularly in cases where the pass doesn't do anything. https://github.com/llvm/llvm-project/pull/101114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (PR #98949)

2024-07-30 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Right, asinf doesn't exist on Windows (see llvm/lib/Analysis/TargetLibraryInfo.cpp). We probably need code to promote calls to llvm.asin.f32 to 64-bit. Not sure how hard it would be to revert this... probably easier to fix forward if we can do that quickly. We'll need a

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: It looks like the removal missed a few bits: PNaClABIBuiltinVaList and clang/lib/CodeGen/Targets/PNaCl.cpp weren't removed. > Unfortunately, this utterly breaks Halide, which was in fact relying on both > of these targets. We can temporarily revert this, but we aren't goi

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: There is no such thing as "generic" LLVM IR, in general: so many target-specific aspects of C have to be directly encoded into the IR, so there's no way to actually make it generic. In this respect, the "le32/le64" targets aren't really any more generic than any other tar

[clang] [clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (PR #98949)

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

[clang] [libcxx] [clang] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

2024-07-15 Thread Eli Friedman via cfe-commits
@@ -2538,6 +2541,311 @@ static RValue EmitHipStdParUnsupportedBuiltin(CodeGenFunction *CGF, return RValue::get(CGF->Builder.CreateCall(UBF, Args)); } +namespace { + +struct PaddingClearer { + PaddingClearer(CodeGenFunction &F) + : CGF(F), CharWidth(CGF.getContext().ge

[clang] [libcxx] [clang] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

2024-07-15 Thread Eli Friedman via cfe-commits
@@ -2538,6 +2541,311 @@ static RValue EmitHipStdParUnsupportedBuiltin(CodeGenFunction *CGF, return RValue::get(CGF->Builder.CreateCall(UBF, Args)); } +namespace { + +struct PaddingClearer { + PaddingClearer(CodeGenFunction &F) + : CGF(F), CharWidth(CGF.getContext().ge

[clang] [libcxx] [clang] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

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

[clang] [libcxx] [clang] Add builtin to clear padding bytes (prework for P0528R3) (PR #75371)

2024-07-15 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Bitfield load and store operations should be done using the same offset/size we normally use to access the bitfield; unconditionally using byte load/store operations will impair optimizations/performance. I guess this might not be possible when unio

[clang] [clang] Limit alignment for emitted vectors (PR #98629)

2024-07-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: What's the relationship between the max vector alignment, and choosing whether to return a vector directly? As long as clang isn't emitting the byval attribute, I don't think it's the frontend's problem. https://github.com/llvm/llvm-project/pull/986

[clang] [test] Precommit tests for PR96025, NFC (PR #98704)

2024-07-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM Please don't use `[test]` as a prefix in commit messages; just use the same prefix you'd use for the code change, e.g. `[clang codegen]` https://github.com/llvm/llvm-project/pull/98704 ___

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > I was under the impression those bits were still needed for Chromium. CC > @dschuff Oh, clang/lib/CodeGen/Targets/PNaCl.cpp is still live for mipsel-nacl target triple. Which we also have zero tests for, but I guess that's a separate issue. https://github.com/llvm/llvm

[clang] [clang][dataflow] Only propagate past CXXDefaultInitExpr if init is (PR #99236)

2024-07-16 Thread Eli Friedman via cfe-commits
@@ -465,7 +465,12 @@ class ResultObjectVisitor : public AnalysisASTVisitor { } if (auto *DIE = dyn_cast(E)) { - PropagateResultObject(DIE->getExpr(), Loc); + // If it has a rewritten init, we should propagate to that. If it doesn't, + // then the CXXDe

[clang] [clang] Limit alignment for emitted vectors (PR #98629)

2024-07-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, I see, there are two checks: one for the "align" attribute, and a separate check for the natural alignment of the type. I'm trying out changing the limit to see how hard it actually is. https://github.com/llvm/llvm-project/pull/98629 ___

[clang] [llvm] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-18 Thread Eli Friedman via cfe-commits
@@ -6886,6 +6886,13 @@ static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) { } } + if (HybridPatchableAttr *Attr = ND.getAttr()) { +if (!ND.isExternallyVisible()) { + S.Diag(Attr->getLocation(), + diag::warn_attribute_hybrid_patchable_n

[clang] [clang codegen] Emit int TBAA metadata on FP math libcall expf (PR #96025)

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

[clang] [clang codegen] Emit int TBAA metadata on FP math libcall expf (PR #96025)

2024-07-18 Thread Eli Friedman via cfe-commits
@@ -688,7 +688,34 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD, const CallExpr *E, llvm::Constant *calleeValue) { CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); CGCallee callee = CGCallee::forDirect(calle

[clang] [clang codegen] Emit int TBAA metadata on FP math libcall expf (PR #96025)

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

[clang] [clang] Emit bad shift warnings (PR #70307)

2024-07-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I think the issue is the usage of "Info.EvalStatus.Diag" to determine whether we consider the expression an ICE; that's going to lead to unpredictable results, and it's not how we handle things anywhere else. Not sure what the goal of that change is. Separately, Sema::Ad

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/99579 We have a mechanism to allow folding expressions that aren't ICEs as an extension; use it more consistently. This ends up causing bad effects on diagnostics in a few cases, but that's not specific to shif

[clang] [clang] Emit bad shift warnings (PR #70307)

2024-07-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Posted #99579. https://github.com/llvm/llvm-project/pull/70307 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Loop over FieldDecls instead of all Decls (PR #99574)

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

[clang] [clang codegen] Fix the ci fail for PR98704 (PR #99267)

2024-07-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: This seems fine. https://github.com/llvm/llvm-project/pull/99267 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
@@ -200,14 +200,7 @@ namespace LongInt { }; enum shiftof { -X = (1<<-29), // all-error {{expression is not an integral constant expression}} \ - // all-note {{negative shift count -29}} - -X2 = (-1<<29), // cxx17-error {{expression is not an integral

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
@@ -142,7 +142,7 @@ constexpr int arb(int n) { // expected-note {{declared here}} expected-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} } constexpr long Overflow[(1 << 30) << 2]{}; // expected-warning {{requires 34

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
@@ -2849,19 +2849,23 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E, if (SA != RHS) { Info.CCEDiag(E, diag::note_constexpr_large_shift) << RHS << E->getType() << LHS.getBitWidth(); + if (!Info.noteUndefinedBehavior()) +r

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/99579 >From 1137011c51285b083cab6c15de670e64337d3de0 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 18 Jul 2024 14:51:13 -0700 Subject: [PATCH 1/3] [ExprConstant] Handle shift overflow the same way as ot

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Pushed new version with an update to make Sema::VerifyIntegerConstantExpression slightly more strict. That handles the cases where the errors were getting dropped. The tradeoff is that we're more strict about arithmetic overflow in certain integer constant expressions (c

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-19 Thread Eli Friedman via cfe-commits
@@ -142,7 +142,7 @@ constexpr int arb(int n) { // expected-note {{declared here}} expected-note {{function parameter 'n' with unknown value cannot be used in a constant expression}} } constexpr long Overflow[(1 << 30) << 2]{}; // expected-warning {{requires 34

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Filed #99680 and #99684 for issues caused by custom codepaths for evaluating ICEs. Hopefully we can improve that at some point. https://github.com/llvm/llvm-project/pull/99579 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-19 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/99579 >From 1137011c51285b083cab6c15de670e64337d3de0 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 18 Jul 2024 14:51:13 -0700 Subject: [PATCH 1/4] [ExprConstant] Handle shift overflow the same way as ot

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Added a few more tests; let me know if there are other tests I should be considering. https://github.com/llvm/llvm-project/pull/99579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

2024-07-19 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/99579 >From 1137011c51285b083cab6c15de670e64337d3de0 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 18 Jul 2024 14:51:13 -0700 Subject: [PATCH 1/5] [ExprConstant] Handle shift overflow the same way as ot

[clang] [ExprConstant] Handle shift overflow the same way as other kinds of overflow (PR #99579)

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

[clang] [Clang] Loop over FieldDecls instead of all Decls (PR #99574)

2024-07-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Empty fields sometimes don't have a corresponding LLVM field number, in order to make the layout work correctly. We slightly extended the cases where this applies recently; see #96422. https://github.com/llvm/llvm-project/pull/99574 ___

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: This really shouldn't work this way: we should go throu

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -2554,16 +2554,27 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_if_present(D)) +return Var->isConstexpr()

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -2554,16 +2554,27 @@ Decl *Parser::ParseDeclarationAfterDeclarator( return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo); } +static bool isConstexprVariable(const Decl *D) { + if (const VarDecl *Var = dyn_cast_if_present(D)) +return Var->isConstexpr()

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-23 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If you have a select with both wrapping and non-wrapping operands, is the result wrapping? If you declare a variable as both wrapping and non-wrapping, is it wrapping? If you declare a function parameter both wrapping and non-wrapping, is it wrapping? If you assign to a

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-23 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The C standard is small enough that if you comb through the C grammar carefully, you can probably come up with explicitly rules for all the important constructs, and verify they work. There's probably still a long tail of weird interactions with current and future clang e

[clang] [Clang] [CodeGen] Perform derived-to-base conversion on explicit object parameter in lambda (PR #89828)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -4684,6 +4684,29 @@ LValue CodeGenFunction::EmitLValueForLambdaField(const FieldDecl *Field, else LambdaLV = MakeAddrLValue(AddrOfExplicitObject, D->getType().getNonReferenceType()); + +// Make sure we have an lvalue to the lamb

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: Zero/sign-extend attributes are also missing, I think.

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-23 Thread Eli Friedman via cfe-commits
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: To clarify, the code in llvm/ still needs to exist beca

[clang] [Clang] Improve testing for the flexible array member (PR #89462)

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

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-24 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > > If you declare a variable as both wrapping and non-wrapping, is it wrapping? > > I am not sure how to do this. I am sure that with the magic of C anything is > possible but I can't conceive a way to have a variable both have the > attribute and not have the attribute (

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-24 Thread Eli Friedman via cfe-commits
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: Sign/zero-extend attributes led to real issues on some

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-24 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > No. But I am confused, isn't this just shadowing a global variable with a > lesser-scoped one. Are they the same? What behavior do we want here? This is declaring, then defining, a global variable; sorry if that wasn't clear. Probably should be an error? It'll be confus

[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

2024-04-25 Thread Eli Friedman via cfe-commits
@@ -908,6 +908,73 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { incrementProfileCounter(&S); } +bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, + bool IsTrivialCXXLoop) { + if (CGM.get

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-25 Thread Eli Friedman via cfe-commits
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); LangAS AS = ArrayQTy.getAddressSpace(); +if (CGF.getLangOpts().OpenCL) + AS = LangAS::openc

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-25 Thread Eli Friedman via cfe-commits
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); LangAS AS = ArrayQTy.getAddressSpace(); +if (CGF.getLangOpts().OpenCL) + AS = LangAS::openc

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-25 Thread Eli Friedman via cfe-commits
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); LangAS AS = ArrayQTy.getAddressSpace(); +if (CGF.getLangOpts().OpenCL) + AS = LangAS::openc

[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

2024-04-25 Thread Eli Friedman via cfe-commits
@@ -908,6 +908,73 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { incrementProfileCounter(&S); } +bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, + bool IsTrivialCXXLoop) { + if (CGM.get

[clang] [clang codegen][NFC] Delete dead code in constant emission. (PR #90106)

2024-04-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/90106 This code was apparently added in de0fe07eef, but never used. I think more of the related code might actually dead, but I haven't tried to dig more deeply. >From b9e5e50524a6ff91badfd5729846d5c948f1d4ce M

[clang] [clang codegen][NFC] Delete dead code in constant emission. (PR #90106)

2024-04-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, I was confused that we had this code that doesn't appear to be doing anything. If you actually have a plan, then we can keep it for now, I guess. It might make sense to try to clarify some of the address-space related APIs: if the caller doesn't want placeholder-stuff

[clang] [clang codegen][NFC] Delete dead code in constant emission. (PR #90106)

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

[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)

2024-04-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Attributes mostly do modify the type. The few that don't, like "aligned" and "may_alias", are a constant source of problems because they get accidentally stripped off. (I don't have any personal experience with "noderef".) https://github.com/llvm/llvm-project/pull/86618

[clang] Fix for merging PR #89456 into llvm 18.X (PR #90118)

2024-04-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The pull request needs to be against llvm:release/18.x, not llvm:main. https://github.com/llvm/llvm-project/pull/90118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm

[clang] Fix for merging PR #89456 into llvm 18.X (PR #90118)

2024-04-25 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: We don't merge anything against the release branch until the buildbots pass. For the buildbots to run, someone needs to manually create a pull request against 18.x branch containing both the original patch and whatever changes are necessary to make the buildbots pass. ht

[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-25 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/90151 In the context of determining whether a class counts as an "aggregate", a constructor template counts as a user-provided constructor. Fixes #86384 >From 9adeffc9ee780c84a525ce0535a84508105e05ae Mon Sep 17

[clang] Re-apply "Emit missing cleanups for stmt-expr" and other commits (PR #89154)

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

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-26 Thread Eli Friedman via cfe-commits
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); LangAS AS = ArrayQTy.getAddressSpace(); +if (CGF.getLangOpts().OpenCL) + AS = LangAS::openc

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-26 Thread Eli Friedman via cfe-commits
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); LangAS AS = ArrayQTy.getAddressSpace(); +if (CGF.getLangOpts().OpenCL) + AS = LangAS::openc

[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-04-26 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The approach makes sense. I'll defer to someone who's more familiar with this code for the full review. https://github.com/llvm/llvm-project/pull/89565 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-26 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/90151 >From 9adeffc9ee780c84a525ce0535a84508105e05ae Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 25 Apr 2024 17:06:40 -0700 Subject: [PATCH 1/2] [clang codegen] Fix MS ABI detection of user-provided c

[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-26 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Added release note. https://github.com/llvm/llvm-project/pull/90151 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-26 Thread Eli Friedman via cfe-commits
@@ -62,6 +62,13 @@ namespace llvm { LibFunc TheLibFunc, AttributeList AttributeList, FunctionType *Invalid, ArgsTy... Args) = delete; + // Handle -mregparm for the given function. + // FIXME: This should likely be implemented in + /

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

2024-04-26 Thread Eli Friedman via cfe-commits
@@ -4781,6 +4782,7 @@ CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name, } } setDSOLocal(F); + markRegisterParameterAttributes(F); efriedma-quic wrote: Suggested text on the clang change: FIXME: We should u

[clang] [clang codegen] Delete unnecessary GEP cleanup code. (PR #90303)

2024-04-26 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/90303 There's some code in AggExprEmitter::VisitCXXParenListOrInitListExpr to try to do early cleanup for GEPs for fields that aren't accessed. But it's unlikely to actually save significant compile-time, and it

[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)

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

[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

2024-04-29 Thread Eli Friedman via cfe-commits
@@ -908,6 +908,73 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { incrementProfileCounter(&S); } +bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, + bool IsTrivialCXXLoop) { + if (CGM.get

[clang] [llvm] [clang][hlsl] Add tan intrinsic part 1 (PR #90276)

2024-04-29 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Are you intentionally skipping implementing changes to __builtin_tan()? https://github.com/llvm/llvm-project/pull/90276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

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

[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #90389)

2024-04-29 Thread Eli Friedman via cfe-commits
@@ -3123,8 +3123,22 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, RegAddr = Tmp.withElementType(LTy); } else if (neededInt) { -RegAddr = Address(CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, gp_offset), - LTy, C

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

2024-04-29 Thread Eli Friedman via cfe-commits
@@ -535,20 +535,24 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType, elementType.isTriviallyCopyableType(CGF.getContext())) { CodeGen::CodeGenModule &CGM = CGF.CGM; ConstantEmitter Emitter(CGF); -LangAS AS = ArrayQTy.getAddressSpa

[clang] [llvm] [CodeGen][i386] Move -mregparm storage earlier and fix Runtime calls (PR #89707)

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

[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

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

[clang] [Clang] Implement P2809: Trivial infinite loops are not Undefined Behavior (PR #90066)

2024-04-30 Thread Eli Friedman via cfe-commits
@@ -908,6 +908,74 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) { incrementProfileCounter(&S); } +bool CodeGenFunction::checkIfLoopMustProgress(const Expr *ControllingExpression, + bool IsTrivialCXXLoop) { + if (CGM.get

[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #90389)

2024-04-30 Thread Eli Friedman via cfe-commits
@@ -3133,15 +3149,13 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, // Copy into a temporary if the type is more aligned than the // register save area. -if (TyAlign.getQuantity() > 8) { - Address Tmp = CGF.CreateMemTemp(Ty); +

[clang] [X86_64] Fix empty field error in vaarg of C++. (PR #90389)

2024-04-30 Thread Eli Friedman via cfe-commits
@@ -3122,9 +3122,25 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1)); RegAddr = Tmp.withElementType(LTy); - } else if (neededInt) { -RegAddr = Address(CGF.Builder.CreateG

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -715,6 +772,11 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { if (CXXRD->getNumBases()) return false; + // See comment in getPadding(). + bool ZeroInitPadding = !CGM.getLangOpts().CPlusPlus; efriedma-quic wrot

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -1745,13 +1748,48 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr( // Default-initialize to null. EmitNullInitializationToLValue(FieldLoc); } +if (ZeroInitPadding) { + CharUnits TotalSize = + Dest.getPreferredSize(CGF.getContext(), D

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -5819,3 +5819,24 @@ specify the starting offset to begin embedding from. The resources is treated as being empty if the specified offset is larger than the number of bytes in the resource. The offset will be applied *before* any ``limit`` parameters are applied. + +Union an

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -1745,13 +1748,48 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr( // Default-initialize to null. EmitNullInitializationToLValue(FieldLoc); } +if (ZeroInitPadding) { + CharUnits TotalSize = + Dest.getPreferredSize(CGF.getContext(), D

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -361,6 +368,13 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, } return GV; } + if (!getLangOpts().CPlusPlus) { +// In C, when an initializer is given, the Linux kernel relies on clang to +// zero-initialize all members not explicitly

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -42,6 +42,66 @@ using namespace CodeGen; namespace { class ConstExprEmitter; +llvm::Constant *getPadding(const CodeGenModule &CGM, CharUnits PadSize) { + if (!CGM.getLangOpts().CPlusPlus) { +// In C23 (N3096) $6.7.10: +// """ +// If any object is initialized wi

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-27 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,219 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=gnu11 -verify -emit-llvm %s -o - | FileCheck %s efriedma-quic wrote: update_cc_test_checks.py, maybe? Unless it doesn't generate clear checks for some reason. https://github.com/llvm/ll

[clang] [llvm] [ARM] musttail fixes (PR #102896)

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

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-28 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: What's the state of byval handling with the current version of the patch? https://github.com/llvm/llvm-project/pull/102896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-28 Thread Eli Friedman via cfe-commits
@@ -4,6 +4,28 @@ ; CHECK-NOT: vmov efriedma-quic wrote: Extra check lines https://github.com/llvm/llvm-project/pull/102896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-28 Thread Eli Friedman via cfe-commits
@@ -3056,18 +3014,26 @@ bool ARMTargetLowering::IsEligibleForTailCallOptimization( // Exception-handling functions need a special set of instructions to indicate // a return to the hardware. Tail-calling another function would probably // break this. - if (CallerF.hasF

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-28 Thread Eli Friedman via cfe-commits
@@ -3056,18 +3014,26 @@ bool ARMTargetLowering::IsEligibleForTailCallOptimization( // Exception-handling functions need a special set of instructions to indicate // a return to the hardware. Tail-calling another function would probably // break this. - if (CallerF.hasF

[clang] Fix #104794: Fixed sret bugs with `clang::musttail` on 32 bit targets (PR #104795)

2024-08-29 Thread Eli Friedman via cfe-commits
@@ -5085,7 +5085,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, RawAddress SRetAlloca = RawAddress::invalid(); llvm::Value *UnusedReturnSizePtr = nullptr; if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) { -if (IsVirtu

[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (PR #97121)

2024-08-29 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: It probably makes sense to add a helper like the following to CodeGenModule or something like that: ``` bool shouldZeroInitPadding() { // Comment explaining reasoning for this rule return !CGM.getLangOpts().CPlusPlus; } ``` So we don't have `//

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-30 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,43 @@ +; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s + +; The repro example from https://github.com/llvm/llvm-project/issues/57069#issuecomment-1212754850 +; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind sspstrong willreturn memory(none)

[clang] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-30 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,43 @@ +; RUN: llc -mtriple=arm-eabi %s -o - | FileCheck %s efriedma-quic wrote: Please generate checks with update_llc_test_checks.py https://github.com/llvm/llvm-project/pull/102896 ___ cfe-commits mailing

[clang] fix kcfi doesn't take effect when callee function has no input parameter (PR #106677)

2024-08-30 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: If a function is declared without a prototype (pre-C23), it doesn't mean it has a void argument list; it means the argument list is undeclared. So you can't just assume the argument list is void; you have to compute the argument types from the actua

[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-09-03 Thread Eli Friedman via cfe-commits
@@ -45,7 +45,7 @@ void test3(packedfloat3 *p) { *p = (packedfloat3) { 3.2f, 2.3f, 0.1f }; } // CHECK: @test3( -// CHECK: store <4 x float> {{.*}}, align 4 +// CHECK: store <3 x float> {{.*}}, align 4 efriedma-quic wrote: On targets with SIMD vectors (basical

[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-09-03 Thread Eli Friedman via cfe-commits
@@ -45,7 +45,7 @@ void test3(packedfloat3 *p) { *p = (packedfloat3) { 3.2f, 2.3f, 0.1f }; } // CHECK: @test3( -// CHECK: store <4 x float> {{.*}}, align 4 +// CHECK: store <3 x float> {{.*}}, align 4 efriedma-quic wrote: > that sounds essentially what the op

[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Under the proposed ABI, `&&A-&&B` is actually "sign(A)-sign(B)". Which is a constant, but not one which can be represented as a relocation (as far as I know). https://github.com/llvm/llvm-project/pull/97647 ___ cfe-commits maili

[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The issue is just that clang expects the following to compile. And with the current version of the patch, I think we end up crashing in the backend. ``` @f.x = internal global i32 trunc (i64 sub (i64 ptrtoint (ptr blockaddress(@f, %A) to i64), i64 ptrtoint (ptr blockaddre

<    4   5   6   7   8   9   10   11   12   13   >