diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-05-20 20:48:03 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-05-20 20:48:03 +0000 |
| commit | b710b1fb22706d6676b4f6547315ffea71826e40 (patch) | |
| tree | 391b89678bc8e1822a7ba9cceda9b785bb2882d4 | |
| parent | 2df953ba74b7a512bf4bc5809acba590f98c8dd5 (diff) | |
| download | bcm5719-llvm-b710b1fb22706d6676b4f6547315ffea71826e40.tar.gz bcm5719-llvm-b710b1fb22706d6676b4f6547315ffea71826e40.zip | |
Fix bug: test/Regression/Transforms/SCCP/2002-05-20-MissedIncomingValue.ll
That was causing a miscompilation of strtol/atoi plus others
llvm-svn: 2669
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 05945458cb6..24d383b2808 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -176,6 +176,16 @@ private: DEBUG_SCCP(cerr << "Marking BB Executable: " << BB); BBExecutable.insert(BB); // Basic block is executable! BBWorkList.push_back(BB); // Add the block to the work list! + + // Visit all of the PHI nodes that merge values from this block... Because + // this block is newly executable, PHI nodes that used to be constant now + // may not be. Note that we only mark PHI nodes that live in blocks that + // can execute! + // + for (Value::use_iterator I = BB->use_begin(), E = BB->use_end(); I != E;++I) + if (PHINode *PN = dyn_cast<PHINode>(*I)) + if (BBExecutable.count(PN->getParent())) + visitPHINode(PN); } @@ -308,7 +318,7 @@ bool SCCP::runOnFunction(Function *F) { InstVal &IV = ValueState[Inst]; if (IV.isConstant()) { Constant *Const = IV.getConstant(); - DEBUG_SCCP(cerr << "Constant: " << Inst << " is: " << Const); + DEBUG_SCCP(cerr << "Constant: " << Const << " = " << Inst); // Replaces all of the uses of a variable with uses of the constant. Inst->replaceAllUsesWith(Const); |

