Remove DbgDeclare only if all uses are converted.

llvm-svn: 130431
This commit is contained in:
Devang Patel 2011-04-28 20:32:02 +00:00
parent 367342e209
commit 72aa1a8a68
1 changed files with 5 additions and 1 deletions

View File

@ -838,14 +838,18 @@ bool llvm::LowerDbgDeclare(Function &F) {
E = Dbgs.end(); I != E; ++I) {
DbgDeclareInst *DDI = *I;
if (AllocaInst *AI = dyn_cast_or_null<AllocaInst>(DDI->getAddress())) {
bool RemoveDDI = true;
for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end();
UI != E; ++UI)
if (StoreInst *SI = dyn_cast<StoreInst>(*UI))
ConvertDebugDeclareToDebugValue(DDI, SI, DIB);
else if (LoadInst *LI = dyn_cast<LoadInst>(*UI))
ConvertDebugDeclareToDebugValue(DDI, LI, DIB);
else
RemoveDDI = false;
if (RemoveDDI)
DDI->eraseFromParent();
}
DDI->eraseFromParent();
}
return true;
}