brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 9194ce9 Raw
115 lines · plain
1; RUN: llc -o - %s | FileCheck %s2; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s --check-prefix=DWARF3; This test checks that parameters on the stack pointer are correctly4; referenced by debug info.5target triple = "x86_64--"6 7@glob = external global i648@ptr = external global ptr9%struct.s = type { i32, i32, i32, i32, i32 }10 11; Simple case: no FP, use offset from RSP.12 13; CHECK-LABEL: f0:14; CHECK-NOT: pushq15; CHECK: movl $42, %eax16; CHECK: retq17define i32 @f0(ptr byval(%struct.s) align 8 %input) !dbg !8 {18  call void @llvm.dbg.declare(metadata ptr %input, metadata !4, metadata !17), !dbg !1819  ret i32 42, !dbg !1820}21 22; DWARF-LABEL: .debug_info contents:23 24; DWARF-LABEL: DW_TAG_subprogram25; DWARF:   DW_AT_frame_base [DW_FORM_exprloc]      (DW_OP_reg7 RSP)26; DWARF:   DW_AT_name [DW_FORM_strp]       ( {{.*}}"f0")27; DWARF:   DW_TAG_formal_parameter28; DWARF-NEXT:     DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg +8)29; DWARF-NEXT:     DW_AT_name [DW_FORM_strp]     ( {{.*}}"input")30 31 32; Dynamic alloca forces the use of RBP as the base pointer33 34; CHECK-LABEL: f1:35; CHECK: pushq %rbp36; CHECK: movl $42, %eax37; CHECK: popq %rbp38; CHECK: retq39define i32 @f1(ptr byval(%struct.s) align 8 %input) !dbg !19 {40  %val = load i64, ptr @glob41  ; this alloca should force FP usage.42  %stackspace = alloca i32, i64 %val, align 143  store ptr %stackspace, ptr @ptr44  call void @llvm.dbg.declare(metadata ptr %input, metadata !20, metadata !17), !dbg !2145  ret i32 42, !dbg !2146}47 48; DWARF-LABEL: DW_TAG_subprogram49; DWARF:   DW_AT_frame_base [DW_FORM_exprloc]      (DW_OP_reg6 RBP)50; DWARF:   DW_AT_name [DW_FORM_strp]       ( {{.*}}"f1")51; DWARF:   DW_TAG_formal_parameter52; DWARF-NEXT:     DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg +16)53; DWARF-NEXT:     DW_AT_name [DW_FORM_strp]     ( {{.*}}"input")54 55; CHECK-LABEL: f2:56; Just check that we are indeed aligning the stack and setting up a base pointer57; in RBX.58; CHECK: pushq %rbp59; CHECK: movq %rsp, %rbp60; CHECK: pushq %rbx61; CHECK: andq $-64, %rsp62; CHECK: subq $64, %rsp63; CHECK: movq %rsp, %rbx64define i32 @f2(ptr byval(%struct.s) align 8 %input) !dbg !22 {65  %val = load i64, ptr @glob66  %stackspace = alloca i32, i64 %val, align 6467  store ptr %stackspace, ptr @ptr68  call void @llvm.dbg.declare(metadata ptr %input, metadata !23, metadata !17), !dbg !2469  ret i32 42, !dbg !2470}71 72; "input" should still be referred to through RBP.73; DWARF-LABEL: DW_TAG_subprogram74; DWARF:   DW_AT_frame_base [DW_FORM_exprloc]      (DW_OP_reg6 RBP)75; DWARF:   DW_AT_name [DW_FORM_strp]       ( {{.*}}"f2")76; DWARF:   DW_TAG_formal_parameter77; DWARF-NEXT:     DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg +16)78; DWARF-NEXT:     DW_AT_name [DW_FORM_strp]     ( {{.*}}"input")79 80declare void @llvm.dbg.declare(metadata, metadata, metadata)81 82!llvm.dbg.cu = !{!2}83!llvm.module.flags = !{!0, !1}84 85!0 = !{i32 2, !"Dwarf Version", i32 4}86!1 = !{i32 2, !"Debug Info Version", i32 3}87!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, emissionKind: FullDebug)88!3 = !DIFile(filename: "dbg-baseptr.ll", directory: "/")89!4 = !DILocalVariable(name: "input", arg: 1, scope: !8, file: !3, line: 5, type: !9)90!5 = !{}91 92!6 = !DISubroutineType(types: !7)93!7 = !{!10, !9}94 95!8 = distinct !DISubprogram(name: "f0", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, unit: !2, retainedNodes: !5)96 97!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", elements: !11)98!10 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)99!11 = !{!12, !13, !14, !15, !16}100!12 = !DIDerivedType(tag: DW_TAG_member, name: "a", baseType: !10, size: 32)101!13 = !DIDerivedType(tag: DW_TAG_member, name: "b", baseType: !10, size: 32, offset: 32)102!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", baseType: !10, size: 32, offset: 64)103!15 = !DIDerivedType(tag: DW_TAG_member, name: "d", baseType: !10, size: 32, offset: 96)104!16 = !DIDerivedType(tag: DW_TAG_member, name: "e", baseType: !10, size: 32, offset: 128)105 106!17 = !DIExpression()107!18 = !DILocation(line: 5, scope: !8)108 109!19 = distinct !DISubprogram(name: "f1", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, retainedNodes: !5)110!20 = !DILocalVariable(name: "input", arg: 1, scope: !19, file: !3, line: 5, type: !9)111!21 = !DILocation(line: 5, scope: !19)112!22 = distinct !DISubprogram(name: "f2", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, retainedNodes: !5)113!23 = !DILocalVariable(name: "input", arg: 1, scope: !22, file: !3, line: 5, type: !9)114!24 = !DILocation(line: 5, scope: !22)115