diff options
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 9 | ||||
-rw-r--r-- | test/CodeGen/debug-info-block-end.c | 17 |
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index c604e56539..11a5ddc7ce 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2135,10 +2135,6 @@ void CGDebugInfo::EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc /// region - end of a DW_TAG_lexical_block. void CGDebugInfo::EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc) { assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); - - // Provide an entry in the line table for the end of the block. - EmitLocation(Builder, Loc); - LexicalBlockStack.pop_back(); } diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index b737a9ed7a..8740fd06df 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -854,8 +854,11 @@ public: /// cleanups. ~LexicalScope() { if (PopDebugStack) { - CGDebugInfo *DI = CGF.getDebugInfo(); - if (DI) DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd()); + if (CGDebugInfo *DI = CGF.getDebugInfo()) { + if (RunCleanupsScope::requiresCleanups()) + DI->EmitLocation(CGF.Builder, Range.getEnd()); + DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd()); + } } } @@ -864,6 +867,8 @@ public: void ForceCleanup() { RunCleanupsScope::ForceCleanup(); if (CGDebugInfo *DI = CGF.getDebugInfo()) { + if (RunCleanupsScope::requiresCleanups()) + DI->EmitLocation(CGF.Builder, Range.getEnd()); DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd()); PopDebugStack = false; } diff --git a/test/CodeGen/debug-info-block-end.c b/test/CodeGen/debug-info-block-end.c new file mode 100644 index 0000000000..72e8868bb4 --- /dev/null +++ b/test/CodeGen/debug-info-block-end.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s + +int bar(); + +int foo(int i) { + int j = 0; + if (i) { + j = bar(); + } + else { + j = bar() + 2; + } + return j; +} + +// Make sure we don't have a line table entry for a block with no cleanups. +// CHECK-NOT: i32 9, i32 3, metadata |