Files
clang-p2996/llvm/test/Instrumentation/DataFlowSanitizer/call.ll
Jianzhou Zhao 80e326a8c4 [dfsan] Support passing non-i16 shadow values in TLS mode
This is a child diff of D92261.

It extended TLS arg/ret to work with aggregate types.

For a function
  t foo(t1 a1, t2 a2, ... tn an)
Its arguments shadow are saved in TLS args like
  a1_s, a2_s, ..., an_s
TLS ret simply includes r_s. By calculating the type size of each shadow
value, we can get their offset.

This is similar to what MSan does. See __msan_retval_tls and __msan_param_tls
from llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp.

Note that this change does not add test cases for overflowed TLS
arg/ret because this is hard to test w/o supporting aggregate shdow
types. We will be adding them after supporting that.

Reviewed-by: morehouse

Differential Revision: https://reviews.llvm.org/D92440
2020-12-04 02:45:07 +00:00

63 lines
1.7 KiB
LLVM

; RUN: opt < %s -dfsan -S | FileCheck %s
; RUN: opt < %s -passes=dfsan -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"
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: @__dfsan_arg_tls
; CHECK: = external thread_local(initialexec) global [100 x i64]
; CHECK-LABEL: @__dfsan_retval_tls
; CHECK: = external thread_local(initialexec) global [100 x i64]
declare i32 @f(i32)
declare float @llvm.sqrt.f32(float)
; CHECK-LABEL: @"dfs$call"
define i32 @call() {
; CHECK: store{{.*}}__dfsan_arg_tls
; CHECK: call{{.*}}@"dfs$f"
; CHECK: load{{.*}}__dfsan_retval_tls
%r = call i32 @f(i32 0)
; CHECK-NOT: store{{.*}}__dfsan_arg_tls
%i = call float @llvm.sqrt.f32(float -1.0)
; CHECK: store{{.*}}__dfsan_retval_tls
; CHECK: ret i32
ret i32 %r
}
declare i32 @__gxx_personality_v0(...)
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
declare void @g(...)
; CHECK-LABEL: @"dfs$h"
; CHECK: personality {{.*}} @"dfs$__gxx_personality_v0" {{.*}} {
define i32 @h() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
; CHECK: invoke void (...) @"dfs$g"(i32 42)
invoke void (...) @g(i32 42)
to label %try.cont unwind label %lpad
lpad:
%0 = landingpad { i8*, i32 }
catch i8* null
%1 = extractvalue { i8*, i32 } %0, 0
; CHECK: store {{.*}} @__dfsan_arg_tls
; CHECK: call {{.*}} @"dfs$__cxa_begin_catch"
; CHECK: load {{.*}} @__dfsan_retval_tls
%2 = tail call i8* @__cxa_begin_catch(i8* %1)
; CHECK: call {{.*}} @"dfs$__cxa_end_catch"
tail call void @__cxa_end_catch()
br label %try.cont
try.cont:
ret i32 0
}