r187074 - Debug Info: Fix an oversight of r186553. Ensure that the function prologue
Adrian Prantl
aprantl at apple.com
Wed Jul 24 13:34:39 PDT 2013
Author: adrian
Date: Wed Jul 24 15:34:39 2013
New Revision: 187074
URL: http://llvm.org/viewvc/llvm-project?rev=187074&view=rev
Log:
Debug Info: Fix an oversight of r186553. Ensure that the function prologue
of an artificial function gets an artificial location as well.
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=187074&r1=187073&r2=187074&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Wed Jul 24 15:34:39 2013
@@ -1313,9 +1313,10 @@ CodeGenFunction::GenerateCopyHelperFunct
SC_Static,
false,
false);
- StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
- // Don't emit any line table entries for the body of this function.
+ // Create a scope with an artificial location for the body of this function.
ArtificialLocation AL(*this, Builder);
+ StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
+ AL.Emit();
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
@@ -1488,9 +1489,10 @@ CodeGenFunction::GenerateDestroyHelperFu
SourceLocation(), II, C.VoidTy, 0,
SC_Static,
false, false);
- StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
- // Don't emit any line table entries for the body of this function.
+ // Create a scope with an artificial location for the body of this function.
ArtificialLocation AL(*this, Builder);
+ StartFunction(FD, C.VoidTy, Fn, FI, args, SourceLocation());
+ AL.Emit();
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=187074&r1=187073&r2=187074&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul 24 15:34:39 2013
@@ -72,13 +72,19 @@ ArtificialLocation::ArtificialLocation(C
: DI(CGF.getDebugInfo()), Builder(B) {
if (DI) {
SavedLoc = DI->getLocation();
+ DI->CurLoc = SourceLocation();
+ Builder.SetCurrentDebugLocation(llvm::DebugLoc());
+ }
+}
+
+void ArtificialLocation::Emit() {
+ if (DI) {
// Sync the Builder.
DI->EmitLocation(Builder, SavedLoc);
DI->CurLoc = SourceLocation();
// Construct a location that has a valid scope, but no line info.
- llvm::DIDescriptor Scope = DI->LexicalBlockStack.empty() ?
- llvm::DIDescriptor(DI->TheCU) :
- llvm::DIDescriptor(DI->LexicalBlockStack.back());
+ assert(!DI->LexicalBlockStack.empty());
+ llvm::DIDescriptor Scope(DI->LexicalBlockStack.back());
Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));
}
}
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=187074&r1=187073&r2=187074&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul 24 15:34:39 2013
@@ -407,9 +407,11 @@ public:
/// an artificial debug location that has a valid scope, but no line
/// information. This is useful when emitting compiler-generated
/// helper functions that have no source location associated with
-/// them.
+/// them. The DWARF specification allows the compiler to use the
+/// special line number 0 to indicate code that can not be attributed
+/// to any source location.
///
-/// This is necessary because pasing an empty SourceLocation to
+/// This is necessary because passing an empty SourceLocation to
/// CGDebugInfo::setLocation() will result in the last valid location
/// being reused.
class ArtificialLocation {
@@ -418,7 +420,12 @@ class ArtificialLocation {
CGBuilderTy &Builder;
public:
ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B);
- /// ~BuildinLocation - Autorestore everything back to normal.
+
+ /// Set the current location to line 0, but within the current scope
+ /// (= the top of the LexicalScopeStack).
+ void Emit();
+
+ /// ~ArtificialLocation - Autorestore everything back to normal.
~ArtificialLocation();
};
Modified: cfe/trunk/test/CodeGenObjC/debug-info-blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-blocks.m?rev=187074&r1=187073&r2=187074&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-info-blocks.m Wed Jul 24 15:34:39 2013
@@ -15,11 +15,14 @@
// Test that we do emit scope info for the helper functions.
// CHECK: define {{.*}} @__copy_helper_block_{{.*}}(i8*, i8*)
// CHECK-NOT: ret
+// CHECK: call {{.*}}, !dbg ![[DBG_LINE:[0-9]+]]
+// CHECK-NOT: ret
// CHECK: load {{.*}}, !dbg ![[COPY_LINE:[0-9]+]]
// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(i8*)
// CHECK-NOT: ret
// CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]]
+// CHECK-DAG: [[DBG_LINE]] = metadata !{i32 0, i32 0, metadata ![[COPY_SP:[0-9]+]], null}
// CHECK-DAG: [[COPY_LINE]] = metadata !{i32 0, i32 0, metadata ![[COPY_SP:[0-9]+]], null}
// CHECK-DAG: [[COPY_SP]] = {{.*}}[ DW_TAG_subprogram ]{{.*}}[__copy_helper_block_]
// CHECK-DAG: [[DESTROY_LINE]] = metadata !{i32 0, i32 0, metadata ![[DESTROY_SP:[0-9]+]], null}
More information about the cfe-commits
mailing list