Index: lib/Transforms/Instrumentation/PGOInstrumentation.cpp =================================================================== --- lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -329,14 +329,16 @@ // Visitor class that finds all indirect call sites. struct PGOIndirectCallSiteVisitor : public InstVisitor { - std::vector IndirectCallInsts; + std::vector IndirectCallInsts; PGOIndirectCallSiteVisitor() {} - void visitCallInst(CallInst &I) { - CallSite CS(&I); - if (CS.getCalledFunction() || !CS.getCalledValue() || I.isInlineAsm()) + void visitCallSite(CallSite CS) { + Instruction *I = CS.getInstruction(); + CallInst *CI = dyn_cast(I); + if (CS.getCalledFunction() || !CS.getCalledValue() || + (CI && CI->isInlineAsm())) return; - IndirectCallInsts.push_back(&I); + IndirectCallInsts.push_back(I); } }; Index: test/Transforms/PGOProfile/indirect_call_profile.ll =================================================================== --- test/Transforms/PGOProfile/indirect_call_profile.ll +++ test/Transforms/PGOProfile/indirect_call_profile.ll @@ -15,3 +15,46 @@ call void %tmp() ret void } + +@bar2 = global void ()* null, align 8 +@_ZTIi = external constant i8* + +; Function Attrs: uwtable +define i32 @foo2(i32, i8** nocapture readnone) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { + %3 = load void ()*, void ()** @bar2, align 8 + invoke void %3() + to label %12 unwind label %4 +; GEN: [[ICALL_TARGET2:%[0-9]+]] = ptrtoint void ()* %3 to i64 +; GEN-NEXT: call void @llvm.instrprof.value.profile(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_foo2, i32 0, i32 0), i64 38432627612, i64 [[ICALL_TARGET2]], i32 0, i32 0) + +;