summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoungsuk Kim <youngsuk.kim@hpe.com>2023-11-18 16:53:39 -0600
committerYoungsuk Kim <youngsuk.kim@hpe.com>2023-11-18 17:03:48 -0600
commitb08960f18888e96d64874486354c16b4116c5f8f (patch)
tree40efae129d28fe760307faac389beb208c4276c5
parentaeccab5664ed05ccd490302a699144d2c2dea59d (diff)
[CGObjCMac] Replace calls to ConstantAggregateBuilderBase::addBitCast (NFC)
Replace calls to `ConstantAggregateBuilderBase::addBitCast` that involve a no-op ptr-to-ptr bitcast. Opaque ptr cleanup effort (NFC)
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 4ac8c4dc9a38..ba52b23be018 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -2014,7 +2014,7 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
// Don't enforce the target's minimum global alignment, since the only use
// of the string is via this class initializer.
GV->setAlignment(llvm::Align(1));
- Fields.addBitCast(GV, CGM.Int8PtrTy);
+ Fields.add(GV);
// String length.
Fields.addInt(CGM.IntTy, StringLength);
@@ -3557,8 +3557,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
// Record a reference to the super class.
LazySymbols.insert(Super->getIdentifier());
- values.addBitCast(GetClassName(Super->getObjCRuntimeNameAsString()),
- ObjCTypes.ClassPtrTy);
+ values.add(GetClassName(Super->getObjCRuntimeNameAsString()));
} else {
values.addNullPointer(ObjCTypes.ClassPtrTy);
}
@@ -3612,14 +3611,12 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
const ObjCInterfaceDecl *Root = ID->getClassInterface();
while (const ObjCInterfaceDecl *Super = Root->getSuperClass())
Root = Super;
- values.addBitCast(GetClassName(Root->getObjCRuntimeNameAsString()),
- ObjCTypes.ClassPtrTy);
+ values.add(GetClassName(Root->getObjCRuntimeNameAsString()));
// The super class for the metaclass is emitted as the name of the
// super class. The runtime fixes this up to point to the
// *metaclass* for the super class.
if (ObjCInterfaceDecl *Super = ID->getClassInterface()->getSuperClass()) {
- values.addBitCast(GetClassName(Super->getObjCRuntimeNameAsString()),
- ObjCTypes.ClassPtrTy);
+ values.add(GetClassName(Super->getObjCRuntimeNameAsString()));
} else {
values.addNullPointer(ObjCTypes.ClassPtrTy);
}
@@ -3815,8 +3812,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
void CGObjCMac::emitMethodDescriptionConstant(ConstantArrayBuilder &builder,
const ObjCMethodDecl *MD) {
auto description = builder.beginStruct(ObjCTypes.MethodDescriptionTy);
- description.addBitCast(GetMethodVarName(MD->getSelector()),
- ObjCTypes.SelectorPtrTy);
+ description.add(GetMethodVarName(MD->getSelector()));
description.add(GetMethodVarType(MD));
description.finishAndAddTo(builder);
}
@@ -3834,10 +3830,9 @@ void CGObjCMac::emitMethodConstant(ConstantArrayBuilder &builder,
assert(fn && "no definition registered for method");
auto method = builder.beginStruct(ObjCTypes.MethodTy);
- method.addBitCast(GetMethodVarName(MD->getSelector()),
- ObjCTypes.SelectorPtrTy);
+ method.add(GetMethodVarName(MD->getSelector()));
method.add(GetMethodVarType(MD));
- method.addBitCast(fn, ObjCTypes.Int8PtrTy);
+ method.add(fn);
method.finishAndAddTo(builder);
}
@@ -5191,10 +5186,10 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() {
if (ID->isWeakImported() && !IMP->isWeakImported())
DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage);
- array.addBitCast(DefinedClasses[i], ObjCTypes.Int8PtrTy);
+ array.add(DefinedClasses[i]);
}
for (unsigned i=0; i<NumCategories; i++)
- array.addBitCast(DefinedCategories[i], ObjCTypes.Int8PtrTy);
+ array.add(DefinedCategories[i]);
array.finishAndAddTo(values);
@@ -6735,8 +6730,7 @@ void CGObjCNonFragileABIMac::emitMethodConstant(ConstantArrayBuilder &builder,
const ObjCMethodDecl *MD,
bool forProtocol) {
auto method = builder.beginStruct(ObjCTypes.MethodTy);
- method.addBitCast(GetMethodVarName(MD->getSelector()),
- ObjCTypes.SelectorPtrTy);
+ method.add(GetMethodVarName(MD->getSelector()));
method.add(GetMethodVarType(MD));
if (forProtocol) {
@@ -6745,7 +6739,7 @@ void CGObjCNonFragileABIMac::emitMethodConstant(ConstantArrayBuilder &builder,
} else {
llvm::Function *fn = GetMethodDefinition(MD);
assert(fn && "no definition for method?");
- method.addBitCast(fn, ObjCTypes.Int8PtrProgramASTy);
+ method.add(fn);
}
method.finishAndAddTo(builder);