xref: /llvm-project/llvm/test/Instrumentation/SanitizerCoverage/wineh.ll (revision fc1270dd2972b5302ff8717d7dcf754c22bbddc3)
1; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc -S | FileCheck %s --check-prefix=CHECK
2
3; Generated from this C++ source:
4; $ clang -O2 t.cpp -S -emit-llvm
5; void g();
6; struct Foo { Foo(); ~Foo(); };
7; int f() {
8;   Foo v;
9;   g();
10;   try {
11;     g();
12;   } catch (int e) {
13;     g();
14;   } catch (...) {
15;     g();
16;   }
17;   return 0;
18; }
19
20; FIXME: We need to do more than this. In particular, __sanitizer_cov callbacks
21; in funclets need token bundles.
22
23; CHECK-LABEL: define i32 @"\01?f@@YAHXZ"()
24; CHECK: catch.dispatch:
25; CHECK-NEXT: catchswitch within none [label %catch3, label %catch] unwind label %ehcleanup
26
27; ModuleID = 't.cpp'
28source_filename = "t.cpp"
29target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
30target triple = "x86_64-pc-windows-msvc19.10.24728"
31
32%rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }
33%struct.Foo = type { i8 }
34
35$"\01??_R0H@8" = comdat any
36
37@"\01??_7type_info@@6B@" = external constant ptr
38@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"\01??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat
39
40; Function Attrs: uwtable
41define i32 @"\01?f@@YAHXZ"() local_unnamed_addr #0 personality ptr @__CxxFrameHandler3 {
42entry:
43  %v = alloca %struct.Foo, align 1
44  %e = alloca i32, align 4
45  call void @llvm.lifetime.start(i64 1, ptr nonnull %v) #4
46  %call = call ptr @"\01??0Foo@@QEAA@XZ"(ptr nonnull %v)
47  invoke void @"\01?g@@YAXXZ"()
48          to label %invoke.cont unwind label %ehcleanup
49
50invoke.cont:                                      ; preds = %entry
51  invoke void @"\01?g@@YAXXZ"()
52          to label %try.cont unwind label %catch.dispatch
53
54catch.dispatch:                                   ; preds = %invoke.cont
55  %0 = catchswitch within none [label %catch3, label %catch] unwind label %ehcleanup
56
57catch3:                                           ; preds = %catch.dispatch
58  %1 = catchpad within %0 [ptr @"\01??_R0H@8", i32 0, ptr %e]
59  invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %1) ]
60          to label %invoke.cont4 unwind label %ehcleanup
61
62invoke.cont4:                                     ; preds = %catch3
63  catchret from %1 to label %try.cont
64
65try.cont:                                         ; preds = %invoke.cont, %invoke.cont2, %invoke.cont4
66  call void @"\01??1Foo@@QEAA@XZ"(ptr nonnull %v) #4
67  call void @llvm.lifetime.end(i64 1, ptr nonnull %v) #4
68  ret i32 0
69
70catch:                                            ; preds = %catch.dispatch
71  %2 = catchpad within %0 [ptr null, i32 64, ptr null]
72  invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %2) ]
73          to label %invoke.cont2 unwind label %ehcleanup
74
75invoke.cont2:                                     ; preds = %catch
76  catchret from %2 to label %try.cont
77
78ehcleanup:                                        ; preds = %catch3, %catch, %catch.dispatch, %entry
79  %3 = cleanuppad within none []
80  call void @"\01??1Foo@@QEAA@XZ"(ptr nonnull %v) #4 [ "funclet"(token %3) ]
81  call void @llvm.lifetime.end(i64 1, ptr nonnull %v) #4
82  cleanupret from %3 unwind to caller
83}
84
85; Function Attrs: argmemonly nounwind
86declare void @llvm.lifetime.start(i64, ptr nocapture) #1
87
88declare ptr @"\01??0Foo@@QEAA@XZ"(ptr returned) unnamed_addr #2
89
90declare void @"\01?g@@YAXXZ"() local_unnamed_addr #2
91
92declare i32 @__CxxFrameHandler3(...)
93
94; Function Attrs: nounwind
95declare void @"\01??1Foo@@QEAA@XZ"(ptr) unnamed_addr #3
96
97; Function Attrs: argmemonly nounwind
98declare void @llvm.lifetime.end(i64, ptr nocapture) #1
99
100attributes #0 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
101attributes #1 = { argmemonly nounwind }
102attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
103attributes #3 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
104attributes #4 = { nounwind }
105
106!llvm.module.flags = !{!0}
107!llvm.ident = !{!1}
108
109!0 = !{i32 1, !"PIC Level", i32 2}
110!1 = !{!"clang version 5.0.0 "}
111