Skip to content

Commit 1de568d

Browse files
committed
[GlobalOpt] Simplify replacement of call with global
With opaque pointers, we no longer need to insert the bitcast.
1 parent d2f2ef8 commit 1de568d

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

llvm/lib/Transforms/IPO/GlobalOpt.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -930,22 +930,7 @@ OptimizeGlobalAddressOfAllocation(GlobalVariable *GV, CallInst *CI,
930930
}
931931

932932
// Update users of the allocation to use the new global instead.
933-
BitCastInst *TheBC = nullptr;
934-
while (!CI->use_empty()) {
935-
Instruction *User = cast<Instruction>(CI->user_back());
936-
if (BitCastInst *BCI = dyn_cast<BitCastInst>(User)) {
937-
if (BCI->getType() == NewGV->getType()) {
938-
BCI->replaceAllUsesWith(NewGV);
939-
BCI->eraseFromParent();
940-
} else {
941-
BCI->setOperand(0, NewGV);
942-
}
943-
} else {
944-
if (!TheBC)
945-
TheBC = new BitCastInst(NewGV, CI->getType(), "newgv", CI);
946-
User->replaceUsesOfWith(CI, TheBC);
947-
}
948-
}
933+
CI->replaceAllUsesWith(NewGV);
949934

950935
SmallSetVector<Constant *, 1> RepValues;
951936
RepValues.insert(NewGV);

0 commit comments

Comments
 (0)