26class MemIntrinsicPlugin :
public InstVisitor<MemIntrinsicPlugin> {
28 TargetLibraryInfo &TLI;
29 std::vector<CandidateInfo> *Candidates;
34 MemIntrinsicPlugin(Function &Fn, TargetLibraryInfo &TLI)
35 :
F(Fn), TLI(TLI), Candidates(nullptr) {}
37 void run(std::vector<CandidateInfo> &Cs) {
42 void visitMemIntrinsic(MemIntrinsic &
MI) {
45 if (isa<ConstantInt>(Length))
50 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
52 void visitCallInst(CallInst &CI) {
53 if (!InstrumentationOptions::Global.pgo_memop_optimize_memcmp_bcmp)
59 if (Func == LibFunc_memcmp || Func == LibFunc_bcmp) {
62 if (isa<ConstantInt>(Length))
66 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
72class IndirectCallPromotionPlugin {
78 IndirectCallPromotionPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
80 void run(std::vector<CandidateInfo> &Candidates) {
82 for (Instruction *
I : Result) {
86 Candidates.emplace_back(CandidateInfo{
Callee, InsertPt, AnnotatedInst});
92class VTableProfilingPlugin {
98 VTableProfilingPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
100 void run(std::vector<CandidateInfo> &Candidates) {
102 for (Instruction *
I : Result) {
112 if (InsertPt ==
nullptr)
116 Candidates.emplace_back(CandidateInfo{
I, InsertPt, AnnotatedInst});
124#define VP_PLUGIN_LIST \
125 MemIntrinsicPlugin, IndirectCallPromotionPlugin, VTableProfilingPlugin
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Value * getArgOperand(unsigned i) const
Base class for instruction visitors.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
LibFunc getLibFunc(StringRef funcName) const
Searches for a particular function name.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< FuncNode * > Func
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
std::vector< CallBase * > findIndirectCalls(Function &F)
std::vector< Instruction * > findVTableAddrs(Function &F)