aboutsummaryrefslogtreecommitdiffstats
path: root/test/Instrumentation/DataFlowSanitizer/load.ll
blob: 6431213f8be5e8a51eb3818dec8f8adca00065d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
; RUN: opt < %s -dfsan -S | FileCheck %s
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"

define i8 @load8(i8* %p) {
  ; CHECK: @"dfs$load8"
  ; CHECK: ptrtoint
  ; CHECK: and
  ; CHECK: mul
  ; CHECK: inttoptr
  ; CHECK: load
  ; CHECK: store{{.*}}__dfsan_retval_tls
  ; CHECK: ret i8
  %a = load i8* %p
  ret i8 %a
}

define i16 @load16(i16* %p) {
  ; CHECK: @"dfs$load16"
  ; CHECK: ptrtoint
  ; CHECK: and
  ; CHECK: mul
  ; CHECK: inttoptr
  ; CHECK: load
  ; CHECK: load
  ; CHECK: icmp ne
  ; CHECK: call{{.*}}__dfsan_union
  ; CHECK: store{{.*}}__dfsan_retval_tls
  ; CHECK: ret i16
  %a = load i16* %p
  ret i16 %a
}

define i32 @load32(i32* %p) {
  ; CHECK: @"dfs$load32"
  ; CHECK: ptrtoint
  ; CHECK: and
  ; CHECK: mul
  ; CHECK: inttoptr
  ; CHECK: bitcast
  ; CHECK: load
  ; CHECK: trunc
  ; CHECK: shl
  ; CHECK: lshr
  ; CHECK: or
  ; CHECK: icmp eq

  ; CHECK: store{{.*}}__dfsan_retval_tls
  ; CHECK: ret i32

  ; CHECK: call{{.*}}__dfsan_union_load

  %a = load i32* %p
  ret i32 %a
}

define i64 @load64(i64* %p) {
  ; CHECK: @"dfs$load64"
  ; CHECK: ptrtoint
  ; CHECK: and
  ; CHECK: mul
  ; CHECK: inttoptr
  ; CHECK: bitcast
  ; CHECK: load
  ; CHECK: trunc
  ; CHECK: shl
  ; CHECK: lshr
  ; CHECK: or
  ; CHECK: icmp eq

  ; CHECK: store{{.*}}__dfsan_retval_tls
  ; CHECK: ret i64

  ; CHECK: call{{.*}}__dfsan_union_load

  ; CHECK: getelementptr
  ; CHECK: load
  ; CHECK: icmp eq

  %a = load i64* %p
  ret i64 %a
}