1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2 ; RUN: opt < %s -pgo-instr-gen -instrprof -S | FileCheck %s --check-prefix=LOWER
4 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
5 ; RUN: opt < %s -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefix=LOWER
7 ; This test is to verify that PGO runtime library calls get created with the
8 ; appropriate operand bundle funclet information when an indirect call
9 ; was marked with as belonging to a particular funclet.
11 ; Test case based on this source:
12 ; extern void may_throw(int);
17 ; int get_x() const { return x; }
18 ; virtual void update() { x++; }
22 ; class derived : public base {
25 ; virtual void update() { x--; }
28 ; void run(base* b, int count) {
33 ; // Virtual function call in exception handler for value profiling.
38 %class.base = type { i32 (...)**, i32 }
39 define dso_local void @"?run@@YAXPEAVbase@@H@Z"(%class.base* %b, i32 %count) personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
41 invoke void @"?may_throw@@YAXH@Z"(i32 %count)
42 to label %try.cont unwind label %catch.dispatch
44 catch.dispatch: ; preds = %entry
45 %tmp = catchswitch within none [label %catch] unwind to caller
47 catch: ; preds = %catch.dispatch
48 %tmp1 = catchpad within %tmp [i8* null, i32 64, i8* null]
49 %tmp2 = bitcast %class.base* %b to void (%class.base*)***
50 %vtable = load void (%class.base*)**, void (%class.base*)*** %tmp2, align 8
51 %tmp3 = load void (%class.base*)*, void (%class.base*)** %vtable, align 8
52 call void %tmp3(%class.base* %b) [ "funclet"(token %tmp1) ]
53 catchret from %tmp1 to label %try.cont
55 try.cont: ; preds = %catch, %entry
60 ; GEN: call void @llvm.instrprof.value.profile(
61 ; GEN-SAME: [ "funclet"(token %tmp1) ]
64 ; LOWER: call void @__llvm_profile_instrument_target(
65 ; LOWER-SAME: [ "funclet"(token %tmp1) ]
67 declare dso_local void @"?may_throw@@YAXH@Z"(i32)
68 declare dso_local i32 @__CxxFrameHandler3(...)