1 ; RUN: opt < %s -passes=dfsan -S | FileCheck %s
2 ; RUN: opt < %s -passes=dfsan -dfsan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,CHECK_ORIGIN
3 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"
4 target triple = "x86_64-unknown-linux-gnu"
8 ; CHECK-LABEL: @inner_callee.dfsan
9 define i32 @inner_callee(i32) {
10 %r = call i32 @f(i32 %0)
12 ; COMM: Store here will be loaded in @outer_caller
13 ; CHECK: store{{.*}}__dfsan_retval_tls
14 ; CHECK_ORIGIN-NEXT: store{{.*}}__dfsan_retval_origin_tls
19 ; CHECK-LABEL: @musttail_call.dfsan
20 define i32 @musttail_call(i32) {
21 ; CHECK: store{{.*}}__dfsan_arg_tls
22 ; CHECK-NEXT: musttail call i32 @inner_callee.dfsan
23 %r = musttail call i32 @inner_callee(i32 %0)
25 ; For "musttail" calls we can not insert any shadow manipulating code between
26 ; call and the return instruction. And we don't need to, because everything is
27 ; taken care of in the callee.
28 ; This is similar to the function above, but the last load and store of
29 ; __dfsan_retval_tls can be elided because we know about the musttail.
35 ; CHECK-LABEL: @outer_caller.dfsan
36 define i32 @outer_caller() {
37 ; CHECK: call{{.*}}@musttail_call.dfsan
38 ; CHECK-NEXT: load{{.*}}__dfsan_retval_tls
39 ; CHECK_ORIGIN-NEXT: load{{.*}}__dfsan_retval_origin_tls
40 %r = call i32 @musttail_call(i32 0)
42 ; CHECK-NEXT: store{{.*}}__dfsan_retval_tls
43 ; CHECK_ORIGIN-NEXT: store{{.*}}__dfsan_retval_origin_tls
48 declare ptr @mismatching_callee(i32)
50 ; CHECK-LABEL: define ptr @mismatching_musttail_call.dfsan
51 define ptr @mismatching_musttail_call(i32) {
52 %r = musttail call ptr @mismatching_callee(i32 %0)
53 ; CHECK: musttail call ptr @mismatching_callee.dfsan
54 ; COMM: No instrumentation between call and ret.