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