Skip to content

Commit 2c61f9c

Browse files
committed
[CVP] Fix use after scope
Store the result of ConstantRange::sdiv() in a variable, as getSingleElement() will return a pointer to the APInt it contains.
1 parent 3ccbd68 commit 2c61f9c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,8 @@ static bool processSDiv(BinaryOperator *SDI, const ConstantRange &LCR,
911911
assert(!SDI->getType()->isVectorTy());
912912

913913
// Check whether the division folds to a constant.
914-
if (const APInt *Elem = LCR.sdiv(RCR).getSingleElement()) {
914+
ConstantRange DivCR = LCR.sdiv(RCR);
915+
if (const APInt *Elem = DivCR.getSingleElement()) {
915916
SDI->replaceAllUsesWith(ConstantInt::get(SDI->getType(), *Elem));
916917
SDI->eraseFromParent();
917918
return true;

0 commit comments

Comments
 (0)