1; RUN: opt < %s -sancov -sanitizer-coverage-level=0 -S -enable-new-pm=0 | FileCheck %s
2; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S -enable-new-pm=0 | FileCheck %s
3; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S -enable-new-pm=0 | FileCheck %s
4; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=0 -S | FileCheck %s
5; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -S | FileCheck %s
6; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=2 -S | FileCheck %s
7
8target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
9target triple = "i686-pc-windows-msvc18.0.0"
10
11declare i32 @llvm.eh.typeid.for(i8*) #2
12declare i8* @llvm.frameaddress(i32)
13declare i8* @llvm.eh.recoverfp(i8*, i8*)
14declare i8* @llvm.localrecover(i8*, i8*, i32)
15declare void @llvm.localescape(...) #1
16
17declare i32 @_except_handler3(...)
18declare void @may_throw(i32* %r)
19
20define i32 @main() sanitize_address personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
21entry:
22  %r = alloca i32, align 4
23  %__exception_code = alloca i32, align 4
24  call void (...) @llvm.localescape(i32* nonnull %__exception_code)
25  %0 = bitcast i32* %r to i8*
26  store i32 0, i32* %r, align 4
27  invoke void @may_throw(i32* nonnull %r) #4
28          to label %__try.cont unwind label %lpad
29
30lpad:                                             ; preds = %entry
31  %1 = landingpad { i8*, i32 }
32          catch i8* bitcast (i32 ()* @"\01?filt$0@0@main@@" to i8*)
33  %2 = extractvalue { i8*, i32 } %1, 1
34  %3 = call i32 @llvm.eh.typeid.for(i8* bitcast (i32 ()* @"\01?filt$0@0@main@@" to i8*)) #1
35  %matches = icmp eq i32 %2, %3
36  br i1 %matches, label %__except, label %eh.resume
37
38__except:                                         ; preds = %lpad
39  store i32 1, i32* %r, align 4
40  br label %__try.cont
41
42__try.cont:                                       ; preds = %entry, %__except
43  %4 = load i32, i32* %r, align 4
44  ret i32 %4
45
46eh.resume:                                        ; preds = %lpad
47  resume { i8*, i32 } %1
48}
49
50; Check that we don't do any instrumentation.
51
52; CHECK-LABEL: define i32 @main()
53; CHECK-NOT: load atomic i32, i32* {{.*}} monotonic, align 4, !nosanitize
54; CHECK-NOT: call void @__sanitizer_cov
55; CHECK: ret i32
56
57; Function Attrs: nounwind
58define internal i32 @"\01?filt$0@0@main@@"() #1 {
59entry:
60  %0 = tail call i8* @llvm.frameaddress(i32 1)
61  %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0)
62  %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0)
63  %__exception_code = bitcast i8* %2 to i32*
64  %3 = getelementptr inbounds i8, i8* %0, i32 -20
65  %4 = bitcast i8* %3 to { i32*, i8* }**
66  %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4
67  %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0
68  %7 = load i32*, i32** %6, align 4
69  %8 = load i32, i32* %7, align 4
70  store i32 %8, i32* %__exception_code, align 4
71  ret i32 1
72}
73
74; CHECK-LABEL: define internal i32 @"\01?filt$0@0@main@@"()
75; CHECK: tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* {{.*}}, i32 0)
76
77define void @ScaleFilterCols_SSSE3(i8* %dst_ptr, i8* %src_ptr, i32 %dst_width, i32 %x, i32 %dx) sanitize_address {
78entry:
79  %dst_width.addr = alloca i32, align 4
80  store i32 %dst_width, i32* %dst_width.addr, align 4
81  %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)
82  ret void
83}
84
85define void @ScaleColsUp2_SSE2() sanitize_address {
86entry:
87  ret void
88}
89