llvm/llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir

# We do not support the call site info for the target now, so we use the experimental option (-emit-call-site-info -debug-entry-values).

# RUN: llc -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -o - %s | FileCheck %s

# This test would previously trigger an assertion when trying to describe the
# call site value for callee()'s float parameter.
#
# Please note that at the time of creating this test the SystemZ target did not
# support call site information, so the "callSites" array has been manually
# added. For now, verify that we don't crash, and that no (invalid) call site
# parameter entry is emitted, but later on when call site information is added
# to the target the LZER instruction should be properly described.

# CHECK-NOT: DW_TAG_GNU_call_site_parameter

# Based on the following C reproducer:
#
# extern void callee(float);
# int caller() {
#   callee(0);
#   return 0;
# }

--- |
  target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
  target triple = "systemz"

  ; Function Attrs: nounwind
  define signext i32 @caller() !dbg !12 {
  entry:
    tail call void @callee(float 0.000000e+00), !dbg !16
    ret i32 0, !dbg !17
  }

  declare !dbg !4 void @callee(float)

  !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 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
  !1 = !DIFile(filename: "systemz-lzer.c", directory: "/")
  !2 = !{}
  !3 = !{!4}
  !4 = !DISubprogram(name: "callee", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
  !5 = !DISubroutineType(types: !6)
  !6 = !{null, !7}
  !7 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
  !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 10.0.0"}
  !12 = distinct !DISubprogram(name: "caller", scope: !1, file: !1, line: 2, type: !13, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
  !13 = !DISubroutineType(types: !14)
  !14 = !{!15}
  !15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !16 = !DILocation(line: 3, scope: !12)
  !17 = !DILocation(line: 4, scope: !12)

...
---
name:            caller
tracksRegLiveness: true
callSites:
  - { bb: 0, offset: 9, fwdArgRegs:
      - { arg: 0, reg: '$f0s' } }
body:             |
  bb.0.entry:
    liveins: $r11d, $r15d, $r14d

    STMG killed $r11d, killed $r15d, $r15d, 88, implicit killed $r14d
    CFI_INSTRUCTION offset $r11d, -72
    CFI_INSTRUCTION offset $r14d, -48
    CFI_INSTRUCTION offset $r15d, -40
    $r15d = AGHI $r15d, -160, implicit-def dead $cc
    CFI_INSTRUCTION def_cfa_offset 320
    $r11d = LGR $r15d
    CFI_INSTRUCTION def_cfa_register $r11d
    renamable $f0s = LZER
    CallBRASL @callee, $f0s, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, debug-location !16
    $r2d = LGHI 0, debug-location !17
    $r11d, $r15d = LMG $r11d, 248, implicit-def $r14d, debug-location !17
    Return implicit killed $r2d, debug-location !17

...