[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace of PointerType::get(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/126274 Follow-up to https://github.com/llvm/llvm-project/issues/123569 The obsolete bitcasts on the LoadInsts are also removed. >From d0613ac62099faefab887605422cba95116ce12a Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:35:31 +0900 Subject: [PATCH] [CodeGen][Hexagon] Replace of PointerType::get(Type) with opaque version (NFC) --- clang/lib/CodeGen/Targets/Hexagon.cpp | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 8fd2a81494d998c..6ad247a5056d376 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -8,6 +8,7 @@ #include "ABIInfoImpl.h" #include "TargetInfo.h" +#include "llvm/IR/DerivedTypes.h" using namespace clang; using namespace clang::CodeGen; @@ -336,10 +337,6 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, // Implement the block where argument is in register saved area CGF.EmitBlock(InRegBlock); - llvm::Type *PTy = CGF.ConvertType(Ty); - llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast( - __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy)); - CGF.Builder.CreateStore(__new_saved_reg_area_pointer, __current_saved_reg_area_pointer_p); @@ -388,22 +385,16 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, CGF.Builder.CreateStore(__new_overflow_area_pointer, __current_saved_reg_area_pointer_p); - // Bitcast the overflow area pointer to the type of argument. - llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty); - llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast( - __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy)); - CGF.EmitBranch(ContBlock); - // Get the correct pointer to load the variable argument // Implement the ContBlock CGF.EmitBlock(ContBlock); llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); - llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy); - llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr"); - ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock); - ArgAddr->addIncoming(__overflow_area_p, OnStackBlock); + llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( + llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); + ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
junlarsen wrote: Test failures seem unrelated. https://github.com/llvm/llvm-project/pull/124782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/124782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace of PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/126274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/126274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126278)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/126278 Follow-up to #123569 >From aa2545fd0122ffb194a92dc42ef94055248aeb20 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:44:25 +0900 Subject: [PATCH] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) Follow-up to #123569 --- clang/lib/CodeGen/Targets/AArch64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp index 4922b082cf09ca9..dc3a1d4287be17b 100644 --- a/clang/lib/CodeGen/Targets/AArch64.cpp +++ b/clang/lib/CodeGen/Targets/AArch64.cpp @@ -843,7 +843,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, llvm::Type *BaseTy = CGF.ConvertType(Ty); if (IsIndirect) -BaseTy = llvm::PointerType::getUnqual(BaseTy); +BaseTy = llvm::PointerType::getUnqual(BaseTy->getContext()); else if (AI.getCoerceToType()) BaseTy = AI.getCoerceToType(); @@ -961,7 +961,7 @@ RValue AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, if (IsIndirect) { // If it's been passed indirectly (actually a struct), whatever we find from // stored registers or on the stack will actually be a struct **. -MemTy = llvm::PointerType::getUnqual(MemTy); +MemTy = llvm::PointerType::getUnqual(MemTy->getContext()); } const Type *Base = nullptr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126279)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/126279 Follow-up to #123569 >From 507705cff12ac89e1f23c0b7233cfd5a13e882d6 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:57:46 +0900 Subject: [PATCH] [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) Follow-up to #123569 --- clang/lib/CodeGen/Targets/XCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/Targets/XCore.cpp b/clang/lib/CodeGen/Targets/XCore.cpp index ced4981fd124f6a..b7824bde5f55a4b 100644 --- a/clang/lib/CodeGen/Targets/XCore.cpp +++ b/clang/lib/CodeGen/Targets/XCore.cpp @@ -149,7 +149,7 @@ RValue XCoreABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, llvm::Type *ArgTy = CGT.ConvertType(Ty); if (AI.canHaveCoerceToType() && !AI.getCoerceToType()) AI.setCoerceToType(ArgTy); - llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy); + llvm::Type *ArgPtrTy = llvm::PointerType::getUnqual(ArgTy->getContext()); Address Val = Address::invalid(); CharUnits ArgSize = CharUnits::Zero(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126280)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/126280 Follow-up to #126278 >From 31586f0db70c1d7da7decb0fef3473930fe17c7b Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:59:34 +0900 Subject: [PATCH] [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) Follow-up to #126278 --- clang/lib/CodeGen/Targets/SystemZ.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/Targets/SystemZ.cpp b/clang/lib/CodeGen/Targets/SystemZ.cpp index 23c96fa5cf98cb3..9bb8ddbc548d2d1 100644 --- a/clang/lib/CodeGen/Targets/SystemZ.cpp +++ b/clang/lib/CodeGen/Targets/SystemZ.cpp @@ -272,7 +272,7 @@ RValue SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, SZCGI.handleExternallyVisibleObjABI(Ty.getTypePtr(), CGT.getCGM(), /*IsParam*/true); if (IsIndirect) { -DirectTy = llvm::PointerType::getUnqual(DirectTy); +DirectTy = llvm::PointerType::getUnqual(DirectTy->getContext()); UnpaddedSize = DirectAlign = CharUnits::fromQuantity(8); } else { if (AI.getCoerceToType()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From f3bbd6f0db4109016d98fe15a2b086b491df2d93 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/2] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index a7584a95c8ca7b9..033528dbceb3bd3 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index ded905cdcc9f440..feb4ddbb52b2b7d 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2868,15 +2868,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
junlarsen wrote: I think I'll do that instead. Sounds a lot more reasonable in my opinion https://github.com/llvm/llvm-project/pull/124782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From f3bbd6f0db4109016d98fe15a2b086b491df2d93 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/2] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index a7584a95c8ca7b9..033528dbceb3bd3 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index ded905cdcc9f440..feb4ddbb52b2b7d 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2868,15 +2868,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124782 >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH 1/2] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac3660..334aedbb8592b5c 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } >From 2bca97745a46f77ed89379d2e02796940e2bf570 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 01:37:11 +0900 Subject: [PATCH 2/2] [Clang][TableGen] Switch to Builder.getPtrTy() --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 334aedbb8592b5c..10ec6e49eb28f98 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; +return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; } const Type *getPointeeType() const { return Pointee; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124782 >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH 1/3] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac3660..334aedbb8592b5c 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } >From 2bca97745a46f77ed89379d2e02796940e2bf570 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 01:37:11 +0900 Subject: [PATCH 2/3] [Clang][TableGen] Switch to Builder.getPtrTy() --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 334aedbb8592b5c..10ec6e49eb28f98 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; +return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; } const Type *getPointeeType() const { return Pointee; } >From 09bb424d081fb1f5ef13e4a5f55371f0eb3afaea Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Fri, 7 Feb 2025 16:42:06 + Subject: [PATCH 3/3] Update clang/utils/TableGen/MveEmitter.cpp Co-authored-by: Nikita Popov --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 10ec6e49eb28f98..dc1377952a2b62b 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; +return "Builder.getPtrTy()"; } const Type *getPointeeType() const { return Pointee; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/2] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547d4..faef6a5fbe1f5b6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f62..572175d9969a097 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
@@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; junlarsen wrote: Ah whoops of course https://github.com/llvm/llvm-project/pull/124782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124782 >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH 1/4] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac3660..334aedbb8592b5c 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } >From 2bca97745a46f77ed89379d2e02796940e2bf570 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 01:37:11 +0900 Subject: [PATCH 2/4] [Clang][TableGen] Switch to Builder.getPtrTy() --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 334aedbb8592b5c..10ec6e49eb28f98 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; +return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; } const Type *getPointeeType() const { return Pointee; } >From 09bb424d081fb1f5ef13e4a5f55371f0eb3afaea Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Fri, 7 Feb 2025 16:42:06 + Subject: [PATCH 3/4] Update clang/utils/TableGen/MveEmitter.cpp Co-authored-by: Nikita Popov --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 10ec6e49eb28f98..dc1377952a2b62b 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(Builder.getPtrTy())"; +return "Builder.getPtrTy()"; } const Type *getPointeeType() const { return Pointee; } >From c320336eef890cab115ccd3054d970bb99531862 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 01:46:57 +0900 Subject: [PATCH 4/4] Run clang format --- clang/utils/TableGen/MveEmitter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index dc1377952a2b62b..39b6e837ed4b71e 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -209,9 +209,7 @@ class PointerType : public Type { Name = "const " + Name; return Name + " *"; } - std::string llvmName() const override { -return "Builder.getPtrTy()"; - } + std::string llvmName() const override { return "Builder.getPtrTy()"; } const Type *getPointeeType() const { return Pointee; } static bool classof(const Type *T) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/3] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547d4..faef6a5fbe1f5b6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f62..572175d9969a097 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen ready_for_review https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
@@ -3054,7 +3054,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { getContext().getDeclAlign(VD)); llvm::Type *VarTy = getTypes().ConvertTypeForMem(VD->getType()); auto *PTy = llvm::PointerType::get( -VarTy, getTypes().getTargetAddressSpace(VD->getType())); +getLLVMContext(), getTypes().getTargetAddressSpace(VD->getType())); Addr = Builder.CreatePointerBitCastOrAddrSpaceCast(Addr, PTy, VarTy); junlarsen wrote: Can this be replaced with an AddrSpaceCast only? i.e CGBuilder::CreateAddrSpaceCast? I'm not too sure how the Clang codegen Address code behaves. https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124782 >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac366..334aedbb8592b5 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang:frontend] Move helper functions to common location for SemaSPIRV (PR #125045)
https://github.com/junlarsen commented: Each file should have license headers, ref https://llvm.org/docs/CodingStandards.html#file-headers https://github.com/llvm/llvm-project/pull/125045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit `this` (PR #122928)
junlarsen wrote: Thanks, I'm not very opinionated on it, but since a lot of libraries in various languages rely on the C API I think it's fair to keep comparible if it makes sense https://github.com/llvm/llvm-project/pull/122928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit `this` (PR #122928)
junlarsen wrote: This causes a breaking change in the C-API which I believe can easily be avoided. I've submitted https://github.com/llvm/llvm-project/pull/124144 as a suggestion to keep compatability https://github.com/llvm/llvm-project/pull/122928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit `this` (PR #122928)
junlarsen wrote: I wasn't aware of that exception either, so my apologies there. I still think it's fair policy to keep things as compatible if easily possible though. https://github.com/llvm/llvm-project/pull/122928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/124771 Follow-up to https://github.com/llvm/llvm-project/issues/123569 >From f3bbd6f0db4109016d98fe15a2b086b491df2d93 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb9..852aa0e686fe3c 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index a7584a95c8ca7b..033528dbceb3bd 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index ded905cdcc9f44..feb4ddbb52b2b7 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2868,15 +2868,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac2..5005f6b3cbd2d1 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
@@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; junlarsen wrote: I do feel a bit guilty about removing this comment. However, I'm not experienced enough to know if it's significant and something we'd like to keep? Perhaps move it to the BlockDescriptorType decl? https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen ready_for_review https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/124782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (PR #124782)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/124782 Follow-up to #123569 I don't know if directly using the CodeGenModule here is the best solution. Let me know if there's something better to use. >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac366..334aedbb8592b5 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen converted_to_draft https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter (NFC) (PR #124782)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124782 >From bc77542fe58bdc94566a9a589039856de50617b0 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 01:29:01 +0900 Subject: [PATCH] [Clang][TableGen] Use PointerType::get(Context) in MVE TableGen emitter Follow-up to #123569 --- clang/utils/TableGen/MveEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index 58a4d3c22ac366..334aedbb8592b5 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -210,7 +210,7 @@ class PointerType : public Type { return Name + " *"; } std::string llvmName() const override { -return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")"; +return "llvm::PointerType::getUnqual(CGM.getLLVMContext())"; } const Type *getPointeeType() const { return Pointee; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
@@ -388,22 +385,16 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, CGF.Builder.CreateStore(__new_overflow_area_pointer, __current_saved_reg_area_pointer_p); - // Bitcast the overflow area pointer to the type of argument. - llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty); - llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast( - __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy)); - CGF.EmitBranch(ContBlock); - // Get the correct pointer to load the variable argument // Implement the ContBlock CGF.EmitBlock(ContBlock); llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); - llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy); - llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr"); - ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock); - ArgAddr->addIncoming(__overflow_area_p, OnStackBlock); + llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( + llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); + ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); junlarsen wrote: Yeah, slight oversight on my end. Just noticed it showed up on the tests too :) https://github.com/llvm/llvm-project/pull/126274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/126274 >From d0613ac62099faefab887605422cba95116ce12a Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:35:31 +0900 Subject: [PATCH 1/2] [CodeGen][Hexagon] Replace of PointerType::get(Type) with opaque version (NFC) --- clang/lib/CodeGen/Targets/Hexagon.cpp | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 8fd2a81494d998c..6ad247a5056d376 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -8,6 +8,7 @@ #include "ABIInfoImpl.h" #include "TargetInfo.h" +#include "llvm/IR/DerivedTypes.h" using namespace clang; using namespace clang::CodeGen; @@ -336,10 +337,6 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, // Implement the block where argument is in register saved area CGF.EmitBlock(InRegBlock); - llvm::Type *PTy = CGF.ConvertType(Ty); - llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast( - __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy)); - CGF.Builder.CreateStore(__new_saved_reg_area_pointer, __current_saved_reg_area_pointer_p); @@ -388,22 +385,16 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, CGF.Builder.CreateStore(__new_overflow_area_pointer, __current_saved_reg_area_pointer_p); - // Bitcast the overflow area pointer to the type of argument. - llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty); - llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast( - __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy)); - CGF.EmitBranch(ContBlock); - // Get the correct pointer to load the variable argument // Implement the ContBlock CGF.EmitBlock(ContBlock); llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); - llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy); - llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr"); - ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock); - ArgAddr->addIncoming(__overflow_area_p, OnStackBlock); + llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( + llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); + ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); } >From 5c5c8c4e1b6482552fb3c02624543ec6ff60f844 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 22:22:15 +0900 Subject: [PATCH 2/2] Use correct saved_reg_area_pointer --- clang/lib/CodeGen/Targets/Hexagon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 6ad247a5056d376..3e6ab74ff7ed7f9 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -393,7 +393,7 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); - ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock); ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][SystemZ] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126280)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/126280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][AArch64] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126278)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/126278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][XCore] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126279)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/126279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/4] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547d4..faef6a5fbe1f5b6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f62..572175d9969a097 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
@@ -8,6 +8,7 @@ #include "ABIInfoImpl.h" #include "TargetInfo.h" +#include "llvm/IR/DerivedTypes.h" junlarsen wrote: Likely not, I think my LSP automatically inserts them when it completes stuff like PointerType::get. I'll remove it and the ones in the other PR too https://github.com/llvm/llvm-project/pull/126274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/5] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547d4..faef6a5fbe1f5b6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f62..572175d9969a097 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/124771 >From 13d65a0cc95fe53f959db343e5be07773ee53f28 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Wed, 29 Jan 2025 00:31:32 +0900 Subject: [PATCH 1/5] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) Follow-up to https://github.com/llvm/llvm-project/issues/123569 --- clang/lib/CodeGen/Address.h | 8 clang/lib/CodeGen/CGBlocks.cpp | 23 +-- clang/lib/CodeGen/CGDecl.cpp| 5 + clang/lib/CodeGen/CGDeclCXX.cpp | 4 ++-- clang/lib/CodeGen/CGExpr.cpp| 4 ++-- clang/lib/CodeGen/CGObjCMac.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 6 +++--- 7 files changed, 14 insertions(+), 38 deletions(-) diff --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h index a18c7169af1eb96..852aa0e686fe3c6 100644 --- a/clang/lib/CodeGen/Address.h +++ b/clang/lib/CodeGen/Address.h @@ -19,6 +19,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DerivedTypes.h" #include "llvm/Support/MathExtras.h" namespace clang { @@ -197,10 +198,9 @@ class Address { /// Return the type of the pointer value. llvm::PointerType *getType() const { -return llvm::PointerType::get( -ElementType, -llvm::cast(Pointer.getPointer()->getType()) -->getAddressSpace()); +auto AS = llvm::cast(Pointer.getPointer()->getType()) + ->getAddressSpace(); +return llvm::PointerType::get(ElementType->getContext(), AS); } /// Return the type of the values stored in this address. diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index aaba354c08547d4..faef6a5fbe1f5b6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1097,31 +1097,10 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() { if (BlockDescriptorType) return BlockDescriptorType; - llvm::Type *UnsignedLongTy = -getTypes().ConvertType(getContext().UnsignedLongTy); - - // struct __block_descriptor { - // unsigned long reserved; - // unsigned long block_size; - // - // // later, the following will be added - // - // struct { - // void (*copyHelper)(); - // void (*copyHelper)(); - // } helpers;// !!! optional - // - // const char *signature; // the block signature - // const char *layout; // reserved - // }; - BlockDescriptorType = llvm::StructType::create( - "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy); - - // Now form a pointer to that. unsigned AddrSpace = 0; if (getLangOpts().OpenCL) AddrSpace = getContext().getTargetAddressSpace(LangAS::opencl_constant); - BlockDescriptorType = llvm::PointerType::get(BlockDescriptorType, AddrSpace); + BlockDescriptorType = llvm::PointerType::get(getLLVMContext(), AddrSpace); return BlockDescriptorType; } diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index cc6815db4d20f62..572175d9969a097 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2870,15 +2870,12 @@ void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) { // We can also keep the existing global if the address space is what we // expect it to be, if not, it is replaced. -QualType ASTTy = VD->getType(); clang::LangAS GVAS = GetGlobalVarAddressSpace(VD); auto TargetAS = getContext().getTargetAddressSpace(GVAS); if (Entry->getType()->getAddressSpace() == TargetAS) continue; -// Make a new global with the correct type / address space. -llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); -llvm::PointerType *PTy = llvm::PointerType::get(Ty, TargetAS); +llvm::PointerType *PTy = llvm::PointerType::get(getLLVMContext(), TargetAS); // Replace all uses of the old global with a cast. Since we mutate the type // in place we neeed an intermediate that takes the spot of the old entry diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index 1c2fecea1a6ac25..5005f6b3cbd2d1a 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -347,7 +347,7 @@ void CodeGenFunction::registerGlobalDtorWithAtExit(llvm::Constant *dtorStub) { // extern "C" int atexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidTy, false), + CGM.getLLVMContext(), dtorStub->getType()->getPointerAddressSpace()) && "Argument to atexit has a wrong type."); @@ -374,7 +374,7 @@ CodeGenFunction::unregisterGlobalDtorWithUnAtExit(llvm::Constant *dtorStub) { // extern "C" int unatexit(void (*f)(void)); assert(dtorStub->getType() == llvm::PointerType::get( - llvm::FunctionType::get(CGM.VoidT
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/126274 >From d0613ac62099faefab887605422cba95116ce12a Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 02:35:31 +0900 Subject: [PATCH 1/3] [CodeGen][Hexagon] Replace of PointerType::get(Type) with opaque version (NFC) --- clang/lib/CodeGen/Targets/Hexagon.cpp | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 8fd2a81494d998c..6ad247a5056d376 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -8,6 +8,7 @@ #include "ABIInfoImpl.h" #include "TargetInfo.h" +#include "llvm/IR/DerivedTypes.h" using namespace clang; using namespace clang::CodeGen; @@ -336,10 +337,6 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, // Implement the block where argument is in register saved area CGF.EmitBlock(InRegBlock); - llvm::Type *PTy = CGF.ConvertType(Ty); - llvm::Value *__saved_reg_area_p = CGF.Builder.CreateBitCast( - __current_saved_reg_area_pointer, llvm::PointerType::getUnqual(PTy)); - CGF.Builder.CreateStore(__new_saved_reg_area_pointer, __current_saved_reg_area_pointer_p); @@ -388,22 +385,16 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, CGF.Builder.CreateStore(__new_overflow_area_pointer, __current_saved_reg_area_pointer_p); - // Bitcast the overflow area pointer to the type of argument. - llvm::Type *OverflowPTy = CGF.ConvertTypeForMem(Ty); - llvm::Value *__overflow_area_p = CGF.Builder.CreateBitCast( - __overflow_area_pointer, llvm::PointerType::getUnqual(OverflowPTy)); - CGF.EmitBranch(ContBlock); - // Get the correct pointer to load the variable argument // Implement the ContBlock CGF.EmitBlock(ContBlock); llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); - llvm::Type *MemPTy = llvm::PointerType::getUnqual(MemTy); - llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI(MemPTy, 2, "vaarg.addr"); - ArgAddr->addIncoming(__saved_reg_area_p, InRegBlock); - ArgAddr->addIncoming(__overflow_area_p, OnStackBlock); + llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( + llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); + ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); } >From 5c5c8c4e1b6482552fb3c02624543ec6ff60f844 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sat, 8 Feb 2025 22:22:15 +0900 Subject: [PATCH 2/3] Use correct saved_reg_area_pointer --- clang/lib/CodeGen/Targets/Hexagon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 6ad247a5056d376..3e6ab74ff7ed7f9 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -393,7 +393,7 @@ Address HexagonABIInfo::EmitVAArgForHexagonLinux(CodeGenFunction &CGF, llvm::Type *MemTy = CGF.ConvertTypeForMem(Ty); llvm::PHINode *ArgAddr = CGF.Builder.CreatePHI( llvm::PointerType::getUnqual(MemTy->getContext()), 2, "vaarg.addr"); - ArgAddr->addIncoming(__new_saved_reg_area_pointer, InRegBlock); + ArgAddr->addIncoming(__current_saved_reg_area_pointer, InRegBlock); ArgAddr->addIncoming(__overflow_area_pointer, OnStackBlock); return Address(ArgAddr, MemTy, CharUnits::fromQuantity(ArgAlign)); >From eec0d490cd021d5bc03de01c179bc701fc2f6e14 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Sun, 9 Feb 2025 00:01:48 +0900 Subject: [PATCH 3/3] Remove inserted includes --- clang/lib/CodeGen/Targets/Hexagon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/CodeGen/Targets/Hexagon.cpp b/clang/lib/CodeGen/Targets/Hexagon.cpp index 3e6ab74ff7ed7f9..aada8d0d61303be 100644 --- a/clang/lib/CodeGen/Targets/Hexagon.cpp +++ b/clang/lib/CodeGen/Targets/Hexagon.cpp @@ -8,7 +8,6 @@ #include "ABIInfoImpl.h" #include "TargetInfo.h" -#include "llvm/IR/DerivedTypes.h" using namespace clang; using namespace clang::CodeGen; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][Hexagon] Replace PointerType::getUnqual(Type) with opaque version (NFC) (PR #126274)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/126274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace of PointerType::get(Type) with opaque version (NFC) (PR #124771)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/124771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128711)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/128711 pointer version (NFC) Follow-up to #123569 >From 22a07820dee329ed68ea2a2cd3b619f980047de9 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Tue, 25 Feb 2025 14:09:39 +0100 Subject: [PATCH] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) Follow-up to #123569 --- clang/lib/CodeGen/ABIInfoImpl.cpp | 2 +- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 8 +--- clang/lib/CodeGen/CGOpenMPRuntime.h | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp b/clang/lib/CodeGen/ABIInfoImpl.cpp index 68887cd7916c7..0a612d3461dc2 100644 --- a/clang/lib/CodeGen/ABIInfoImpl.cpp +++ b/clang/lib/CodeGen/ABIInfoImpl.cpp @@ -430,7 +430,7 @@ Address CodeGen::EmitVAArgInstr(CodeGenFunction &CGF, Address VAListAddr, CharUnits TyAlignForABI = TyInfo.Align; llvm::Type *ElementTy = CGF.ConvertTypeForMem(Ty); -llvm::Type *BaseTy = llvm::PointerType::getUnqual(ElementTy); +llvm::Type *BaseTy = llvm::PointerType::getUnqual(CGF.getLLVMContext()); llvm::Value *Addr = CGF.Builder.CreateVAArg(VAListAddr.emitRawPointer(CGF), BaseTy); return Address(Addr, ElementTy, TyAlignForABI); diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index c2289985e9519..7ff0d14b564fe 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1476,13 +1476,7 @@ llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() { } llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() { - if (!Kmpc_MicroTy) { -// Build void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid,...) -llvm::Type *MicroParams[] = {llvm::PointerType::getUnqual(CGM.Int32Ty), - llvm::PointerType::getUnqual(CGM.Int32Ty)}; -Kmpc_MicroTy = llvm::FunctionType::get(CGM.VoidTy, MicroParams, true); - } - return llvm::PointerType::getUnqual(Kmpc_MicroTy); + return llvm::PointerType::getUnqual(CGM.getLLVMContext()); } static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h index 3791bb7159235..03a80d2bbc686 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -386,10 +386,6 @@ class CGOpenMPRuntime { /// Map for SourceLocation and OpenMP runtime library debug locations. typedef llvm::DenseMap OpenMPDebugLocMapTy; OpenMPDebugLocMapTy OpenMPDebugLocMap; - /// The type for a microtask which gets passed to __kmpc_fork_call(). - /// Original representation is: - /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...); - llvm::FunctionType *Kmpc_MicroTy = nullptr; /// Stores debug location and ThreadID for the function. struct DebugLocThreadIdTy { llvm::Value *DebugLoc; diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index bcd171724c41d..03c46a37717ab 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -953,7 +953,7 @@ ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, Builder.CreateCondBr(IsVirtualOffset, MergeBB, ResignBB); CGF.EmitBlock(ResignBB); - llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.Int8Ty); + llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.getLLVMContext()); MemFnPtr = Builder.CreateIntToPtr(MemFnPtr, PtrTy); MemFnPtr = CGF.emitPointerAuthResign(MemFnPtr, SrcType, CurAuthInfo, NewAuthInfo, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128711)
junlarsen wrote: * **#128711** https://app.graphite.dev/github/pr/llvm/llvm-project/128711?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/128711?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/128711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128715)
@@ -3270,9 +3263,7 @@ CGObjCGNU::GenerateProtocolList(ArrayRef Protocols) { llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF, const ObjCProtocolDecl *PD) { auto protocol = GenerateProtocolRef(PD); - llvm::Type *T = - CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType()); - return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T)); + return CGF.Builder.CreateBitCast(protocol, PtrTy); junlarsen wrote: Is this obsolete? I wasn't quite able to tell. https://github.com/llvm/llvm-project/pull/128715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128711)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/128711 >From 22a07820dee329ed68ea2a2cd3b619f980047de9 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Tue, 25 Feb 2025 14:09:39 +0100 Subject: [PATCH] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) Follow-up to #123569 --- clang/lib/CodeGen/ABIInfoImpl.cpp | 2 +- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 8 +--- clang/lib/CodeGen/CGOpenMPRuntime.h | 4 clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp b/clang/lib/CodeGen/ABIInfoImpl.cpp index 68887cd7916c7..0a612d3461dc2 100644 --- a/clang/lib/CodeGen/ABIInfoImpl.cpp +++ b/clang/lib/CodeGen/ABIInfoImpl.cpp @@ -430,7 +430,7 @@ Address CodeGen::EmitVAArgInstr(CodeGenFunction &CGF, Address VAListAddr, CharUnits TyAlignForABI = TyInfo.Align; llvm::Type *ElementTy = CGF.ConvertTypeForMem(Ty); -llvm::Type *BaseTy = llvm::PointerType::getUnqual(ElementTy); +llvm::Type *BaseTy = llvm::PointerType::getUnqual(CGF.getLLVMContext()); llvm::Value *Addr = CGF.Builder.CreateVAArg(VAListAddr.emitRawPointer(CGF), BaseTy); return Address(Addr, ElementTy, TyAlignForABI); diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index c2289985e9519..7ff0d14b564fe 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1476,13 +1476,7 @@ llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() { } llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() { - if (!Kmpc_MicroTy) { -// Build void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid,...) -llvm::Type *MicroParams[] = {llvm::PointerType::getUnqual(CGM.Int32Ty), - llvm::PointerType::getUnqual(CGM.Int32Ty)}; -Kmpc_MicroTy = llvm::FunctionType::get(CGM.VoidTy, MicroParams, true); - } - return llvm::PointerType::getUnqual(Kmpc_MicroTy); + return llvm::PointerType::getUnqual(CGM.getLLVMContext()); } static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h index 3791bb7159235..03a80d2bbc686 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -386,10 +386,6 @@ class CGOpenMPRuntime { /// Map for SourceLocation and OpenMP runtime library debug locations. typedef llvm::DenseMap OpenMPDebugLocMapTy; OpenMPDebugLocMapTy OpenMPDebugLocMap; - /// The type for a microtask which gets passed to __kmpc_fork_call(). - /// Original representation is: - /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...); - llvm::FunctionType *Kmpc_MicroTy = nullptr; /// Stores debug location and ThreadID for the function. struct DebugLocThreadIdTy { llvm::Value *DebugLoc; diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index bcd171724c41d..03c46a37717ab 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -953,7 +953,7 @@ ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, Builder.CreateCondBr(IsVirtualOffset, MergeBB, ResignBB); CGF.EmitBlock(ResignBB); - llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.Int8Ty); + llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.getLLVMContext()); MemFnPtr = Builder.CreateIntToPtr(MemFnPtr, PtrTy); MemFnPtr = CGF.emitPointerAuthResign(MemFnPtr, SrcType, CurAuthInfo, NewAuthInfo, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128715)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/128715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128715)
https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/128715 >From e993b0d23cbb018a090f49f1f4f63c0dd0a89a66 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Tue, 25 Feb 2025 14:40:11 +0100 Subject: [PATCH] [CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) Follow-up to #123569 --- clang/lib/CodeGen/CGObjCGNU.cpp | 29 ++--- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index d1876f47c0eea..0d011d08aacf8 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -819,7 +819,7 @@ class CGObjCGNUstep : public CGObjCGNU { const ObjCRuntime &R = CGM.getLangOpts().ObjCRuntime; SlotStructTy = llvm::StructType::get(PtrTy, PtrTy, PtrTy, IntTy, IMPTy); - SlotTy = llvm::PointerType::getUnqual(SlotStructTy); + SlotTy = PtrTy; // Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender); SlotLookupFn.init(&CGM, "objc_msg_lookup_sender", SlotTy, PtrToIdTy, SelectorTy, IdTy); @@ -2284,10 +2284,12 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, BoolTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy); Int8Ty = llvm::Type::getInt8Ty(VMContext); + + PtrTy = llvm::PointerType::getUnqual(cgm.getLLVMContext()); + PtrToIntTy = PtrTy; // C string type. Used in lots of places. - PtrToInt8Ty = llvm::PointerType::getUnqual(Int8Ty); - ProtocolPtrTy = llvm::PointerType::getUnqual( - Types.ConvertType(CGM.getContext().getObjCProtoType())); + PtrToInt8Ty = PtrTy; + ProtocolPtrTy = PtrTy; Zeros[0] = llvm::ConstantInt::get(LongTy, 0); Zeros[1] = Zeros[0]; @@ -2302,9 +2304,6 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, SelectorElemTy = CGM.getTypes().ConvertTypeForMem(selTy->getPointeeType()); } - PtrToIntTy = llvm::PointerType::getUnqual(IntTy); - PtrTy = PtrToInt8Ty; - Int32Ty = llvm::Type::getInt32Ty(VMContext); Int64Ty = llvm::Type::getInt64Ty(VMContext); @@ -2323,7 +2322,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, IdTy = PtrToInt8Ty; IdElemTy = Int8Ty; } - PtrToIdTy = llvm::PointerType::getUnqual(IdTy); + PtrToIdTy = PtrTy; ProtocolTy = llvm::StructType::get(IdTy, PtrToInt8Ty, // name PtrToInt8Ty, // protocols @@ -2351,7 +2350,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, PtrToInt8Ty, PtrToInt8Ty }); ObjCSuperTy = llvm::StructType::get(IdTy, IdTy); - PtrToObjCSuperTy = llvm::PointerType::getUnqual(ObjCSuperTy); + PtrToObjCSuperTy = PtrTy; llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext); @@ -2383,9 +2382,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, PtrDiffTy, BoolTy, BoolTy); // IMP type - llvm::Type *IMPArgs[] = { IdTy, SelectorTy }; - IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs, - true)); + IMPTy = PtrTy; const LangOptions &Opts = CGM.getLangOpts(); if ((Opts.getGC() != LangOptions::NonGC) || Opts.ObjCAutoRefCount) @@ -2679,8 +2676,6 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, Class->getSuperClass()->getNameAsString(), /*isWeak*/false); if (IsClassMessage) { // Load the isa pointer of the superclass is this is a class method. - ReceiverClass = Builder.CreateBitCast(ReceiverClass, - llvm::PointerType::getUnqual(IdTy)); ReceiverClass = Builder.CreateAlignedLoad(IdTy, ReceiverClass, CGF.getPointerAlign()); } @@ -2721,8 +2716,6 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF, } // Cast the pointer to a simplified version of the class structure llvm::Type *CastTy = llvm::StructType::get(IdTy, IdTy); -ReceiverClass = Builder.CreateBitCast(ReceiverClass, - llvm::PointerType::getUnqual(CastTy)); // Get the superclass pointer ReceiverClass = Builder.CreateStructGEP(CastTy, ReceiverClass, 1); // Load the superclass pointer @@ -3270,9 +3263,7 @@ CGObjCGNU::GenerateProtocolList(ArrayRef Protocols) { llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF, const ObjCProtocolDecl *PD) { auto protocol = GenerateProtocolRef(PD); - llvm::Type *T = - CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType()); - return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T)); + return CGF.Builder.CreateBitCast(protocol, PtrTy); } llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/c
[clang] [CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128715)
@@ -2284,10 +2284,12 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion, BoolTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy); Int8Ty = llvm::Type::getInt8Ty(VMContext); + + PtrTy = llvm::PointerType::getUnqual(cgm.getLLVMContext()); junlarsen wrote: Simply re-ordered initialization here so the other types can refer to PtrTy https://github.com/llvm/llvm-project/pull/128715 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f98718c - Remove leftover unused variable from #128711
Author: Mats Jun Larsen Date: 2025-03-03T23:32:03+01:00 New Revision: f98718c9a169d90e676f877c5b6761b22f424b73 URL: https://github.com/llvm/llvm-project/commit/f98718c9a169d90e676f877c5b6761b22f424b73 DIFF: https://github.com/llvm/llvm-project/commit/f98718c9a169d90e676f877c5b6761b22f424b73.diff LOG: Remove leftover unused variable from #128711 Added: Modified: clang/lib/CodeGen/CGOpenMPRuntime.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index cfb7439e43e29..06a652c146fb9 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1847,7 +1847,6 @@ void CGOpenMPRuntime::emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, auto &&ThenGen = [&M, OutlinedFn, CapturedVars, RTLoc, this](CodeGenFunction &CGF, PrePostActionTy &) { // Build call __kmpc_fork_call(loc, n, microtask, var1, .., varn); -CGOpenMPRuntime &RT = CGF.CGM.getOpenMPRuntime(); llvm::Value *Args[] = { RTLoc, CGF.Builder.getInt32(CapturedVars.size()), // Number of captured vars ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/133871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Remove unused ExternalProtocolPtrTy (NFC) (PR #133870)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/133870 This function was previously used to get a type to the protocol that was used to bitcast the initializer of GenerateProtocol. This bitcast has later been removed (thanks to opaque pointers), but the member was left behind. History: - 020de3254acc3 used ExternalProtocolPtrTy - 34ee69b4ce662 removes the bitcast >From 306bdfcc1e4d73c50aa719c6a3186e5cc45243a1 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Mon, 31 Mar 2025 23:29:11 +0200 Subject: [PATCH] [clang][CGObjC] Remove unused ExternalProtocolPtrTy (NFC) This function was previously used to get a type to the protocol that was used to bitcast the initializer of GenerateProtocol. This bitcast has later been removed (thanks to opaque pointers), but the member was left behind. History: - 020de3254acc3 used ExternalProtocolPtrTy - 34ee69b4ce662 removes the bitcast --- clang/lib/CodeGen/CGObjCMac.cpp | 22 +- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 639c38e7c4555..026a8dc7d75ca 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -184,25 +184,6 @@ class ObjCCommonTypesHelper { /// SelectorPtrTy - LLVM type for selector handles (typeof(SEL)) llvm::PointerType *SelectorPtrTy; -private: - /// ProtocolPtrTy - LLVM type for external protocol handles - /// (typeof(Protocol)) - llvm::Type *ExternalProtocolPtrTy; - -public: - llvm::Type *getExternalProtocolPtrTy() { -if (!ExternalProtocolPtrTy) { - // FIXME: It would be nice to unify this with the opaque type, so that the - // IR comes out a bit cleaner. - CodeGen::CodeGenTypes &Types = CGM.getTypes(); - ASTContext &Ctx = CGM.getContext(); - llvm::Type *T = Types.ConvertType(Ctx.getObjCProtoType()); - ExternalProtocolPtrTy = llvm::PointerType::getUnqual(T); -} - -return ExternalProtocolPtrTy; - } - // SuperCTy - clang type for struct objc_super. QualType SuperCTy; // SuperPtrCTy - clang type for struct objc_super *. @@ -5636,8 +5617,7 @@ CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm) /* *** */ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) -: VMContext(cgm.getLLVMContext()), CGM(cgm), - ExternalProtocolPtrTy(nullptr) { +: VMContext(cgm.getLLVMContext()), CGM(cgm) { CodeGen::CodeGenTypes &Types = CGM.getTypes(); ASTContext &Ctx = CGM.getContext(); unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Remove unused ExternalProtocolPtrTy (NFC) (PR #133870)
junlarsen wrote: * **#133870** https://app.graphite.dev/github/pr/llvm/llvm-project/133870?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/133870?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/133870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)
https://github.com/junlarsen created https://github.com/llvm/llvm-project/pull/133871 Part of #123569 >From 0176250dfba2962f24e0e4d484b4ac0ce833bed5 Mon Sep 17 00:00:00 2001 From: Mats Jun Larsen Date: Mon, 31 Mar 2025 23:50:17 +0200 Subject: [PATCH] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) Part of #123569 --- clang/lib/CodeGen/CGObjCMac.cpp | 55 - 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 639c38e7c4555..98f988dfecf84 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2011,7 +2011,7 @@ CodeGen::RValue CGObjCMac::GenerateMessageSendSuper( CGF.Builder.CreateStructGEP(ObjCSuper, 0)); // If this is a class message the metaclass is passed as the target. - llvm::Type *ClassTyPtr = llvm::PointerType::getUnqual(ObjCTypes.ClassTy); + llvm::Type *ClassTyPtr = llvm::PointerType::getUnqual(VMContext); llvm::Value *Target; if (IsClassMessage) { if (isCategoryImpl) { @@ -5657,7 +5657,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) IvarOffsetVarTy = LongTy; ObjectPtrTy = cast(Types.ConvertType(Ctx.getObjCIdType())); - PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy); + PtrObjectPtrTy = llvm::PointerType::getUnqual(VMContext); SelectorPtrTy = cast(Types.ConvertType(Ctx.getObjCSelType())); @@ -5688,7 +5688,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) SuperPtrCTy = Ctx.getPointerType(SuperCTy); SuperTy = cast(Types.ConvertType(SuperCTy)); - SuperPtrTy = llvm::PointerType::getUnqual(SuperTy); + SuperPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _prop_t { // char *name; @@ -5704,7 +5704,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) PropertyListTy = llvm::StructType::create( "struct._prop_list_t", IntTy, IntTy, llvm::ArrayType::get(PropertyTy, 0)); // struct _prop_list_t * - PropertyListPtrTy = llvm::PointerType::getUnqual(PropertyListTy); + PropertyListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_method { // SEL _cmd; @@ -5716,7 +5716,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_cache * CacheTy = llvm::StructType::create(VMContext, "struct._objc_cache"); - CachePtrTy = llvm::PointerType::getUnqual(CacheTy); + CachePtrTy = llvm::PointerType::getUnqual(VMContext); } ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) @@ -5737,8 +5737,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) llvm::ArrayType::get(MethodDescriptionTy, 0)); // struct _objc_method_description_list * - MethodDescriptionListPtrTy = - llvm::PointerType::getUnqual(MethodDescriptionListTy); + MethodDescriptionListPtrTy = llvm::PointerType::getUnqual(VMContext); // Protocol description structures @@ -5756,7 +5755,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) PropertyListPtrTy); // struct _objc_protocol_extension * - ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(ProtocolExtensionTy); + ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(VMContext); // Handle construction of Protocol and ProtocolList types @@ -5779,9 +5778,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) "struct._objc_protocol_list"); // struct _objc_protocol_list * - ProtocolListPtrTy = llvm::PointerType::getUnqual(ProtocolListTy); + ProtocolListPtrTy = llvm::PointerType::getUnqual(VMContext); - ProtocolPtrTy = llvm::PointerType::getUnqual(ProtocolTy); + ProtocolPtrTy = llvm::PointerType::getUnqual(VMContext); // Class description structures @@ -5795,17 +5794,17 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) // struct _objc_ivar_list * IvarListTy = llvm::StructType::create(VMContext, "struct._objc_ivar_list"); - IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy); + IvarListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_method_list * MethodListTy = llvm::StructType::create(VMContext, "struct._objc_method_list"); - MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy); + MethodListPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_class_extension * ClassExtensionTy = llvm::StructType::create( "struct._objc_class_extension", IntTy, Int8PtrTy, PropertyListPtrTy); - ClassExtensionPtrTy = llvm::PointerType::getUnqual(ClassExtensionTy); + ClassExtensionPtrTy = llvm::PointerType::getUnqual(VMContext); // struct _objc_class { // Class isa; @@ -5828,7 +5827,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) Int8PtrTy, ClassExtensionPtrTy}, "stru
[clang] [clang][CGObjC] Prefer PointerType::get with LLVMContext over Type (NFC) (PR #133871)
junlarsen wrote: * **#133871** https://app.graphite.dev/github/pr/llvm/llvm-project/133871?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/133871?utm_source=stack-comment-view-in-graphite"; target="_blank">(View in Graphite) * `main` This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn more about https://stacking.dev/?utm_source=stack-comment";>stacking. https://github.com/llvm/llvm-project/pull/133871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Remove unused ExternalProtocolPtrTy (NFC) (PR #133870)
https://github.com/junlarsen closed https://github.com/llvm/llvm-project/pull/133870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CGObjC] Remove unused ExternalProtocolPtrTy (NFC) (PR #133870)
https://github.com/junlarsen edited https://github.com/llvm/llvm-project/pull/133870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits