[PATCH] D66328: [DebugInfo] Add debug location to dynamic atexit destructor

Alexandre Ganea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 19:28:02 PDT 2019


aganea created this revision.
aganea added reviewers: rnk, aprantl.
aganea added a project: clang.

Previously, when clang was compiled with -DLLVM_ENABLE_ASSERTIONS=ON, the attached test was yielding:

  inlinable function call in a function with debug info must have a !dbg location
    call void @"??1?$c at UB@@@@QEAA at XZ"(%struct.c* @"?f@?1??d@@YAPEAU?$c at UB@@@@XZ at 4U2@A")
  fatal error: error in backend: Broken module found, compilation aborted!
  Stack dump:
  0.      Program arguments: <f:\svn\buildninja\bin\clang -cc1 -emit-llvm phoenix.cpp> -gcodeview -debug-info-kind=limited
  1.      <eof> parser at end of file
  2.      Per-function optimization

Fixes PR43012


Repository:
  rC Clang

https://reviews.llvm.org/D66328

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGen/debug-info-no-location.cpp


Index: test/CodeGen/debug-info-no-location.cpp
===================================================================
--- test/CodeGen/debug-info-no-location.cpp
+++ test/CodeGen/debug-info-no-location.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang -cc1 -emit-llvm %s -gcodeview -debug-info-kind=limited -o - | FileCheck %s
+// CHECK: call void @"??1?$c at UB@@@@QEAA at XZ"(%struct.c* @"?f@?1??d@@YAPEAU?$c at UB@@@@XZ at 4U2@A"), !dbg !51
+// CHECK-NEXT: ret void, !dbg !51
+// CHECK: !48 = distinct !DISubprogram(name: "`dynamic atexit destructor for 'f'", scope: !3, file: !3, line: 16, type: !49, scopeLine: 16, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !27, retainedNodes: !29)
+// CHECK: !51 = !DILocation(line: 16, scope: !48)
+
+struct a {
+  ~a();
+};
+template <typename b> struct c : a {
+  c(void (b::*)());
+};
+struct B {
+  virtual void e();
+};
+c<B> *d() { static c<B> f(&B::e); return &f; }
Index: lib/CodeGen/CGDeclCXX.cpp
===================================================================
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -246,7 +246,8 @@
   CodeGenFunction CGF(CGM);
 
   CGF.StartFunction(GlobalDecl(&VD, DynamicInitKind::AtExit),
-                    CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+                    CGM.getContext().VoidTy, fn, FI, FunctionArgList(),
+                    VD.getLocation(), VD.getInit()->getExprLoc());
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66328.215526.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190816/2920a237/attachment.bin>


More information about the cfe-commits mailing list