|
@@ -3811,6 +3811,9 @@ static void ReplaceConstantWithInst(Constant *C, Value *V, IRBuilder<> &Builder)
|
|
|
if (Instruction *I = dyn_cast<Instruction>(U)) {
|
|
|
I->replaceUsesOfWith(C, V);
|
|
|
} else {
|
|
|
+ // Skip unused ConstantExpr.
|
|
|
+ if (U->user_empty())
|
|
|
+ continue;
|
|
|
ConstantExpr *CE = cast<ConstantExpr>(U);
|
|
|
Instruction *Inst = CE->getAsInstruction();
|
|
|
Builder.Insert(Inst);
|
|
@@ -3818,6 +3821,7 @@ static void ReplaceConstantWithInst(Constant *C, Value *V, IRBuilder<> &Builder)
|
|
|
ReplaceConstantWithInst(CE, Inst, Builder);
|
|
|
}
|
|
|
}
|
|
|
+ C->removeDeadConstantUsers();
|
|
|
}
|
|
|
|
|
|
static void ReplaceUnboundedArrayUses(Value *V, Value *Src, IRBuilder<> &Builder) {
|