1; RUN: opt < %s -asan -asan-module -asan-use-after-return -asan-stack-dynamic-alloca -S | FileCheck %s 2; RUN: opt < %s -asan -asan-module -asan-use-after-return=0 -asan-stack-dynamic-alloca=0 -S | FileCheck %s 3 4target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 5target triple = "i686-pc-windows-msvc18.0.0" 6 7declare i32 @llvm.eh.typeid.for(i8*) #2 8declare i8* @llvm.frameaddress(i32) 9declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) 10declare i8* @llvm.localrecover(i8*, i8*, i32) 11declare void @llvm.localescape(...) #1 12 13declare i32 @_except_handler3(...) 14declare void @may_throw(i32* %r) 15 16define i32 @main() sanitize_address personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) { 17entry: 18 %r = alloca i32, align 4 19 %__exception_code = alloca i32, align 4 20 call void (...) @llvm.localescape(i32* nonnull %__exception_code) 21 %0 = bitcast i32* %r to i8* 22 store i32 0, i32* %r, align 4 23 invoke void @may_throw(i32* nonnull %r) #4 24 to label %__try.cont unwind label %lpad 25 26lpad: ; preds = %entry 27 %1 = landingpad { i8*, i32 } 28 catch i8* bitcast (i32 ()* @"\01?filt$0@0@main@@" to i8*) 29 %2 = extractvalue { i8*, i32 } %1, 1 30 %3 = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 ()* @"\01?filt$0@0@main@@" to i8*)) #1 31 %matches = icmp eq i32 %2, %3 32 br i1 %matches, label %__except, label %eh.resume 33 34__except: ; preds = %lpad 35 store i32 1, i32* %r, align 4 36 br label %__try.cont 37 38__try.cont: ; preds = %entry, %__except 39 %4 = load i32, i32* %r, align 4 40 ret i32 %4 41 42eh.resume: ; preds = %lpad 43 resume { i8*, i32 } %1 44} 45 46; Check that the alloca remains static and the localescape call remains in the 47; entry block. 48 49; CHECK-LABEL: define i32 @main() 50; CHECK-NOT: br {{.*}}label 51; CHECK: %__exception_code = alloca i32, align 4 52; CHECK-NOT: br {{.*}}label 53; CHECK: call void (...) @llvm.localescape(i32* nonnull %__exception_code) 54 55; Function Attrs: nounwind 56define internal i32 @"\01?filt$0@0@main@@"() #1 { 57entry: 58 %0 = tail call i8* @llvm.frameaddress(i32 1) 59 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0) 60 %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0) 61 %__exception_code = bitcast i8* %2 to i32* 62 %3 = getelementptr inbounds i8, i8* %0, i32 -20 63 %4 = bitcast i8* %3 to { i32*, i8* }** 64 %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4 65 %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0 66 %7 = load i32*, i32** %6, align 4 67 %8 = load i32, i32* %7, align 4 68 store i32 %8, i32* %__exception_code, align 4 69 ret i32 1 70} 71 72; CHECK-LABEL: define internal i32 @"\01?filt$0@0@main@@"() 73; CHECK: tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* {{.*}}, i32 0) 74 75define void @ScaleFilterCols_SSSE3(i8* %dst_ptr, i8* %src_ptr, i32 %dst_width, i32 %x, i32 %dx) sanitize_address { 76entry: 77 %dst_width.addr = alloca i32, align 4 78 store i32 %dst_width, i32* %dst_width.addr, align 4 79 %0 = call { i8*, i8*, i32, i32, i32 } asm sideeffect "", "=r,=r,={ax},=r,=r,=*rm,rm,rm,0,1,2,3,4,5,~{memory},~{cc},~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{dirflag},~{fpsr},~{flags}"(i32* nonnull %dst_width.addr, i32 %x, i32 %dx, i8* %dst_ptr, i8* %src_ptr, i32 0, i32 0, i32 0, i32 %dst_width) 80 ret void 81} 82 83define void @ScaleColsUp2_SSE2() sanitize_address { 84entry: 85 ret void 86} 87