mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-17 20:46:23 +00:00
[SCCP] Get a copy of the state of CopyOf once.
This fixes potential reference invalidations, when no lattice value is assigned for CopyOf. As the state of CopyOf won't change while in handleCallResult, we can get a copy once and use that. Should fix PR45749.
This commit is contained in:
parent
65553e0fc8
commit
1d38c691e8
@ -1223,22 +1223,23 @@ void SCCPSolver::handleCallResult(CallBase &CB) {
|
||||
Value *CopyOf = CB.getOperand(0);
|
||||
auto *PI = getPredicateInfoFor(&CB);
|
||||
auto *PBranch = dyn_cast_or_null<PredicateBranch>(PI);
|
||||
ValueLatticeElement OriginalVal = getValueState(CopyOf);
|
||||
if (!PI || !PBranch) {
|
||||
mergeInValue(ValueState[&CB], &CB, getValueState(CopyOf));
|
||||
mergeInValue(ValueState[&CB], &CB, OriginalVal);
|
||||
return;
|
||||
}
|
||||
|
||||
// Everything below relies on the condition being a comparison.
|
||||
auto *Cmp = dyn_cast<CmpInst>(PBranch->Condition);
|
||||
if (!Cmp) {
|
||||
mergeInValue(ValueState[&CB], &CB, getValueState(CopyOf));
|
||||
mergeInValue(ValueState[&CB], &CB, OriginalVal);
|
||||
return;
|
||||
}
|
||||
|
||||
Value *CmpOp0 = Cmp->getOperand(0);
|
||||
Value *CmpOp1 = Cmp->getOperand(1);
|
||||
if (CopyOf != CmpOp0 && CopyOf != CmpOp1) {
|
||||
mergeInValue(ValueState[&CB], &CB, getValueState(CopyOf));
|
||||
mergeInValue(ValueState[&CB], &CB, OriginalVal);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1259,7 +1260,6 @@ void SCCPSolver::handleCallResult(CallBase &CB) {
|
||||
|
||||
ValueLatticeElement CondVal = getValueState(CmpOp1);
|
||||
ValueLatticeElement &IV = ValueState[&CB];
|
||||
ValueLatticeElement OriginalVal = getValueState(CopyOf);
|
||||
if (CondVal.isConstantRange() || OriginalVal.isConstantRange()) {
|
||||
auto NewCR =
|
||||
ConstantRange::getFull(DL.getTypeSizeInBits(CopyOf->getType()));
|
||||
@ -1299,7 +1299,7 @@ void SCCPSolver::handleCallResult(CallBase &CB) {
|
||||
return;
|
||||
}
|
||||
|
||||
return (void)mergeInValue(IV, &CB, getValueState(CopyOf));
|
||||
return (void)mergeInValue(IV, &CB, OriginalVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user