r198461 - Debug info: Ensure that the last stop point in a function is still within
Adrian Prantl
aprantl at apple.com
Fri Jan 3 15:34:31 PST 2014
Author: adrian
Date: Fri Jan 3 17:34:30 2014
New Revision: 198461
URL: http://llvm.org/viewvc/llvm-project?rev=198461&view=rev
Log:
Debug info: Ensure that the last stop point in a function is still within
the lexical block formed by the compound statement that is the function
body.
rdar://problem/15010825
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
cfe/trunk/test/CodeGenObjC/arc-linetable.m
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 3 17:34:30 2014
@@ -2537,7 +2537,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
/// information in the source file. If the location is invalid, the
/// previous location will be reused.
void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
- bool ForceColumnInfo) {
+ bool ForceColumnInfo,
+ llvm::MDNode *ForceScope) {
// Update our current location
setLocation(Loc);
@@ -2556,7 +2557,7 @@ void CGDebugInfo::EmitLocation(CGBuilder
// Update last state.
PrevLoc = CurLoc;
- llvm::MDNode *Scope = LexicalBlockStack.back();
+ llvm::MDNode *Scope = ForceScope ? ForceScope : &*LexicalBlockStack.back();
Builder.SetCurrentDebugLocation(llvm::DebugLoc::get
(getLineNumber(CurLoc),
getColumnNumber(CurLoc, ForceColumnInfo),
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Jan 3 17:34:30 2014
@@ -211,11 +211,17 @@ public:
/// getLocation - Return the current source location.
SourceLocation getLocation() const { return CurLoc; }
+ /// getScope() - Return the current scope.
+ llvm::MDNode *getScope() const { return LexicalBlockStack.back(); }
+
/// EmitLocation - Emit metadata to indicate a change in line/column
/// information in the source file.
/// \param ForceColumnInfo Assume DebugColumnInfo option is true.
+ /// \param ForceScope Force the location to be in a specific lexical
+ /// scope rather than the top of LexicalBlockStack.
void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
- bool ForceColumnInfo = false);
+ bool ForceColumnInfo = false,
+ llvm::MDNode *ForceScope = 0);
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
/// start of a new function.
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Jan 3 17:34:30 2014
@@ -37,7 +37,7 @@ void CodeGenFunction::EmitStopPoint(cons
Loc = S->getLocStart();
DI->EmitLocation(Builder, Loc);
- LastStopPoint = Loc;
+ LastStopPoint = std::make_pair(Loc, DI->getScope());
}
}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 3 17:34:30 2014
@@ -207,9 +207,10 @@ void CodeGenFunction::FinishFunction(Sou
// all will be fine.
if (CGDebugInfo *DI = getDebugInfo()) {
if (OnlySimpleReturnStmts)
- DI->EmitLocation(Builder, LastStopPoint);
+ DI->EmitLocation(Builder, LastStopPoint.first,
+ false, LastStopPoint.second);
else
- DI->EmitLocation(Builder, EndLoc);
+ DI->EmitLocation(Builder, EndLoc, false, LastStopPoint.second);
}
// Pop any cleanups that might have been associated with the
@@ -226,7 +227,7 @@ void CodeGenFunction::FinishFunction(Sou
if (CGDebugInfo *DI = getDebugInfo())
if (OnlySimpleReturnStmts)
- DI->EmitLocation(Builder, EndLoc);
+ DI->EmitLocation(Builder, EndLoc, false, LastStopPoint.second);
}
// Emit function epilog (to return).
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Jan 3 17:34:30 2014
@@ -859,7 +859,7 @@ private:
unsigned NumSimpleReturnExprs;
/// The last regular (non-return) debug location (breakpoint) in the function.
- SourceLocation LastStopPoint;
+ std::pair<SourceLocation, llvm::MDNode*> LastStopPoint;
public:
/// A scope within which we are constructing the fields of an object which
Modified: cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp Fri Jan 3 17:34:30 2014
@@ -46,12 +46,14 @@ void bar()
void baz()
{
if (!foo())
- // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
+ // CHECK: ![[SCOPE1:.*]] = metadata !{{{.*}}, i32 [[@LINE-1]], {{.*}}} ; [ DW_TAG_lexical_block ]
+ // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[SCOPE1]], null}
return;
if (foo()) {
// no cleanup
- // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
+ // CHECK: {{.*}} = metadata !{i32 [[@LINE+2]], i32 0, metadata ![[SCOPE2:.*]], null}
+ // CHECK: ![[SCOPE2]] = metadata !{{{.*}}, i32 [[@LINE-3]], {{.*}}} ; [ DW_TAG_lexical_block ]
return;
}
// CHECK: ![[RETBAZ]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
Modified: cfe/trunk/test/CodeGenObjC/arc-linetable.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-linetable.m?rev=198461&r1=198460&r2=198461&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-linetable.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-linetable.m Fri Jan 3 17:34:30 2014
@@ -47,8 +47,11 @@
@implementation AppDelegate : NSObject
+// CHECK: ![[TESTNOSIDEEFFECT:.*]] = {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+1]]] [local] [def] [-[AppDelegate testNoSideEffect:]]
- (int)testNoSideEffect:(NSString *)foo {
- // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
+ // CHECK: ![[COMPOUND_STMT:.*]] = metadata !{i32 786443, metadata !{{.*}}, metadata ![[TESTNOSIDEEFFECT]], i32 [[@LINE-1]], i32 0, i32 0} ; [ DW_TAG_lexical_block ]
+ int x = 1;
+ // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[COMPOUND_STMT]], null}
return 1; // Return expression
// CHECK: ![[RET1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
} // Cleanup + Ret
More information about the cfe-commits
mailing list