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