27  Module &M = *InsertionPt->getParent()->getParent()->getParent();
 
   30  if (Func == 
"mcount" ||
 
   32      Func == 
"llvm.arm.gnu.eabi.mcount" ||
 
   33      Func == 
"\01_mcount" ||
 
   34      Func == 
"\01mcount" ||
 
   37      Func == 
"__cyg_profile_func_enter_bare") {
 
   38    Triple TargetTriple(M.getTargetTriple());
 
   39    if (TargetTriple.
isOSAIX() && Func == 
"__mcount") {
 
   40      Type *SizeTy = M.getDataLayout().getIntPtrType(
C);
 
   44                                              ConstantInt::get(SizeTy, 0));
 
   46          M.getOrInsertFunction(Func,
 
   49          {GV}, 
"", InsertionPt);
 
   79  if (Func == 
"__cyg_profile_func_enter" || Func == 
"__cyg_profile_func_exit") {
 
   91    Value *Args[] = {&CurFn, RetAddr};
 
 
  108  if (
F.hasFnAttribute(Attribute::Naked))
 
  114  if (
F.hasAvailableExternallyLinkage())
 
  117  StringRef EntryAttr = PostInlining ? 
"instrument-function-entry-inlined" 
  118                                     : 
"instrument-function-entry";
 
  120  StringRef ExitAttr = PostInlining ? 
"instrument-function-exit-inlined" 
  121                                    : 
"instrument-function-exit";
 
  123  StringRef EntryFunc = 
F.getFnAttribute(EntryAttr).getValueAsString();
 
  124  StringRef ExitFunc = 
F.getFnAttribute(ExitAttr).getValueAsString();
 
  132  if (!EntryFunc.
empty()) {
 
  134    if (
auto SP = 
F.getSubprogram())
 
  139    F.removeFnAttr(EntryAttr);
 
  142  if (!ExitFunc.
empty()) {
 
  149      if (
CallInst *CI = BB.getTerminatingMustTailCall())
 
  153      if (
DebugLoc TerminatorDL = 
T->getDebugLoc())
 
  155      else if (
auto SP = 
F.getSubprogram())
 
  161    F.removeFnAttr(ExitAttr);
 
 
  168struct PostInlineEntryExitInstrumenter : 
public FunctionPass {
 
  170  PostInlineEntryExitInstrumenter() : FunctionPass(ID) {
 
  174  void getAnalysisUsage(AnalysisUsage &AU)
 const override {
 
  178  bool runOnFunction(Function &
F)
 override { return ::runOnFunction(
F, 
true); }
 
  180char PostInlineEntryExitInstrumenter::ID = 0;
 
  184    PostInlineEntryExitInstrumenter, 
"post-inline-ee-instrument",
 
  185    "Instrument function entry/exit with calls to e.g. mcount() " 
  190    PostInlineEntryExitInstrumenter, 
"post-inline-ee-instrument",
 
  191    "Instrument function entry/exit with calls to e.g. mcount() " 
  196  return new PostInlineEntryExitInstrumenter();
 
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
static bool runOnFunction(Function &F, bool PostInlining)
 
static void insertCall(Function &CurFn, StringRef Func, BasicBlock::iterator InsertionPt, DebugLoc DL)
 
This is the interface for a simple mod/ref and alias analysis over globals.
 
Module.h This file contains the declarations for the Module class.
 
#define INITIALIZE_PASS_DEPENDENCY(depName)
 
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
 
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
 
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
 
LLVM Basic Block Representation.
 
InstListType::iterator iterator
Instruction iterators...
 
Represents analyses that only rely on functions' control flow.
 
This class represents a function call, abstracting a target machine's calling convention.
 
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
 
Legacy analysis pass which computes a DominatorTree.
 
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
 
FunctionPass class - This class is used to implement most global optimizations.
 
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
 
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
 
@ InternalLinkage
Rename collisions when linking (static functions).
 
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
 
This is an important class for using LLVM in a threaded context.
 
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
 
A Module instance is used to store all the information related to an LLVM module.
 
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
 
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
 
A set of analyses that are preserved following a run of a transformation pass.
 
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
 
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
 
StringRef - Represent a constant reference to a string, i.e.
 
constexpr bool empty() const
empty - Check if the string is empty.
 
Triple - Helper class for working with autoconf configuration names.
 
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
 
bool isOSAIX() const
Tests whether the OS is AIX.
 
bool isAArch64() const
Tests whether the target is AArch64 (little and big endian).
 
bool isSystemZ() const
Tests whether the target is SystemZ.
 
bool isLoongArch() const
Tests whether the target is LoongArch (32- and 64-bit).
 
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
 
The instances of the Type class are immutable: once they are created, they are never changed.
 
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
 
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
 
LLVM Value Representation.
 
An efficient, type-erasing, non-owning reference to a callable.
 
This class implements an extremely fast bulk output stream that can only output to a stream.
 
@ C
The default llvm calling convention, compatible with C.
 
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
 
This is an optimization pass for GlobalISel generic memory operations.
 
LLVM_ABI FunctionPass * createPostInlineEntryExitInstrumenterPass()
 
LLVM_ABI void initializePostInlineEntryExitInstrumenterPass(PassRegistry &)
 
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
 
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
 
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
 
A CRTP mix-in to automatically provide informational APIs needed for passes.