Clean up the lazy initialization of DIBuilder a bit.

llvm-svn: 131956
This commit is contained in:
Cameron Zwarich 2011-05-24 06:00:08 +00:00
parent 3b1d1217f8
commit 46e1ebf367
4 changed files with 8 additions and 13 deletions

View File

@ -123,10 +123,10 @@ class LoadAndStorePromoter {
protected:
SSAUpdater &SSA;
DbgDeclareInst *DDI;
DIBuilder *&DIB;
DIBuilder *DIB;
public:
LoadAndStorePromoter(const SmallVectorImpl<Instruction*> &Insts,
SSAUpdater &S, DbgDeclareInst *DDI, DIBuilder *&DIB,
SSAUpdater &S, DbgDeclareInst *DDI, DIBuilder *DIB,
StringRef Name = StringRef());
virtual ~LoadAndStorePromoter() {}

View File

@ -602,13 +602,12 @@ namespace {
SmallPtrSet<Value*, 4> &PointerMustAliases;
SmallVectorImpl<BasicBlock*> &LoopExitBlocks;
AliasSetTracker &AST;
DIBuilder *DIB; // Only passed to LoadAndStorePromoter.
public:
LoopPromoter(Value *SP,
const SmallVectorImpl<Instruction*> &Insts, SSAUpdater &S,
SmallPtrSet<Value*, 4> &PMA,
SmallVectorImpl<BasicBlock*> &LEB, AliasSetTracker &ast)
: LoadAndStorePromoter(Insts, S, 0, DIB), SomePtr(SP),
: LoadAndStorePromoter(Insts, S, 0, 0), SomePtr(SP),
PointerMustAliases(PMA), LoopExitBlocks(LEB), AST(ast) {}
virtual bool isInstInList(Instruction *I,

View File

@ -1367,6 +1367,8 @@ bool SROA::performPromotion(Function &F) {
Insts.push_back(cast<Instruction>(*UI));
DbgDeclareInst *DDI = FindAllocaDbgDeclare(AI);
if (DDI && !DIB)
DIB = new DIBuilder(*AI->getParent()->getParent()->getParent());
AllocaPromoter(Insts, SSA, DDI, DIB).run(AI, Insts);
Insts.clear();
}

View File

@ -358,7 +358,7 @@ Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) {
LoadAndStorePromoter::
LoadAndStorePromoter(const SmallVectorImpl<Instruction*> &Insts,
SSAUpdater &S, DbgDeclareInst *DD, DIBuilder *&DB,
SSAUpdater &S, DbgDeclareInst *DD, DIBuilder *DB,
StringRef BaseName) : SSA(S), DDI(DD), DIB(DB) {
if (Insts.empty()) return;
@ -407,11 +407,8 @@ run(const SmallVectorImpl<Instruction*> &Insts) const {
if (BlockUses.size() == 1) {
// If it is a store, it is a trivial def of the value in the block.
if (StoreInst *SI = dyn_cast<StoreInst>(User)) {
if (DDI) {
if (!DIB)
DIB = new DIBuilder(*SI->getParent()->getParent()->getParent());
if (DDI)
ConvertDebugDeclareToDebugValue(DDI, SI, *DIB);
}
SSA.AddAvailableValue(BB, SI->getOperand(0));
} else
// Otherwise it is a load, queue it to rewrite as a live-in load.
@ -466,11 +463,8 @@ run(const SmallVectorImpl<Instruction*> &Insts) const {
// If this is a store to an unrelated pointer, ignore it.
if (!isInstInList(SI, Insts)) continue;
if (DDI) {
if (!DIB)
DIB = new DIBuilder(*SI->getParent()->getParent()->getParent());
if (DDI)
ConvertDebugDeclareToDebugValue(DDI, SI, *DIB);
}
// Remember that this is the active value in the block.
StoredValue = SI->getOperand(0);