aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-28 18:39:46 +0000
committerChris Lattner <sabre@nondot.org>2002-04-28 18:39:46 +0000
commit5b5df1747feac197fd839c956952fd4d79c58e79 (patch)
treec048f696c7ece0e32eb4f9aa5d69acbae893c92b /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent9f4eb01dd4cdf267f0b5aac40e78e262890b6aa5 (diff)
* Fix bug: test/Regression/Transforms/Mem2Reg/2002-03-28-UninitializedVal.ll
* Minor cleanup that was missed in last patch git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index e9ca9f15c3..23dd2865a0 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -146,10 +146,18 @@ bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier &DF) {
}
}
+ // Set the incoming values for the basic block to be null values for all of
+ // the alloca's. We do this in case there is a load of a value that has not
+ // been stored yet. In this case, it will get this null value.
+ //
+ CurrentValue.push_back(vector<Value *>(Allocas.size()));
+ for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
+ CurrentValue[0][i] =
+ Constant::getNullValue(Allocas[i]->getType()->getElementType());
+
// Walks all basic blocks in the function performing the SSA rename algorithm
// and inserting the phi nodes we marked as necessary
//
- CurrentValue.push_back(vector<Value *>(Allocas.size()));
traverse(F->front(), 0); // there is no predecessor of the root node
// Remove all instructions marked by being placed in the KillList...
@@ -197,13 +205,13 @@ void PromoteInstance::traverse(BasicBlock *BB, BasicBlock *Pred) {
// variable we need phinodes for.
vector<PHINode *> &BBPNs = NewPhiNodes[BB];
for (unsigned k = 0; k != BBPNs.size(); ++k)
- if (BBPNs[k]) {
+ if (PHINode *PN = BBPNs[k]) {
// at this point we can assume that the array has phi nodes.. let's add
// the incoming data
- BBPNs[k]->addIncoming(TOS[k], Pred);
+ PN->addIncoming(TOS[k], Pred);
// also note that the active variable IS designated by the phi node
- TOS[k] = BBPNs[k];
+ TOS[k] = PN;
}
// don't revisit nodes