[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-25 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,321 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=armv7a-none-eabi %s -o - | FileCheck %s + +declare i32 @many_args_callee(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) + +define i32 @many

[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-25 Thread Eli Friedman via cfe-commits
@@ -12658,10 +12658,10 @@ This instruction requires several arguments: the return value of the callee is returned to the caller's caller, even if a void return type is in use. - Both markers imply that the callee does not access allocas from the caller. - The `

[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-25 Thread Eli Friedman via cfe-commits
@@ -5112,7 +5112,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] Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C" (PR #109898)

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

[clang] Revert "[clang][CodeGen] Zero init unspecified fields in initializers in C" (PR #109898)

2024-09-24 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/109898 Reverts llvm/llvm-project#97121 Causing failures on LNT bots; log shows a crash in ConstStructBuilder::BuildStruct. >From cf31625ebefd05e8ca07f6f6b664d9a5bee9cd0f Mon Sep 17 00:00:00 2001 From: Eli Fried

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

2024-09-23 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM I think we'll need to watch out for performance regressions... in most cases, we can probably zero-pad cheaply, but there might be cases where it isn't cheap, or cases where it should be cheap but the LLVM backend can't figure i

[clang] [compiler-rt] [clang][CodeGen] Use byval for SystemZ indirect arguments (PR #66404)

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

[clang] [llvm] [Loads] Check context instruction for context-sensitive derefability (PR #109277)

2024-09-20 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Yes, that makes sense, thanks. https://github.com/llvm/llvm-project/pull/109277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)

2024-09-20 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: getAddrOfCurrentPosition() is one way to do it... but it's not the only way to do it. It was specifically designed to handle cases in CGExprConstant that would have been difficult to refactor otherwise. Here, it's simple to compute the correct address beforehand, so you c

[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)

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

[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)

2024-09-20 Thread Eli Friedman via cfe-commits
@@ -738,7 +738,7 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { // Zero-sized fields are not emitted, but their initializers may still // prevent emission of this struct as a constant. if (isEmptyFieldForLayout(CGM.getContext(), F

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-20 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, that makes sense... so the issue is generally with functions we emit lazily? I'd say it's reasonable to emit an error if we have two definitions for the same symbol, even if we don't end up emitting them because they're deferred. Lazy emission is an optimization, and

[clang] [clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation (PR #109208)

2024-09-19 Thread Eli Friedman via cfe-commits
@@ -8573,7 +8661,10 @@ class LValueExprEvaluator bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E); bool VisitMemberExpr(const MemberExpr *E); - bool VisitStringLiteral(const StringLiteral *

[clang] [llvm] [Loads] Check context instruction for context-sensitive derefability (PR #109277)

2024-09-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Please update the documentation for isSafeToSpeculativelyExecute() to specify the semantics in the case where the operands of the instruction don't dominate CtxI. https://github.com/llvm/llvm-project/pull/109277 ___ cfe-commits m

[clang] [lld] [llvm] [mlir] [IR] Introduce `T` to `DataLayout` to represent flat address space if a target supports it (PR #108786)

2024-09-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > If DataLayout is still a good place, then it might be just about whether we > call it a flat address space, or optimizable address space, and nothing would > be different from what is done in this PR. We've avoided putting optimization properties in the DataLayout in the

[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)

2024-09-19 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefixes=CHECK +// RUN: %clang_cc1 -x c++ %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefixes=CHECK-CXX + +union Foo { + struct Empty {} val; +}; + +u

[clang] [clang][CodeGen] Check initializer of zero-size fields for nullptr (PR #109271)

2024-09-19 Thread Eli Friedman via cfe-commits
@@ -738,7 +738,7 @@ bool ConstStructBuilder::Build(const InitListExpr *ILE, bool AllowOverwrite) { // Zero-sized fields are not emitted, but their initializers may still // prevent emission of this struct as a constant. if (isEmptyFieldForLayout(CGM.getContext(), F

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

2024-09-18 Thread Eli Friedman via cfe-commits
@@ -870,6 +904,15 @@ bool ConstStructBuilder::Build(const APValue &Val, const RecordDecl *RD, if (!EltInit) return false; +if (ZeroInitPadding) { + if (!DoZeroInitPadding(Layout, FieldNo, *Field, SizeSoFar, + IsFlexibleArray, All

[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove feature sha1 from FMV. (PR #108383)

2024-09-18 Thread Eli Friedman via cfe-commits
@@ -33,7 +33,6 @@ enum CPUFeatures { FEAT_FP, FEAT_SIMD, FEAT_CRC, - FEAT_SHA1, efriedma-quic wrote: We've generally been more conservative with compiler-rt.builtins compared with other parts of compiler-rt, like sanitizers. People do ship static lib

[clang] [PowerPC] Fix incorrect store alignment for __builtin_vsx_build_pair() (PR #108606)

2024-09-17 Thread Eli Friedman via cfe-commits
@@ -18197,7 +18197,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, CallOps.push_back(Ops[i]); llvm::Function *F = CGM.getIntrinsic(ID); Value *Call = Builder.CreateCall(F, CallOps); -return Builder.CreateAlignedStore(Call, Ops[0], MaybeAli

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-17 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: In the example in https://github.com/llvm/llvm-project/pull/107581#issuecomment-2343651051 , there are four relevant calls to GetOrCreateLLVMFunction: one for each function with IsInDefinition false, and one for each function with IsInDefinition true. The last of those c

[clang] [PowerPC] Fix incorrect store alignment for __builtin_vsx_build_pair() (PR #108606)

2024-09-17 Thread Eli Friedman via cfe-commits
@@ -18197,7 +18197,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, CallOps.push_back(Ops[i]); llvm::Function *F = CGM.getIntrinsic(ID); Value *Call = Builder.CreateCall(F, CallOps); -return Builder.CreateAlignedStore(Call, Ops[0], MaybeAli

[clang] [PowerPC] Fix incorrect store alignment for __builtin_vsx_build_pair() (PR #108606)

2024-09-16 Thread Eli Friedman via cfe-commits
@@ -18197,7 +18197,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, CallOps.push_back(Ops[i]); llvm::Function *F = CGM.getIntrinsic(ID); Value *Call = Builder.CreateCall(F, CallOps); -return Builder.CreateAlignedStore(Call, Ops[0], MaybeAli

[clang] Reland "[clang] Add nuw attribute to GEPs (#105496)" (PR #107257)

2024-09-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > Should be fixed by > https://github.com/llvm/llvm-project/commit/940f89255e4a3982d94dad57837e8e658092af78. I quickly glanced through the other uses of setIsInBounds in LLVM; the one in CodeGenPrepare seems suspicious. https://github.com/llvm/llvm-project/pull/107257 ___

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > I see that it is set and the reason the existing error is not emitted is > because of the !Entry->isDeclaration() condition. For non-lambda methods, the way this works it that we call GetOrCreateLLVMFunction for both methods... for the first method, the `!Entry->isDecla

[clang] [clang][codegen] Don't mark "int" TBAA on FP libcalls with indirect args (PR #108853)

2024-09-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: How does this interact with #107598? https://github.com/llvm/llvm-project/pull/108853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PAC] Fix address discrimination for type info vtable pointers (PR #102199)

2024-09-16 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I think you should be able to avoid constructing the initializer twice if you restructure the code a bit to just construct the global before the call to BuildVTablePointer. I added GlobalVariable::replaceInitializer because I was looking at this rev

[clang] [lld] [llvm] [mlir] [IR] Introduce `T` to `DataLayout` to represent flat address space if a target supports it (PR #108786)

2024-09-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Both in InferAddressSpaces, and in Attributor, you don't really care about whether a flat address-space exists. All you really need to know is whether, for a given pair of address-spaces "A" and "B", `addrspacecast ptr addrspace(A) %x to ptr addrspace(B)` should be optimi

[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove feature sha1 from FMV. (PR #108383)

2024-09-12 Thread Eli Friedman via cfe-commits
@@ -33,7 +33,6 @@ enum CPUFeatures { FEAT_FP, FEAT_SIMD, FEAT_CRC, - FEAT_SHA1, efriedma-quic wrote: Are there ABI stability concerns if you modify this enum? https://github.com/llvm/llvm-project/pull/108383

[clang] Reland "[clang] Add nuw attribute to GEPs (#105496)" (PR #107257)

2024-09-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Reproduced: https://godbolt.org/z/G4jrhdjef . Looks like an instcombine bug. https://github.com/llvm/llvm-project/pull/107257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-11 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Sure, it makes sense to print a diagnostic for lambdas. - I'm having a bit of trouble understanding the way the new code is structured. What makes the definition of lambda call operators special here? Do we not call GetOrCreateLLVMFunction with IsForDefinition set?

[clang] [NFC] Move warning from CodeGen to Sema. (PR #107397)

2024-09-09 Thread Eli Friedman via cfe-commits
@@ -6784,6 +6784,10 @@ def warn_arc_lifetime_result_type : Warning< "ARC %select{unused|__unsafe_unretained|__strong|__weak|__autoreleasing}0 " "lifetime qualifier on return type is ignored">, InGroup; +def warn_next_larger_fp_type_same_size_than_fp : Warning< + "higher

[clang] [llvm] [ARM] Save floating point registers and status registers with save_fp function attribute (PR #89654)

2024-09-09 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,34 @@ +// REQUIRES: arm-registered-target +// RUN: %clang -target arm-none-none-eabihf -mcpu=cortex-r5 -mfpu=vfpv3-d16 -marm -S -o - %s \ +// RUN: | FileCheck %s --check-prefix=CHECK-R +// RUN: %clang -target arm-none-none-eabihf -mcpu=cortex-r5 -mfpu=vfpv3-d16 -mthum

[clang] [lld] [llvm] [clang][MIPS] Add support for mipsel-windows-* targets (PR #107744)

2024-09-09 Thread Eli Friedman via cfe-commits
=?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Poussineau , =?utf-8?q?Hervé?= Po

[clang] [HLSL] Allow truncation to scalar (PR #104844)

2024-09-09 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: ExprConstant.cpp currently assumes that an CK_HLSLVectorTruncation can't return a scalar type. https://github.com/llvm/llvm-project/pull/104844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The relevant bit of code is: ``` // The OpenCL operator with a vector condition is sufficiently // different to merit its own checker. if ((getLangOpts().OpenCL && Cond.get()->getType()->isVectorType()) || Cond.get()->getType()->isExtVectorType()) return Open

[clang] [Clang] Add __builtin_selectvector and use it for AVX512 intrinsics (PR #91306)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: You mean, if all three operands are boolean vectors? I'm surprised that doesn't already work. https://github.com/llvm/llvm-project/pull/91306 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: (You shouldn't need to special-case lambdas; any use of the type needs the appropriate mangling, except maybe the function declaration itself.) https://github.com/llvm/llvm-project/pull/107581 ___ cfe-commits mailing list cfe-comm

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > The SME type attributes are not part of the name mangling If `int(&)() __arm_streaming` is a different type from `int(&)()` for template instantiation, it should have different mangling. If it doesn't, that's a bug. If there is no spec for the correct mangling, someone

[clang] [TBAA] Emit "omnipotent char" for intrinsics with type cast (PR #107793)

2024-09-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: See https://reviews.llvm.org/D119319; CC @sdesmalen-arm @paulwalker-arm https://github.com/llvm/llvm-project/pull/107793 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [Clang] Emit error for duplicate mangled names within a lambda (PR #107581)

2024-09-06 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Isn't this a bug in the mangler? I mean, it's better to print an error rather than silently miscompile, but this doesn't really solve the issue. https://github.com/llvm/llvm-project/pull/107581 ___ cfe-commits mailing list cfe-com

[clang] [llvm] [ARM] Save floating point registers and status registers with save_fp function attribute (PR #89654)

2024-09-06 Thread Eli Friedman via cfe-commits
@@ -338,10 +338,16 @@ def warn_anyx86_excessive_regsave : Warning< InGroup>; def warn_arm_interrupt_vfp_clobber : Warning< "interrupt service routine with vfp enabled may clobber the " - "interruptee's vfp state">, + "interruptee's vfp state; " + "consider using the `int

[clang] [llvm] [ARM] Save floating point registers and status registers with save_fp function attribute (PR #89654)

2024-09-06 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,34 @@ +// REQUIRES: arm-registered-target +// RUN: %clang -target arm-none-none-eabihf -mcpu=cortex-r5 -mfpu=vfpv3-d16 -marm -S -o - %s \ +// RUN: | FileCheck %s --check-prefix=CHECK-R +// RUN: %clang -target arm-none-none-eabihf -mcpu=cortex-r5 -mfpu=vfpv3-d16 -mthum

[clang] [llvm] [DirectX] Add DirectXTargetCodeGenInfo (PR #104856)

2024-09-05 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,53 @@ +//===- DirectX.cpp-===// +// +// 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: Apa

[clang] [clang] Check inline defs when emitting speculative vtable (PR #100785)

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

[clang] [clang] Fix FnInfoOpts::operator&= and FnInfoOpts::operator|= not updating assigned operands (PR #107050)

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

[clang] [clang] Fix FnInfoOpts::operator&= and FnInfoOpts::operator|= not updating assigned operands (PR #107050)

2024-09-05 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM... but in the future, please try to make the commit message indicate what effects this has. (I'll rewrite it this time.) https://github.com/llvm/llvm-project/pull/107050 ___ cfe-commit

[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)

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

[clang] [clang] Check inline defs when emitting speculative vtable (PR #100785)

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

[clang] [Clang][CodeGen] Don't emit assumptions if current block is unreachable. (PR #106936)

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

[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)

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

[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)

2024-09-03 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If there isn't a way to emit conforming code, then I think it's fine to emit non-conforming code, as long as there's an appropriate comment. Breaking the ABI is clearly worse. Does this impact non-MS targets? https://github.com/llvm/llvm-project/pull/107154 _

[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)

2024-09-03 Thread Eli Friedman via cfe-commits
@@ -19553,17 +19555,18 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, // If we're not in C++, diagnose the overflow of enumerator values, // which in C99 means that the enumerator value is not representable in -// an int (C99 6.7.2.2p2).

[clang] [MS] Put dllexported inline global initializers in a comdat (PR #107154)

2024-09-03 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: What's the interaction here with the standard's ordering guarantees? The comment in the code indicates that we can't make a separate comdat for ordered initialization... but inline variables do require partial ordering. Please update the comment as appropriate. https://

[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] [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] 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] [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] [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] [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] 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] [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] [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
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
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] [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] [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
@@ -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
@@ -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
@@ -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] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)

2024-08-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: It doesn't fuse unless AllowFPOpFusion is set. https://github.com/llvm/llvm-project/pull/105746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-08-22 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: Even if we can prove it doesn't trap,

[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)

2024-08-22 Thread Eli Friedman via cfe-commits
@@ -348,20 +348,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, .Default(llvm::FloatABI::Default); // Set FP fusion mode. - switch (LangOpts.getDefaultFPContractMode()) { - case LangOptions::FPM_Off: -// Preserve any contraction performed by the

[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)

2024-08-22 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: Is the backend actually ready for this? Looking quickly at the backend, it looks like target-independent code is fine, but some of the target-specific code doesn't respect the "contract" flag on instructions. https://github.com/llvm/llvm-project/pul

[clang] Honor pragmas with -ffp-contract=fast, depecate fast-honor-pragmas (PR #105746)

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

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Oh, I see. If you can prove that it would be illegal to use a negative index with a particular pointer, you might be able to optimize... but I'm not sure how aggressive we want to be here. Even if the C standard technically disallows indexing past the beginning/end of a

[clang] [clang] Add nuw attribute to GEPs (PR #105496)

2024-08-21 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM; the approach here seems appropriate. (The EmitCheckedInBoundsGEP API could probably use a refactor so we don't have calls to isSignedOverflowDefined() scattered all over the place, but that's a separate issue.) https://github.

[clang] [clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (PR #98138)

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

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

2024-08-19 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] fix divide by zero in ComplexExprEvaluator (PR #104666)

2024-08-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Opened #104738 as a followup. https://github.com/llvm/llvm-project/pull/104666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [PowerPC] Fix codegen for transparent_union function params (PR #101738)

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

[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-08-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The failure is essentially a bootstrap failure. (The buildbot in question is not technically bootstrapping, but it's using clang 18 as the host compiler.) https://github.com/llvm/llvm-project/pull/100724 ___ cfe-commits mailing l

[clang] [clang] Handle tm mangling on Solaris in PPMacroExpansion.cpp (PR #100724)

2024-08-15 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The mangler is in clang/lib/AST/ItaniumMangle.cpp; maybe look at CXXNameMangler::mangleStandardSubstitution. https://github.com/llvm/llvm-project/pull/100724 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

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

2024-08-15 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] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM The other thing you could do is modify ScalarExprEmitter::EmitCompare... if it sees an overflow pattern, it passes that down as an argument to the visit of the add. But I guess given the current structure of the code, that gets

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I think serialization is missing for the new bit on BinaryOperator. I'm not sure why we're storing it in the first place, though; it's queried in exactly one place, so there isn't really any benefit to precomputing it. https://github.com/llvm/llvm-p

[clang] [clang] Check inline defs when emitting speculative vtable (PR #100785)

2024-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM... but please consider submitting a patch to expand the explanation in ItaniumCXXABI::canSpeculativelyEmitVTableAsBaseClass. If I'm following correctly, the function in question is, in fact, odr-used in the translation unit in q

[clang] [clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (PR #98138)

2024-08-14 Thread Eli Friedman via cfe-commits
@@ -106,9 +101,9 @@ class CodeGenTypes { } CodeGenModule &getCGM() const { return CGM; } ASTContext &getContext() const { return Context; } - const ABIInfo &getABIInfo() const { return TheABIInfo; } + const ABIInfo &getABIInfo() const; efriedma-quic wro

[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)

2024-08-14 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Please fix the diagnostics in pre-C23 mode to mention that we're following C23 rules. https://github.com/llvm/llvm-project/pull/103917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/

[clang] [clang] Emit nuw GEPs for array subscript expressions (PR #103088)

2024-08-13 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > adding nuw is also valid for signed indices here I don't understand how you think this would work; a-1 and a+-1 are required to produce the same result. https://github.com/llvm/llvm-project/pull/103088 ___ cfe-commits mailing l

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -3860,6 +3860,7 @@ class CStyleCastExpr final class BinaryOperator : public Expr { enum { LHS, RHS, END_EXPR }; Stmt *SubExprs[END_EXPR]; + bool ExcludedOverflowPattern = false; efriedma-quic wrote: I'd prefer to avoid increasing the size of BinaryOper

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -195,13 +196,23 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { if (!Op.mayHaveIntegerOverflow()) return true; + const UnaryOperator *UO = dyn_cast(Op.E); + + if (UO && UO->getOpcode() == UO_Minus && UO->isIntegerConstantExpr(Ctx)

[clang] [llvm] [HLSL][DXIL][SPIRV] Create llvm dot intrinsic and use for HLSL (PR #102872)

2024-08-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Missing LangRef changes. https://github.com/llvm/llvm-project/pull/102872 ___ 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-12 Thread Eli Friedman via cfe-commits
@@ -3088,70 +3057,44 @@ bool ARMTargetLowering::IsEligibleForTailCallOptimization( getEffectiveCallingConv(CalleeCC, isVarArg), getEffectiveCallingConv(CallerCC, CallerF.isVarArg()), MF, C, Ins, CCAssignFnForReturn(CalleeCC, isVarArg), -

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

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 ; RUN: llc -mtriple armv7 -target-abi aapcs -float-abi soft -O0 -o - < %s \ ; RUN: | FileCheck %s -check-prefix CHECK-SOFT -check-prefix CHECK

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

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -540,6 +540,8 @@ class CCState { }); } + void dump() const; efriedma-quic wrote: `#ifndef NDEBUG`? https://github.com/llvm/llvm-project/pull/102896 ___ cfe-commits mailing list cfe-commits@list

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

2024-08-12 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

  1   2   3   4   5   6   7   8   9   10   >