@@ -3194,8 +3194,9 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
3194
3194
if (GV->getAddressSpace () !=
3195
3195
getDataLayout ().getDefaultGlobalsAddressSpace ()) {
3196
3196
GVInGlobalsAS = llvm::ConstantExpr::getAddrSpaceCast (
3197
- GV, GV->getValueType ()->getPointerTo (
3198
- getDataLayout ().getDefaultGlobalsAddressSpace ()));
3197
+ GV,
3198
+ llvm::PointerType::get (
3199
+ GV->getContext (), getDataLayout ().getDefaultGlobalsAddressSpace ()));
3199
3200
}
3200
3201
3201
3202
// Create the ConstantStruct for the global annotation.
@@ -3445,9 +3446,7 @@ ConstantAddress CodeGenModule::GetAddrOfMSGuidDecl(const MSGuidDecl *GD) {
3445
3446
}
3446
3447
3447
3448
llvm::Type *Ty = getTypes ().ConvertTypeForMem (GD->getType ());
3448
- llvm::Constant *Addr = llvm::ConstantExpr::getBitCast (
3449
- GV, Ty->getPointerTo (GV->getAddressSpace ()));
3450
- return ConstantAddress (Addr, Ty, Alignment);
3449
+ return ConstantAddress (GV, Ty, Alignment);
3451
3450
}
3452
3451
3453
3452
ConstantAddress CodeGenModule::GetAddrOfUnnamedGlobalConstantDecl (
@@ -3521,11 +3520,8 @@ ConstantAddress CodeGenModule::GetWeakRefReference(const ValueDecl *VD) {
3521
3520
3522
3521
// See if there is already something with the target's name in the module.
3523
3522
llvm::GlobalValue *Entry = GetGlobalValue (AA->getAliasee ());
3524
- if (Entry) {
3525
- unsigned AS = getTypes ().getTargetAddressSpace (VD->getType ());
3526
- auto Ptr = llvm::ConstantExpr::getBitCast (Entry, DeclTy->getPointerTo (AS));
3527
- return ConstantAddress (Ptr, DeclTy, Alignment);
3528
- }
3523
+ if (Entry)
3524
+ return ConstantAddress (Entry, DeclTy, Alignment);
3529
3525
3530
3526
llvm::Constant *Aliasee;
3531
3527
if (isa<llvm::FunctionType>(DeclTy))
@@ -4359,8 +4355,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
4359
4355
// (If function is requested for a definition, we always need to create a new
4360
4356
// function, not just return a bitcast.)
4361
4357
if (!IsForDefinition)
4362
- return llvm::ConstantExpr::getBitCast (
4363
- Entry, Ty->getPointerTo (Entry->getAddressSpace ()));
4358
+ return Entry;
4364
4359
}
4365
4360
4366
4361
// This function doesn't have a complete type (for example, the return
@@ -4400,9 +4395,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
4400
4395
Entry->removeDeadConstantUsers ();
4401
4396
}
4402
4397
4403
- llvm::Constant *BC = llvm::ConstantExpr::getBitCast (
4404
- F, Entry->getValueType ()->getPointerTo (Entry->getAddressSpace ()));
4405
- addGlobalValReplacement (Entry, BC);
4398
+ addGlobalValReplacement (Entry, F);
4406
4399
}
4407
4400
4408
4401
assert (F->getName () == MangledName && " name was uniqued!" );
@@ -4464,8 +4457,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
4464
4457
return F;
4465
4458
}
4466
4459
4467
- return llvm::ConstantExpr::getBitCast (F,
4468
- Ty->getPointerTo (F->getAddressSpace ()));
4460
+ return F;
4469
4461
}
4470
4462
4471
4463
// / GetAddrOfFunction - Return the address of the given function. If Ty is
@@ -4502,7 +4494,7 @@ CodeGenModule::GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty, bool ForVTable,
4502
4494
cast<llvm::Function>(F->stripPointerCasts ()), GD);
4503
4495
if (IsForDefinition)
4504
4496
return F;
4505
- return llvm::ConstantExpr::getBitCast ( Handle, Ty-> getPointerTo ()) ;
4497
+ return Handle;
4506
4498
}
4507
4499
return F;
4508
4500
}
@@ -4650,15 +4642,14 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
4650
4642
}
4651
4643
4652
4644
// Make sure the result is of the correct type.
4653
- if (Entry->getType ()->getAddressSpace () != TargetAS) {
4654
- return llvm::ConstantExpr::getAddrSpaceCast (Entry,
4655
- Ty->getPointerTo (TargetAS));
4656
- }
4645
+ if (Entry->getType ()->getAddressSpace () != TargetAS)
4646
+ return llvm::ConstantExpr::getAddrSpaceCast (
4647
+ Entry, llvm::PointerType::get (Ty->getContext (), TargetAS));
4657
4648
4658
4649
// (If global is requested for a definition, we always need to create a new
4659
4650
// global, not just return a bitcast.)
4660
4651
if (!IsForDefinition)
4661
- return llvm::ConstantExpr::getBitCast ( Entry, Ty-> getPointerTo (TargetAS)) ;
4652
+ return Entry;
4662
4653
}
4663
4654
4664
4655
auto DAddrSpace = GetGlobalVarAddressSpace (D);
0 commit comments