aboutsummaryrefslogtreecommitdiffstats
path: root/test/Instrumentation
diff options
context:
space:
mode:
Diffstat (limited to 'test/Instrumentation')
-rw-r--r--test/Instrumentation/DataFlowSanitizer/arith.ll62
-rw-r--r--test/Instrumentation/DataFlowSanitizer/call.ll23
-rw-r--r--test/Instrumentation/DataFlowSanitizer/lit.local.cfg1
-rw-r--r--test/Instrumentation/DataFlowSanitizer/load.ll81
-rw-r--r--test/Instrumentation/DataFlowSanitizer/store.ll75
5 files changed, 242 insertions, 0 deletions
diff --git a/test/Instrumentation/DataFlowSanitizer/arith.ll b/test/Instrumentation/DataFlowSanitizer/arith.ll
new file mode 100644
index 0000000..ecb77a2
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/arith.ll
@@ -0,0 +1,62 @@
+; 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 @add(i8 %a, i8 %b) {
+ ; CHECK: @add
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}__dfsan_union
+ ; CHECK: add i8
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i8
+ %c = add i8 %a, %b
+ ret i8 %c
+}
+
+define i8 @sub(i8 %a, i8 %b) {
+ ; CHECK: @sub
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}__dfsan_union
+ ; CHECK: sub i8
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i8
+ %c = sub i8 %a, %b
+ ret i8 %c
+}
+
+define i8 @mul(i8 %a, i8 %b) {
+ ; CHECK: @mul
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}__dfsan_union
+ ; CHECK: mul i8
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i8
+ %c = mul i8 %a, %b
+ ret i8 %c
+}
+
+define i8 @sdiv(i8 %a, i8 %b) {
+ ; CHECK: @sdiv
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}__dfsan_union
+ ; CHECK: sdiv i8
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i8
+ %c = sdiv i8 %a, %b
+ ret i8 %c
+}
+
+define i8 @udiv(i8 %a, i8 %b) {
+ ; CHECK: @udiv
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}__dfsan_union
+ ; CHECK: udiv i8
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i8
+ %c = udiv i8 %a, %b
+ ret i8 %c
+}
diff --git a/test/Instrumentation/DataFlowSanitizer/call.ll b/test/Instrumentation/DataFlowSanitizer/call.ll
new file mode 100644
index 0000000..c374246
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -0,0 +1,23 @@
+; 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"
+
+; CHECK: @__dfsan_arg_tls = external thread_local(initialexec) global [64 x i16]
+; CHECK: @__dfsan_retval_tls = external thread_local(initialexec) global i16
+
+declare i32 @f(i32)
+declare float @llvm.sqrt.f32(float)
+
+; CHECK: @call
+define i32 @call() {
+ ; CHECK: store{{.*}}__dfsan_arg_tls
+ ; CHECK: call{{.*}}@f
+ ; CHECK: load{{.*}}__dfsan_retval_tls
+ %r = call i32 @f(i32 0)
+
+ ; CHECK-NOT: store{{.*}}__dfsan_arg_tls
+ %i = call float @llvm.sqrt.f32(float -1.0)
+
+ ; CHECK: store{{.*}}__dfsan_retval_tls
+ ; CHECK: ret i32
+ ret i32 %r
+}
diff --git a/test/Instrumentation/DataFlowSanitizer/lit.local.cfg b/test/Instrumentation/DataFlowSanitizer/lit.local.cfg
new file mode 100644
index 0000000..19eebc0
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.ll', '.c', '.cpp']
diff --git a/test/Instrumentation/DataFlowSanitizer/load.ll b/test/Instrumentation/DataFlowSanitizer/load.ll
new file mode 100644
index 0000000..d12a17a
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/load.ll
@@ -0,0 +1,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: @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: @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: @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: @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
+}
diff --git a/test/Instrumentation/DataFlowSanitizer/store.ll b/test/Instrumentation/DataFlowSanitizer/store.ll
new file mode 100644
index 0000000..0c0aa49
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/store.ll
@@ -0,0 +1,75 @@
+; 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 void @store8(i8 %v, i8* %p) {
+ ; CHECK: @store8
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: ptrtoint
+ ; CHECK: and
+ ; CHECK: mul
+ ; CHECK: inttoptr
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: store
+ store i8 %v, i8* %p
+ ret void
+}
+
+define void @store16(i16 %v, i16* %p) {
+ ; CHECK: @store16
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: ptrtoint
+ ; CHECK: and
+ ; CHECK: mul
+ ; CHECK: inttoptr
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: store
+ store i16 %v, i16* %p
+ ret void
+}
+
+define void @store32(i32 %v, i32* %p) {
+ ; CHECK: @store32
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: ptrtoint
+ ; CHECK: and
+ ; CHECK: mul
+ ; CHECK: inttoptr
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: store
+ store i32 %v, i32* %p
+ ret void
+}
+
+define void @store64(i64 %v, i64* %p) {
+ ; CHECK: @store64
+ ; CHECK: load{{.*}}__dfsan_arg_tls
+ ; CHECK: ptrtoint
+ ; CHECK: and
+ ; CHECK: mul
+ ; CHECK: inttoptr
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: insertelement
+ ; CHECK: bitcast
+ ; CHECK: getelementptr
+ ; CHECK: store
+ ; CHECK: store
+ store i64 %v, i64* %p
+ ret void
+}