1 ; This check verifies that stack depth instrumentation works correctly.
2 ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 \
3 ; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s
4 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 \
5 ; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
6 ; RUN: -S | FileCheck %s
7 ; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=1 \
8 ; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s
9 ; RUN: opt < %s -passes='module(sancov-module),function(sancov-func)' -sanitizer-coverage-level=3 \
10 ; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \
11 ; RUN: -S | FileCheck %s
13 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux-gnu"
16 ; CHECK: @__sancov_lowest_stack = thread_local(initialexec) global i64 -1
17 @__sancov_lowest_stack = thread_local global i64 0, align 8
21 ; CHECK-LABEL: define i32 @foo
22 ; CHECK-NOT: call i8* @llvm.frameaddress(i32 0)
23 ; CHECK-NOT: @__sancov_lowest_stack
31 ; CHECK-LABEL: define i32 @bar
32 ; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0)
33 ; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[intType:i[0-9]+]]
34 ; CHECK: [[lowest:%[^ \t]+]] = load [[intType]], [[intType]]* @__sancov_lowest_stack
35 ; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[intType]] [[frameInt]], [[lowest]]
36 ; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label
38 ; CHECK: store [[intType]] [[frameInt]], [[intType]]* @__sancov_lowest_stack
39 ; CHECK: %call = call i32 @foo()
40 ; CHECK: ret i32 %call
42 %call = call i32 @foo()
46 define weak_odr hidden i64* @_ZTW21__sancov_lowest_stack() {
47 ret i64* @__sancov_lowest_stack