15c7fc769SMatt Morehouse; This check verifies that stack depth instrumentation works correctly. 2*eca01b03SLeonard Chan; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 \ 3007f674cSLeonard Chan; RUN: -sanitizer-coverage-stack-depth -S | FileCheck %s 4*eca01b03SLeonard Chan; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 \ 5007f674cSLeonard Chan; RUN: -sanitizer-coverage-stack-depth -sanitizer-coverage-trace-pc-guard \ 6007f674cSLeonard Chan; RUN: -S | FileCheck %s 75c7fc769SMatt Morehouse 85c7fc769SMatt Morehousetarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 95c7fc769SMatt Morehousetarget triple = "x86_64-unknown-linux-gnu" 105c7fc769SMatt Morehouse 11b1fa8255SMatt Morehouse; CHECK: @__sancov_lowest_stack = thread_local(initialexec) global i64 -1 125c7fc769SMatt Morehouse@__sancov_lowest_stack = thread_local global i64 0, align 8 135c7fc769SMatt Morehouse 145c7fc769SMatt Morehousedefine i32 @foo() { 155c7fc769SMatt Morehouseentry: 165c7fc769SMatt Morehouse; CHECK-LABEL: define i32 @foo 17006cf8c0SChristudasan Devadasan; CHECK-NOT: call i8* @llvm.frameaddress.p0i8(i32 0) 18034126e5SMatt Morehouse; CHECK-NOT: @__sancov_lowest_stack 195c7fc769SMatt Morehouse; CHECK: ret i32 7 205c7fc769SMatt Morehouse 215c7fc769SMatt Morehouse ret i32 7 225c7fc769SMatt Morehouse} 235c7fc769SMatt Morehouse 245c7fc769SMatt Morehousedefine i32 @bar() { 255c7fc769SMatt Morehouseentry: 265c7fc769SMatt Morehouse; CHECK-LABEL: define i32 @bar 27006cf8c0SChristudasan Devadasan; CHECK: [[framePtr:%[^ \t]+]] = call i8* @llvm.frameaddress.p0i8(i32 0) 28034126e5SMatt Morehouse; CHECK: [[frameInt:%[^ \t]+]] = ptrtoint i8* [[framePtr]] to [[intType:i[0-9]+]] 29034126e5SMatt Morehouse; CHECK: [[lowest:%[^ \t]+]] = load [[intType]], [[intType]]* @__sancov_lowest_stack 30034126e5SMatt Morehouse; CHECK: [[cmp:%[^ \t]+]] = icmp ult [[intType]] [[frameInt]], [[lowest]] 315c7fc769SMatt Morehouse; CHECK: br i1 [[cmp]], label %[[ifLabel:[^ \t]+]], label 32c0e6b8acSJames Y Knight; CHECK: [[ifLabel]]: 33034126e5SMatt Morehouse; CHECK: store [[intType]] [[frameInt]], [[intType]]* @__sancov_lowest_stack 345c7fc769SMatt Morehouse; CHECK: %call = call i32 @foo() 355c7fc769SMatt Morehouse; CHECK: ret i32 %call 365c7fc769SMatt Morehouse 375c7fc769SMatt Morehouse %call = call i32 @foo() 385c7fc769SMatt Morehouse ret i32 %call 395c7fc769SMatt Morehouse} 405c7fc769SMatt Morehouse 415c7fc769SMatt Morehousedefine weak_odr hidden i64* @_ZTW21__sancov_lowest_stack() { 425c7fc769SMatt Morehouse ret i64* @__sancov_lowest_stack 435c7fc769SMatt Morehouse} 44