26class MemIntrinsicPlugin :
public InstVisitor<MemIntrinsicPlugin> {
27 const InstrumentationOptions &Opts;
29 TargetLibraryInfo &TLI;
30 std::vector<CandidateInfo> *Candidates;
35 MemIntrinsicPlugin(Function &Fn, TargetLibraryInfo &TLI)
36 : Opts(Fn.
getContext().getLibraryOptions().
get<InstrumentationOptions>()),
37 F(Fn), TLI(TLI), Candidates(nullptr) {}
39 void run(std::vector<CandidateInfo> &Cs) {
44 void visitMemIntrinsic(MemIntrinsic &
MI) {
47 if (isa<ConstantInt>(Length))
52 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
54 void visitCallInst(CallInst &CI) {
55 if (!Opts.pgo_memop_optimize_memcmp_bcmp)
61 if (Func == LibFunc_memcmp || Func == LibFunc_bcmp) {
64 if (isa<ConstantInt>(Length))
68 Candidates->emplace_back(CandidateInfo{
Length, InsertPt, AnnotatedInst});
74class IndirectCallPromotionPlugin {
80 IndirectCallPromotionPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
82 void run(std::vector<CandidateInfo> &Candidates) {
84 for (Instruction *
I : Result) {
88 Candidates.emplace_back(CandidateInfo{
Callee, InsertPt, AnnotatedInst});
94class VTableProfilingPlugin {
100 VTableProfilingPlugin(Function &Fn, TargetLibraryInfo &TLI) :
F(Fn) {}
102 void run(std::vector<CandidateInfo> &Candidates) {
104 for (Instruction *
I : Result) {
114 if (InsertPt ==
nullptr)
118 Candidates.emplace_back(CandidateInfo{
I, InsertPt, AnnotatedInst});
126#define VP_PLUGIN_LIST \
127 MemIntrinsicPlugin, IndirectCallPromotionPlugin, VTableProfilingPlugin
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
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)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
std::vector< Instruction * > findVTableAddrs(Function &F)