@@ -1014,8 +1014,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1014
1014
if (CGM.getTriple ().isOSBinFormatCOFF ()) {
1015
1015
cast<llvm::GlobalValue>(isa)->setDLLStorageClass (llvm::GlobalValue::DLLImportStorageClass);
1016
1016
}
1017
- } else if (isa->getType () != PtrToIdTy)
1018
- isa = llvm::ConstantExpr::getBitCast (isa, PtrToIdTy);
1017
+ }
1019
1018
1020
1019
// struct
1021
1020
// {
@@ -1108,10 +1107,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1108
1107
std::pair<llvm::GlobalVariable*, int > v{ObjCStrGV, 0 };
1109
1108
EarlyInitList.emplace_back (Sym, v);
1110
1109
}
1111
- llvm::Constant *ObjCStr = llvm::ConstantExpr::getBitCast (ObjCStrGV, IdTy);
1112
- ObjCStrings[Str] = ObjCStr;
1113
- ConstantStrings.push_back (ObjCStr);
1114
- return ConstantAddress (ObjCStr, IdElemTy, Align);
1110
+ ObjCStrings[Str] = ObjCStrGV;
1111
+ ConstantStrings.push_back (ObjCStrGV);
1112
+ return ConstantAddress (ObjCStrGV, IdElemTy, Align);
1115
1113
}
1116
1114
1117
1115
void PushProperty (ConstantArrayBuilder &PropertiesArray,
@@ -1193,9 +1191,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1193
1191
ReferencedProtocols.end ());
1194
1192
SmallVector<llvm::Constant *, 16 > Protocols;
1195
1193
for (const auto *PI : RuntimeProtocols)
1196
- Protocols.push_back (
1197
- llvm::ConstantExpr::getBitCast (GenerateProtocolRef (PI),
1198
- ProtocolPtrTy));
1194
+ Protocols.push_back (GenerateProtocolRef (PI));
1199
1195
return GenerateProtocolList (Protocols);
1200
1196
}
1201
1197
@@ -1305,7 +1301,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1305
1301
llvm::GlobalValue::ExternalLinkage, nullptr , Name);
1306
1302
GV->setAlignment (CGM.getPointerAlign ().getAsAlign ());
1307
1303
}
1308
- return llvm::ConstantExpr::getBitCast (GV, ProtocolPtrTy) ;
1304
+ return GV ;
1309
1305
}
1310
1306
1311
1307
// / Existing protocol references.
@@ -1322,9 +1318,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1322
1318
std::string RefName = SymbolForProtocolRef (Name);
1323
1319
assert (!TheModule.getGlobalVariable (RefName));
1324
1320
// Emit a reference symbol.
1325
- auto GV = new llvm::GlobalVariable (TheModule, ProtocolPtrTy,
1326
- false , llvm::GlobalValue::LinkOnceODRLinkage,
1327
- llvm::ConstantExpr::getBitCast (Protocol, ProtocolPtrTy) , RefName);
1321
+ auto GV = new llvm::GlobalVariable (TheModule, ProtocolPtrTy, false ,
1322
+ llvm::GlobalValue::LinkOnceODRLinkage,
1323
+ Protocol , RefName);
1328
1324
GV->setComdat (TheModule.getOrInsertComdat (RefName));
1329
1325
GV->setSection (sectionName<ProtocolReferenceSection>());
1330
1326
GV->setAlignment (CGM.getPointerAlign ().getAsAlign ());
@@ -1381,9 +1377,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1381
1377
auto RuntimeProtocols =
1382
1378
GetRuntimeProtocolList (PD->protocol_begin (), PD->protocol_end ());
1383
1379
for (const auto *PI : RuntimeProtocols)
1384
- Protocols.push_back (
1385
- llvm::ConstantExpr::getBitCast (GenerateProtocolRef (PI),
1386
- ProtocolPtrTy));
1380
+ Protocols.push_back (GenerateProtocolRef (PI));
1387
1381
llvm::Constant *ProtocolList = GenerateProtocolList (Protocols);
1388
1382
1389
1383
// Collect information about methods
@@ -1420,8 +1414,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
1420
1414
GV->setSection (sectionName<ProtocolSection>());
1421
1415
GV->setComdat (TheModule.getOrInsertComdat (SymName));
1422
1416
if (OldGV) {
1423
- OldGV->replaceAllUsesWith (llvm::ConstantExpr::getBitCast (GV,
1424
- OldGV->getType ()));
1417
+ OldGV->replaceAllUsesWith (GV);
1425
1418
OldGV->removeFromParent ();
1426
1419
GV->setName (SymName);
1427
1420
}
@@ -2493,10 +2486,9 @@ ConstantAddress CGObjCGNU::GenerateConstantString(const StringLiteral *SL) {
2493
2486
llvm::Constant *isa = TheModule.getNamedGlobal (Sym);
2494
2487
2495
2488
if (!isa)
2496
- isa = new llvm::GlobalVariable (TheModule, IdTy, /* isConstant */ false ,
2497
- llvm::GlobalValue::ExternalWeakLinkage, nullptr , Sym);
2498
- else if (isa->getType () != PtrToIdTy)
2499
- isa = llvm::ConstantExpr::getBitCast (isa, PtrToIdTy);
2489
+ isa = new llvm::GlobalVariable (TheModule, IdTy, /* isConstant */ false ,
2490
+ llvm::GlobalValue::ExternalWeakLinkage,
2491
+ nullptr , Sym);
2500
2492
2501
2493
ConstantInitBuilder Builder (CGM);
2502
2494
auto Fields = Builder.beginStruct ();
0 commit comments