@@ -1784,7 +1784,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1784
1784
}
1785
1785
}
1786
1786
if (!IsCOFF)
1787
- classFields.add (llvm::ConstantExpr::getBitCast ( SuperClass, PtrTy) );
1787
+ classFields.add (SuperClass);
1788
1788
else
1789
1789
classFields.addNullPointer (PtrTy);
1790
1790
} else
@@ -1959,16 +1959,14 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1959
1959
// Resolve the class aliases, if they exist.
1960
1960
// FIXME: Class pointer aliases shouldn't exist!
1961
1961
if (ClassPtrAlias) {
1962
- ClassPtrAlias->replaceAllUsesWith (
1963
- llvm::ConstantExpr::getBitCast (classStruct, IdTy));
1962
+ ClassPtrAlias->replaceAllUsesWith (classStruct);
1964
1963
ClassPtrAlias->eraseFromParent ();
1965
1964
ClassPtrAlias = nullptr ;
1966
1965
}
1967
1966
if (auto Placeholder =
1968
1967
TheModule.getNamedGlobal (SymbolForClass (className)))
1969
1968
if (Placeholder != classStruct) {
1970
- Placeholder->replaceAllUsesWith (
1971
- llvm::ConstantExpr::getBitCast (classStruct, Placeholder->getType ()));
1969
+ Placeholder->replaceAllUsesWith (classStruct);
1972
1970
Placeholder->eraseFromParent ();
1973
1971
classStruct->setName (SymbolForClass (className));
1974
1972
}
@@ -2415,7 +2413,7 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
2415
2413
false ,
2416
2414
llvm::GlobalValue::ExternalLinkage,
2417
2415
nullptr , " __objc_id_type_info" );
2418
- return llvm::ConstantExpr::getBitCast ( IDEHType, PtrToInt8Ty) ;
2416
+ return IDEHType;
2419
2417
}
2420
2418
2421
2419
const ObjCObjectPointerType *PT =
@@ -2429,9 +2427,8 @@ llvm::Constant *CGObjCGNUstep::GetEHType(QualType T) {
2429
2427
std::string typeinfoName = " __objc_eh_typeinfo_" + className;
2430
2428
2431
2429
// Return the existing typeinfo if it exists
2432
- llvm::Constant *typeinfo = TheModule.getGlobalVariable (typeinfoName);
2433
- if (typeinfo)
2434
- return llvm::ConstantExpr::getBitCast (typeinfo, PtrToInt8Ty);
2430
+ if (llvm::Constant *typeinfo = TheModule.getGlobalVariable (typeinfoName))
2431
+ return typeinfo;
2435
2432
2436
2433
// Otherwise create it.
2437
2434
@@ -2495,9 +2492,7 @@ ConstantAddress CGObjCGNU::GenerateConstantString(const StringLiteral *SL) {
2495
2492
Fields.add (isa);
2496
2493
Fields.add (MakeConstantString (Str));
2497
2494
Fields.addInt (IntTy, Str.size ());
2498
- llvm::Constant *ObjCStr =
2499
- Fields.finishAndCreateGlobal (" .objc_str" , Align);
2500
- ObjCStr = llvm::ConstantExpr::getBitCast (ObjCStr, PtrToInt8Ty);
2495
+ llvm::Constant *ObjCStr = Fields.finishAndCreateGlobal (" .objc_str" , Align);
2501
2496
ObjCStrings[Str] = ObjCStr;
2502
2497
ConstantStrings.push_back (ObjCStr);
2503
2498
return ConstantAddress (ObjCStr, Int8Ty, Align);
@@ -3060,8 +3055,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
3060
3055
Elements.finishAndCreateGlobal (ClassSym, CGM.getPointerAlign (), false ,
3061
3056
llvm::GlobalValue::ExternalLinkage);
3062
3057
if (ClassRef) {
3063
- ClassRef->replaceAllUsesWith (llvm::ConstantExpr::getBitCast (Class,
3064
- ClassRef->getType ()));
3058
+ ClassRef->replaceAllUsesWith (Class);
3065
3059
ClassRef->removeFromParent ();
3066
3060
Class->setName (ClassSym);
3067
3061
}
@@ -3227,9 +3221,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
3227
3221
Elements.add (PropertyList);
3228
3222
Elements.add (OptionalPropertyList);
3229
3223
ExistingProtocols[ProtocolName] =
3230
- llvm::ConstantExpr::getBitCast (
3231
- Elements.finishAndCreateGlobal (" .objc_protocol" , CGM.getPointerAlign ()),
3232
- IdTy);
3224
+ Elements.finishAndCreateGlobal (" .objc_protocol" , CGM.getPointerAlign ());
3233
3225
}
3234
3226
void CGObjCGNU::GenerateProtocolHolderCategory () {
3235
3227
// Collect information about instance methods
@@ -3263,9 +3255,8 @@ void CGObjCGNU::GenerateProtocolHolderCategory() {
3263
3255
ProtocolList.finishAndCreateGlobal (" .objc_protocol_list" ,
3264
3256
CGM.getPointerAlign ()),
3265
3257
PtrTy);
3266
- Categories.push_back (llvm::ConstantExpr::getBitCast (
3267
- Elements.finishAndCreateGlobal (" " , CGM.getPointerAlign ()),
3268
- PtrTy));
3258
+ Categories.push_back (
3259
+ Elements.finishAndCreateGlobal (" " , CGM.getPointerAlign ()));
3269
3260
}
3270
3261
3271
3262
// / Libobjc2 uses a bitfield representation where small(ish) bitfields are
@@ -3736,7 +3727,6 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
3736
3727
3737
3728
statics = allStaticsArray.finishAndCreateGlobal (" .objc_statics_ptr" ,
3738
3729
CGM.getPointerAlign ());
3739
- statics = llvm::ConstantExpr::getBitCast (statics, PtrTy);
3740
3730
}
3741
3731
3742
3732
// Array of classes, categories, and constant objects.
@@ -3799,9 +3789,6 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
3799
3789
// FIXME: We're generating redundant loads and stores here!
3800
3790
llvm::Constant *selPtr = llvm::ConstantExpr::getGetElementPtr (
3801
3791
selectorList->getValueType (), selectorList, idxs);
3802
- // If selectors are defined as an opaque type, cast the pointer to this
3803
- // type.
3804
- selPtr = llvm::ConstantExpr::getBitCast (selPtr, SelectorTy);
3805
3792
selectorAliases[i]->replaceAllUsesWith (selPtr);
3806
3793
selectorAliases[i]->eraseFromParent ();
3807
3794
}
@@ -3922,7 +3909,6 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
3922
3909
llvm::Constant *TheClass =
3923
3910
TheModule.getGlobalVariable (" _OBJC_CLASS_" + iter->first , true );
3924
3911
if (TheClass) {
3925
- TheClass = llvm::ConstantExpr::getBitCast (TheClass, PtrTy);
3926
3912
Builder.CreateCall (RegisterAlias,
3927
3913
{TheClass, MakeConstantString (iter->second )});
3928
3914
}
0 commit comments