27class MemIntrinsicPlugin :
public InstVisitor<MemIntrinsicPlugin> {
30 std::vector<CandidateInfo> *Candidates;
36 :
F(Fn), TLI(TLI), Candidates(nullptr) {}
38 void run(std::vector<CandidateInfo> &Cs) {
46 if (isa<ConstantInt>(Length))
51 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
61 (Func == LibFunc_memcmp || Func == LibFunc_bcmp)) {
64 if (isa<ConstantInt>(Length))
68 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
74class IndirectCallPromotionPlugin {
82 void run(std::vector<CandidateInfo> &Candidates) {
88 Candidates.emplace_back(CandidateInfo{
Callee, InsertPt, AnnotatedInst});
94class VTableProfilingPlugin {
102 void run(std::vector<CandidateInfo> &Candidates) {
105 Instruction *InsertPt =
I->getNextNonDebugInstruction();
109 while (InsertPt && (dyn_cast<PHINode>(InsertPt) || InsertPt->
isEHPad()))
114 if (InsertPt ==
nullptr)
118 Candidates.emplace_back(CandidateInfo{
I, InsertPt, AnnotatedInst});
126#define VP_PLUGIN_LIST \
127 MemIntrinsicPlugin, IndirectCallPromotionPlugin, VTableProfilingPlugin
cl::opt< bool > MemOPOptMemcmpBcmp("pgo-memop-optimize-memcmp-bcmp", cl::init(true), cl::Hidden, cl::desc("Size-specialize memcmp and bcmp calls"))
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> 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
This class represents a function call, abstracting a target machine's calling convention.
Base class for instruction visitors.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
This is the common base class for memset/memcpy/memmove.
Provides information about what library functions are available for the current target.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
LLVM Value Representation.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
std::vector< CallBase * > findIndirectCalls(Function &F)
std::vector< Instruction * > findVTableAddrs(Function &F)