Skip to content

Commit

Permalink
[CGObjCGNU] Remove unneeded method 'CGObjCGNUstep2::EnforceType' (NFC)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
JOE1994 committed Nov 18, 2023
1 parent f0da97d commit a540808
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions clang/lib/CodeGen/CGObjCGNU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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_",
Expand All @@ -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;

Expand Down

0 comments on commit a540808

Please sign in to comment.