29class MemIntrinsicPlugin :
public InstVisitor<MemIntrinsicPlugin> {
31 TargetLibraryInfo &TLI;
32 std::vector<CandidateInfo> *Candidates;
37 MemIntrinsicPlugin(Function &Fn, TargetLibraryInfo &TLI)
38 :
F(Fn), TLI(TLI), Candidates(nullptr) {}
40 void run(std::vector<CandidateInfo> &Cs) {
45 void visitMemIntrinsic(MemIntrinsic &
MI) {
48 if (isa<ConstantInt>(Length))
53 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
55 void visitCallInst(CallInst &CI) {
56 if (!MemOPOptMemcmpBcmp)
62 if (Func == LibFunc_memcmp || Func == LibFunc_bcmp) {
65 if (isa<ConstantInt>(Length))
69 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
75class IndirectCallPromotionPlugin {
81 IndirectCallPromotionPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
83 void run(std::vector<CandidateInfo> &Candidates) {
85 for (Instruction *
I : Result) {
89 Candidates.emplace_back(CandidateInfo{
Callee, InsertPt, AnnotatedInst});
95class VTableProfilingPlugin {
101 VTableProfilingPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
103 void run(std::vector<CandidateInfo> &Candidates) {
105 for (Instruction *
I : Result) {
110 while (InsertPt && (dyn_cast<PHINode>(InsertPt) || InsertPt->
isEHPad()))
115 if (InsertPt ==
nullptr)
119 Candidates.emplace_back(CandidateInfo{
I, InsertPt, AnnotatedInst});
127#define VP_PLUGIN_LIST \
128 MemIntrinsicPlugin, IndirectCallPromotionPlugin, VTableProfilingPlugin
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.
DXILDebugInfoMap run(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)
cl::opt< bool > MemOPOptMemcmpBcmp("pgo-memop-optimize-memcmp-bcmp", cl::init(true), cl::Hidden, cl::desc("Size-specialize memcmp and bcmp calls"))
std::vector< Instruction * > findVTableAddrs(Function &F)