diff options
author | Devang Patel <dpatel@apple.com> | 2010-01-29 18:30:57 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-01-29 18:30:57 +0000 |
commit | 27a53de9b8bdf36656918573e22df42239eeac09 (patch) | |
tree | 7d49a2ca243e1b83860d2364f4415468c673034f /lib/Analysis/DebugInfo.cpp | |
parent | 4f17eb87218ce4879a4ef0ed15c9ac5cf0294c2a (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DebugInfo.cpp')
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index bff193d52e..d692ad7fd8 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/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, |