[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-11-06 Thread John McCall via cfe-commits
@@ -1780,6 +1780,14 @@ class TargetInfo : public TransferrableTargetInfo, return 0; } + /// \returns Target specific address space for indirect (e.g. sret) arguments. + /// If such an address space exists, it must be convertible to and from the + /// alloca address s

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
https://github.com/rjmccall requested changes to this pull request. https://github.com/llvm/llvm-project/pull/116991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { if (!CodeGenOpts.PointerTBAA) return AnyPtr; // Compute the depth of the pointer and generate a tag of the form "p -// ". +// ". Look through pointer and array types to

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
@@ -230,6 +232,11 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { ->getString(); TyName = Name; } else { + // Be conservative if the type a MemberPointerType. Those would require + // stripping const-qualifiers inside the typ

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { if (!CodeGenOpts.PointerTBAA) return AnyPtr; // Compute the depth of the pointer and generate a tag of the form "p -// ". +// ". Look through pointer and array types to

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { if (!CodeGenOpts.PointerTBAA) return AnyPtr; // Compute the depth of the pointer and generate a tag of the form "p -// ". +// ". Look through pointer and array types to

[clang] [CodeGen] Do not emit call site attributes for LLVM intrinsics. (PR #116881)

2024-11-19 Thread John McCall via cfe-commits
rjmccall wrote: Yeah, that's my take as well. Anything we do to make this work better risks being interpreted as treating this as somehow supported, which it absolutely is not. https://github.com/llvm/llvm-project/pull/116881 ___ cfe-commits mailing

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-20 Thread John McCall via cfe-commits
rjmccall wrote: Hmm. We're talking here about C++'s type similarity rules, which come from C++ [conv.qual]p1: > A cv-decomposition of a type T is a sequence of cv_i and P_i such that T is > “cv_0 P_0 cv_1 P_1 ··· cv_n−1 P_n−1 cv_n U” for n ≥ 0, where each cv_i is a > set of cv-qualifiers, an

[clang] [TBAA] Don't emit pointer tbaa for unnamed structs or unions. (PR #116596)

2024-11-19 Thread John McCall via cfe-commits
@@ -230,6 +230,15 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { ->getString(); TyName = Name; } else { + // For unnamed structs or unions C's compatible types rule applies. Two + // compatible types in different compilation

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
rjmccall wrote: Address spaces from language dialects generally have required relationships and behaviors in the language, and that really shouldn't be overridden by targets. However, targets do need to be able to decide how target-specific address spaces work, including how they interact with

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
rjmccall wrote: I'm not sure what you're saying would need to pulled into a .cpp file. It looks like there's only one actual call to `TI.isAddressSpaceSupersetOf`, so if you just pass around an `ASTContext &` to that point, nothing else will need to drill into it. And frankly that entire exp

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
rjmccall wrote: Oh, you can just forward-declare `class ASTContext` at the top of that file. It's funny that that isn't already there. https://github.com/llvm/llvm-project/pull/115777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
rjmccall wrote: > Okay the problem with using `ASTContext` here is that it creates some > recursive includes. ~I can do this by moving the check into `Type.cpp` > instead, so this will be function call instead of being inlined.~ This would > require a lot of extra stuff so I'm going to defer i

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
@@ -697,45 +699,21 @@ class Qualifiers { /// every address space is a superset of itself. /// CL2.0 adds: /// __generic is a superset of any address space except for __constant. - static bool isAddressSpaceSupersetOf(LangAS A, LangAS B) { -// Address spaces must

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: Broadly LGTM. A few structural requests. https://github.com/llvm/llvm-project/pull/115777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
@@ -17,34 +17,34 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/NVPTXAddrSpace.h" #include "llvm/TargetParser/Triple.h" #include namespace clang { namespace targets { static cons

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
@@ -31,6 +31,7 @@ namespace clang { template class CanProxy; template struct CanProxyAdaptor; class CXXRecordDecl; +class ASTContext; rjmccall wrote: Minor nit: these are alphabetized. https://github.com/llvm/llvm-project/pull/115777 _

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/115777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

2024-11-13 Thread John McCall via cfe-commits
@@ -697,45 +699,21 @@ class Qualifiers { /// every address space is a superset of itself. /// CL2.0 adds: /// __generic is a superset of any address space except for __constant. - static bool isAddressSpaceSupersetOf(LangAS A, LangAS B) { -// Address spaces must

[clang] [clang] Set FPOptions at the beginning of CompoundStmt (PR #111654)

2024-11-17 Thread John McCall via cfe-commits
rjmccall wrote: I'm sorry if you've explained this before, but I thought our general approach was to just store the options in individual expressions, and CodeGen should in general already be paying attention to those options. Is there a specific reason we also need to honor these at the comp

[clang] [AArch64][ARM] Treat __bf16 as vendor extension type for C++ name mangling substitution (PR #115956)

2024-11-17 Thread John McCall via cfe-commits
rjmccall wrote: The ABI spec is pretty clear about this, and demangling is likely to get very screwed up because of the inconsistency. I think should do the following: - We should file a bug with GCC pointing out the problem. - We should fix the bug under new `-fclang-abi-compat=` versions, bu

[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding if an address space is compatible (PR #115777)

2024-11-14 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. Code LGTM. I would still prefer this PR to just contain the NFC refactor, with a follow up that adds the semantic changes to the AMDGPU and NVPTX targets. https://github.com/llvm/llvm-project/pull/115777 ___

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-11-14 Thread John McCall via cfe-commits
@@ -5390,11 +5390,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, V->getType()->isIntegerTy()) V = Builder.CreateZExt(V, ArgInfo.getCoerceToType()); -// If the argument doesn't match, perform a bitcast to coerce it. This -

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-11-14 Thread John McCall via cfe-commits
@@ -5390,11 +5390,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, V->getType()->isIntegerTy()) V = Builder.CreateZExt(V, ArgInfo.getCoerceToType()); -// If the argument doesn't match, perform a bitcast to coerce it. This -

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-11-14 Thread John McCall via cfe-commits
@@ -5159,16 +5156,19 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, } else if (!ReturnValue.isNull()) { SRetPtr = ReturnValue.getAddress(); } else { - SRetPtr = CreateMemTemp(RetTy, "tmp", &SRetAlloca); + SRetPtr = CreateMemTempWith

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -1780,6 +1786,15 @@ void CXXNameMangler::mangleDeviceStubName(const IdentifierInfo *II) { << II->getName(); } +void CXXNameMangler::mangleOCLDeviceStubName(const IdentifierInfo *II) { + // ::= __clang_ocl_kern_imp_ + // ::= [n] + // ::= + StringRef OCLDevi

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -5692,7 +5692,10 @@ CGCallee CodeGenFunction::EmitCallee(const Expr *E) { // Resolve direct calls. } else if (auto DRE = dyn_cast(E)) { if (auto FD = dyn_cast(DRE->getDecl())) { - return EmitDirectCallee(*this, FD); + auto CalleeDecl = FD->hasAttr() +

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
https://github.com/rjmccall requested changes to this pull request. https://github.com/llvm/llvm-project/pull/115821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -2343,6 +2343,15 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, // Collect function IR attributes from the CC lowering. // We'll collect the paramete and result attributes later. CallingConv = FI.getEffectiveCallingConvention(); + GlobalDecl GD = Calle

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -1085,8 +1085,10 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { blockAddr.getPointer(), ConvertType(blockInfo.getBlockExpr()->getType())); if (IsOpenCL) { -CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, Inv

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -1780,6 +1786,15 @@ void CXXNameMangler::mangleDeviceStubName(const IdentifierInfo *II) { << II->getName(); } +void CXXNameMangler::mangleOCLDeviceStubName(const IdentifierInfo *II) { + // ::= __clang_ocl_kern_imp_ + // ::= [n] + // ::= + StringRef OCLDevi

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-02 Thread John McCall via cfe-commits
@@ -71,14 +71,19 @@ class GlobalDecl { GlobalDecl(const FunctionDecl *D, unsigned MVIndex = 0) : MultiVersionIndex(MVIndex) { if (!D->hasAttr()) { + if (D->hasAttr()) { +Value.setPointerAndInt(D, unsigned(KernelReferenceKind::Kernel)); +return;

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2024-12-03 Thread John McCall via cfe-commits
@@ -1085,8 +1085,10 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { blockAddr.getPointer(), ConvertType(blockInfo.getBlockExpr()->getType())); if (IsOpenCL) { -CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, Inv

[clang] [Clang] [NFC] Migrate visitors in ARCMigrate (PR #116792)

2024-12-05 Thread John McCall via cfe-commits
rjmccall wrote: Apple actually removed this migrator from Xcode 16. As far as Apple is concerned, this is now dead code, and we intend to open a PR to remove it (but thank you for the prompt!). https://github.com/llvm/llvm-project/pull/116792 ___ cfe

[clang] [flang] [Clang] Remove ARCMigrate (PR #119269)

2024-12-09 Thread John McCall via cfe-commits
rjmccall wrote: Yes, I believe that's essentially just a version of the rewriter that uses a different ABI (it tries to match the non-fragile Apple ObjC runtime rather than the fragile one). https://github.com/llvm/llvm-project/pull/119269 ___ cfe-co

[clang] [flang] [Clang] Remove ARCMigrate (PR #119269)

2024-12-09 Thread John McCall via cfe-commits
rjmccall wrote: `test/Rewrite` is for the Objective-C => MSVC-compatible C++ rewriter (`-rewrite-objc`), which is a different feature. That feature might *also* be obsolete, but we haven't signed off on that yet AFAIK. https://github.com/llvm/llvm-project/pull/119269 _

[clang] [clang] Use a Worklist for some CodeGenFunctions (PR #115395)

2025-01-01 Thread John McCall via cfe-commits
@@ -0,0 +1,37 @@ +// RUN: split-file %s %t +// RUN: python %t/gen.py %t/switch-overflow.c %t/tmp.c && %clang_cc1 -emit-llvm %t/tmp.c -o - | FileCheck %t/tmp.c + +//--- gen.py rjmccall wrote: If you don't mind working on the representation issue, I think that wou

[clang] [clang][Sema] Fix type of an statement expression ending with an atomic type (PR #119711)

2025-02-03 Thread John McCall via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -15919,10 +15919,17 @@ ExprResult Sema::ActOnStmtExprResult(ExprResult ER) { if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)

[clang] [clang][Sema] Fix type of an statement expression ending with an atomic type (PR #119711)

2025-02-03 Thread John McCall via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/119711 ___ cfe-commits mailing list cf

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-30 Thread John McCall via cfe-commits
@@ -2489,6 +2489,81 @@ are listed below. $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc +Strict Aliasing +--- + +The C and C++ standards require accesses to objects in memory to use l-values of +an appropriate type for the object. This is

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-30 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/122116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-02-04 Thread John McCall via cfe-commits
rjmccall wrote: We're documenting a weaker guarantee than we implement, yes. https://github.com/llvm/llvm-project/pull/122116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Fix type of an statement expression ending with an atomic type (PR #119711)

2025-02-04 Thread John McCall via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -15919,10 +15919,17 @@ ExprResult Sema::ActOnStmtExprResult(ExprResult ER) { if (Cast && Cast->getCastKind() == CK_ARCConsumeObject)

[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

2025-02-07 Thread John McCall via cfe-commits
@@ -256,7 +277,7 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { // similar-types rule. const auto *RT = Ty->getAs(); if (!RT) -return AnyPtr; +return getAnyPtr(); rjmccall wrote: This and the site below sho

[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

2025-02-10 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: Functionality LGTM; just some suggested tweaks to the comments. https://github.com/llvm/llvm-project/pull/126047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

2025-02-10 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/126047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

2025-02-10 Thread John McCall via cfe-commits
@@ -80,6 +80,28 @@ llvm::MDNode *CodeGenTBAA::getChar() { return Char; } +llvm::MDNode *CodeGenTBAA::getAnyPtr(unsigned PtrDepth) { + assert(PtrDepth >= 1 && "Pointer must have some depth"); + + // Populate at least PtrDepth elements in AnyPtrs. These are the type nodes +

[clang] [Clang] Add GCC's __builtin_stack_address() to Clang. (PR #121332)

2025-01-30 Thread John McCall via cfe-commits
rjmccall wrote: I agree with Nikita. I have no problem with supporting this builtin, but it feels like something that should be expressed portably as an IR intrinsic and then get lowered in the backend rather than needing frontend work for every target. https://github.com/llvm/llvm-project/pu

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
@@ -800,7 +800,9 @@ static ABIArgInfo classifyExpandedType(SwiftAggLowering &lowering, if (lowering.empty()) { return ABIArgInfo::getIgnore(); } else if (lowering.shouldPassIndirectly(forReturn)) { -return ABIArgInfo::getIndirect(alignmentForIndirect, /*byval*/ fal

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/114062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
https://github.com/rjmccall requested changes to this pull request. I'm fine with how you're handling the address spaces for now. I'd like to talk about the rule you're implementing, though. It looks like it's supposed to be: - return values always use the alloca AS - arguments always use the

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
@@ -225,7 +225,9 @@ ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty, bool Variadic, // Records with non-trivial destructors/copy-constructors should not be // passed by value. if (auto RAA = getRecordArgABI(Ty, getCXXABI())) - return getNaturalAlign

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/114062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-10 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/114062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][NFC] Increase NumStmtBits by 2 as we are approaching the limit (PR #120341)

2024-12-17 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: Let's just increase to 9 bits. Have you checked whether the size of `Stmt` or `Expr` changes when you do this? https://github.com/llvm/llvm-project/pull/120341 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang] [clang][NFC] Increase NumStmtBits by 2 as we are approaching the limit (PR #120341)

2024-12-18 Thread John McCall via cfe-commits
rjmccall wrote: > > > Let's just increase to 9 bits. > > > Have you checked whether the size of `Stmt` or `Expr` changes when you do > > > this? > > > > > > @rjmccall I've changed it to 9 bits and checked that `Stmt` and `Expr` are > > still 8 bytes and 16 bytes resp.. > > I think checking j

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-12 Thread John McCall via cfe-commits
@@ -800,7 +800,9 @@ static ABIArgInfo classifyExpandedType(SwiftAggLowering &lowering, if (lowering.empty()) { return ABIArgInfo::getIgnore(); } else if (lowering.shouldPassIndirectly(forReturn)) { -return ABIArgInfo::getIndirect(alignmentForIndirect, /*byval*/ fal

[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-12-12 Thread John McCall via cfe-commits
@@ -225,7 +225,9 @@ ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty, bool Variadic, // Records with non-trivial destructors/copy-constructors should not be // passed by value. if (auto RAA = getRecordArgABI(Ty, getCXXABI())) - return getNaturalAlign

[clang] [clang][NFC] Increase NumStmtBits by 2 as we are approaching the limit (PR #120341)

2024-12-20 Thread John McCall via cfe-commits
rjmccall wrote: > FYI it looks like this has a fairly large impact on compile-time, esp at `O0` > with a clang host compiler > (https://llvm-compile-time-tracker.com/compare.php?from=1fcb6a9754a8db057e18f629cb90011b638901e7&to=4797437463e63ee289a1ff1904cfb7b2fe6cb4c2&stat=instructions%3Au). >

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread John McCall via cfe-commits
rjmccall wrote: I haven't looked at your patch yet, and I'm not familiar with the `diagnose_if` feature; I'm just commenting about the AST design question because I was tagged in to do so. If `diagnose_if` is about compile-time evaluation — essentially assertion failures during constant evalua

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-21 Thread John McCall via cfe-commits
@@ -230,6 +243,12 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { ->getString(); TyName = Name; } else { + // Be conservative if the type isn't a RecordType. We are specifically rjmccall wrote: ```suggestion

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-21 Thread John McCall via cfe-commits
@@ -18,10 +20,23 @@ struct A {}; // CHECK-LABEL: define {{.*}} @_Z1g const int *(A::*const *g(const int *(A::* const **p)[3], int *(A::***q)[3]))[3] { + // CHECK: load ptr, ptr %p.addr // CHECK: load ptr, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]] const int *(A::*const *x)[3

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-21 Thread John McCall via cfe-commits
@@ -205,14 +205,27 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { llvm::MDNode *AnyPtr = createScalarTypeNode("any pointer", getChar(), Size); if (!CodeGenOpts.PointerTBAA) return AnyPtr; -// Compute the depth of the pointer and generate a

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-21 Thread John McCall via cfe-commits
rjmccall wrote: Having an abstraction for this would be nice. It doesn't *have* to be a base class specifically, though; we can do a more extrinsic tagged-union without actually unifying the class hierarchies, like `llvm::CallSite` does. Swift has a type called `AnyFunctionRef` that unifies se

[clang] [Clang] Enable -fpointer-tbaa by default. (PR #117244)

2024-11-21 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: This seems reasonable to me. Since it's standards-compliant, has a specific opt-out flag, and is overridden by the general `-fno-strict-aliasing` flag, I don't see any need for the RFC process. Still, you should definitely wait for more feedback, especial

[clang] [TBAA] Don't emit pointer tbaa for unnamed structs or unions. (PR #116596)

2024-11-21 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. https://github.com/llvm/llvm-project/pull/116596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Don't emit pointer tbaa for unnamed structs or unions. (PR #116596)

2024-11-21 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/116596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

2024-11-21 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. https://github.com/llvm/llvm-project/pull/116991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Don't emit pointer tbaa for unnamed structs or unions. (PR #116596)

2024-11-21 Thread John McCall via cfe-commits
@@ -249,6 +249,21 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) { if (!Ty->isRecordType()) return AnyPtr; + // For unnamed structs or unions C's compatible types rule applies. Two + // compatible types in different compilation units c

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread John McCall via cfe-commits
rjmccall wrote: > An abstraction that includes blocks doesn't help us here because we are > looking for the combination of `NamedDecl` and `DeclContext` and `BlockDecl` > isn't a `NamedDecl`. I think you're focusing a little narrowly here. I can't imagine why you'd specifically need a `NamedD

[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

2025-01-24 Thread John McCall via cfe-commits
@@ -5692,7 +5692,10 @@ CGCallee CodeGenFunction::EmitCallee(const Expr *E) { // Resolve direct calls. } else if (auto DRE = dyn_cast(E)) { if (auto FD = dyn_cast(DRE->getDecl())) { - return EmitDirectCallee(*this, FD); + auto CalleeDecl = FD->hasAttr() +

[clang] [Clang] Fix __{add, remove}_pointer in Objective-C++ (PR #123678)

2025-01-24 Thread John McCall via cfe-commits
rjmccall wrote: It's probably right that these should match the behavior of adding or removing a `*` (the latter of which can happen via template argument deduction), which does mean they need to handle ObjC pointer types correctly. https://github.com/llvm/llvm-project/pull/123678

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: Last minute re-read caught a couple slip-ups, and yeah, as mentioned, please feel free to augment this with other relevant information for users. Also, I'm definitely not sure the separate clang-cl section is worth keeping; it's pretty short, and any extr

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread John McCall via cfe-commits
@@ -2489,6 +2489,81 @@ are listed below. $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc +Strict Aliasing +--- + +The C and C++ standards require accesses to objects in memory to use l-values of +an appropriate type for the object. This is

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread John McCall via cfe-commits
@@ -2489,6 +2489,81 @@ are listed below. $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc +Strict Aliasing +--- + +The C and C++ standards require accesses to objects in memory to use l-values of +an appropriate type for the object. This is

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/122116 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-29 Thread John McCall via cfe-commits
@@ -2489,6 +2489,81 @@ are listed below. $ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc +Strict Aliasing +--- + +The C and C++ standards require accesses to objects in memory to use l-values of +an appropriate type for the object. This is

[clang] [flang] [llvm] [Clang] Remove ARCMigrate (PR #119269)

2025-01-29 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. This looks right to me, but let me tag in @akyrtzi just to make his own pass over this. https://github.com/llvm/llvm-project/pull/119269 ___ cfe-commits mailing list cfe-commits@lists.llvm.org ht

[clang] [PAC] Ignore noexcept on function type when computing discriminator of member function pointers (PR #109056)

2025-01-16 Thread John McCall via cfe-commits
@@ -3442,6 +3442,13 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) { encodeTypeForFunctionPointerAuth(*this, Out, T); } else { T = T.getUnqualifiedType(); +// Drop exception specification from member function pointer type. rj

[clang] [PAC] Ignore noexcept on function type when computing discriminator of member function pointers (PR #109056)

2025-01-16 Thread John McCall via cfe-commits
@@ -3442,6 +3442,13 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) { encodeTypeForFunctionPointerAuth(*this, Out, T); } else { T = T.getUnqualifiedType(); +// Drop exception specification from member function pointer type. +if (auto *MPT

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-09 Thread John McCall via cfe-commits
rjmccall wrote: I agree that allowing `void*` l-values to alias arbitrary pointer objects is probably the right pragmatic choice. We should document it, though. @pinskia, does GCC apply this recursively — e.g. are `void**` l-values treated specially in any way, or are they basically just `char

[clang] [PAC] Ignore noexcept on function type when computing discriminator of member function pointers (PR #109056)

2025-01-16 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/109056 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [TBAA] Don't emit pointer-tbaa for void pointers. (PR #122116)

2025-01-09 Thread John McCall via cfe-commits
rjmccall wrote: Okay, so if the ultimate pointee type is `void`, we're basically treating that as a generic pointer, no matter what the pointer depth is? I guess that makes sense. > What would be a good place to document this? Hmm, I was hoping that we would have a section in the manual alre

[clang] [PAC] Ignore noexcept on function type when computing discriminator of member function pointers (PR #109056)

2025-01-16 Thread John McCall via cfe-commits
@@ -3442,6 +3442,35 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) { encodeTypeForFunctionPointerAuth(*this, Out, T); } else { T = T.getUnqualifiedType(); +// Drop exception specification from member function pointer type. rj

[clang] [clang] run clang-format on some CGObjC files (PR #126644)

2025-02-12 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. Thank you; LGTM. https://github.com/llvm/llvm-project/pull/126644 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Sema] Fix type of an statement expression ending with an atomic type (PR #119711)

2025-02-12 Thread John McCall via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -163,6 +163,7 @@ Bug Fixes to C++ Support Bug Fixes to AST Handling ^ +- F

[clang] [clang][Sema] Fix type of an statement expression ending with an atomic type (PR #119711)

2025-02-12 Thread John McCall via cfe-commits
Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?=, Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?=, Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?=, Alejandro =?utf-8?q?=C3=81lvarez_Ayll=C3=B3n?= Message-ID: In-Reply-To: @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +

[clang] [clang] run clang-format on some CGObjC files (PR #126644)

2025-02-11 Thread John McCall via cfe-commits
@@ -3397,53 +3309,53 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { enum FragileClassFlags { /// Apparently: is not a meta-class. - FragileABI_Class_Factory = 0x1, + FragileABI_Class_Factory = 0x1, rjmccall

[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

2025-02-11 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. Thanks, the new comment looks great. LGTM. https://github.com/llvm/llvm-project/pull/126047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/

[clang] [clang] Add value_type attr, use it to add noalias when pass-by-value. (PR #95004)

2025-03-18 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/95004 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add value_type attr, use it to add noalias when pass-by-value. (PR #95004)

2025-03-18 Thread John McCall via cfe-commits
@@ -9242,3 +9242,15 @@ Declares that a function potentially allocates heap memory, and prevents any pot of ``nonallocating`` by the compiler. }]; } + +def ValueTypeDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``value_type`` attribute can be u

[clang] [clang] Add value_type attr, use it to add noalias when pass-by-value. (PR #95004)

2025-03-18 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/95004 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Add value_type attr, use it to add noalias when pass-by-value. (PR #95004)

2025-03-17 Thread John McCall via cfe-commits
@@ -9242,3 +9242,15 @@ Declares that a function potentially allocates heap memory, and prevents any pot of ``nonallocating`` by the compiler. }]; } + +def ValueTypeDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``value_type`` attribute can be u

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-04-09 Thread John McCall via cfe-commits
@@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s + +#define AQ __ptrauth

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-04-09 Thread John McCall via cfe-commits
@@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s + +#define AQ __ptrauth

[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)

2025-04-11 Thread John McCall via cfe-commits
@@ -0,0 +1,142 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++11 -fptrauth-calls -fptrauth-intrinsics -verify -fsyntax-only %s + +#define AQ __ptrauth

[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

2025-04-17 Thread John McCall via cfe-commits
@@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const { inline bool Type::isBooleanType() const { if (const auto *BT = dyn_cast(CanonicalType)) return BT->getKind() == BuiltinType::Bool; + if (const EnumType *ET = dyn_cast(CanonicalType)) { +//

<    5   6   7   8   9   10   11   >