[clang] [X86][vectorcall] Do not consume register for indirect return value (PR #97939)

2024-07-07 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM I meant, at the beginning of X86_32ABIInfo::computeInfo there's a chain of if statements that set up the properties of different calling conventions, and maybe some bits could be set there. If you don't think that makes sense,

[clang] [RISCV] Handle empty structs/unions passing in C++ (PR #97315)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > What about the case I have mentioned in https://godbolt.org/z/vdhGbvj6W ? That test doesn't really prove anything useful. The zeroing of a0 doesn't have any ABI significance: "struct s12" doesn't have any data in it, so the caller can't use the value in a0 for anything.

[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I'm not against having a security hardening feature to avoid using LR as a GPR. But we'd want to name it something different, to make it clear that it's a security-hardening feature, not a guarantee that the compiler won't clobber LR. https://github.com/llvm/llvm-project/

[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: We have a mechanism which specifically encodes the distinction we want here: ReserveXRegisterForRA. This was implemented for debugging/regression tests (see https://reviews.llvm.org/D132717), but we can expose it more generally. Naming is hard, but maybe `-mavoid-non-call

[clang] [RISCV] Handle empty structs/unions passing in C++ (PR #97315)

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

[clang] [llvm] [AIX] Add -msave-reg-params to save arguments to stack (PR #97524)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Why do we want a module flag, and not a function attribute? Module flags are generally problematic during LTO, so we try to avoid them if they aren't truly necessary. https://github.com/llvm/llvm-project/pull/97524 ___ cfe-commi

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > > For CGClass, it's not directly tied to the LLVM structure layout, but I'm > > not sure the generated code would be semantically correct if an "empty" > > field that isn't isEmpty() overlaps with actual data. > > I haven't addressed this yet. To clarify, are you referri

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-08 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: It looks like in the latest patch, there's still a couple uses of isZeroSize() in CGExprConstant? https://github.com/llvm/llvm-project/pull/96422 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[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

[clang] [clang] Implement function pointer type discrimination (PR #96992)

2024-07-08 Thread Eli Friedman via cfe-commits
@@ -3140,6 +3140,269 @@ ASTContext::getPointerAuthVTablePointerDiscriminator(const CXXRecordDecl *RD) { return llvm::getPointerAuthStableSipHash(Str); } +/// Encode a function type for use in the discriminator of a function pointer +/// type. We can't use the itanium scheme

[clang] [clang] Implement function pointer type discrimination (PR #96992)

2024-07-08 Thread Eli Friedman via cfe-commits
@@ -2220,6 +2220,11 @@ llvm::Constant *ConstantLValueEmitter::emitPointerAuthPointer(const Expr *E) { // The assertions here are all checked by Sema. assert(Result.Val.isLValue()); + auto *Base = Result.Val.getLValueBase().get(); + if (auto *Decl = dyn_cast_or_null(Base

[clang] [llvm] [AArch64] Add -mlr-for-calls-only to replace the now removed -ffixed-x30 flag. (PR #98073)

2024-07-08 Thread Eli Friedman via cfe-commits
@@ -3267,10 +3267,13 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( InsertSEH(MIB, TII, MachineInstr::FrameSetup); } else { // The code when the pair of ZReg is not present MachineInstrBuilder MIB = BuildMI(MBB, MI, DL, TII.get(StrOpc)); - if (!

[clang] [llvm] [AArch64] Add -mlr-for-calls-only to replace the now removed -ffixed-x30 flag. (PR #98073)

2024-07-08 Thread Eli Friedman via cfe-commits
@@ -4917,6 +4917,9 @@ foreach i = {1-31} in def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group, HelpText<"Reserve the x"#i#" register (AArch64/RISC-V only)">; +def mlr_for_calls_only : Flag<["-"], "mlr-for-calls-only">, Group, efriedma-quic wrote: Name

[clang] [llvm] [AIX] Add -msave-reg-params to save arguments to stack (PR #97524)

2024-07-09 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The question is, if LTO merges two bitcode modules together with different settings for the flag, how do you want the backend to behave? Usually you want it to just continue to apply to the same functions it would have without LTO; the only way to represent that is a func

[clang] [llvm] [AArch64] Add -mlr-for-calls-only to replace the now removed -ffixed-x30 flag. (PR #98073)

2024-07-09 Thread Eli Friedman via cfe-commits
@@ -3267,10 +3267,13 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( InsertSEH(MIB, TII, MachineInstr::FrameSetup); } else { // The code when the pair of ZReg is not present MachineInstrBuilder MIB = BuildMI(MBB, MI, DL, TII.get(StrOpc)); - if (!

[clang] [llvm] [AArch64] Add -mlr-for-calls-only to replace the now removed -ffixed-x30 flag. (PR #98073)

2024-07-09 Thread Eli Friedman via cfe-commits
@@ -3267,10 +3267,13 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( InsertSEH(MIB, TII, MachineInstr::FrameSetup); } else { // The code when the pair of ZReg is not present MachineInstrBuilder MIB = BuildMI(MBB, MI, DL, TII.get(StrOpc)); - if (!

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-09 Thread Eli Friedman via cfe-commits
@@ -137,6 +137,16 @@ bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays, bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr = false); +/// isEmptyFieldForLayout - Return true iff the field i

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-09 Thread Eli Friedman via cfe-commits
@@ -1,7 +1,17 @@ -// RUN: %clang_cc1 -emit-llvm < %s | grep "zeroinitializer, i16 16877" +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s // PR4390 struct sysfs_dirent { - union { struct sysfs_elem_dir {} s_dir; }; + union { struct sysfs_elem_dir { int x; } s_dir; }; unsi

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-09 Thread Eli Friedman via cfe-commits
@@ -185,6 +203,18 @@ CALL_AO(PackedMembers) // CHECK: call void @llvm.memcpy.p0.p0.i64({{.*}} align 1 {{.*}} align 1 {{.*}}i64 16, i1 {{.*}}) // CHECK: ret ptr +// WithEmptyField copy-assignment: +// CHECK-LABEL: define linkonce_odr nonnull align {{[0-9]+}} dereferenceable({

[clang] [clang] inherit GD to let the codegen add kcfi type for ifunc (PR #96400)

2024-07-10 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The usual mechanism for emitting deferred definitions involves CodeGenModule::EmitDeferred(): declarations get added to the list by addDeferredDeclToEmit(), then it goes through to emit all the declarations on the list. So it's a matter of making sure the resolver ends up

[clang] [llvm] [AArch64] Add -mlr-for-calls-only to replace the now removed -ffixed-x30 flag. (PR #98073)

2024-07-10 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. The updated approach makes sense, I think. Please check that AArch64TargetLowering::LowerRETURNADDR works correctly when LR is reserved; I think it should just work, but I'm not completely sure. Otherwise LGTM https://github.com/llv

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

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

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

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

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-10 Thread Eli Friedman via cfe-commits
@@ -1,7 +1,19 @@ -// RUN: %clang_cc1 -emit-llvm < %s | grep "zeroinitializer, i16 16877" +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefixes=CHECK,EMPTY +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck %s

[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

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

[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

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

[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

2024-07-11 Thread Eli Friedman via cfe-commits
@@ -152,7 +152,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo { diag::warn_target_unsupported_branch_protection_attribute) << Arch; } else { - BPI.setFnAttributes(*Fn); + setBranchProtectionFnAttributes(BPI, (*Fn

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-11 Thread Eli Friedman via cfe-commits
@@ -310,6 +310,41 @@ bool CodeGen::isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, return true; } +bool CodeGen::isEmptyFieldForLayout(const ASTContext &Context, +const FieldDecl *FD) { + if (FD->isZeroLengthBitField(Con

[clang] [C2y] Claim partial conformance to WG14 N3244 (PR #98525)

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

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

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

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

2024-07-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: > max aligment [...] LLVM Verifier accepts is 2^14 The verifier limit in most places is 2^32. It looks like 2^14 is specifically for ByVal. And there isn't really any good reason for that limit; it was arbitrarily chosen in b567e3ffb0, nearly two decades ago, and could e

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

2024-07-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: (The relevant bitfield is was renamed to MemAlign, and is now in llvm/include/llvm/CodeGen/TargetCallingConv.h) https://github.com/llvm/llvm-project/pull/98629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] Reset PostAllocaInsertPt when the AllocaInsertPt is changed in clang::CodeGenFunction (PR #98668)

2024-07-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Does this affect the generated IR in some existing case? If it does, can you include a regression test in clang/test/CodeGen? https://github.com/llvm/llvm-project/pull/98668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2024-07-12 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: >> How does this interact with StrictFP? > I don't think it related to StrictFP, because we only care whether the global > variable errno is modified? which may bring in alias to other global > variable. As now the type of errno is int, so we record

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

2024-07-12 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,43 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// The test may fail as time out on windows +// REQUIRES: system-linux + +// RUN: %clang -S -O3 -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,

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

2024-07-12 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] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)

2024-07-12 Thread Eli Friedman via cfe-commits
@@ -707,7 +707,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] Limit alignment for emitted vectors (PR #98629)

2024-07-12 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The size of ArgFlagsTy is, as far as I can tell, basically irrelevant: it's only used as part of computing the calling convention in isel. I don't think anyone will notice if it's a few bytes larger. The non-byval alignment limit was last adjusted in https://reviews.llvm

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

2024-07-12 Thread Eli Friedman via cfe-commits
@@ -133,6 +133,7 @@ struct TransferrableTargetInfo { unsigned short SuitableAlign; unsigned short NewAlign; unsigned MaxVectorAlign; efriedma-quic wrote: It's used in the same ASTContext code that's modified by this patch. Probably fine to adjust it fo

[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)

2024-04-15 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(si

[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)

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

[clang] [llvm] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

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

[clang] [NFC] Parameterize Initialization of `clang::CodeGenerator` on a `TargetInfo` instance which may differ from the one in the `ASTContext` (PR #88977)

2024-04-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I don't understand the scenario you're envisioning here. If, for example, `sizeof(long)` is different in the AST vs. CodeGen, everything will very likely explode. And I don't want to make an open-ended commitment to support modifying properties of the target based on wha

[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

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

[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I don't think this works correctly? You need to evaluate both the getCommonExpr(), and the getSubExpr(). https://github.com/llvm/llvm-project/pull/1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang] [Coverage] Handle array decomposition correctly (PR #88881)

2024-04-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Say you have: ``` int foo(); struct A { A(); A(const A&, int = foo()); }; struct B { A a[10]; }; void f(const B& b) { B bb = b; } ``` We want to visit the call to foo(), I think? https://github.com/llvm/llvm-project/pull/1 __

[clang] [Coverage][NFC] Avoid visiting non-unique `OpaqueValueExpr` (PR #88910)

2024-04-16 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Looks like automation didn't trigger for some reason... but quoting the automated message that's supposed to trigger: > ⚠️ We detected that you are using a GitHub private e-mail address to > contribute to the repo. > Please turn off [Keep my email addresses > private](htt

[clang] [ARM64EC] Fix arm_neon.h on ARM64EC. (PR #88572)

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

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Eli Friedman via cfe-commits
@@ -154,11 +154,20 @@ llvm::Value *CodeGen::emitRoundPointerUpToAlignment(CodeGenFunction &CGF, llvm::Value *Ptr, CharUnits Align) { // OverflowArgArea = (OverflowArgArea

[clang] [llvm] [WIP] Expand variadic functions in IR (PR #89007)

2024-04-16 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,1056 @@ +//===-- ExpandVariadicsPass.cpp *- C++ -*-=// +// +// 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: Apach

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

2024-04-17 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: What, if anything, about the scenario you're describing is specific to "normal" cleanups? https://github.com/llvm/llvm-project/pull/89154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: FieldNo and Layout are referring to fields of "RD"; the "Field" found in the recursive visit is a member of Record (or

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-17 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: Maybe instead of looking for RecordDecls, this code should be looking for fields where the type of the field is an anon

[clang] [ARM64EC] Add softintrin.lib as an implicit dependency to object files. (PR #89171)

2024-04-17 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic created https://github.com/llvm/llvm-project/pull/89171 This copies MSVC behavior, and avoids weird link errors in certain cases. >From 617b140cbd0c878bb6f4994d89aae3bbd8ea2754 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 17 Apr 2024 23:04:50 -0700 Su

[clang] [ARM64EC] Add softintrin.lib as an implicit dependency to object files. (PR #89171)

2024-04-17 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/89171 >From 39eeb2e7a0f5d82dffdbcb179a1ec967db235264 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 17 Apr 2024 23:04:50 -0700 Subject: [PATCH] [ARM64EC] Add softintrin.lib as an implicit dependency to o

[clang] [InstallAPI][Tests] Update tests to be resilient to reversion iteration config (PR #89270)

2024-04-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: How hard would it be to make the output here have a consistent order? I mean, emitting diagnostics in a consistent order isn't nearly as important as emitting consistent binaries, but it's still nice to have if we can get it easily. https://github.com/llvm/llvm-project/p

[clang] [clang] Handle trivial_abi attribute for Microsoft ABI. (PR #88857)

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

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -844,7 +847,18 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( if (const FieldDecl *Field = efriedma-quic wrote: > if there's an inner struct that's not accessible, that doesn't affect the > offsets of fields outside of that inner

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

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

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

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

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: We should probably apply the same fix to CountCountedByAttrs. Along those lines, we should be able to handle: ``` struct bar { int count; int array[] __attribute__((counted_by(count))); }; struct foo { struct bar x; }; void init(void * __attribute

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -826,29 +826,31 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) { const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLe

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,22 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + struct bar { +int cou

[clang] [ARM64EC] Add softintrin.lib as an implicit dependency to object files. (PR #89171)

2024-04-18 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic updated https://github.com/llvm/llvm-project/pull/89171 >From 39eeb2e7a0f5d82dffdbcb179a1ec967db235264 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 17 Apr 2024 23:04:50 -0700 Subject: [PATCH] [ARM64EC] Add softintrin.lib as an implicit dependency to o

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,40 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wno-missing-declarations -emit-llvm -o - %s | FileCheck %s + +struct foo { + int x,y,z; + struct bar

[clang] [clang] Handle trivial_abi attribute for Microsoft ABI. (PR #88857)

2024-04-18 Thread Eli Friedman via cfe-commits
@@ -1105,6 +1105,11 @@ bool MicrosoftCXXABI::hasMostDerivedReturn(GlobalDecl GD) const { static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, CodeGenModule &CGM) { + // If the record is marked with the trivial_abi attribute, we don'

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-18 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: For the vector case, I think you want __builtin_convertvector or something like that https://github.com/llvm/llvm-project/pull/89051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/li

[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)

2024-04-19 Thread Eli Friedman via cfe-commits
@@ -8001,6 +8007,22 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, } } +// SME functions may require SVE to be available for unwinding, as the +// value of VG needs to be preserved across streaming-mode changes. +if (CallerFD &

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM Please don't forget to fix CountCountedByAttrs... but it's fine if it's in a followup. https://github.com/llvm/llvm-project/pull/89126 ___ cfe-commits mailing list cfe-commits@lists.ll

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

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

[clang] [ARM64EC] Add softintrin.lib as an implicit dependency to object files. (PR #89171)

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

[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)

2024-04-19 Thread Eli Friedman via cfe-commits
@@ -826,29 +826,32 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField( ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) { const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = getLangOpts().getStrictFlexArraysLe

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

2024-04-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Strictly speaking, I don't think this is NFC. Consider, for example: ``` struct S { struct X { int array[1]; } x; struct Y { int count; int array[] __attribute__((__counted_by__(count))); } y; }; void f(void* __attribute__((pass_dynamic_object_size(0; void g(struct

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

2024-04-19 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If you can pull it off without increasing the size of Decl, sure; not sure it's worthwhile otherwise. https://github.com/llvm/llvm-project/pull/89462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/c

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

2024-04-19 Thread Eli Friedman via cfe-commits
@@ -930,12 +931,12 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, // Get the flexible array member Decl. const RecordDecl *OuterRD = nullptr; - std::string FAMName; + const FieldDecl *FAMDecl = nullptr; if (const auto *ME = dyn_cast(Bas

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

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

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

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

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-22 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,194 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature +fullbf16 -S -emit-llvm %s -o - | FileCheck %s +// CHECK-LABEL: define dso_local half @test

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: Looks like automation didn't trigger, but: > ⚠️ We detected that you are using a GitHub private e-mail address to > contribute to the repo. > Please turn off [Keep my email addresses > private](https://github.com/settings/emails) setting in your account. > See [LLVM > Dis

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

2024-04-22 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: I'm still not happy with the AST representation here. The current representation is likely to cause unpredictable results in edge cases, and compatibility constraints mean whatever result the current version happens to produce for those cases is locked in forever. And th

[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] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

2024-05-11 Thread Eli Friedman via cfe-commits
@@ -792,7 +792,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState &State, return ABIArgInfo::getDirect(); return ABIArgInfo::getExpand(); } -return getIndirectResult(Ty, /*ByVal=*/false, State); +return getIndirectResult(Ty, IsVe

[clang] [X86][vectorcall] Pass built types byval when xmm0~6 exhausted (PR #91846)

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

[clang] [llvm] [BPF] Fix linking issues in static map initializers (PR #91310)

2024-05-12 Thread Eli Friedman via cfe-commits
@@ -1950,8 +1950,22 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) { if (D->hasAttr()) return CGM.GetWeakRefReference(D).getPointer(); -if (auto FD = dyn_cast(D)) - return CGM.GetAddrOfFunction(FD); +if (auto FD = dyn_cast(D)) {

[clang] [Clang][AArch64][SVE] Allow write to SVE vector elements using the subscript operator (PR #91965)

2024-05-13 Thread Eli Friedman via cfe-commits
@@ -4180,8 +4180,10 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, // If the base is a vector type, then we are forming a vector element lvalue // with this subscript. - if (E->getBase()->getType()->isVectorType() && - !isa(E->getBase

[clang] [Clang][AArch64][SVE] Allow write to SVE vector elements using the subscript operator (PR #91965)

2024-05-13 Thread Eli Friedman via cfe-commits
@@ -88,3 +88,13 @@ float subscript_float32(svfloat32_t a, size_t b) { double subscript_float64(svfloat64_t a, size_t b) { return a[b]; } + +// CHECK-LABEL: @subscript_write_float32( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[VECINS:%.*]] = insertelement [[A:%.*]], float 1

[clang] [llvm] [clang][SPIR-V] Add support for AMDGCN flavoured SPIRV (PR #89796)

2024-05-14 Thread Eli Friedman via cfe-commits
@@ -6088,6 +6088,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, StringRef Prefix = llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch()); if (!Prefix.empty()) { +if (Prefix == "spv" && +getTarget().getTr

[clang] [Clang] Fix incorrect passing of _BitInt args (PR #90741)

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

[clang] [Clang][objectsize] Generate object size calculation for sub-objects (PR #86858)

2024-05-14 Thread Eli Friedman via cfe-commits
@@ -1052,6 +1053,165 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +class ObjectSizeVisitor +: public ConstStmtVisitor { + bool SkipASE; + +

[clang] [Clang][objectsize] Generate object size calculation for sub-objects (PR #86858)

2024-05-14 Thread Eli Friedman via cfe-commits
@@ -1052,6 +1053,165 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, return Builder.CreateSelect(Cmp, Res, ConstantInt::get(ResType, 0, IsSigned)); } +namespace { + +class ObjectSizeVisitor +: public ConstStmtVisitor { + bool SkipASE; + +

<    2   3   4   5   6   7   8   9   10   11   >