From b20724dff4485de5381b578f840df61c4cb31867 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 16 Oct 2004 18:10:06 +0000 Subject: [PATCH] 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 --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 9edd864f55d..6423b762da9 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 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(AI->use_back()); if (LoadInst *LI = dyn_cast(U)) { // Must be a load of uninitialized value. - LI->replaceAllUsesWith(Constant::getNullValue(AI->getAllocatedType())); + LI->replaceAllUsesWith(UndefValue::get(AI->getAllocatedType())); if (AST && isa(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 &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(LI->getType())) AST->deleteValue(LI); -- 2.11.0