-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[CodeGen][ObjCGNU] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) #128715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@llvm/pr-subscribers-clang Author: Mats Jun Larsen (junlarsen) ChangesFollow-up to #123569 Full diff: https://github.com/llvm/llvm-project/pull/128715.diff 1 Files Affected:
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<std::string> 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) {
|
|
@llvm/pr-subscribers-clang-codegen Author: Mats Jun Larsen (junlarsen) ChangesFollow-up to #123569 Full diff: https://github.com/llvm/llvm-project/pull/128715.diff 1 Files Affected:
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<std::string> 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) {
|
25790b6 to
e993b0d
Compare
e993b0d to
28e5c87
Compare
| ProtocolPtrTy = llvm::PointerType::getUnqual( | ||
| Types.ConvertType(CGM.getContext().getObjCProtoType())); | ||
| PtrToInt8Ty = PtrTy; | ||
| ProtocolPtrTy = PtrTy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably drop all these duplicate types in a followup...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I can look into this in the future
Merge activity
|
28e5c87 to
3d2d02b
Compare
…ointer version (NFC) Follow-up to #123569
3d2d02b to
bb126b5
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/16825 Here is the relevant piece of the build log for the reference |

Follow-up to #123569