Home | History | Annotate | Download | only in MemorySanitizer
      1 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS1 %s
      2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS2 %s
      3 
      4 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"
      5 target triple = "x86_64-unknown-linux-gnu"
      6 
      7 
      8 ; Check origin instrumentation of stores.
      9 ; Check that debug info for origin propagation code is set correctly.
     10 
     11 ; Function Attrs: nounwind
     12 define void @Store(i32* nocapture %p, i32 %x) #0 !dbg !4 {
     13 entry:
     14   tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !11, metadata !DIExpression()), !dbg !16
     15   tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !12, metadata !DIExpression()), !dbg !16
     16   store i32 %x, i32* %p, align 4, !dbg !17, !tbaa !18
     17   ret void, !dbg !22
     18 }
     19 
     20 ; Function Attrs: nounwind readnone
     21 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
     22 
     23 attributes #0 = { nounwind sanitize_memory "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
     24 attributes #1 = { nounwind readnone }
     25 
     26 !llvm.dbg.cu = !{!0}
     27 !llvm.module.flags = !{!13, !14}
     28 !llvm.ident = !{!15}
     29 
     30 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (204220)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
     31 !1 = !DIFile(filename: "../2.cc", directory: "/tmp/build0")
     32 !2 = !{}
     33 !4 = distinct !DISubprogram(name: "Store", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !10)
     34 !5 = !DIFile(filename: "../2.cc", directory: "/tmp/build0")
     35 !6 = !DISubroutineType(types: !7)
     36 !7 = !{null, !8, !9}
     37 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
     38 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     39 !10 = !{!11, !12}
     40 !11 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8)
     41 !12 = !DILocalVariable(name: "x", line: 1, arg: 2, scope: !4, file: !5, type: !9)
     42 !13 = !{i32 2, !"Dwarf Version", i32 4}
     43 !14 = !{i32 1, !"Debug Info Version", i32 3}
     44 !15 = !{!"clang version 3.5.0 (204220)"}
     45 !16 = !DILocation(line: 1, scope: !4)
     46 !17 = !DILocation(line: 2, scope: !4)
     47 !18 = !{!19, !19, i64 0}
     48 !19 = !{!"int", !20, i64 0}
     49 !20 = !{!"omnipotent char", !21, i64 0}
     50 !21 = !{!"Simple C/C++ TBAA"}
     51 !22 = !DILocation(line: 3, scope: !4)
     52 
     53 
     54 ; CHECK-LABEL: @Store
     55 ; CHECK: load {{.*}} @__msan_param_tls
     56 ; CHECK: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
     57 ; CHECK: store {{.*}}!dbg ![[DBG:[01-9]+]]
     58 ; CHECK: icmp
     59 ; CHECK: br i1
     60 ; CHECK: <label>
     61 
     62 ; Origin tracking level 1: simply store the origin value
     63 ; CHECK-ORIGINS1: store i32 {{.*}}[[ORIGIN]],{{.*}}!dbg !{{.*}}[[DBG]]
     64 
     65 ; Origin tracking level 2: pass origin value through __msan_chain_origin and store the result.
     66 ; CHECK-ORIGINS2: [[ORIGIN2:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 {{.*}}[[ORIGIN]])
     67 ; CHECK-ORIGINS2: store i32 {{.*}}[[ORIGIN2]],{{.*}}!dbg !{{.*}}[[DBG]]
     68 
     69 ; CHECK: br label{{.*}}!dbg !{{.*}}[[DBG]]
     70 ; CHECK: <label>
     71 ; CHECK: store{{.*}}!dbg !{{.*}}[[DBG]]
     72 ; CHECK: ret void
     73