aboutsummaryrefslogtreecommitdiffstats
path: root/test/Instrumentation
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-08-14 18:54:12 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-08-14 18:54:12 +0000
commitfdb1a6c341c0e289f3f900cdab87f831262c0e93 (patch)
treee35e2e89168b0bc5fac51bb9df0541a1201213ce /test/Instrumentation
parent35d5e9044c580c843eb6e825d87816619e6d7f8f (diff)
downloadexternal_llvm-fdb1a6c341c0e289f3f900cdab87f831262c0e93.zip
external_llvm-fdb1a6c341c0e289f3f900cdab87f831262c0e93.tar.gz
external_llvm-fdb1a6c341c0e289f3f900cdab87f831262c0e93.tar.bz2
DataFlowSanitizer: greylist is now ABI list.
This replaces the old incomplete greylist functionality with an ABI list, which can provide more detailed information about the ABI and semantics of specific functions. The pass treats every function in the "uninstrumented" category in the ABI list file as conforming to the "native" (i.e. unsanitized) ABI. Unless the ABI list contains additional categories for those functions, a call to one of those functions will produce a warning message, as the labelling behaviour of the function is unknown. The other supported categories are "functional", "discard" and "custom". - "discard" -- This function does not write to (user-accessible) memory, and its return value is unlabelled. - "functional" -- This function does not write to (user-accessible) memory, and the label of its return value is the union of the label of its arguments. - "custom" -- Instead of calling the function, a custom wrapper __dfsw_F is called, where F is the name of the function. This function may wrap the original function or provide its own implementation. Differential Revision: http://llvm-reviews.chandlerc.com/D1345 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Instrumentation')
-rw-r--r--test/Instrumentation/DataFlowSanitizer/abilist.ll47
-rw-r--r--test/Instrumentation/DataFlowSanitizer/abilist.ll.txt11
2 files changed, 58 insertions, 0 deletions
diff --git a/test/Instrumentation/DataFlowSanitizer/abilist.ll b/test/Instrumentation/DataFlowSanitizer/abilist.ll
new file mode 100644
index 0000000..d8bce82
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/abilist.ll
@@ -0,0 +1,47 @@
+; RUN: opt < %s -dfsan -dfsan-args-abi -dfsan-abilist=%s.txt -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: i32 @discard(i32 %a, i32 %b)
+define i32 @discard(i32 %a, i32 %b) {
+ ret i32 0
+}
+
+; CHECK: i32 @functional(i32 %a, i32 %b)
+define i32 @functional(i32 %a, i32 %b) {
+ %c = add i32 %a, %b
+ ret i32 %c
+}
+
+declare void @custom1(i32 %a, i32 %b)
+
+declare i32 @custom2(i32 %a, i32 %b)
+
+; CHECK: @f
+define void @f() {
+ ; CHECK: %[[LABELRETURN:.*]] = alloca i16
+
+ ; CHECK: call void @__dfsw_custom1(i32 1, i32 2, i16 0, i16 0)
+ call void @custom1(i32 1, i32 2)
+
+ ; CHECK: call i32 @__dfsw_custom2(i32 1, i32 2, i16 0, i16 0, i16* %[[LABELRETURN]])
+ call i32 @custom2(i32 1, i32 2)
+
+ ret void
+}
+
+; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16)
+; CHECK: %[[LABELRETURN2:.*]] = alloca i16
+; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2
+; CHECK: %[[RVSHADOW:.*]] = load i16* %[[LABELRETURN2]]
+; CHECK: insertvalue {{.*}}[[RV]], 0
+; CHECK: insertvalue {{.*}}[[RVSHADOW]], 1
+; CHECK: ret { i32, i16 }
+
+; CHECK: @g
+define i32 (i32, i32)* @g() {
+ ; CHECK: ret {{.*}} @"dfsw$custom2"
+ ret i32 (i32, i32)* @custom2
+}
+
+; CHECK: declare void @__dfsw_custom1(i32, i32, i16, i16)
+; CHECK: declare i32 @__dfsw_custom2(i32, i32, i16, i16, i16*)
diff --git a/test/Instrumentation/DataFlowSanitizer/abilist.ll.txt b/test/Instrumentation/DataFlowSanitizer/abilist.ll.txt
new file mode 100644
index 0000000..fec2a50
--- /dev/null
+++ b/test/Instrumentation/DataFlowSanitizer/abilist.ll.txt
@@ -0,0 +1,11 @@
+fun:discard=uninstrumented
+fun:discard=discard
+
+fun:functional=uninstrumented
+fun:functional=functional
+
+fun:custom1=uninstrumented
+fun:custom1=custom
+
+fun:custom2=uninstrumented
+fun:custom2=custom