1# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=prologepilog %s -o - | FileCheck %s 2 3# MIR test case produced by compiling: 4# 5# typedef struct { int a; long b; } S1; 6# 7# extern void bar(int *); 8# 9# void foo(int p1, S1 p2, int p3, int p4, int p5, int p6, int p7, int p8) { 10# int local1 = p1; 11# int local2 = p6; 12# int arr[2]; 13# bar(arr); 14# } 15# 16# using the following commands (with some manual stripping of metadata): 17# 18# $ clang -O1 -g -S -emit-llvm 19# $ llc -O1 -stop-before=prologepilog 20 21--- | 22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 23 target triple = "x86_64-unknown-linux-gnu" 24 25 ; Function Attrs: nounwind uwtable 26 define dso_local void @foo(i32 %p1, i32 %p2.coerce0, i64 %p2.coerce1, i32 %p3, i32 %p4, i32 %p5, i32 %p6, i32 %p7, i32 %p8) local_unnamed_addr #0 !dbg !7 { 27 entry: 28 %arr = alloca [2 x i32], align 4 29 call void @llvm.dbg.value(metadata i32 %p1, metadata !18, metadata !DIExpression()), !dbg !28 30 call void @llvm.dbg.value(metadata i32 %p2.coerce0, metadata !19, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !28 31 call void @llvm.dbg.value(metadata i64 %p2.coerce1, metadata !19, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg !28 32 call void @llvm.dbg.value(metadata i32 %p3, metadata !20, metadata !DIExpression()), !dbg !28 33 call void @llvm.dbg.value(metadata i32 %p4, metadata !21, metadata !DIExpression()), !dbg !28 34 call void @llvm.dbg.value(metadata i32 %p5, metadata !22, metadata !DIExpression()), !dbg !28 35 call void @llvm.dbg.value(metadata i32 %p6, metadata !23, metadata !DIExpression()), !dbg !28 36 call void @llvm.dbg.value(metadata i32 %p7, metadata !24, metadata !DIExpression()), !dbg !28 37 call void @llvm.dbg.value(metadata i32 %p8, metadata !25, metadata !DIExpression()), !dbg !28 38 call void @llvm.dbg.value(metadata i32 %p1, metadata !26, metadata !DIExpression()), !dbg !28 39 call void @llvm.dbg.value(metadata i32 %p6, metadata !27, metadata !DIExpression()), !dbg !28 40 %arraydecay1 = bitcast [2 x i32]* %arr to i32*, !dbg !28 41 call void @bar(i32* nonnull %arraydecay1), !dbg !28 42 ret void, !dbg !28 43 } 44 45 ; Function Attrs: nounwind readnone speculatable 46 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 47 48 declare dso_local void @bar(i32*) local_unnamed_addr 49 50 ; Function Attrs: nounwind readnone speculatable 51 declare void @llvm.dbg.value(metadata, metadata, metadata) #1 52 53 attributes #0 = { nounwind uwtable } 54 attributes #1 = { nounwind readnone speculatable } 55 56 !llvm.dbg.cu = !{!0} 57 !llvm.module.flags = !{!3, !4, !5} 58 !llvm.ident = !{!6} 59 60 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) 61 !1 = !DIFile(filename: "params.c", directory: "/") 62 !2 = !{} 63 !3 = !{i32 2, !"Dwarf Version", i32 4} 64 !4 = !{i32 2, !"Debug Info Version", i32 3} 65 !5 = !{i32 1, !"wchar_size", i32 4} 66 !6 = !{!"clang version 9.0.0"} 67 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17) 68 !8 = !DISubroutineType(types: !9) 69 !9 = !{null, !10, !11, !10, !10, !10, !10, !10, !10} 70 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 71 !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "S1", file: !1, line: 1, baseType: !12) 72 !12 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !1, line: 1, size: 128, elements: !13) 73 !13 = !{!14, !15} 74 !14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !1, line: 1, baseType: !10, size: 32) 75 !15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !12, file: !1, line: 1, baseType: !16, size: 64, offset: 64) 76 !16 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) 77 !17 = !{!18, !19, !20, !21, !22, !23, !24, !25, !26, !27} 78 !18 = !DILocalVariable(name: "p1", arg: 1, scope: !7, file: !1, line: 5, type: !10) 79 !19 = !DILocalVariable(name: "p2", arg: 2, scope: !7, file: !1, line: 5, type: !11) 80 !20 = !DILocalVariable(name: "p3", arg: 3, scope: !7, file: !1, line: 5, type: !10) 81 !21 = !DILocalVariable(name: "p4", arg: 4, scope: !7, file: !1, line: 5, type: !10) 82 !22 = !DILocalVariable(name: "p5", arg: 5, scope: !7, file: !1, line: 5, type: !10) 83 !23 = !DILocalVariable(name: "p6", arg: 6, scope: !7, file: !1, line: 5, type: !10) 84 !24 = !DILocalVariable(name: "p7", arg: 7, scope: !7, file: !1, line: 5, type: !10) 85 !25 = !DILocalVariable(name: "p8", arg: 8, scope: !7, file: !1, line: 5, type: !10) 86 !26 = !DILocalVariable(name: "local1", scope: !7, file: !1, line: 6, type: !10) 87 !27 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 7, type: !10) 88 !28 = !DILocation(line: 5, column: 21, scope: !7) 89 90... 91--- 92name: foo 93tracksRegLiveness: true 94fixedStack: 95 - { id: 0, type: default, offset: 16, size: 4, alignment: 16, stack-id: default, 96 isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true } 97 - { id: 1, type: default, offset: 8, size: 4, alignment: 8, stack-id: default, 98 isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true } 99 - { id: 2, type: default, offset: 0, size: 4, alignment: 16, stack-id: default, 100 isImmutable: true, isAliased: false, callee-saved-register: '', callee-saved-restored: true } 101stack: 102 - { id: 0, name: arr, type: default, offset: 0, size: 8, alignment: 4, 103 stack-id: default, callee-saved-register: '', callee-saved-restored: true } 104body: | 105 bb.0.entry: 106 DBG_VALUE $edi, $noreg, !18, !DIExpression(), debug-location !28 107 DBG_VALUE $esi, $noreg, !19, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !28 108 DBG_VALUE $rdx, $noreg, !19, !DIExpression(DW_OP_LLVM_fragment, 64, 64), debug-location !28 109 DBG_VALUE $ecx, $noreg, !20, !DIExpression(), debug-location !28 110 DBG_VALUE $r8d, $noreg, !21, !DIExpression(), debug-location !28 111 DBG_VALUE %fixed-stack.2, 0, !23, !DIExpression(), debug-location !28 112 DBG_VALUE $r9d, $noreg, !22, !DIExpression(), debug-location !28 113 DBG_VALUE %fixed-stack.1, 0, !24, !DIExpression(), debug-location !28 114 DBG_VALUE %fixed-stack.0, 0, !25, !DIExpression(), debug-location !28 115 DBG_VALUE $edi, $noreg, !26, !DIExpression(), debug-location !28 116 DBG_VALUE %fixed-stack.2, 0, !27, !DIExpression(), debug-location !28 117 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !28 118 renamable $rdi = LEA64r %stack.0.arr, 1, $noreg, 0, $noreg 119 CALL64pcrel32 @bar, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !28 120 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !28 121 RET 0, debug-location !28 122 123... 124 125# CHECK: ![[P1:.*]] = !DILocalVariable(name: "p1" 126# CHECK: ![[P2:.*]] = !DILocalVariable(name: "p2" 127# CHECK: ![[P3:.*]] = !DILocalVariable(name: "p3" 128# CHECK: ![[P4:.*]] = !DILocalVariable(name: "p4" 129# CHECK: ![[P5:.*]] = !DILocalVariable(name: "p5" 130# CHECK: ![[P6:.*]] = !DILocalVariable(name: "p6" 131# CHECK: ![[P7:.*]] = !DILocalVariable(name: "p7" 132# CHECK: ![[P8:.*]] = !DILocalVariable(name: "p8" 133# CHECK: ![[LOCAL1:.*]] = !DILocalVariable(name: "local1" 134# CHECK: ![[LOCAL2:.*]] = !DILocalVariable(name: "local2" 135 136# Please note that an additional DBG_VALUE has been added for p6 to see that 137# FI- and register-described DBG_VALUEs for the same variable are not reordered. 138 139# Parameters passed in registers are emitted before the prologue code. 140# CHECK: bb.0.entry: 141# CHECK-NEXT: DBG_VALUE $edi, $noreg, ![[P1]], !DIExpression() 142# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_fragment, 0, 32) 143# CHECK-NEXT: DBG_VALUE $rdx, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_fragment, 64, 64) 144# CHECK-NEXT: DBG_VALUE $ecx, $noreg, ![[P3]], !DIExpression() 145# CHECK-NEXT: DBG_VALUE $r8d, $noreg, ![[P4]], !DIExpression() 146# CHECK-NEXT: DBG_VALUE $r9d, $noreg, ![[P5]], !DIExpression() 147# CHECK-NEXT: frame-setup PUSH64r 148 149# Locals and stack parameters are emitted after the prologue code. 150# CHECK: DBG_VALUE $rsp, 0, ![[P6]], !DIExpression(DW_OP_plus_uconst, 16) 151# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[P7]], !DIExpression(DW_OP_plus_uconst, 24) 152# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[P8]], !DIExpression(DW_OP_plus_uconst, 32) 153# CHECK-NEXT: DBG_VALUE $edi, $noreg, ![[LOCAL1]], !DIExpression() 154# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[LOCAL2]], !DIExpression(DW_OP_plus_uconst, 16) 155