Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 1 | ; This check verifies that stack depth instrumentation works correctly. |
| 2 | ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 \ |
Matt Morehouse | f42bd31 | 2017-08-25 21:18:29 +0000 | [diff] [blame] | 3 | ; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 4 | ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 \ |
| 5 | ; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \ |
Matt Morehouse | f42bd31 | 2017-08-25 21:18:29 +0000 | [diff] [blame] | 6 | ; RUN: -S | FileCheck %s |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 7 | |
| 8 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 9 | target triple = "x86_64-unknown-linux-gnu" |
| 10 | |
Matt Morehouse | b1fa825 | 2017-08-22 21:28:29 +0000 | [diff] [blame] | 11 | ; CHECK: @__sancov_lowest_stack = thread_local(initialexec) global i64 -1 |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 12 | @__sancov_lowest_stack = thread_local global i64 0, align 8 |
| 13 | |
| 14 | define i32 @foo() { |
| 15 | entry: |
| 16 | ; CHECK-LABEL: define i32 @foo |
Matt Morehouse | f42bd31 | 2017-08-25 21:18:29 +0000 | [diff] [blame] | 17 | ; CHECK-NOT: call i8* @llvm.frameaddress(i32 0) |
| 18 | ; CHECK-NOT: @__sancov_lowest_stack |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 19 | ; CHECK: ret i32 7 |
| 20 | |
| 21 | ret i32 7 |
| 22 | } |
| 23 | |
| 24 | define i32 @bar() { |
| 25 | entry: |
| 26 | ; CHECK-LABEL: define i32 @bar |
| 27 | ; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress(i32 0) |
Matt Morehouse | f42bd31 | 2017-08-25 21:18:29 +0000 | [diff] [blame] | 28 | ; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[intType:i[0-9]+]] |
| 29 | ; CHECK: [[lowest:%[^ \t]+]] = load [[intType]], [[intType]]* @__sancov_lowest_stack |
| 30 | ; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[intType]] [[frameInt]], [[lowest]] |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 31 | ; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label |
| 32 | ; CHECK: <label>:[[ifLabel]]: |
Matt Morehouse | f42bd31 | 2017-08-25 21:18:29 +0000 | [diff] [blame] | 33 | ; CHECK: store [[intType]] [[frameInt]], [[intType]]* @__sancov_lowest_stack |
Matt Morehouse | 5c7fc76 | 2017-08-18 18:43:30 +0000 | [diff] [blame] | 34 | ; CHECK: %call = call i32 @foo() |
| 35 | ; CHECK: ret i32 %call |
| 36 | |
| 37 | %call = call i32 @foo() |
| 38 | ret i32 %call |
| 39 | } |
| 40 | |
| 41 | define weak_odr hidden i64* @_ZTW21__sancov_lowest_stack() { |
| 42 | ret i64* @__sancov_lowest_stack |
| 43 | } |