Home | History | Annotate | Download | only in AddressSanitizer
      1 ; RUN: opt < %s -asan -asan-module -asan-use-after-return=0 -S | FileCheck %s
      2 
      3 ; Checks that llvm.dbg.declare instructions are updated 
      4 ; accordingly as we merge allocas.
      5 
      6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
      7 target triple = "x86_64-unknown-linux-gnu"
      8 
      9 define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address !dbg !5 {
     10 entry:
     11   %p.addr = alloca i32, align 4
     12   %r = alloca i32, align 4
     13   store volatile i32 %p, i32* %p.addr, align 4
     14   call void @llvm.dbg.declare(metadata i32* %p.addr, metadata !10, metadata !DIExpression()), !dbg !11
     15   call void @llvm.dbg.declare(metadata i32* %r, metadata !12, metadata !DIExpression()), !dbg !14
     16   %0 = load i32, i32* %p.addr, align 4, !dbg !14
     17   %add = add nsw i32 %0, 1, !dbg !14
     18   store volatile i32 %add, i32* %r, align 4, !dbg !14
     19   %1 = load i32, i32* %r, align 4, !dbg !15
     20   ret i32 %1, !dbg !15
     21 }
     22 
     23 ;   CHECK: define i32 @_Z3zzzi
     24 ;   CHECK: entry:
     25 ; Verify that llvm.dbg.declare calls are in the entry basic block.
     26 ;   CHECK-NOT: %entry
     27 ;   CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 32))
     28 ;   CHECK-NOT: %entry
     29 ;   CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 48))
     30 
     31 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
     32 
     33 !llvm.dbg.cu = !{!0}
     34 !llvm.module.flags = !{!17}
     35 
     36 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 169314)", isOptimized: true, emissionKind: FullDebug, file: !16, enums: !1, retainedTypes: !1, globals: !1)
     37 !1 = !{}
     38 !5 = distinct !DISubprogram(name: "zzz", linkageName: "_Z3zzzi", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !16, scope: !6, type: !7, retainedNodes: !1)
     39 !6 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
     40 !7 = !DISubroutineType(types: !8)
     41 !8 = !{!9, !9}
     42 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     43 !10 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !5, file: !6, type: !9)
     44 !11 = !DILocation(line: 1, scope: !5)
     45 !12 = !DILocalVariable(name: "r", line: 2, scope: !13, file: !6, type: !9)
     46 
     47 ; Verify that debug descriptors for argument and local variable will be replaced
     48 ; with descriptors that end with OpDeref (encoded as 2).
     49 ;   CHECK: ![[ARG_ID]] = !DILocalVariable(name: "p", arg: 1,{{.*}} line: 1
     50 ;   CHECK: ![[VAR_ID]] = !DILocalVariable(name: "r",{{.*}} line: 2
     51 ; Verify that there are no more variable descriptors.
     52 ;   CHECK-NOT: !DILocalVariable(tag: DW_TAG_arg_variable
     53 ;   CHECK-NOT: !DILocalVariable(tag: DW_TAG_auto_variable
     54 
     55 
     56 !13 = distinct !DILexicalBlock(line: 1, column: 0, file: !16, scope: !5)
     57 !14 = !DILocation(line: 2, scope: !13)
     58 !15 = !DILocation(line: 3, scope: !13)
     59 !16 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
     60 !17 = !{i32 1, !"Debug Info Version", i32 3}
     61