58 lines · plain
1; RUN: opt < %s -passes=asan -asan-use-after-return=never -S | FileCheck --check-prefix=CHECK-PLAIN --implicit-check-not=__asan_stack_malloc %s2; RUN: opt < %s -passes=asan -asan-use-after-return=runtime -S | FileCheck --check-prefixes=CHECK-UAR,CHECK-UAR-RUNTIME %s3; RUN: opt < %s -passes=asan -asan-use-after-return=always -S | FileCheck --check-prefixes=CHECK-UAR,CHECK-UAR-ALWAYS %s4target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"5target triple = "x86_64-unknown-linux-gnu"6 7declare void @Foo(ptr)8 9define void @Bar() uwtable sanitize_address {10entry:11; CHECK-PLAIN-LABEL: Bar12; CHECK-PLAIN-NOT: label13; CHECK-PLAIN: ret void14 15; CHECK-UAR-LABEL: Bar16; CHECK-UAR-RUNTIME: load i32, ptr @__asan_option_detect_stack_use_after_return17; CHECK-UAR-RUNTIME: label18; CHECK-UAR-RUNTIME: call i64 @__asan_stack_malloc_419; CHECK-UAR-ALWAYS: call i64 @__asan_stack_malloc_always_420; CHECK-UAR-RUNTIME: label21; Poison red zones.22; CHECK-UAR: store i64 -100768041256498331123; CHECK-UAR: store i64 7205759811393611424; CHECK-UAR: store i32 -21895911825; CHECK-UAR: store i64 -86808207405692031626; CHECK-UAR: store i16 -308527; CHECK-UAR: call void @Foo28; CHECK-UAR: call void @Foo29; CHECK-UAR: call void @Foo30; If LocalStackBase != OrigStackBase31; CHECK-UAR: label32; Then Block: poison the entire frame.33 ; CHECK-UAR: call void @__asan_set_shadow_f5(i64 %{{[0-9]+}}, i64 128)34 ; CHECK-UAR-NOT: store i6435 ; CHECK-UAR: label36; Else Block: no UAR frame. Only unpoison the redzones.37 ; CHECK-UAR: store i64 038 ; CHECK-UAR: store i64 039 ; CHECK-UAR: store i32 040 ; CHECK-UAR: store i64 041 ; CHECK-UAR: store i16 042 ; CHECK-UAR-NOT: store43 ; CHECK-UAR: label44; Done, no more stores.45; CHECK-UAR-NOT: store46; CHECK-UAR: ret void47 48 %x = alloca [20 x i8], align 1649 %y = alloca [25 x i8], align 150 %z = alloca [500 x i8], align 151 call void @Foo(ptr %x)52 call void @Foo(ptr %y)53 call void @Foo(ptr %z)54 ret void55}56 57 58