Compiler projects using llvm
# RUN: llc -start-after=livedebugvalues --filetype=obj %s -o - \
# RUN:     | llvm-dwarfdump -v -name=param - | FileCheck %s
#
# Generated with opt -sroa -inline, llc -stop-after=livedebugvalues, with some
# metadata removed by hand.
#
# int glob;
# __attribute__((always_inline))
# static void inline_me(int param) {
#   {
#     int local = param;
#     glob = local;
#   }
# }
# int fun(int number) {
#   inline_me(number);
#   if (number)
#     return 0;
#   return 1;
# }
#
# The inlined parameter 'param' is available for the entirety of its enclosing
# scope. We expect to see a single location entry despite the fact that the
# final instruction in that scope belongs to a dominated scope.
#
# Except for 'param', all DILocalVariable metadata has been removed.
#
# Ignore first entry (abstract), we want to look at the concrete instance.
# CHECK:       DW_TAG_formal_parameter [
# CHECK:       DW_TAG_formal_parameter [
# CHECK-NEXT:    DW_AT_location [DW_FORM_exprloc] (DW_OP_reg5 RDI)
# CHECK-NEXT:    DW_AT_abstract_origin {{.*}} "param"

--- |
  target triple = "x86_64-unknown-linux-gnu"

  @glob = dso_local global i32 0, align 4, !dbg !0
  declare void @llvm.dbg.declare(metadata, metadata, metadata)
  declare void @llvm.dbg.value(metadata, metadata, metadata)
  define dso_local i32 @fun(i32 %number) !dbg !11 {
  entry:
    call void @llvm.dbg.value(metadata i32 %number, metadata !17, metadata !DIExpression()), !dbg !24
    store i32 %number, i32* @glob, align 4, !dbg !27
    %tobool = icmp ne i32 %number, 0, !dbg !32
    br i1 %tobool, label %return, label %if.end, !dbg !34

  if.end:                                           ; preds = %entry
    br label %return, !dbg !35

  return:                                           ; preds = %entry, %if.end
    %retval.0 = phi i32 [ 1, %if.end ], [ 0, %entry ], !dbg !16
    ret i32 %retval.0, !dbg !36
  }

  !llvm.dbg.cu = !{!2}
  !llvm.module.flags = !{!7, !8, !9}
  !llvm.ident = !{!10}

  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
  !1 = distinct !DIGlobalVariable(name: "glob", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
  !3 = !DIFile(filename: "test.c", directory: "/")
  !4 = !{}
  !5 = !{!0}
  !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !7 = !{i32 7, !"Dwarf Version", i32 4}
  !8 = !{i32 2, !"Debug Info Version", i32 3}
  !9 = !{i32 1, !"wchar_size", i32 4}
  !10 = !{!"clang version 11.0.0"}
  !11 = distinct !DISubprogram(name: "fun", scope: !3, file: !3, line: 9, type: !12, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)
  !12 = !DISubroutineType(types: !13)
  !13 = !{!6, !6}
  !14 = !{}
  !16 = !DILocation(line: 0, scope: !11)
  !17 = !DILocalVariable(name: "param", arg: 1, scope: !18, file: !3, line: 3, type: !6)
  !18 = distinct !DISubprogram(name: "inline_me", scope: !3, file: !3, line: 3, type: !19, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21)
  !19 = !DISubroutineType(types: !20)
  !20 = !{null, !6}
  !21 = !{!17}
  !23 = distinct !DILexicalBlock(scope: !18, file: !3, line: 4, column: 3)
  !24 = !DILocation(line: 0, scope: !18, inlinedAt: !25)
  !25 = distinct !DILocation(line: 10, column: 3, scope: !11)
  !26 = !DILocation(line: 0, scope: !23, inlinedAt: !25)
  !27 = !DILocation(line: 6, column: 10, scope: !23, inlinedAt: !25)
  !32 = !DILocation(line: 11, column: 7, scope: !33)
  !33 = distinct !DILexicalBlock(scope: !11, file: !3, line: 11, column: 7)
  !34 = !DILocation(line: 11, column: 7, scope: !11)
  !35 = !DILocation(line: 13, column: 3, scope: !11)
  !36 = !DILocation(line: 14, column: 1, scope: !11)

...
---
name:            fun
body:             |
  bb.0.entry:
    successors: %bb.2(0x50000000), %bb.1(0x30000000)
    liveins: $edi

    DBG_VALUE $edi, $noreg, !17, !DIExpression(), debug-location !24
    MOV32mr $rip, 1, $noreg, @glob, $noreg, renamable $edi, debug-location !27 :: (store (s32) into @glob)
    renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
    TEST32rr killed renamable $edi, renamable $edi, implicit-def $eflags, debug-location !32
    JCC_1 %bb.1, 4, implicit $eflags, debug-location !34

  bb.2.return:
    liveins: $eax

    RET64 $eax, debug-location !36

  bb.1.if.end:
    renamable $eax = MOV32ri 1
    RET64 $eax, debug-location !36

...