• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -sancov -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 { i8**, i8*, [3 x i8] }
33%struct.Foo = type { i8 }
34
35$"\01??_R0H@8" = comdat any
36
37@"\01??_7type_info@@6B@" = external constant i8*
38@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat
39
40; Function Attrs: uwtable
41define i32 @"\01?f@@YAHXZ"() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
42entry:
43  %v = alloca %struct.Foo, align 1
44  %e = alloca i32, align 4
45  %0 = getelementptr inbounds %struct.Foo, %struct.Foo* %v, i64 0, i32 0
46  call void @llvm.lifetime.start(i64 1, i8* nonnull %0) #4
47  %call = call %struct.Foo* @"\01??0Foo@@QEAA@XZ"(%struct.Foo* nonnull %v)
48  invoke void @"\01?g@@YAXXZ"()
49          to label %invoke.cont unwind label %ehcleanup
50
51invoke.cont:                                      ; preds = %entry
52  invoke void @"\01?g@@YAXXZ"()
53          to label %try.cont unwind label %catch.dispatch
54
55catch.dispatch:                                   ; preds = %invoke.cont
56  %1 = catchswitch within none [label %catch3, label %catch] unwind label %ehcleanup
57
58catch3:                                           ; preds = %catch.dispatch
59  %2 = catchpad within %1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %e]
60  invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %2) ]
61          to label %invoke.cont4 unwind label %ehcleanup
62
63invoke.cont4:                                     ; preds = %catch3
64  catchret from %2 to label %try.cont
65
66try.cont:                                         ; preds = %invoke.cont, %invoke.cont2, %invoke.cont4
67  call void @"\01??1Foo@@QEAA@XZ"(%struct.Foo* nonnull %v) #4
68  call void @llvm.lifetime.end(i64 1, i8* nonnull %0) #4
69  ret i32 0
70
71catch:                                            ; preds = %catch.dispatch
72  %3 = catchpad within %1 [i8* null, i32 64, i8* null]
73  invoke void @"\01?g@@YAXXZ"() [ "funclet"(token %3) ]
74          to label %invoke.cont2 unwind label %ehcleanup
75
76invoke.cont2:                                     ; preds = %catch
77  catchret from %3 to label %try.cont
78
79ehcleanup:                                        ; preds = %catch3, %catch, %catch.dispatch, %entry
80  %4 = cleanuppad within none []
81  call void @"\01??1Foo@@QEAA@XZ"(%struct.Foo* nonnull %v) #4 [ "funclet"(token %4) ]
82  call void @llvm.lifetime.end(i64 1, i8* nonnull %0) #4
83  cleanupret from %4 unwind to caller
84}
85
86; Function Attrs: argmemonly nounwind
87declare void @llvm.lifetime.start(i64, i8* nocapture) #1
88
89declare %struct.Foo* @"\01??0Foo@@QEAA@XZ"(%struct.Foo* returned) unnamed_addr #2
90
91declare void @"\01?g@@YAXXZ"() local_unnamed_addr #2
92
93declare i32 @__CxxFrameHandler3(...)
94
95; Function Attrs: nounwind
96declare void @"\01??1Foo@@QEAA@XZ"(%struct.Foo*) unnamed_addr #3
97
98; Function Attrs: argmemonly nounwind
99declare void @llvm.lifetime.end(i64, i8* nocapture) #1
100
101attributes #0 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
102attributes #1 = { argmemonly nounwind }
103attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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 #3 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
105attributes #4 = { nounwind }
106
107!llvm.module.flags = !{!0}
108!llvm.ident = !{!1}
109
110!0 = !{i32 1, !"PIC Level", i32 2}
111!1 = !{!"clang version 5.0.0 "}
112