diff options
author | Devang Patel <dpatel@apple.com> | 2011-03-18 23:45:43 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-03-18 23:45:43 +0000 |
commit | 2c7ee2700ca526274e4dc3c7d4032b6dad8271af (patch) | |
tree | 8c4047e68a64368808c6d466db46b3c436f1db8f /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 3ac171d49a24df8c8891c7ccdb010f9de4e5c26d (diff) | |
download | bcm5719-llvm-2c7ee2700ca526274e4dc3c7d4032b6dad8271af.tar.gz bcm5719-llvm-2c7ee2700ca526274e4dc3c7d4032b6dad8271af.zip |
If an AllocaInst referred by DbgDeclareInst is used by a LoadInst then the LoadInst should also get a corresponding llvm.dbg.value intrinsic.
llvm-svn: 127924
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 623d89b2f63..88c6f18c6ed 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -794,6 +794,28 @@ bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, return true; } +/// Inserts a llvm.dbg.value instrinsic before the stores to an alloca'd value +/// that has an associated llvm.dbg.decl intrinsic. +bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, + LoadInst *LI, DIBuilder &Builder) { + DIVariable DIVar(DDI->getVariable()); + if (!DIVar.Verify()) + return false; + + Instruction *DbgVal = + Builder.insertDbgValueIntrinsic(LI->getOperand(0), 0, + DIVar, LI); + + // Propagate any debug metadata from the store onto the dbg.value. + DebugLoc LIDL = LI->getDebugLoc(); + if (!LIDL.isUnknown()) + DbgVal->setDebugLoc(LIDL); + // Otherwise propagate debug metadata from dbg.declare. + else + DbgVal->setDebugLoc(DDI->getDebugLoc()); + return true; +} + /// LowerDbgDeclare - Lowers llvm.dbg.declare intrinsics into appropriate set /// of llvm.dbg.value intrinsics. bool llvm::LowerDbgDeclare(Function &F) { @@ -815,6 +837,8 @@ bool llvm::LowerDbgDeclare(Function &F) { 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); } DDI->eraseFromParent(); } |