[clang] a540808 - [CGObjCGNU] Remove unneeded method 'CGObjCGNUstep2::EnforceType' (NFC)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 18 12:08:40 PST 2023
Author: Youngsuk Kim
Date: 2023-11-18T14:06:45-06:00
New Revision: a540808de254b18b304aa0915638a0900b36d9fa
URL: https://github.com/llvm/llvm-project/commit/a540808de254b18b304aa0915638a0900b36d9fa
DIFF: https://github.com/llvm/llvm-project/commit/a540808de254b18b304aa0915638a0900b36d9fa.diff
LOG: [CGObjCGNU] Remove unneeded method 'CGObjCGNUstep2::EnforceType' (NFC)
Method CGObjCGNUstep2::EnforceType is called from 2 call-sites to perform
bitcasts which are no-ops given that opaque pointers are enabled in LLVM.
Remove the method. Opaque ptr cleanup effort (NFC).
Added:
Modified:
clang/lib/CodeGen/CGObjCGNU.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index ffffbd9e8b2b3bf..01fd8f5a00ee39f 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1421,11 +1421,6 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
Protocol = GV;
return GV;
}
- llvm::Constant *EnforceType(llvm::Constant *Val, llvm::Type *Ty) {
- if (Val->getType() == Ty)
- return Val;
- return llvm::ConstantExpr::getBitCast(Val, Ty);
- }
llvm::Value *GetTypedSelector(CodeGenFunction &CGF, Selector Sel,
const std::string &TypeEncoding) override {
return GetConstantSelector(Sel, TypeEncoding);
@@ -1462,7 +1457,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
auto SelVarName = (StringRef(".objc_selector_") + Sel.getAsString() + "_" +
MangledTypes).str();
if (auto *GV = TheModule.getNamedGlobal(SelVarName))
- return EnforceType(GV, SelectorTy);
+ return GV;
ConstantInitBuilder builder(CGM);
auto SelBuilder = builder.beginStruct();
SelBuilder.add(ExportUniqueString(Sel.getAsString(), ".objc_sel_name_",
@@ -1473,8 +1468,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
GV->setComdat(TheModule.getOrInsertComdat(SelVarName));
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
GV->setSection(sectionName<SelectorSection>());
- auto *SelVal = EnforceType(GV, SelectorTy);
- return SelVal;
+ return GV;
}
llvm::StructType *emptyStruct = nullptr;
More information about the cfe-commits
mailing list