[llvm-commits] CVS: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Oct 16 11:10:47 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
PromoteMemoryToRegister.cpp updated: 1.70 -> 1.71
---
Log message:
When promoting mem2reg, make uninitialized values become undef isntead of 0.
---
Diffs of the changes: (+9 -9)
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.70 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.71
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.70 Sun Sep 19 13:51:51 2004
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sat Oct 16 13:10:06 2004
@@ -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 @@
//
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 @@
// 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 @@
// 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 @@
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 @@
}
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 @@
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);
More information about the llvm-commits
mailing list