003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Transforms/Instrumentation
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Transforms
/
Instrumentation
/
📁
..
📄
AddressSanitizer.cpp
(139.95 KB)
📄
BoundsChecking.cpp
(9.32 KB)
📄
CFGMST.h
(10.51 KB)
📄
CGProfile.cpp
(5.08 KB)
📄
ControlHeightReduction.cpp
(79.97 KB)
📄
DataFlowSanitizer.cpp
(69.1 KB)
📄
GCOVProfiling.cpp
(46.3 KB)
📄
HWAddressSanitizer.cpp
(58.38 KB)
📄
IndirectCallPromotion.cpp
(16.27 KB)
📄
InstrOrderFile.cpp
(7.19 KB)
📄
InstrProfiling.cpp
(40.67 KB)
📄
Instrumentation.cpp
(5.17 KB)
📄
MaximumSpanningTree.h
(3.58 KB)
📄
MemorySanitizer.cpp
(196.17 KB)
📄
PGOInstrumentation.cpp
(68.08 KB)
📄
PGOMemOPSizeOpt.cpp
(18.04 KB)
📄
PoisonChecking.cpp
(12.92 KB)
📄
SanitizerCoverage.cpp
(41.36 KB)
📄
ThreadSanitizer.cpp
(31.63 KB)
📄
ValueProfileCollector.cpp
(2.67 KB)
📄
ValueProfileCollector.h
(3.25 KB)
📄
ValueProfilePlugins.inc
(3.3 KB)
Editing: ValueProfilePlugins.inc
//=== ValueProfilePlugins.inc - set of plugins used by ValueProfileCollector =// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains a set of plugin classes used in ValueProfileCollectorImpl. // Each plugin is responsible for collecting Value Profiling candidates for a // particular optimization. // Each plugin must satisfy the interface described in ValueProfileCollector.cpp // //===----------------------------------------------------------------------===// #include "ValueProfileCollector.h" #include "llvm/Analysis/IndirectCallVisitor.h" #include "llvm/IR/InstVisitor.h" using namespace llvm; using CandidateInfo = ValueProfileCollector::CandidateInfo; extern cl::opt<bool> MemOPOptMemcmpBcmp; ///--------------------------- MemIntrinsicPlugin ------------------------------ class MemIntrinsicPlugin : public InstVisitor<MemIntrinsicPlugin> { Function &F; TargetLibraryInfo &TLI; std::vector<CandidateInfo> *Candidates; public: static constexpr InstrProfValueKind Kind = IPVK_MemOPSize; MemIntrinsicPlugin(Function &Fn, TargetLibraryInfo &TLI) : F(Fn), TLI(TLI), Candidates(nullptr) {} void run(std::vector<CandidateInfo> &Cs) { Candidates = &Cs; visit(F); Candidates = nullptr; } void visitMemIntrinsic(MemIntrinsic &MI) { Value *Length = MI.getLength(); // Not instrument constant length calls. if (dyn_cast<ConstantInt>(Length)) return; Instruction *InsertPt = &MI; Instruction *AnnotatedInst = &MI; Candidates->emplace_back(CandidateInfo{Length, InsertPt, AnnotatedInst}); } void visitCallInst(CallInst &CI) { if (!MemOPOptMemcmpBcmp) return; auto *F = CI.getCalledFunction(); if (!F) return; LibFunc Func; if (TLI.getLibFunc(CI, Func) && (Func == LibFunc_memcmp || Func == LibFunc_bcmp)) { Value *Length = CI.getArgOperand(2); // Not instrument constant length calls. if (dyn_cast<ConstantInt>(Length)) return; Instruction *InsertPt = &CI; Instruction *AnnotatedInst = &CI; Candidates->emplace_back(CandidateInfo{Length, InsertPt, AnnotatedInst}); } } }; ///------------------------ IndirectCallPromotionPlugin ------------------------ class IndirectCallPromotionPlugin { Function &F; public: static constexpr InstrProfValueKind Kind = IPVK_IndirectCallTarget; IndirectCallPromotionPlugin(Function &Fn, TargetLibraryInfo &TLI) : F(Fn) {} void run(std::vector<CandidateInfo> &Candidates) { std::vector<CallBase *> Result = findIndirectCalls(F); for (Instruction *I : Result) { Value *Callee = cast<CallBase>(I)->getCalledOperand(); Instruction *InsertPt = I; Instruction *AnnotatedInst = I; Candidates.emplace_back(CandidateInfo{Callee, InsertPt, AnnotatedInst}); } } }; ///----------------------- Registration of the plugins ------------------------- /// For now, registering a plugin with the ValueProfileCollector is done by /// adding the plugin type to the VP_PLUGIN_LIST macro. #define VP_PLUGIN_LIST \ MemIntrinsicPlugin, \ IndirectCallPromotionPlugin
Upload File
Create Folder