brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 069993f Raw
58 lines · plain
1; RUN: opt < %s -passes=dfsan -S | FileCheck %s2; RUN: opt < %s -passes=dfsan -dfsan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,CHECK_ORIGIN3target 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"4target triple = "x86_64-unknown-linux-gnu"5 6declare i32 @f(i32)7 8; CHECK-LABEL: @inner_callee.dfsan9define i32 @inner_callee(i32) {10  %r = call i32 @f(i32 %0)11 12  ; COMM: Store here will be loaded in @outer_caller13  ; CHECK: store{{.*}}__dfsan_retval_tls14  ; CHECK_ORIGIN-NEXT: store{{.*}}__dfsan_retval_origin_tls15  ; CHECK-NEXT: ret i3216  ret i32 %r17}18 19; CHECK-LABEL: @musttail_call.dfsan20define i32 @musttail_call(i32) {21  ; CHECK: store{{.*}}__dfsan_arg_tls22  ; CHECK-NEXT: musttail call i32 @inner_callee.dfsan23  %r = musttail call i32 @inner_callee(i32 %0)24 25  ; For "musttail" calls we can not insert any shadow manipulating code between26  ; call and the return instruction. And we don't need to, because everything is27  ; taken care of in the callee.28  ; This is similar to the function above, but the last load and store of29  ; __dfsan_retval_tls can be elided because we know about the musttail.30 31  ; CHECK-NEXT: ret i3232  ret i32 %r33}34 35; CHECK-LABEL: @outer_caller.dfsan36define i32 @outer_caller() {37  ; CHECK: call{{.*}}@musttail_call.dfsan38  ; CHECK-NEXT: load{{.*}}__dfsan_retval_tls39  ; CHECK_ORIGIN-NEXT: load{{.*}}__dfsan_retval_origin_tls40  %r = call i32 @musttail_call(i32 0)41 42  ; CHECK-NEXT: store{{.*}}__dfsan_retval_tls43  ; CHECK_ORIGIN-NEXT: store{{.*}}__dfsan_retval_origin_tls44  ; CHECK-NEXT: ret i3245  ret i32 %r46}47 48declare ptr @mismatching_callee(i32)49 50; CHECK-LABEL: define ptr @mismatching_musttail_call.dfsan51define ptr @mismatching_musttail_call(i32) {52  %r = musttail call ptr @mismatching_callee(i32 %0)53  ; CHECK: musttail call ptr @mismatching_callee.dfsan54  ; COMM: No instrumentation between call and ret.55  ; CHECK-NEXT: ret ptr56  ret ptr %r57}58