brintos

brintos / llvm-project-archived public Read only

0
0
Text · 16.6 KiB · e1d9651 Raw
347 lines · plain
1# RUN: llc -o - %s -start-after=livedebugvalues -O0 -mtriple=x86_64-unknown-linux-gnu | FileCheck %s2# RUN: llc -o - %s -start-after=livedebugvalues  -O0 -mtriple=x86_64-unknown-linux-gnu -filetype=obj \3# RUN:   | llvm-dwarfdump -debug-info - | FileCheck %s --check-prefix=DWARF4#5# Verify that we have correct debug info for local variables in code6# instrumented with AddressSanitizer.7#8# Generated from the source file test.cc:9# int bar(int y) {10#   return y + 2;11# }12# with "clang++ -S -emit-llvm -mllvm -asan-skip-promotable-allocas=0 -fsanitize=address -O0 -g test.cc"13#14# The address of the (potentially now malloc'ed) alloca ends up15# in rdi, after which it is spilled to the stack. We record the16# spill OFFSET on the stack for checking the debug info below.17# CHECK: #DEBUG_VALUE: bar:y <- [DW_OP_deref] [$rcx+0]18# CHECK: movq %rcx, [[OFFSET:[0-9]+]](%rsp)19# CHECK-NEXT: [[START_LABEL:.Ltmp[0-9]+]]20# CHECK-NEXT: #DEBUG_VALUE: bar:y <- [DW_OP_plus_uconst [[OFFSET]], DW_OP_deref, DW_OP_deref]21# This location should be valid until the end of the function.22#23# CHECK:        movq    %rbp, %rsp24# CHECK-NEXT: [[END_LABEL:.Ltmp[0-9]+]]:25#26# CHECK: .Ldebug_loc{{[0-9]+}}:27# We expect two location ranges for the variable.28#29# First, its address is stored in %rcx:30# CHECK:      .quad .Ltmp0-.Lfunc_begin031# CHECK-NEXT: .quad [[START_LABEL]]-.Lfunc_begin032# CHECK: DW_OP_breg233# DWARF:       DW_TAG_formal_parameter34# DWARF:         DW_AT_location35# DWARF-NEXT:      [{{.*}}, {{.*}}): DW_OP_breg2 RCX+0, DW_OP_deref36#37# Then it's addressed via %rsp:38# CHECK:      .quad [[START_LABEL]]-.Lfunc_begin039# CHECK-NEXT: .quad [[END_LABEL]]-.Lfunc_begin040# CHECK: DW_OP_breg741# CHECK-NEXT: [[OFFSET]]42# CHECK: DW_OP_deref43# DWARF-NEXT:      [{{.*}}, {{.*}}): DW_OP_breg7 RSP+{{[0-9]+}}, DW_OP_deref, DW_OP_deref)44--- |45  @__asan_option_detect_stack_use_after_return = external global i3246  @___asan_gen_ = private unnamed_addr constant [16 x i8] c"1 32 4 6 y.addr\00", align 147  48  ; Function Attrs: nounwind sanitize_address uwtable49  define i32 @_Z3bari(i32 %y) #0 !dbg !6 {50  entry:51    %MyAlloca = alloca [64 x i8], align 3252    %0 = ptrtoint ptr %MyAlloca to i6453    %1 = load i32, ptr @__asan_option_detect_stack_use_after_return54    %2 = icmp ne i32 %1, 055    br i1 %2, label %3, label %556  57  ; <label>:3:                                      ; preds = %entry58    %4 = call i64 @__asan_stack_malloc_0(i64 64, i64 %0)59    br label %560  61  ; <label>:5:                                      ; preds = %3, %entry62    %6 = phi i64 [ %0, %entry ], [ %4, %3 ]63    %7 = add i64 %6, 3264    %8 = inttoptr i64 %7 to ptr65    %9 = inttoptr i64 %6 to ptr66    store i64 1102416563, ptr %967    %10 = add i64 %6, 868    %11 = inttoptr i64 %10 to ptr69    store i64 ptrtoint (ptr @___asan_gen_ to i64), ptr %1170    %12 = add i64 %6, 1671    %13 = inttoptr i64 %12 to ptr72    store i64 ptrtoint (ptr @_Z3bari to i64), ptr %1373    %14 = lshr i64 %6, 374    %15 = add i64 %14, 214745088075    %16 = add i64 %15, 076    %17 = inttoptr i64 %16 to ptr77    store i64 -868083100587789839, ptr %1778    %18 = ptrtoint ptr %8 to i6479    %19 = lshr i64 %18, 380    %20 = add i64 %19, 214745088081    %21 = inttoptr i64 %20 to ptr82    %22 = load i8, ptr %2183    %23 = icmp ne i8 %22, 084    call void @llvm.dbg.declare(metadata ptr %8, metadata !10, metadata !DIExpression(DW_OP_deref)), !dbg !1185    br i1 %23, label %24, label %3086  87  ; <label>:24:                                     ; preds = %588    %25 = and i64 %18, 789    %26 = add i64 %25, 390    %27 = trunc i64 %26 to i891    %28 = icmp sge i8 %27, %2292    br i1 %28, label %29, label %3093  94  ; <label>:29:                                     ; preds = %2495    call void @__asan_report_store4(i64 %18)96    call void asm sideeffect "", ""()97    unreachable98  99  ; <label>:30:                                     ; preds = %24, %5100    store i32 %y, ptr %8, align 4101    %31 = ptrtoint ptr %8 to i64, !dbg !12102    %32 = lshr i64 %31, 3, !dbg !12103    %33 = add i64 %32, 2147450880, !dbg !12104    %34 = inttoptr i64 %33 to ptr, !dbg !12105    %35 = load i8, ptr %34, !dbg !12106    %36 = icmp ne i8 %35, 0, !dbg !12107    br i1 %36, label %37, label %43, !dbg !12108  109  ; <label>:37:                                     ; preds = %30110    %38 = and i64 %31, 7, !dbg !12111    %39 = add i64 %38, 3, !dbg !12112    %40 = trunc i64 %39 to i8, !dbg !12113    %41 = icmp sge i8 %40, %35, !dbg !12114    br i1 %41, label %42, label %43115  116  ; <label>:42:                                     ; preds = %37117    call void @__asan_report_load4(i64 %31), !dbg !12118    call void asm sideeffect "", ""()119    unreachable120  121  ; <label>:43:                                     ; preds = %37, %30122    %44 = load i32, ptr %8, align 4, !dbg !12123    %add = add nsw i32 %44, 2, !dbg !12124    store i64 1172321806, ptr %9, !dbg !12125    %45 = icmp ne i64 %6, %0, !dbg !12126    br i1 %45, label %46, label %53, !dbg !12127  128  ; <label>:46:                                     ; preds = %43129    %47 = add i64 %15, 0, !dbg !12130    %48 = inttoptr i64 %47 to ptr, !dbg !12131    store i64 -723401728380766731, ptr %48, !dbg !12132    %49 = add i64 %6, 56, !dbg !12133    %50 = inttoptr i64 %49 to ptr, !dbg !12134    %51 = load i64, ptr %50, !dbg !12135    %52 = inttoptr i64 %51 to ptr, !dbg !12136    store i8 0, ptr %52, !dbg !12137    br label %56, !dbg !12138  139  ; <label>:53:                                     ; preds = %43140    %54 = add i64 %15, 0, !dbg !12141    %55 = inttoptr i64 %54 to ptr, !dbg !12142    store i64 0, ptr %55, !dbg !12143    br label %56, !dbg !12144  145  ; <label>:56:                                     ; preds = %53, %46146    ret i32 %add, !dbg !12147  }148  149  ; Function Attrs: nounwind readnone speculatable150  declare void @llvm.dbg.declare(metadata, metadata, metadata) #1151  152  declare void @__asan_init_v3()153  154  declare void @__asan_report_load4(i64)155  156  declare void @__asan_report_store4(i64)157  158  declare i64 @__asan_stack_malloc_0(i64, i64)159  160  ; Function Attrs: nounwind161  declare void @llvm.stackprotector(ptr, ptr) #2162  163  attributes #0 = { nounwind sanitize_address uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }164  attributes #1 = { nounwind readnone speculatable }165  attributes #2 = { nounwind }166  167  !llvm.dbg.cu = !{!0}168  !llvm.module.flags = !{!3, !4}169  !llvm.ident = !{!5}170  171  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5.0 (209308)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)172  !1 = !DIFile(filename: "test.cc", directory: "/llvm_cmake_gcc")173  !2 = !{}174  !3 = !{i32 2, !"Dwarf Version", i32 4}175  !4 = !{i32 2, !"Debug Info Version", i32 3}176  !5 = !{!"clang version 3.5.0 (209308)"}177  !6 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)178  !7 = !DISubroutineType(types: !8)179  !8 = !{!9, !9}180  !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)181  !10 = !DILocalVariable(name: "y", arg: 1, scope: !6, file: !1, line: 1, type: !9)182  !11 = !DILocation(line: 0, scope: !6)183  !12 = !DILocation(line: 2, scope: !6)184 185...186---187name:            _Z3bari188alignment:       16189tracksRegLiveness: true190liveins:         191  - { reg: '$edi' }192frameInfo:       193  stackSize:       152194  offsetAdjustment: -160195  maxAlignment:    32196  adjustsStack:    true197  hasCalls:        true198  maxCallFrameSize: 0199fixedStack:      200  - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default }201stack:           202  - { id: 0, name: MyAlloca, offset: -96, size: 64, alignment: 32, stack-id: default }203  - { id: 1, type: spill-slot, offset: -100, size: 4, alignment: 4, stack-id: default }204  - { id: 2, type: spill-slot, offset: -112, size: 8, alignment: 8, stack-id: default }205  - { id: 3, type: spill-slot, offset: -120, size: 8, alignment: 8, stack-id: default }206  - { id: 4, type: spill-slot, offset: -128, size: 8, alignment: 8, stack-id: default }207  - { id: 5, type: spill-slot, offset: -136, size: 8, alignment: 8, stack-id: default }208  - { id: 6, type: spill-slot, offset: -144, size: 8, alignment: 8, stack-id: default }209  - { id: 7, type: spill-slot, offset: -145, size: 1, alignment: 1, stack-id: default }210  - { id: 8, type: spill-slot, offset: -146, size: 1, alignment: 1, stack-id: default }211  - { id: 9, type: spill-slot, offset: -152, size: 4, alignment: 4, stack-id: default }212body:             |213  bb.0.entry:214    liveins: $edi215  216    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp217    CFI_INSTRUCTION def_cfa_offset 16218    CFI_INSTRUCTION offset $rbp, -16219    $rbp = frame-setup MOV64rr $rsp220    CFI_INSTRUCTION def_cfa_register $rbp221    $rsp = frame-setup AND64ri8 $rsp, -32, implicit-def dead $eflags222    $rsp = frame-setup SUB64ri32 $rsp, 160, implicit-def dead $eflags223    renamable $rax = LEA64r $rsp, 1, $noreg, 64, $noreg224    CMP32mi $noreg, 1, $noreg, @__asan_option_detect_stack_use_after_return, $noreg, 0, implicit-def $eflags :: (load (s32) from @__asan_option_detect_stack_use_after_return)225    $rcx = MOV64rr $rax226    MOV32mr $rsp, 1, $noreg, 60, $noreg, killed $edi :: (store (s32) into %stack.1)227    MOV64mr $rsp, 1, $noreg, 48, $noreg, killed $rax :: (store (s64) into %stack.2)228    MOV64mr $rsp, 1, $noreg, 40, $noreg, killed $rcx :: (store (s64) into %stack.3)229    JCC_1 %bb.2, 4, implicit $eflags230  231  bb.1 (%ir-block.3):232    $edi = MOV32ri 64, implicit-def $rdi233    $rsi = MOV64rm $rsp, 1, $noreg, 48, $noreg :: (load (s64) from %stack.2)234    CALL64pcrel32 @__asan_stack_malloc_0, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit-def $rax235    MOV64mr $rsp, 1, $noreg, 40, $noreg, killed $rax :: (store (s64) into %stack.3)236  237  bb.2 (%ir-block.5):238    $rax = MOV64rm $rsp, 1, $noreg, 40, $noreg :: (load (s64) from %stack.3)239    $rcx = MOV64rr $rax240    renamable $rcx = ADD64ri8 renamable $rcx, 32, implicit-def $eflags241    MOV64mi32 renamable $rax, 1, $noreg, 0, $noreg, 1102416563 :: (store (s64) into %ir.9)242    renamable $rdx = MOV64ri @___asan_gen_243    MOV64mr renamable $rax, 1, $noreg, 8, $noreg, killed renamable $rdx :: (store (s64) into %ir.11)244    renamable $rdx = MOV64ri @_Z3bari245    MOV64mr renamable $rax, 1, $noreg, 16, $noreg, killed renamable $rdx :: (store (s64) into %ir.13)246    $rdx = MOV64rr $rax247    renamable $rdx = SHR64ri renamable $rdx, 3, implicit-def $eflags248    $rsi = MOV64rr $rdx249    renamable $rsi = ADD64ri32 renamable $rsi, 2147450880, implicit-def $eflags250    renamable $rdi = MOV64ri -868083100587789839251    MOV64mr killed renamable $rdx, 1, $noreg, 2147450880, $noreg, killed renamable $rdi :: (store (s64) into %ir.17)252    $rdx = MOV64rr $rcx253    renamable $rdx = SHR64ri renamable $rdx, 3, implicit-def $eflags254    renamable $r8b = MOV8rm killed renamable $rdx, 1, $noreg, 2147450880, $noreg :: (load (s8) from %ir.21)255    DBG_VALUE renamable $rcx, 0, !10, !DIExpression(DW_OP_deref), debug-location !11256    CMP8ri renamable $r8b, 0, implicit-def $eflags257    MOV64mr $rsp, 1, $noreg, 32, $noreg, killed $rax :: (store (s64) into %stack.4)258    MOV64mr $rsp, 1, $noreg, 24, $noreg, killed $rcx :: (store (s64) into %stack.5)259    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11260    MOV64mr $rsp, 1, $noreg, 16, $noreg, killed $rsi :: (store (s64) into %stack.6)261    MOV8mr $rsp, 1, $noreg, 15, $noreg, killed $r8b :: (store (s8) into %stack.7)262    JCC_1 %bb.5, 4, implicit $eflags263  264  bb.3 (%ir-block.24):265    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11266    $rax = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)267    renamable $rax = AND64ri8 renamable $rax, 7, implicit-def $eflags268    renamable $rax = ADD64ri8 renamable $rax, 3, implicit-def $eflags269    $cl = MOV8rr $al, implicit killed $rax270    $dl = MOV8rm $rsp, 1, $noreg, 15, $noreg :: (load (s8) from %stack.7)271    CMP8rr killed renamable $cl, killed renamable $dl, implicit-def $eflags272    JCC_1 %bb.5, 12, implicit $eflags273  274  bb.4 (%ir-block.29):275    successors: 276  277    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11278    $rdi = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)279    CALL64pcrel32 @__asan_report_store4, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi280    INLINEASM &"", 1281  282  bb.5 (%ir-block.30):283    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11284    $rax = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)285    $ecx = MOV32rm $rsp, 1, $noreg, 60, $noreg :: (load (s32) from %stack.1)286    MOV32mr renamable $rax, 1, $noreg, 0, $noreg, killed renamable $ecx :: (store (s32) into %ir.8)287    renamable $rax = SHR64ri renamable $rax, 3, implicit-def $eflags, debug-location !12288    renamable $dl = MOV8rm killed renamable $rax, 1, $noreg, 2147450880, $noreg, debug-location !12 :: (load (s8) from %ir.34)289    CMP8ri renamable $dl, 0, implicit-def $eflags, debug-location !12290    MOV8mr $rsp, 1, $noreg, 14, $noreg, killed $dl :: (store (s8) into %stack.8)291    JCC_1 %bb.8, 4, implicit $eflags, debug-location !12292  293  bb.6 (%ir-block.37):294    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11295    $rax = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)296    renamable $rax = AND64ri8 renamable $rax, 7, implicit-def $eflags, debug-location !12297    renamable $rax = ADD64ri8 renamable $rax, 3, implicit-def $eflags, debug-location !12298    $cl = MOV8rr $al, implicit killed $rax, debug-location !12299    $dl = MOV8rm $rsp, 1, $noreg, 14, $noreg :: (load (s8) from %stack.8)300    CMP8rr killed renamable $cl, killed renamable $dl, implicit-def $eflags, debug-location !12301    JCC_1 %bb.8, 12, implicit $eflags302  303  bb.7 (%ir-block.42):304    successors: 305  306    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11307    $rdi = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)308    CALL64pcrel32 @__asan_report_load4, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, debug-location !12309    INLINEASM &"", 1310  311  bb.8 (%ir-block.43):312    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11313    $rax = MOV64rm $rsp, 1, $noreg, 24, $noreg :: (load (s64) from %stack.5)314    renamable $ecx = MOV32rm killed renamable $rax, 1, $noreg, 0, $noreg, debug-location !12 :: (load (s32) from %ir.8)315    renamable $ecx = ADD32ri8 renamable $ecx, 2, implicit-def $eflags, debug-location !12316    $rdx = MOV64rm $rsp, 1, $noreg, 32, $noreg :: (load (s64) from %stack.4)317    MOV64mi32 renamable $rdx, 1, $noreg, 0, $noreg, 1172321806, debug-location !12 :: (store (s64) into %ir.9)318    $rsi = MOV64rm $rsp, 1, $noreg, 48, $noreg :: (load (s64) from %stack.2)319    CMP64rr killed renamable $rdx, killed renamable $rsi, implicit-def $eflags, debug-location !12320    MOV32mr $rsp, 1, $noreg, 8, $noreg, killed $ecx :: (store (s32) into %stack.9)321    JCC_1 %bb.10, 4, implicit $eflags, debug-location !12322  323  bb.9 (%ir-block.46):324    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11325    renamable $rax = MOV64ri -723401728380766731, debug-location !12326    $rcx = MOV64rm $rsp, 1, $noreg, 16, $noreg :: (load (s64) from %stack.6)327    MOV64mr killed renamable $rcx, 1, $noreg, 0, $noreg, killed renamable $rax, debug-location !12 :: (store (s64) into %ir.48)328    $rax = MOV64rm $rsp, 1, $noreg, 32, $noreg :: (load (s64) from %stack.4)329    renamable $rdx = MOV64rm killed renamable $rax, 1, $noreg, 56, $noreg, debug-location !12 :: (load (s64) from %ir.50)330    MOV8mi killed renamable $rdx, 1, $noreg, 0, $noreg, 0, debug-location !12 :: (store (s8) into %ir.52)331    JMP_1 %bb.11, debug-location !12332  333  bb.10 (%ir-block.53):334    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11335    $rax = MOV64rm $rsp, 1, $noreg, 16, $noreg :: (load (s64) from %stack.6)336    MOV64mi32 killed renamable $rax, 1, $noreg, 0, $noreg, 0, debug-location !12 :: (store (s64) into %ir.55)337  338  bb.11 (%ir-block.56):339    DBG_VALUE $rsp, 0, !10, !DIExpression(DW_OP_plus_uconst, 24, DW_OP_deref, DW_OP_deref), debug-location !11340    $eax = MOV32rm $rsp, 1, $noreg, 8, $noreg :: (load (s32) from %stack.9)341    $rsp = MOV64rr $rbp, debug-location !12342    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !12343    CFI_INSTRUCTION def_cfa $rsp, 8, debug-location !12344    RET64 implicit killed $eax, debug-location !12345 346...347