Skip to content

Commit a21ae2f

Browse files
authored
[CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (llvm#128715)
Follow-up to llvm#123569
1 parent f2473bc commit a21ae2f

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ class CGObjCGNUstep : public CGObjCGNU {
819819
const ObjCRuntime &R = CGM.getLangOpts().ObjCRuntime;
820820

821821
SlotStructTy = llvm::StructType::get(PtrTy, PtrTy, PtrTy, IntTy, IMPTy);
822-
SlotTy = llvm::PointerType::getUnqual(SlotStructTy);
822+
SlotTy = PtrTy;
823823
// Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender);
824824
SlotLookupFn.init(&CGM, "objc_msg_lookup_sender", SlotTy, PtrToIdTy,
825825
SelectorTy, IdTy);
@@ -2284,10 +2284,12 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
22842284
BoolTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
22852285

22862286
Int8Ty = llvm::Type::getInt8Ty(VMContext);
2287+
2288+
PtrTy = llvm::PointerType::getUnqual(cgm.getLLVMContext());
2289+
PtrToIntTy = PtrTy;
22872290
// C string type. Used in lots of places.
2288-
PtrToInt8Ty = llvm::PointerType::getUnqual(Int8Ty);
2289-
ProtocolPtrTy = llvm::PointerType::getUnqual(
2290-
Types.ConvertType(CGM.getContext().getObjCProtoType()));
2291+
PtrToInt8Ty = PtrTy;
2292+
ProtocolPtrTy = PtrTy;
22912293

22922294
Zeros[0] = llvm::ConstantInt::get(LongTy, 0);
22932295
Zeros[1] = Zeros[0];
@@ -2302,9 +2304,6 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
23022304
SelectorElemTy = CGM.getTypes().ConvertTypeForMem(selTy->getPointeeType());
23032305
}
23042306

2305-
PtrToIntTy = llvm::PointerType::getUnqual(IntTy);
2306-
PtrTy = PtrToInt8Ty;
2307-
23082307
Int32Ty = llvm::Type::getInt32Ty(VMContext);
23092308
Int64Ty = llvm::Type::getInt64Ty(VMContext);
23102309

@@ -2323,7 +2322,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
23232322
IdTy = PtrToInt8Ty;
23242323
IdElemTy = Int8Ty;
23252324
}
2326-
PtrToIdTy = llvm::PointerType::getUnqual(IdTy);
2325+
PtrToIdTy = PtrTy;
23272326
ProtocolTy = llvm::StructType::get(IdTy,
23282327
PtrToInt8Ty, // name
23292328
PtrToInt8Ty, // protocols
@@ -2351,7 +2350,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
23512350
PtrToInt8Ty, PtrToInt8Ty });
23522351

23532352
ObjCSuperTy = llvm::StructType::get(IdTy, IdTy);
2354-
PtrToObjCSuperTy = llvm::PointerType::getUnqual(ObjCSuperTy);
2353+
PtrToObjCSuperTy = PtrTy;
23552354

23562355
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
23572356

@@ -2383,9 +2382,7 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
23832382
PtrDiffTy, BoolTy, BoolTy);
23842383

23852384
// IMP type
2386-
llvm::Type *IMPArgs[] = { IdTy, SelectorTy };
2387-
IMPTy = llvm::PointerType::getUnqual(llvm::FunctionType::get(IdTy, IMPArgs,
2388-
true));
2385+
IMPTy = PtrTy;
23892386

23902387
const LangOptions &Opts = CGM.getLangOpts();
23912388
if ((Opts.getGC() != LangOptions::NonGC) || Opts.ObjCAutoRefCount)
@@ -2679,8 +2676,6 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
26792676
Class->getSuperClass()->getNameAsString(), /*isWeak*/false);
26802677
if (IsClassMessage) {
26812678
// Load the isa pointer of the superclass is this is a class method.
2682-
ReceiverClass = Builder.CreateBitCast(ReceiverClass,
2683-
llvm::PointerType::getUnqual(IdTy));
26842679
ReceiverClass =
26852680
Builder.CreateAlignedLoad(IdTy, ReceiverClass, CGF.getPointerAlign());
26862681
}
@@ -2721,8 +2716,6 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
27212716
}
27222717
// Cast the pointer to a simplified version of the class structure
27232718
llvm::Type *CastTy = llvm::StructType::get(IdTy, IdTy);
2724-
ReceiverClass = Builder.CreateBitCast(ReceiverClass,
2725-
llvm::PointerType::getUnqual(CastTy));
27262719
// Get the superclass pointer
27272720
ReceiverClass = Builder.CreateStructGEP(CastTy, ReceiverClass, 1);
27282721
// Load the superclass pointer
@@ -3269,10 +3262,7 @@ CGObjCGNU::GenerateProtocolList(ArrayRef<std::string> Protocols) {
32693262

32703263
llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction &CGF,
32713264
const ObjCProtocolDecl *PD) {
3272-
auto protocol = GenerateProtocolRef(PD);
3273-
llvm::Type *T =
3274-
CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
3275-
return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
3265+
return GenerateProtocolRef(PD);
32763266
}
32773267

32783268
llvm::Constant *CGObjCGNU::GenerateProtocolRef(const ObjCProtocolDecl *PD) {

0 commit comments

Comments
 (0)