Compiler projects using llvm
# RUN: llc -emit-call-site-info -mtriple=x86_64-pc-linux -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
    RET64 killed $eax, debug-location !18

...