Skip to content

Commit a540808

Browse files
committed
[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).
1 parent f0da97d commit a540808

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,11 +1421,6 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
14211421
Protocol = GV;
14221422
return GV;
14231423
}
1424-
llvm::Constant *EnforceType(llvm::Constant *Val, llvm::Type *Ty) {
1425-
if (Val->getType() == Ty)
1426-
return Val;
1427-
return llvm::ConstantExpr::getBitCast(Val, Ty);
1428-
}
14291424
llvm::Value *GetTypedSelector(CodeGenFunction &CGF, Selector Sel,
14301425
const std::string &TypeEncoding) override {
14311426
return GetConstantSelector(Sel, TypeEncoding);
@@ -1462,7 +1457,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
14621457
auto SelVarName = (StringRef(".objc_selector_") + Sel.getAsString() + "_" +
14631458
MangledTypes).str();
14641459
if (auto *GV = TheModule.getNamedGlobal(SelVarName))
1465-
return EnforceType(GV, SelectorTy);
1460+
return GV;
14661461
ConstantInitBuilder builder(CGM);
14671462
auto SelBuilder = builder.beginStruct();
14681463
SelBuilder.add(ExportUniqueString(Sel.getAsString(), ".objc_sel_name_",
@@ -1473,8 +1468,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
14731468
GV->setComdat(TheModule.getOrInsertComdat(SelVarName));
14741469
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
14751470
GV->setSection(sectionName<SelectorSection>());
1476-
auto *SelVal = EnforceType(GV, SelectorTy);
1477-
return SelVal;
1471+
return GV;
14781472
}
14791473
llvm::StructType *emptyStruct = nullptr;
14801474

0 commit comments

Comments
 (0)