diff options
author | Tim Northover <tnorthover@apple.com> | 2018-10-12 09:01:59 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2018-10-12 09:01:59 +0000 |
commit | 487780678fcaf2662aa820bd50364addb935dfe8 (patch) | |
tree | 8a64bdddd5ec14e109ce9d4cc0428512f165307c /llvm/lib/Transforms/Scalar/SCCP.cpp | |
parent | 285c0f4fdc14a266f0765816c42c2c8a57601cbb (diff) | |
download | bcm5719-llvm-487780678fcaf2662aa820bd50364addb935dfe8.tar.gz bcm5719-llvm-487780678fcaf2662aa820bd50364addb935dfe8.zip |
SCCP: avoid caching DenseMap entry that might be invalidated.
Later calls to getValueState might insert entries into the ValueState map and
cause reallocation, invalidating a reference.
llvm-svn: 344327
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index d024e03b80a..7196bc82edc 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1017,8 +1017,9 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) { // Handle ICmpInst instruction. void SCCPSolver::visitCmpInst(CmpInst &I) { - LatticeVal &IV = ValueState[&I]; - if (IV.isOverdefined()) return; + // Do not cache this lookup, getValueState calls later in the function might + // invalidate the reference. + if (ValueState[&I].isOverdefined()) return; Value *Op1 = I.getOperand(0); Value *Op2 = I.getOperand(1); @@ -1046,7 +1047,8 @@ void SCCPSolver::visitCmpInst(CmpInst &I) { } // If operands are still unknown, wait for it to resolve. - if (!V1State.isOverdefined() && !V2State.isOverdefined() && !IV.isConstant()) + if (!V1State.isOverdefined() && !V2State.isOverdefined() && + !ValueState[&I].isConstant()) return; markOverdefined(&I); |