summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-16 18:10:06 +0000
committerChris Lattner <sabre@nondot.org>2004-10-16 18:10:06 +0000
commitb20724dff4485de5381b578f840df61c4cb31867 (patch)
treed9305c2755793d0889fee14929a741c9ec1878b2 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent5d356a7c82046b5610c59545b6fbc82ca5e5da76 (diff)
downloadllvm-b20724dff4485de5381b578f840df61c4cb31867.tar.gz
llvm-b20724dff4485de5381b578f840df61c4cb31867.tar.bz2
llvm-b20724dff4485de5381b578f840df61c4cb31867.tar.xz
When promoting mem2reg, make uninitialized values become undef isntead of 0.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 9edd864f55..6423b762da 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -17,7 +17,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
-#include "llvm/Constant.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
@@ -288,7 +288,7 @@ void PromoteMem2Reg::run() {
//
std::vector<Value *> Values(Allocas.size());
for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
- Values[i] = Constant::getNullValue(Allocas[i]->getAllocatedType());
+ Values[i] = UndefValue::get(Allocas[i]->getAllocatedType());
// Walks all basic blocks in the function performing the SSA rename algorithm
// and inserting the phi nodes we marked as necessary
@@ -307,7 +307,7 @@ void PromoteMem2Reg::run() {
// Just delete the users now.
//
if (!A->use_empty())
- A->replaceAllUsesWith(Constant::getNullValue(A->getType()));
+ A->replaceAllUsesWith(UndefValue::get(A->getType()));
if (AST) AST->deleteValue(A);
A->getParent()->getInstList().erase(A);
}
@@ -356,9 +356,9 @@ void PromoteMem2Reg::run() {
// entries inserted into every PHI nodes for the block.
for (unsigned i = 0, e = PNs.size(); i != e; ++i)
if (PHINode *PN = PNs[i]) {
- Value *NullVal = Constant::getNullValue(PN->getType());
+ Value *UndefVal = UndefValue::get(PN->getType());
for (unsigned pred = 0, e = Preds.size(); pred != e; ++pred)
- PN->addIncoming(NullVal, Preds[pred]);
+ PN->addIncoming(UndefVal, Preds[pred]);
}
}
}
@@ -414,7 +414,7 @@ void PromoteMem2Reg::PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI) {
Instruction *U = cast<Instruction>(AI->use_back());
if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
// Must be a load of uninitialized value.
- LI->replaceAllUsesWith(Constant::getNullValue(AI->getAllocatedType()));
+ LI->replaceAllUsesWith(UndefValue::get(AI->getAllocatedType()));
if (AST && isa<PointerType>(LI->getType()))
AST->deleteValue(LI);
} else {
@@ -423,8 +423,8 @@ void PromoteMem2Reg::PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI) {
}
BB->getInstList().erase(U);
} else {
- // Uses of the uninitialized memory location shall get zero...
- Value *CurVal = Constant::getNullValue(AI->getAllocatedType());
+ // Uses of the uninitialized memory location shall get undef.
+ Value *CurVal = UndefValue::get(AI->getAllocatedType());
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
Instruction *Inst = I++;
@@ -473,7 +473,7 @@ PromoteLocallyUsedAllocas(BasicBlock *BB, const std::vector<AllocaInst*> &AIs) {
if (AIt != CurValues.end()) {
// Loads just returns the "current value"...
if (AIt->second == 0) // Uninitialized value??
- AIt->second =Constant::getNullValue(AIt->first->getAllocatedType());
+ AIt->second = UndefValue::get(AIt->first->getAllocatedType());
LI->replaceAllUsesWith(AIt->second);
if (AST && isa<PointerType>(LI->getType()))
AST->deleteValue(LI);