diff options
| author | Adrian Prantl <aprantl@apple.com> | 2014-11-21 00:35:25 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2014-11-21 00:35:25 +0000 |
| commit | 88eec39460db6bc00dcccaed44dbaa50c817e2fc (patch) | |
| tree | 80e8870e63f4409051c6ed93f407dfc99e917085 /clang/lib/CodeGen | |
| parent | b5b4dd81ba02bce1a9818841c5f33d876423e04f (diff) | |
| download | bcm5719-llvm-88eec39460db6bc00dcccaed44dbaa50c817e2fc.tar.gz bcm5719-llvm-88eec39460db6bc00dcccaed44dbaa50c817e2fc.zip | |
Debug info for blocks: Fix a bug caught by the Verifier.
When emitting nested block definitions, the insert-at-point variant of
DIBuilder::insertDeclare() could be called with the insertion point set
to the end-of-BasicBlock sentinel, causing the parent pointer of the
CallInst to be set to the intentionally bogus value of the sentinel.
Fixed by conditionally invoking the correct version of insertDeclare().
rdar://problem/19034882
llvm-svn: 222487
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 2fe93f87ccc..f088cd6746d 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1243,7 +1243,9 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, } DI->EmitDeclareOfBlockDeclRefVariable(variable, BlockPointerDbgLoc, - Builder, blockInfo); + Builder, blockInfo, + entry_ptr == entry->end() + ? nullptr : entry_ptr); } } // Recover location if it was changed in the above loop. diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e91b6fdf298..416f69e7c31 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2940,7 +2940,7 @@ llvm::DIType CGDebugInfo::CreateSelfType(const QualType &QualTy, void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable( const VarDecl *VD, llvm::Value *Storage, CGBuilderTy &Builder, - const CGBlockInfo &blockInfo) { + const CGBlockInfo &blockInfo, llvm::Instruction *InsertPoint) { assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); @@ -2998,8 +2998,11 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable( VD->getName(), Unit, Line, Ty); // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *Call = DBuilder.insertDeclare( - Storage, D, DBuilder.createExpression(addr), Builder.GetInsertPoint()); + llvm::Instruction *Call = InsertPoint ? + DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), + InsertPoint) + : DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), + Builder.GetInsertBlock()); Call->setDebugLoc( llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back())); } diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 49d99aac264..89d592e7d2e 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -263,7 +263,8 @@ public: void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable, llvm::Value *storage, CGBuilderTy &Builder, - const CGBlockInfo &blockInfo); + const CGBlockInfo &blockInfo, + llvm::Instruction *InsertPoint = 0); /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument /// variable declaration. |

