mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-29 11:17:28 +00:00
[InstCombine] Fix worklist management in varargs transform
Add a replaceUse() helper to mirror replaceOperand() for the rare cases where we're working directly on uses. NFC apart from worklist order changes.
This commit is contained in:
parent
6f07a9e80a
commit
28f67bd5c5
@ -4573,7 +4573,7 @@ Instruction *InstCombiner::visitCallBase(CallBase &Call) {
|
|||||||
I != E; ++I, ++ix) {
|
I != E; ++I, ++ix) {
|
||||||
CastInst *CI = dyn_cast<CastInst>(*I);
|
CastInst *CI = dyn_cast<CastInst>(*I);
|
||||||
if (CI && isSafeToEliminateVarargsCast(Call, DL, CI, ix)) {
|
if (CI && isSafeToEliminateVarargsCast(Call, DL, CI, ix)) {
|
||||||
*I = CI->getOperand(0);
|
replaceUse(*I, CI->getOperand(0));
|
||||||
|
|
||||||
// Update the byval type to match the argument type.
|
// Update the byval type to match the argument type.
|
||||||
if (Call.isByValArgument(ix)) {
|
if (Call.isByValArgument(ix)) {
|
||||||
|
@ -686,6 +686,12 @@ public:
|
|||||||
return &I;
|
return &I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Replace use and add the previously used value to the worklist.
|
||||||
|
void replaceUse(Use &U, Value *NewValue) {
|
||||||
|
Worklist.addValue(U);
|
||||||
|
U = NewValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a result tuple for an overflow intrinsic \p II with a given
|
/// Creates a result tuple for an overflow intrinsic \p II with a given
|
||||||
/// \p Result and a constant \p Overflow value.
|
/// \p Result and a constant \p Overflow value.
|
||||||
Instruction *CreateOverflowTuple(IntrinsicInst *II, Value *Result,
|
Instruction *CreateOverflowTuple(IntrinsicInst *II, Value *Result,
|
||||||
|
@ -87,9 +87,7 @@ bool InstCombiner::SimplifyDemandedBits(Instruction *I, unsigned OpNo,
|
|||||||
Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known,
|
Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known,
|
||||||
Depth, I);
|
Depth, I);
|
||||||
if (!NewVal) return false;
|
if (!NewVal) return false;
|
||||||
// Add the old operand back to the worklist.
|
replaceUse(U, NewVal);
|
||||||
Worklist.addValue(U.get());
|
|
||||||
U = NewVal;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user