[msan] Wrap indirect functions.
[oota-llvm.git] / test / Instrumentation / MemorySanitizer / wrap_indirect_calls.ll
1 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-wrap-indirect-calls=zzz -S | FileCheck %s
2 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"
3 target triple = "x86_64-unknown-linux-gnu"
4
5 ; Test for -msan-wrap-indirect-calls functionality.
6 ; Replaces indirect call to %f with a call to whatever is returned from the
7 ; wrapper function.
8
9 ; This does not depend on the sanitize_memory attribute.
10 define i32 @func(i32 (i32, i32)* nocapture %f, i32 %x, i32 %y) {
11 entry:
12   %call = tail call i32 %f(i32 %x, i32 %y)
13   ret i32 %call
14 }
15
16 ; CHECK: @func
17 ; CHECK: bitcast i32 (i32, i32)* %f to void ()*
18 ; CHECK: call void ()* (void ()*)* @zzz(void ()*
19 ; CHECK: [[A:%[01-9a-z]+]] = bitcast void ()* {{.*}} to i32 (i32, i32)*
20 ; CHECK: call i32 {{.*}}[[A]](i32 {{.*}}, i32 {{.*}})
21 ; CHECK: ret i32