@@ -54,18 +54,6 @@ bool SCCPSolver::isOverdefined(const ValueLatticeElement &LV) {
54
54
return !LV.isUnknownOrUndef () && !SCCPSolver::isConstant (LV);
55
55
}
56
56
57
- static bool canRemoveInstruction (Instruction *I) {
58
- if (wouldInstructionBeTriviallyDead (I))
59
- return true ;
60
-
61
- // Some instructions can be handled but are rejected above. Catch
62
- // those cases by falling through to here.
63
- // TODO: Mark globals as being constant earlier, so
64
- // TODO: wouldInstructionBeTriviallyDead() knows that atomic loads
65
- // TODO: are safe to remove.
66
- return isa<LoadInst>(I);
67
- }
68
-
69
57
bool SCCPSolver::tryToReplaceWithConstant (Value *V) {
70
58
Constant *Const = getConstantOrNull (V);
71
59
if (!Const)
@@ -75,8 +63,7 @@ bool SCCPSolver::tryToReplaceWithConstant(Value *V) {
75
63
// Calls with "clang.arc.attachedcall" implicitly use the return value and
76
64
// those uses cannot be updated with a constant.
77
65
CallBase *CB = dyn_cast<CallBase>(V);
78
- if (CB && ((CB->isMustTailCall () &&
79
- !canRemoveInstruction (CB)) ||
66
+ if (CB && ((CB->isMustTailCall () && !wouldInstructionBeTriviallyDead (CB)) ||
80
67
CB->getOperandBundle (LLVMContext::OB_clang_arc_attachedcall))) {
81
68
Function *F = CB->getCalledFunction ();
82
69
@@ -244,7 +231,7 @@ bool SCCPSolver::simplifyInstsInBlock(BasicBlock &BB,
244
231
if (Inst.getType ()->isVoidTy ())
245
232
continue ;
246
233
if (tryToReplaceWithConstant (&Inst)) {
247
- if (canRemoveInstruction (&Inst))
234
+ if (wouldInstructionBeTriviallyDead (&Inst))
248
235
Inst.eraseFromParent ();
249
236
250
237
MadeChanges = true ;
0 commit comments