[llvm] r264818 - [PGO] Handle invoke inst in IR based icall instrumentation
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 19:16:13 PDT 2016
Author: davidxl
Date: Tue Mar 29 21:16:07 2016
New Revision: 264818
URL: http://llvm.org/viewvc/llvm-project?rev=264818&view=rev
Log:
[PGO] Handle invoke inst in IR based icall instrumentation
Differential Revision: http://reviews.llvm.org/D18580
Modified:
llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/trunk/test/Transforms/PGOProfile/indirect_call_profile.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=264818&r1=264817&r2=264818&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Tue Mar 29 21:16:07 2016
@@ -329,14 +329,16 @@ BasicBlock *FuncPGOInstrumentation<Edge,
// Visitor class that finds all indirect call sites.
struct PGOIndirectCallSiteVisitor
: public InstVisitor<PGOIndirectCallSiteVisitor> {
- std::vector<CallInst *> IndirectCallInsts;
+ std::vector<Instruction *> 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<CallInst>(I);
+ if (CS.getCalledFunction() || !CS.getCalledValue() ||
+ (CI && CI->isInlineAsm()))
return;
- IndirectCallInsts.push_back(&I);
+ IndirectCallInsts.push_back(I);
}
};
Modified: llvm/trunk/test/Transforms/PGOProfile/indirect_call_profile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PGOProfile/indirect_call_profile.ll?rev=264818&r1=264817&r2=264818&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/PGOProfile/indirect_call_profile.ll (original)
+++ llvm/trunk/test/Transforms/PGOProfile/indirect_call_profile.ll Tue Mar 29 21:16:07 2016
@@ -15,3 +15,45 @@ entry:
call void %tmp()
ret void
}
+
+ at bar2 = global void ()* null, align 8
+ at _ZTIi = external constant i8*
+
+define i32 @foo2(i32 %arg, i8** nocapture readnone %arg1) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+bb:
+ %tmp2 = load void ()*, void ()** @bar2, align 8
+ invoke void %tmp2()
+ to label %bb10 unwind label %bb2
+; GEN: [[ICALL_TARGET2:%[0-9]+]] = ptrtoint void ()* %tmp2 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)
+
+bb2: ; preds = %bb
+ %tmp3 = landingpad { i8*, i32 }
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ %tmp4 = extractvalue { i8*, i32 } %tmp3, 1
+ %tmp5 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+ %tmp6 = icmp eq i32 %tmp4, %tmp5
+ br i1 %tmp6, label %bb7, label %bb11
+
+bb7: ; preds = %bb2
+ %tmp8 = extractvalue { i8*, i32 } %tmp3, 0
+ %tmp9 = tail call i8* @__cxa_begin_catch(i8* %tmp8)
+ tail call void @__cxa_end_catch()
+ br label %bb10
+
+bb10: ; preds = %bb7, %bb
+ ret i32 0
+
+bb11: ; preds = %bb2
+ resume { i8*, i32 } %tmp3
+}
+
+declare i32 @__gxx_personality_v0(...)
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.eh.typeid.for(i8*) #0
+
+declare i8* @__cxa_begin_catch(i8*)
+
+declare void @__cxa_end_catch()
+
More information about the llvm-commits
mailing list