brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 720758e Raw
120 lines · plain
1# RUN: llc -o - %s -start-after=patchable-function -O0 -mtriple=x86_64-unknown-linux-gnu | FileCheck %s2# Test dwarf codegen of DW_OP_minus.3#4# This was built by compiling the following source with SafeStack and5# simplifying the result a little.6# extern "C" {7# void Capture(int *);8# void f() {9#   int buf[100];10#   Capture(buf);11# }12# }13# The interesting part is !DIExpression(DW_OP_constu, 400, DW_OP_minus)14#15# RCX - 40016# CHECK:      .short    3                       # Loc expr size17# CHECK-NEXT: .byte     114                     # DW_OP_breg218# CHECK-NEXT: .byte     240                     # -40019# CHECK-NEXT: .byte     12420#21# RCX is clobbered in call @Capture, but there is a spilled copy.22# *(RSP + 8) - 40023# CHECK:      .short    7                       # Loc expr size24# CHECK-NEXT: .byte     119                     # DW_OP_breg725# CHECK-NEXT: .byte     8                       # 826# CHECK-NEXT: .byte     6                       # DW_OP_deref27# CHECK-NEXT: .byte     16                      # DW_OP_constu28# CHECK-NEXT: .byte     144                     # 40029# CHECK-NEXT: .byte     3                       #30# CHECK-NEXT: .byte     28                      # DW_OP_minus31--- |32  @__safestack_unsafe_stack_ptr = external thread_local(initialexec) global ptr33  34  define void @f() !dbg !5 {35  entry:36    %unsafe_stack_ptr = load ptr, ptr @__safestack_unsafe_stack_ptr37    %unsafe_stack_static_top = getelementptr i8, ptr %unsafe_stack_ptr, i32 -40038    store ptr %unsafe_stack_static_top, ptr @__safestack_unsafe_stack_ptr39    %0 = getelementptr i8, ptr %unsafe_stack_ptr, i32 -40040    %buf = bitcast ptr %0 to ptr41    %1 = bitcast ptr %buf to ptr, !dbg !1442    call void @llvm.dbg.declare(metadata ptr %unsafe_stack_ptr, metadata !9, metadata !DIExpression(DW_OP_constu, 400, DW_OP_minus)), !dbg !1543    %arraydecay = getelementptr inbounds [100 x i32], ptr %buf, i64 0, i64 0, !dbg !1644    call void @Capture(ptr %arraydecay), !dbg !1745    store ptr %unsafe_stack_ptr, ptr @__safestack_unsafe_stack_ptr, !dbg !1846    ret void, !dbg !1847  }48  49  ; Function Attrs: nounwind readnone speculatable50  declare void @llvm.dbg.declare(metadata, metadata, metadata) #051  52  declare void @Capture(ptr)53  54  ; Function Attrs: nounwind55  declare void @llvm.stackprotector(ptr, ptr) #156  57  attributes #0 = { nounwind readnone speculatable }58  attributes #1 = { nounwind }59  60  !llvm.dbg.cu = !{!0}61  !llvm.module.flags = !{!3, !4}62  63  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 248518) (llvm/trunk 248512)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)64  !1 = !DIFile(filename: "1.cc", directory: "/tmp")65  !2 = !{}66  !3 = !{i32 2, !"Dwarf Version", i32 4}67  !4 = !{i32 2, !"Debug Info Version", i32 3}68  !5 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8)69  !6 = !DISubroutineType(types: !7)70  !7 = !{null}71  !8 = !{!9}72  !9 = !DILocalVariable(name: "buf", scope: !5, file: !1, line: 5, type: !10)73  !10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 3200, align: 32, elements: !12)74  !11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)75  !12 = !{!13}76  !13 = !DISubrange(count: 100)77  !14 = !DILocation(line: 5, column: 3, scope: !5)78  !15 = !DILocation(line: 5, column: 7, scope: !5)79  !16 = !DILocation(line: 6, column: 11, scope: !5)80  !17 = !DILocation(line: 6, column: 3, scope: !5)81  !18 = !DILocation(line: 7, column: 1, scope: !5)82 83...84---85name:            f86alignment:       1687tracksRegLiveness: true88frameInfo:       89  stackSize:       2490  maxAlignment:    891  adjustsStack:    true92  hasCalls:        true93  maxCallFrameSize: 094stack:           95  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 8, stack-id: default }96  - { id: 1, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default }97body:             |98  bb.0.entry:99    $rsp = frame-setup SUB64ri8 $rsp, 24, implicit-def dead $eflags100    CFI_INSTRUCTION def_cfa_offset 32101    renamable $rax = MOV64rm $rip, 1, $noreg, target-flags(x86-gottpoff) @__safestack_unsafe_stack_ptr, $noreg :: (load (s64) from got)102    renamable $rcx = MOV64rm renamable $rax, 1, $noreg, 0, $fs :: (dereferenceable load (s64) from @__safestack_unsafe_stack_ptr)103    DBG_VALUE renamable $rcx, 0, !9, !DIExpression(DW_OP_constu, 400, DW_OP_minus), debug-location !15104    $rdx = MOV64rr $rcx105    renamable $rdx = ADD64ri32 renamable $rdx, -400, implicit-def dead $eflags106    MOV64mr renamable $rax, 1, $noreg, 0, $fs, renamable $rdx :: (store (s64) into @__safestack_unsafe_stack_ptr)107    $rdi = MOV64rr killed $rdx, debug-location !17108    MOV64mr $rsp, 1, $noreg, 16, $noreg, killed $rax :: (store (s64) into %stack.0)109    MOV64mr $rsp, 1, $noreg, 8, $noreg, killed $rcx :: (store (s64) into %stack.1)110    DBG_VALUE $rsp, 0, !9, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref, DW_OP_constu, 400, DW_OP_minus), debug-location !15111    CALL64pcrel32 @Capture, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !17112    $rax = MOV64rm $rsp, 1, $noreg, 16, $noreg :: (load (s64) from %stack.0)113    $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg :: (load (s64) from %stack.1)114    MOV64mr killed renamable $rax, 1, $noreg, 0, $fs, killed renamable $rcx, debug-location !18 :: (store (s64) into @__safestack_unsafe_stack_ptr)115    $rsp = frame-destroy ADD64ri8 $rsp, 24, implicit-def dead $eflags, debug-location !18116    CFI_INSTRUCTION def_cfa_offset 8, debug-location !18117    RET64 debug-location !18118 119...120