[clang] b08960f - [CGObjCMac] Replace calls to ConstantAggregateBuilderBase::addBitCast (NFC)
Youngsuk Kim via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 18 15:10:45 PST 2023
Author: Youngsuk Kim
Date: 2023-11-18T17:03:48-06:00
New Revision: b08960f18888e96d64874486354c16b4116c5f8f
URL: https://github.com/llvm/llvm-project/commit/b08960f18888e96d64874486354c16b4116c5f8f
DIFF: https://github.com/llvm/llvm-project/commit/b08960f18888e96d64874486354c16b4116c5f8f.diff
LOG: [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)
Added:
Modified:
clang/lib/CodeGen/CGObjCMac.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 4ac8c4dc9a38745..ba52b23be018b85 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);
More information about the cfe-commits
mailing list