27 if (Func ==
"mcount" ||
29 Func ==
"llvm.arm.gnu.eabi.mcount" ||
30 Func ==
"\01_mcount" ||
31 Func ==
"\01mcount" ||
34 Func ==
"__cyg_profile_func_enter_bare") {
35 Triple TargetTriple(M.getTargetTriple());
36 if (TargetTriple.
isOSAIX() && Func ==
"__mcount") {
37 Type *SizeTy = M.getDataLayout().getIntPtrType(
C);
38 Type *SizePtrTy = PointerType::getUnqual(
C);
43 M.getOrInsertFunction(Func,
46 {GV},
"", InsertionPt);
47 Call->setDebugLoc(
DL);
51 Call->setDebugLoc(
DL);
56 if (Func ==
"__cyg_profile_func_enter" || Func ==
"__cyg_profile_func_exit") {
57 Type *ArgTypes[] = {PointerType::getUnqual(
C), PointerType::getUnqual(
C)};
68 Value *Args[] = {&CurFn, RetAddr};
71 Call->setDebugLoc(
DL);
85 if (
F.hasFnAttribute(Attribute::Naked))
88 StringRef EntryAttr = PostInlining ?
"instrument-function-entry-inlined"
89 :
"instrument-function-entry";
91 StringRef ExitAttr = PostInlining ?
"instrument-function-exit-inlined"
92 :
"instrument-function-exit";
94 StringRef EntryFunc =
F.getFnAttribute(EntryAttr).getValueAsString();
95 StringRef ExitFunc =
F.getFnAttribute(ExitAttr).getValueAsString();
103 if (!EntryFunc.
empty()) {
105 if (
auto SP =
F.getSubprogram())
106 DL = DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP);
110 F.removeFnAttr(EntryAttr);
113 if (!ExitFunc.
empty()) {
116 if (!isa<ReturnInst>(
T))
120 if (
CallInst *CI = BB.getTerminatingMustTailCall())
124 if (
DebugLoc TerminatorDL =
T->getDebugLoc())
126 else if (
auto SP =
F.getSubprogram())
127 DL = DILocation::get(SP->getContext(), 0, 0, SP);
132 F.removeFnAttr(ExitAttr);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool runOnFunction(Function &F, bool PostInlining)
static void insertCall(Function &CurFn, StringRef Func, Instruction *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.
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVMContext & getContext() const
Get the context in which this basic block lives.
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="", Instruction *InsertBefore=nullptr)
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Module * getParent()
Get the module that this global value is contained inside of...
@ InternalLinkage
Rename collisions when linking (static functions).
const BasicBlock * getParent() const
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
This is an important class for using LLVM in a threaded context.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
void 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 isOSAIX() const
Tests whether the OS is AIX.
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 Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt32Ty(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.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.