157 lines · plain
1# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=prologepilog %s -o - | FileCheck %s2 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-llvm19# $ llc -O1 -stop-before=prologepilog20 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 uwtable26 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 429 call void @llvm.dbg.value(metadata i32 %p1, metadata !18, metadata !DIExpression()), !dbg !2830 call void @llvm.dbg.value(metadata i32 %p2.coerce0, metadata !19, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !2831 call void @llvm.dbg.value(metadata i64 %p2.coerce1, metadata !19, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg !2832 call void @llvm.dbg.value(metadata i32 %p3, metadata !20, metadata !DIExpression()), !dbg !2833 call void @llvm.dbg.value(metadata i32 %p4, metadata !21, metadata !DIExpression()), !dbg !2834 call void @llvm.dbg.value(metadata i32 %p5, metadata !22, metadata !DIExpression()), !dbg !2835 call void @llvm.dbg.value(metadata i32 %p6, metadata !23, metadata !DIExpression()), !dbg !2836 call void @llvm.dbg.value(metadata i32 %p7, metadata !24, metadata !DIExpression()), !dbg !2837 call void @llvm.dbg.value(metadata i32 %p8, metadata !25, metadata !DIExpression()), !dbg !2838 call void @llvm.dbg.value(metadata i32 %p1, metadata !26, metadata !DIExpression()), !dbg !2839 call void @llvm.dbg.value(metadata i32 %p6, metadata !27, metadata !DIExpression()), !dbg !2840 %arraydecay1 = bitcast ptr %arr to ptr, !dbg !2841 call void @bar(ptr nonnull %arraydecay1), !dbg !2842 ret void, !dbg !2843 }44 45 ; Function Attrs: nounwind readnone speculatable46 declare void @llvm.dbg.declare(metadata, metadata, metadata) #147 48 declare dso_local void @bar(ptr) local_unnamed_addr49 50 ; Function Attrs: nounwind readnone speculatable51 declare void @llvm.dbg.value(metadata, metadata, metadata) #152 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: foo93tracksRegLiveness: true94fixedStack: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 }101frameInfo:102 adjustsStack: true103stack:104 - { id: 0, name: arr, type: default, offset: 0, size: 8, alignment: 4,105 stack-id: default, callee-saved-register: '', callee-saved-restored: true }106body: |107 bb.0.entry:108 DBG_VALUE $edi, $noreg, !18, !DIExpression(), debug-location !28109 DBG_VALUE $esi, $noreg, !19, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !28110 DBG_VALUE $rdx, $noreg, !19, !DIExpression(DW_OP_LLVM_fragment, 64, 64), debug-location !28111 DBG_VALUE $ecx, $noreg, !20, !DIExpression(), debug-location !28112 DBG_VALUE $r8d, $noreg, !21, !DIExpression(), debug-location !28113 DBG_VALUE %fixed-stack.2, 0, !23, !DIExpression(), debug-location !28114 DBG_VALUE $r9d, $noreg, !22, !DIExpression(), debug-location !28115 DBG_VALUE %fixed-stack.1, 0, !24, !DIExpression(), debug-location !28116 DBG_VALUE %fixed-stack.0, 0, !25, !DIExpression(), debug-location !28117 DBG_VALUE $edi, $noreg, !26, !DIExpression(), debug-location !28118 DBG_VALUE %fixed-stack.2, 0, !27, !DIExpression(), debug-location !28119 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !28120 renamable $rdi = LEA64r %stack.0.arr, 1, $noreg, 0, $noreg121 CALL64pcrel32 @bar, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !28122 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !28123 RET 0, debug-location !28124 125...126 127# CHECK: ![[P1:.*]] = !DILocalVariable(name: "p1"128# CHECK: ![[P2:.*]] = !DILocalVariable(name: "p2"129# CHECK: ![[P3:.*]] = !DILocalVariable(name: "p3"130# CHECK: ![[P4:.*]] = !DILocalVariable(name: "p4"131# CHECK: ![[P5:.*]] = !DILocalVariable(name: "p5"132# CHECK: ![[P6:.*]] = !DILocalVariable(name: "p6"133# CHECK: ![[P7:.*]] = !DILocalVariable(name: "p7"134# CHECK: ![[P8:.*]] = !DILocalVariable(name: "p8"135# CHECK: ![[LOCAL1:.*]] = !DILocalVariable(name: "local1"136# CHECK: ![[LOCAL2:.*]] = !DILocalVariable(name: "local2"137 138# Please note that an additional DBG_VALUE has been added for p6 to see that139# FI- and register-described DBG_VALUEs for the same variable are not reordered.140 141# Parameters passed in registers are emitted before the prologue code.142# CHECK: bb.0.entry:143# CHECK-NEXT: DBG_VALUE $edi, $noreg, ![[P1]], !DIExpression()144# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_fragment, 0, 32)145# CHECK-NEXT: DBG_VALUE $rdx, $noreg, ![[P2]], !DIExpression(DW_OP_LLVM_fragment, 64, 64)146# CHECK-NEXT: DBG_VALUE $ecx, $noreg, ![[P3]], !DIExpression()147# CHECK-NEXT: DBG_VALUE $r8d, $noreg, ![[P4]], !DIExpression()148# CHECK-NEXT: DBG_VALUE $r9d, $noreg, ![[P5]], !DIExpression()149# CHECK-NEXT: frame-setup PUSH64r150 151# Locals and stack parameters are emitted after the prologue code.152# CHECK: DBG_VALUE $rsp, 0, ![[P6]], !DIExpression(DW_OP_plus_uconst, 16)153# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[P7]], !DIExpression(DW_OP_plus_uconst, 24)154# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[P8]], !DIExpression(DW_OP_plus_uconst, 32)155# CHECK-NEXT: DBG_VALUE $edi, $noreg, ![[LOCAL1]], !DIExpression()156# CHECK-NEXT: DBG_VALUE $rsp, 0, ![[LOCAL2]], !DIExpression(DW_OP_plus_uconst, 16)157