[PATCH] D64500: [DebugInfo] Remove call sites when eliminating unreachable blocks

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 06:24:58 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b29ec58b70e: [DebugInfo] Remove call sites when eliminating unreachable blocks (authored by dstenb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64500/new/

https://reviews.llvm.org/D64500

Files:
  llvm/lib/CodeGen/UnreachableBlockElim.cpp
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir


Index: llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
@@ -0,0 +1,68 @@
+# RUN: llc -mtriple=x86_64-pc-linux -debug-entry-values -run-pass=unreachable-mbb-elimination -o - %s | FileCheck %s
+
+# Verify that the call site information for the call residing in the eliminated
+# block is removed. This test case would previously trigger an assertion when
+# deleting the call instruction.
+
+# CHECK: name: main
+# CHECK: callSites: []
+
+--- |
+  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+  target triple = "x86_64-unknown-linux-gnu"
+
+  ; Function Attrs: nounwind uwtable
+  define i32 @main() !dbg !12 {
+    unreachable
+  }
+
+  declare !dbg !4 void @foo()
+
+  !llvm.dbg.cu = !{!0}
+  !llvm.module.flags = !{!8, !9, !10}
+  !llvm.ident = !{!11}
+
+  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
+  !1 = !DIFile(filename: "unreachable.c", directory: "/")
+  !2 = !{}
+  !3 = !{!4}
+  !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !5 = !DISubroutineType(types: !6)
+  !6 = !{null}
+  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+  !8 = !{i32 2, !"Dwarf Version", i32 4}
+  !9 = !{i32 2, !"Debug Info Version", i32 3}
+  !10 = !{i32 1, !"wchar_size", i32 4}
+  !11 = !{!"clang version 9.0.0"}
+  !12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !13, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+  !13 = !DISubroutineType(types: !14)
+  !14 = !{!7}
+  !15 = distinct !DILexicalBlock(scope: !12, file: !1, line: 4, column: 7)
+  !16 = !DILocation(line: 4, column: 7, scope: !12)
+  !17 = !DILocation(line: 5, column: 5, scope: !15)
+  !18 = !DILocation(line: 6, column: 3, scope: !12)
+
+...
+---
+name:            main
+tracksRegLiveness: true
+callSites:
+  - { bb: 1, offset: 0 }
+body:             |
+  bb.0:
+    successors: %bb.2(0x80000000)
+
+    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
+    CFI_INSTRUCTION def_cfa_offset 16
+    JMP_1 %bb.2, debug-location !16
+
+  bb.1:
+    CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, debug-location !17
+
+  bb.2:
+    $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !18
+    $rcx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !18
+    CFI_INSTRUCTION def_cfa_offset 8, debug-location !18
+    RETQ killed $eax, debug-location !18
+
+...
Index: llvm/lib/CodeGen/UnreachableBlockElim.cpp
===================================================================
--- llvm/lib/CodeGen/UnreachableBlockElim.cpp
+++ llvm/lib/CodeGen/UnreachableBlockElim.cpp
@@ -146,8 +146,14 @@
   }
 
   // Actually remove the blocks now.
-  for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i)
+  for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
+    // Remove any call site information for calls in the block.
+    for (auto &I : DeadBlocks[i]->instrs())
+      if (I.isCall(MachineInstr::IgnoreBundle))
+        DeadBlocks[i]->getParent()->updateCallSiteInfo(&I);
+
     DeadBlocks[i]->eraseFromParent();
+  }
 
   // Cleanup PHI nodes.
   for (MachineFunction::iterator I = F.begin(), E = F.end(); I != E; ++I) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64500.214621.patch
Type: text/x-patch
Size: 3661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/a7d66f7b/attachment.bin>


More information about the llvm-commits mailing list