From 34432aeb6d42fbe3e327d1d339ea4156c99aa133 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 14 Nov 2013 12:29:04 +0000 Subject: [msan] Fast path optimization for wrap-indirect-calls feature of MemorySanitizer. Indirect call wrapping helps MSanDR (dynamic instrumentation companion tool for MSan) to catch all cases where execution leaves a compiler-instrumented module by allowing the tool to rewrite targets of indirect calls. This change is an optimization that skips wrapping for calls when target is inside the current module. This relies on the linker providing symbols at the begin and end of the module code (or code + data, does not really matter). Gold linker provides such symbols by default. GNU (BFD) linker needs a link flag: -Wl,--defsym=__executable_start=0. More info: https://code.google.com/p/memory-sanitizer/wiki/MSanDR#Native_exec git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194697 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../MemorySanitizer/wrap_indirect_calls.ll | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/Instrumentation') diff --git a/test/Instrumentation/MemorySanitizer/wrap_indirect_calls.ll b/test/Instrumentation/MemorySanitizer/wrap_indirect_calls.ll index f847019..afc04b6 100644 --- a/test/Instrumentation/MemorySanitizer/wrap_indirect_calls.ll +++ b/test/Instrumentation/MemorySanitizer/wrap_indirect_calls.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -msan -msan-check-access-address=0 -msan-wrap-indirect-calls=zzz -S | FileCheck %s +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-wrap-indirect-calls=zzz -msan-wrap-indirect-calls-fast=0 -S | FileCheck %s +; RUN: opt < %s -msan -msan-check-access-address=0 -msan-wrap-indirect-calls=zzz -msan-wrap-indirect-calls-fast=1 -S | FileCheck -check-prefix=CHECK-FAST %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" target triple = "x86_64-unknown-linux-gnu" @@ -16,6 +17,18 @@ entry: ; CHECK: @func ; CHECK: bitcast i32 (i32, i32)* %f to void ()* ; CHECK: call void ()* (void ()*)* @zzz(void ()* -; CHECK: [[A:%[01-9a-z]+]] = bitcast void ()* {{.*}} to i32 (i32, i32)* +; CHECK: [[A:%[01-9a-z_.]+]] = bitcast void ()* {{.*}} to i32 (i32, i32)* ; CHECK: call i32 {{.*}}[[A]](i32 {{.*}}, i32 {{.*}}) ; CHECK: ret i32 + +; CHECK-FAST: @func +; CHECK-FAST: bitcast i32 (i32, i32)* %f to void ()* +; CHECK-FAST: icmp ult void ()* {{.*}}, bitcast (i32* @__executable_start to void ()*) +; CHECK-FAST: icmp uge void ()* {{.*}}, bitcast (i32* @_end to void ()*) +; CHECK-FAST: or i1 +; CHECK-FAST: br i1 +; CHECK-FAST: call void ()* (void ()*)* @zzz(void ()* +; CHECK-FAST: br label +; CHECK-FAST: [[A:%[01-9a-z_.]+]] = phi i32 (i32, i32)* [ %f, %entry ], [ {{.*}} ] +; CHECK-FAST: call i32 {{.*}}[[A]](i32 {{.*}}, i32 {{.*}}) +; CHECK-FAST: ret i32 -- cgit v1.1