diff options
author | Dan Gohman <gohman@apple.com> | 2008-06-20 16:39:44 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-06-20 16:39:44 +0000 |
commit | b5210efb31f39bc0d42badd6d4accb1ec3f661d0 (patch) | |
tree | 866396a5746e7629c1528e6b4acb6e1eedadab31 /llvm/lib/Transforms/Scalar/SCCP.cpp | |
parent | 795e2943a2b70423ff1e10b084e401c70c9e49df (diff) | |
download | bcm5719-llvm-b5210efb31f39bc0d42badd6d4accb1ec3f661d0.tar.gz bcm5719-llvm-b5210efb31f39bc0d42badd6d4accb1ec3f661d0.zip |
Fix the conditions under which SCCP should examine insertvalue
instructions. Thanks to Matthijs Kooijman for pointing this out!
llvm-svn: 52542
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index dc6d497bd00..3ca03b3c1d9 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -750,7 +750,7 @@ void SCCPSolver::visitInsertValueInst(InsertValueInst &IVI) { Value *Val = IVI.getOperand(1); // If the operand to the getresult is an undef, the result is undef. - if (isa<UndefValue>(Aggr)) + if (isa<UndefValue>(Aggr) && isa<UndefValue>(Val)) return; // Currently only handle single-index insertvalues. @@ -758,6 +758,23 @@ void SCCPSolver::visitInsertValueInst(InsertValueInst &IVI) { markOverdefined(&IVI); return; } + + // Currently only handle insertvalue instructions that are in a single-use + // chain that builds up a return value. + for (const InsertValueInst *TmpIVI = &IVI; ; ) { + if (!TmpIVI->hasOneUse()) { + markOverdefined(&IVI); + return; + } + const Value *V = *TmpIVI->use_begin(); + if (isa<ReturnInst>(V)) + break; + TmpIVI = dyn_cast<InsertValueInst>(V); + if (!TmpIVI) { + markOverdefined(&IVI); + return; + } + } // See if we are tracking the result of the callee. Function *F = IVI.getParent()->getParent(); |