diff --git a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h index 4236544d3ecc4a..a876385581e727 100644 --- a/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h +++ b/llvm/include/llvm/Transforms/InstCombine/InstCombiner.h @@ -446,10 +446,9 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner { } /// Replace use and add the previously used value to the worklist. - Instruction *replaceUse(Use &U, Value *NewValue) { + void replaceUse(Use &U, Value *NewValue) { Worklist.addValue(U); U = NewValue; - return cast(U.getUser()); } /// Combiner aware instruction erasure. diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 94d3f99156852e..01249613d47a06 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2436,8 +2436,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { assert(isa(Assume)); if (isAssumeWithEmptyBundle(*cast(II))) return eraseInstFromFunction(CI); - return replaceUse(II->getOperandUse(0), - ConstantInt::getTrue(II->getContext())); + replaceUse(II->getOperandUse(0), ConstantInt::getTrue(II->getContext())); + return nullptr; }; // Remove an assume if it is followed by an identical assume. // TODO: Do we need this? Unless there are conflicting assumptions, the @@ -2964,8 +2964,10 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) { } // Can remove shuffle iff just shuffled elements, no repeats, undefs, or // other changes. - if (UsedIndices.all()) - return replaceUse(II->getOperandUse(ArgIdx), V); + if (UsedIndices.all()) { + replaceUse(II->getOperandUse(ArgIdx), V); + return nullptr; + } break; } case Intrinsic::is_fpclass: { diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index fbaf798a0cea87..1f2441bc9fcf9c 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1251,7 +1251,7 @@ static bool replaceInInstruction(Value *V, Value *Old, Value *New, bool Changed = false; for (Use &U : I->operands()) { if (U == Old) { - IC.addToWorklist(IC.replaceUse(U, New)); + IC.replaceUse(U, New); Changed = true; } else { Changed |= replaceInInstruction(U, Old, New, IC, Depth + 1);