summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-01-29 18:30:57 +0000
committerDevang Patel <dpatel@apple.com>2010-01-29 18:30:57 +0000
commit7f8be9ba95f792f9394909ce94c25e0941be9ba5 (patch)
tree46673ad9dce6b64fb54aa7cf63bcd9160fdf9a44 /llvm/lib/Analysis/DebugInfo.cpp
parent6f923f89c351a0dcef9a02e0877839e6083bf967 (diff)
downloadbcm5719-llvm-7f8be9ba95f792f9394909ce94c25e0941be9ba5.tar.gz
bcm5719-llvm-7f8be9ba95f792f9394909ce94c25e0941be9ba5.zip
Before inserting llvm.dbg.declare intrinsic at the end of a basic block, check whether the basic block has a terminator or not.
This API is used by clang and the test case is test/CodeGen/debug-info-crash.c in clang module. llvm-svn: 94820
Diffstat (limited to 'llvm/lib/Analysis/DebugInfo.cpp')
-rw-r--r--llvm/lib/Analysis/DebugInfo.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp
index bff193d52ed..d692ad7fd83 100644
--- a/llvm/lib/Analysis/DebugInfo.cpp
+++ b/llvm/lib/Analysis/DebugInfo.cpp
@@ -1055,8 +1055,13 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1),
D.getNode() };
- return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);
-}
+
+ // If this block already has a terminator then insert this intrinsic
+ // before the terminator.
+ if (TerminatorInst *T = InsertAtEnd->getTerminator())
+ return CallInst::Create(DeclareFn, Args, Args+2, "", T);
+ else
+ return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);}
/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
OpenPOWER on IntegriCloud