Compiler projects using llvm
# RUN: llc -mtriple=x86_64-- -run-pass livedebugvalues -o - %s -experimental-debug-variable-locations=false | FileCheck %s --implicit-check-not=DBG_VALUE_LIST
#
# A DBG_VALUE_LIST that has a component spilt and restored should had its
# expression and operands updated to refer to the stack for that period, and
# then return to normal once the value is restored.
#
# CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "c"
# 
# CHECK-LABEL: bb.0.entry:
# CHECK:       DBG_VALUE_LIST ![[VAR]],
# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
# CHECK-SAME:  $rdi, $rsi,
# CHECK:       MOV64mr $rsp, 1, $noreg, -16, $noreg, $rdi
# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]],
# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_LLVM_arg, 1, DW_OP_plus),
# CHECK-SAME:                $rsp, $rsi,
# CHECK:       $rdi = MOV64rm $rsp, 1, $noreg, -16,
# CHECK-NEXT:  DBG_VALUE_LIST ![[VAR]],
# CHECK-SAME:  !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus),
# CHECK-SAME:  $rdi, $rsi,

--- |
  ; ModuleID = 'test.cpp'
  source_filename = "test.cpp"
  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"
  
  ; Function Attrs: norecurse nounwind readnone uwtable
  define dso_local i32 @_Z3fooii(i32 %a, i32 %b) local_unnamed_addr !dbg !7 {
  entry:
    ret i32 0, !dbg !17
  }
  
  ; Function Attrs: nounwind readnone speculatable willreturn
  declare void @llvm.dbg.value(metadata, metadata, metadata)
  
  !llvm.dbg.cu = !{!0}
  !llvm.module.flags = !{!3, !4, !5}
  !llvm.ident = !{!6}
  
  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
  !1 = !DIFile(filename: "test.cpp", directory: "/")
  !2 = !{}
  !3 = !{i32 7, !"Dwarf Version", i32 4}
  !4 = !{i32 2, !"Debug Info Version", i32 3}
  !5 = !{i32 1, !"wchar_size", i32 4}
  !6 = !{!"clang version 11.0.0"}
  !7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooii", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
  !8 = !DISubroutineType(types: !9)
  !9 = !{!10, !10, !10}
  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !11 = !{!12, !13, !14}
  !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
  !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 2, type: !10)
  !14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !10)
  !15 = !DILocation(line: 0, scope: !7)
  !16 = !DILocation(line: 4, column: 12, scope: !7)
  !17 = !DILocation(line: 4, column: 3, scope: !7)

...
---
name:            _Z3fooii
stack:
  - { id: 0, offset: -16, size: 8, alignment: 8, type: spill-slot }
body:             |
  bb.0.entry:
    liveins: $rdi, $rsi
  
    $rsp = frame-setup SUB64ri8 $rsp, 24, implicit-def dead $eflags
    DBG_VALUE_LIST !14, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $rdi, $rsi, debug-location !15
    MOV64mr $rsp, 1, _, -16, _, $rdi, debug-location !15 :: (store (s64) into %stack.0)
    $rax = COPY killed $rdi
    $rdi = MOV64ri 0
    $rdi = MOV64rm $rsp, 1, $noreg, -16, $noreg, debug-location !15 :: (load (s64) from %stack.0)
    RET64
...