r286400 - Use an artificial debug location for non-virtual thunks.

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 9 13:43:52 PST 2016


Author: adrian
Date: Wed Nov  9 15:43:51 2016
New Revision: 286400

URL: http://llvm.org/viewvc/llvm-project?rev=286400&view=rev
Log:
Use an artificial debug location for non-virtual thunks.
Thunks are artificial and have no corresponding source location except for the
line number on the DISubprogram, which is marked as artificial.

<rdar://problem/11941095>

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGVTables.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=286400&r1=286399&r2=286400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Nov  9 15:43:51 2016
@@ -3032,9 +3032,8 @@ void CGDebugInfo::EmitFunctionStart(Glob
 
   if (!HasDecl || D->isImplicit()) {
     Flags |= llvm::DINode::FlagArtificial;
-    // Artificial functions without a location should not silently reuse CurLoc.
-    if (Loc.isInvalid())
-      CurLoc = SourceLocation();
+    // Artificial functions should not silently reuse CurLoc.
+    CurLoc = SourceLocation();
   }
   unsigned LineNo = getLineNumber(Loc);
   unsigned ScopeLine = getLineNumber(ScopeLoc);

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=286400&r1=286399&r2=286400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Nov  9 15:43:51 2016
@@ -229,8 +229,11 @@ void CodeGenFunction::StartThunk(llvm::F
     CGM.getCXXABI().addImplicitStructorParams(*this, ResultType, FunctionArgs);
 
   // Start defining the function.
+  auto NL = ApplyDebugLocation::CreateEmpty(*this);
   StartFunction(GlobalDecl(), ResultType, Fn, FnInfo, FunctionArgs,
-                MD->getLocation(), MD->getLocation());
+                MD->getLocation());
+  // Create a scope with an artificial location for the body of this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Since we didn't pass a GlobalDecl to StartFunction, do this ourselves.
   CGM.getCXXABI().EmitInstanceFunctionProlog(*this);
@@ -282,7 +285,7 @@ void CodeGenFunction::EmitCallAndReturnF
 
   // Add the rest of the arguments.
   for (const ParmVarDecl *PD : MD->parameters())
-    EmitDelegateCallArg(CallArgs, PD, PD->getLocStart());
+    EmitDelegateCallArg(CallArgs, PD, SourceLocation());
 
   const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
 
@@ -396,6 +399,8 @@ void CodeGenFunction::generateThunk(llvm
                                     const CGFunctionInfo &FnInfo,
                                     GlobalDecl GD, const ThunkInfo &Thunk) {
   StartThunk(Fn, GD, FnInfo);
+  // Create a scope with an artificial location for the body of this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Get our callee.
   llvm::Type *Ty =

Modified: cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp?rev=286400&r1=286399&r2=286400&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-thunk.cpp Wed Nov  9 15:43:51 2016
@@ -13,8 +13,17 @@ struct C : A, B {
 };
 
 void C::f() { }
-
-// CHECK: !DISubprogram(linkageName: "_ZThn{{[48]}}_N1C1fEv"
+// CHECK: define void @_ZThn{{[48]}}_N1C1fEv
+// CHECK-SAME: !dbg ![[SP:[0-9]+]]
+// CHECK-NOT: {{ret }}
+// CHECK: = load{{.*}} !dbg ![[DBG:[0-9]+]]
+// CHECK-NOT: {{ret }}
+// CHECK: ret void, !dbg ![[DBG]]
+//
+// CHECK: ![[SP]] = distinct !DISubprogram(linkageName: "_ZThn{{[48]}}_N1C1fEv"
 // CHECK-SAME:          line: 15
 // CHECK-SAME:          isDefinition: true
+// CHECK-SAME:          DIFlagArtificial
 // CHECK-SAME:          ){{$}}
+//
+// CHECK: ![[DBG]] = !DILocation(line: 0

Modified: cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp?rev=286400&r1=286399&r2=286400&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-windows-dtor.cpp Wed Nov  9 15:43:51 2016
@@ -19,4 +19,4 @@ template struct AB<int>;
 // CHECK: define
 
 // CHECK: [[THUNK_VEC_DEL_DTOR]] = distinct !DISubprogram
-// CHECK: [[THUNK_LOC]] = !DILocation(line: 15, scope: [[THUNK_VEC_DEL_DTOR]])
+// CHECK: [[THUNK_LOC]] = !DILocation(line: 0, scope: [[THUNK_VEC_DEL_DTOR]])




More information about the cfe-commits mailing list