2 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3 ; RUN: opt < %s -passes=pgo-instr-gen,instrprof -S | FileCheck %s --check-prefix=LOWER
5 ; This test is to verify that PGO runtime library calls get created with the
6 ; appropriate operand bundle funclet information when an indirect call
7 ; was marked with as belonging to a particular funclet.
9 ; Test case based on this source:
10 ; extern void may_throw(int);
15 ; int get_x() const { return x; }
16 ; virtual void update() { x++; }
20 ; class derived : public base {
23 ; virtual void update() { x--; }
26 ; void run(base* b, int count) {
31 ; // Virtual function call in exception handler for value profiling.
36 %class.base = type { ptr, i32 }
37 define dso_local void @"?run@@YAXPEAVbase@@H@Z"(ptr %b, i32 %count) personality ptr @__CxxFrameHandler3 {
39 invoke void @"?may_throw@@YAXH@Z"(i32 %count)
40 to label %try.cont unwind label %catch.dispatch
42 catch.dispatch: ; preds = %entry
43 %tmp = catchswitch within none [label %catch] unwind to caller
45 catch: ; preds = %catch.dispatch
46 %tmp1 = catchpad within %tmp [ptr null, i32 64, ptr null]
47 %vtable = load ptr, ptr %b, align 8
48 %tmp3 = load ptr, ptr %vtable, align 8
49 call void %tmp3(ptr %b) [ "funclet"(token %tmp1) ]
50 catchret from %tmp1 to label %try.cont
52 try.cont: ; preds = %catch, %entry
57 ; GEN: call void @llvm.instrprof.value.profile(
58 ; GEN-SAME: [ "funclet"(token %tmp1) ]
61 ; LOWER: call void @__llvm_profile_instrument_target(
62 ; LOWER-SAME: [ "funclet"(token %tmp1) ]
64 declare dso_local void @"?may_throw@@YAXH@Z"(i32)
65 declare dso_local i32 @__CxxFrameHandler3(...)