49 #define DEBUG_TYPE "insert-gcov-profiling" 80 GCOVProfiler(
const GCOVOptions &Opts) : Options(Opts) {
81 assert((Options.EmitNotes || Options.EmitData) &&
82 "GCOVProfiler asked to do nothing?");
83 ReversedVersion[0] = Options.Version[3];
84 ReversedVersion[1] = Options.Version[2];
85 ReversedVersion[2] = Options.Version[1];
86 ReversedVersion[3] = Options.Version[0];
87 ReversedVersion[4] =
'\0';
95 void emitProfileNotes();
99 bool emitProfileArcs();
101 bool isFunctionInstrumented(
const Function &F);
102 std::vector<Regex> createRegexesFromString(
StringRef RegexesStr);
103 static bool doesFilenameMatchARegex(
StringRef Filename,
104 std::vector<Regex> &Regexes);
116 insertCounterWriteout(
ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
119 void AddFlushBeforeForkAndExec();
121 enum class GCovFileType { GCNO, GCDA };
127 char ReversedVersion[5];
132 std::function<const TargetLibraryInfo &(Function &F)> GetTLI;
135 std::vector<Regex> FilterRe;
136 std::vector<Regex> ExcludeRe;
140 class GCOVProfilerLegacyPass :
public ModulePass {
143 GCOVProfilerLegacyPass()
149 StringRef getPassName()
const override {
return "GCOV Profiler"; }
151 bool runOnModule(
Module &M)
override {
153 return getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
162 GCOVProfiler Profiler;
168 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
169 "Insert instrumentation for GCOV profiling",
false,
false)
172 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
173 "Insert instrumentation for GCOV profiling",
false,
false)
176 return new GCOVProfilerLegacyPass(Options);
180 if (!SP->getLinkageName().empty())
181 return SP->getLinkageName();
203 static const char *
const LinesTag;
204 static const char *
const FunctionTag;
205 static const char *
const BlockTag;
206 static const char *
const EdgeTag;
208 GCOVRecord() =
default;
210 void writeBytes(
const char *Bytes,
int Size) {
211 os->write(Bytes, Size);
215 writeBytes(reinterpret_cast<char*>(&i), 4);
220 static unsigned lengthOfGCOVString(
StringRef s) {
224 return (s.
size() / 4) + 1;
228 uint32_t Len = lengthOfGCOVString(s);
235 writeBytes(
"\0\0\0\0", 4 - (s.
size() % 4));
240 const char *
const GCOVRecord::LinesTag =
"\0\0\x45\x01";
241 const char *
const GCOVRecord::FunctionTag =
"\0\0\0\1";
242 const char *
const GCOVRecord::BlockTag =
"\0\0\x41\x01";
243 const char *
const GCOVRecord::EdgeTag =
"\0\0\x43\x01";
251 class GCOVLines :
public GCOVRecord {
254 assert(Line != 0 &&
"Line zero is not a valid real line number.");
255 Lines.push_back(Line);
260 return lengthOfGCOVString(Filename) + 2 + Lines.size();
265 writeGCOVString(Filename);
266 for (
int i = 0,
e = Lines.size(); i !=
e; ++i)
276 std::string Filename;
287 return LinesByFile.try_emplace(Filename, Filename, os).first->second;
291 OutEdges.push_back(&Successor);
297 for (
auto &
I : LinesByFile) {
298 Len +=
I.second.length();
302 writeBytes(LinesTag, 4);
310 for (
auto &
I : SortedLinesByFile)
311 I->getValue().writeOut();
320 assert(LinesByFile.empty());
344 : SP(SP), Ident(Ident),
UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
351 for (
auto &BB : *F) {
353 if (i == 1 && ExitBlockBeforeBody)
355 Blocks.insert(std::make_pair(&BB,
GCOVBlock(i++, os)));
357 if (!ExitBlockBeforeBody)
358 ReturnBlock.Number = i;
360 std::string FunctionNameAndLine;
364 FuncChecksum =
hash_value(FunctionNameAndLine);
368 return Blocks.find(BB)->second;
375 std::string getEdgeDestinations() {
376 std::string EdgeDestinations;
381 for (
int i = 0,
e = Block.OutEdges.size(); i !=
e; ++i)
382 EDOS << Block.OutEdges[i]->Number;
384 return EdgeDestinations;
391 void setCfgChecksum(
uint32_t Checksum) {
392 CfgChecksum = Checksum;
396 writeBytes(FunctionTag, 4);
399 1 + lengthOfGCOVString(Filename) + 1;
408 writeGCOVString(Filename);
409 write(SP->getLine());
412 writeBytes(BlockTag, 4);
413 write(Blocks.size() + 1);
414 for (
int i = 0,
e = Blocks.size() + 1; i !=
e; ++i) {
420 if (Blocks.empty())
return;
424 if (Block.OutEdges.empty())
continue;
426 writeBytes(EdgeTag, 4);
427 write(Block.OutEdges.size() * 2 + 1);
429 for (
int i = 0,
e = Block.OutEdges.size(); i !=
e; ++i) {
431 << Block.OutEdges[i]->Number <<
"\n");
432 write(Block.OutEdges[i]->Number);
439 getBlock(&
I).writeOut();
455 std::vector<Regex> GCOVProfiler::createRegexesFromString(
StringRef RegexesStr) {
456 std::vector<Regex> Regexes;
457 while (!RegexesStr.
empty()) {
458 std::pair<StringRef, StringRef> HeadTail = RegexesStr.
split(
';');
459 if (!HeadTail.first.empty()) {
460 Regex Re(HeadTail.first);
463 Ctx->emitError(
Twine(
"Regex ") + HeadTail.first +
464 " is not valid: " + Err);
466 Regexes.emplace_back(std::move(Re));
468 RegexesStr = HeadTail.second;
473 bool GCOVProfiler::doesFilenameMatchARegex(
StringRef Filename,
474 std::vector<Regex> &Regexes) {
475 for (
Regex &Re : Regexes) {
476 if (Re.match(Filename)) {
483 bool GCOVProfiler::isFunctionInstrumented(
const Function &
F) {
484 if (FilterRe.empty() && ExcludeRe.empty()) {
488 auto It = InstrumentedFiles.
find(Filename);
489 if (It != InstrumentedFiles.end()) {
501 RealFilename = Filename;
503 RealFilename = RealPath;
506 bool ShouldInstrument;
507 if (FilterRe.empty()) {
508 ShouldInstrument = !doesFilenameMatchARegex(RealFilename, ExcludeRe);
509 }
else if (ExcludeRe.empty()) {
510 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe);
512 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe) &&
513 !doesFilenameMatchARegex(RealFilename, ExcludeRe);
515 InstrumentedFiles[Filename] = ShouldInstrument;
516 return ShouldInstrument;
520 GCovFileType OutputType) {
521 bool Notes = OutputType == GCovFileType::GCNO;
523 if (
NamedMDNode *GCov = M->getNamedMetadata(
"llvm.gcov")) {
524 for (
int i = 0,
e = GCov->getNumOperands(); i !=
e; ++i) {
525 MDNode *
N = GCov->getOperand(i);
529 if (dyn_cast<MDNode>(N->
getOperand(ThreeElement ? 2 : 1)) != CU)
537 if (!NotesFile || !DataFile)
539 return Notes ? NotesFile->
getString() : DataFile->getString();
548 return Filename.
str();
558 return CurPath.
str();
561 bool GCOVProfiler::runOnModule(
564 this->GetTLI = std::move(GetTLI);
567 AddFlushBeforeForkAndExec();
569 FilterRe = createRegexesFromString(Options.Filter);
570 ExcludeRe = createRegexesFromString(Options.Exclude);
572 if (Options.EmitNotes) emitProfileNotes();
573 if (Options.EmitData)
return emitProfileArcs();
580 GCOVProfiler Profiler(GCOVOpts);
585 return FAM.getResult<TargetLibraryAnalysis>(F);
599 if (isa<DbgInfoIntrinsic>(&
I))
continue;
606 if (Loc.
getLine() == 0)
continue;
622 if (isa<AllocaInst>(*It))
return true;
623 if (isa<DbgInfoIntrinsic>(*It))
return true;
624 if (
auto *II = dyn_cast<IntrinsicInst>(It)) {
625 if (II->getIntrinsicID() == llvm::Intrinsic::localescape)
return true;
631 void GCOVProfiler::AddFlushBeforeForkAndExec() {
634 auto *TLI = &GetTLI(F);
636 if (
CallInst *CI = dyn_cast<CallInst>(&
I)) {
639 if (TLI->getLibFunc(*
Callee, LF) &&
640 (LF == LibFunc_fork || LF == LibFunc_execl ||
641 LF == LibFunc_execle || LF == LibFunc_execlp ||
642 LF == LibFunc_execv || LF == LibFunc_execvp ||
643 LF == LibFunc_execve || LF == LibFunc_execvpe ||
644 LF == LibFunc_execvP)) {
655 for (
auto I : ForkAndExecs) {
660 I->getParent()->splitBasicBlock(
I);
664 void GCOVProfiler::emitProfileNotes() {
666 if (!CU_Nodes)
return;
673 auto *CU = cast<DICompileUnit>(CU_Nodes->
getOperand(i));
683 Ctx->emitError(
Twine(
"failed to open coverage notes file for writing: ") +
688 std::string EdgeDestinations;
690 unsigned FunctionIdent = 0;
707 Funcs.push_back(std::make_unique<GCOVFunction>(SP, &F, &out, FunctionIdent++,
708 Options.UseCfgChecksum,
709 Options.ExitBlockBeforeBody));
716 Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
725 }
else if (isa<ReturnInst>(TI)) {
726 Block.addEdge(Func.getReturnBlock());
732 if (isa<DbgInfoIntrinsic>(&
I))
continue;
742 if (Line == Loc.
getLine())
continue;
747 GCOVLines &Lines = Block.getFile(Filename);
752 EdgeDestinations += Func.getEdgeDestinations();
755 FileChecksums.push_back(
hash_value(EdgeDestinations));
756 out.
write(
"oncg", 4);
757 out.
write(ReversedVersion, 4);
758 out.
write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
760 for (
auto &Func : Funcs) {
761 Func->setCfgChecksum(FileChecksums.back());
765 out.
write(
"\0\0\0\0\0\0\0\0", 8);
770 bool GCOVProfiler::emitProfileArcs() {
772 if (!CU_Nodes)
return false;
784 if (!Result) Result =
true;
790 if (isa<ReturnInst>(TI)) {
791 EdgeToCounter[{&BB,
nullptr}] = Edges++;
794 EdgeToCounter[{&BB, Succ}] = Edges++;
806 CountersBySP.
push_back(std::make_pair(Counters, SP));
811 const unsigned EdgeCount =
817 PHINode *Phi = BuilderForPhi.CreatePHI(Int64PtrTy, EdgeCount);
819 auto It = EdgeToCounter.
find({Pred, &BB});
821 const unsigned Edge = It->second;
822 Value *EdgeCounter = BuilderForPhi.CreateConstInBoundsGEP2_64(
829 Value *Count = Builder.CreateLoad(Builder.getInt64Ty(), Phi);
831 Builder.CreateStore(Count, Phi);
834 if (isa<ReturnInst>(TI)) {
835 auto It = EdgeToCounter.
find({&BB,
nullptr});
837 const unsigned Edge = It->second;
838 Value *Counter = Builder.CreateConstInBoundsGEP2_64(
841 Count = Builder.CreateAdd(Count, Builder.getInt64(1));
842 Builder.CreateStore(Count, Counter);
848 Function *WriteoutF = insertCounterWriteout(CountersBySP);
849 Function *FlushF = insertFlush(CountersBySP);
856 "__llvm_gcov_init", M);
860 if (Options.NoRedZone)
876 Builder.
CreateCall(GCOVInit, {WriteoutF, FlushF});
940 Function *GCOVProfiler::insertCounterWriteout(
941 ArrayRef<std::pair<GlobalVariable *, MDNode *> > CountersBySP) {
946 "__llvm_gcov_writeout", M);
948 WriteoutF->
addFnAttr(Attribute::NoInline);
949 if (Options.NoRedZone)
950 WriteoutF->
addFnAttr(Attribute::NoRedZone);
955 auto *TLI = &GetTLI(*WriteoutF);
985 Constant *TwoZero32s[] = {Zero32, Zero32};
989 auto *CU = cast<DICompileUnit>(CUNodes->
getOperand(i));
995 std::string FilenameGcda = mangleName(CU, GCovFileType::GCDA);
996 uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
1004 for (
int j : llvm::seq<int>(0, CountersBySP.size())) {
1005 auto *
SP = cast_or_null<DISubprogram>(CountersBySP[j].second);
1006 uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
1008 EmitFunctionCallArgsTy,
1010 Options.FunctionNamesInData
1014 Builder.
getInt8(Options.UseCfgChecksum),
1018 unsigned Arcs = cast<ArrayType>(GV->
getValueType())->getNumElements();
1025 int CountersSize = CountersBySP.size();
1026 assert(CountersSize == (
int)EmitFunctionCallArgsArray.size() &&
1027 "Mismatched array size!");
1028 assert(CountersSize == (
int)EmitArcsCallArgsArray.
size() &&
1029 "Mismatched array size!");
1030 auto *EmitFunctionCallArgsArrayTy =
1033 *M, EmitFunctionCallArgsArrayTy,
true,
1036 EmitFunctionCallArgsArray),
1037 Twine(
"__llvm_internal_gcov_emit_function_args.") +
Twine(i));
1038 auto *EmitArcsCallArgsArrayTy =
1040 EmitFunctionCallArgsArrayGV->setUnnamedAddr(
1043 *M, EmitArcsCallArgsArrayTy,
true,
1046 Twine(
"__llvm_internal_gcov_emit_arcs_args.") +
Twine(i));
1051 {StartFileCallArgs, Builder.
getInt32(CountersSize),
1053 EmitFunctionCallArgsArrayGV,
1056 EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV, TwoZero32s)}));
1060 if (FileInfos.
empty()) {
1070 if ((int64_t)FileInfos.
size() > (int64_t)INT_MAX)
1071 FileInfos.
resize(INT_MAX);
1079 "__llvm_internal_gcov_emit_file_info");
1083 auto *FileLoopHeader =
1085 auto *CounterLoopHeader =
1099 FileInfoArrayTy, FileInfoArrayGV, {Builder.
getInt32(0), IV});
1100 auto *StartFileCallArgsPtr =
1106 StartFileCallArgsPtr, 0)),
1109 StartFileCallArgsPtr, 1)),
1112 StartFileCallArgsPtr, 2))});
1116 Builder.
CreateLoad(FileInfoTy->getElementType(1),
1118 auto *EmitFunctionCallArgsArray =
1119 Builder.
CreateLoad(FileInfoTy->getElementType(2),
1121 auto *EmitArcsCallArgsArray =
1122 Builder.
CreateLoad(FileInfoTy->getElementType(3),
1124 auto *EnterCounterLoopCond =
1126 Builder.
CreateCondBr(EnterCounterLoopCond, CounterLoopHeader, FileLoopLatch);
1132 EmitFunctionCallArgsTy, EmitFunctionCallArgsArray, JV);
1135 {Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(0),
1137 EmitFunctionCallArgsPtr, 0)),
1138 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(1),
1140 EmitFunctionCallArgsPtr, 1)),
1141 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(2),
1143 EmitFunctionCallArgsPtr, 2)),
1144 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(3),
1146 EmitFunctionCallArgsPtr, 3)),
1147 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(4),
1149 EmitFunctionCallArgsPtr,
1153 EmitFunctionCall->addParamAttr(2, AK);
1154 EmitFunctionCall->addParamAttr(3, AK);
1155 EmitFunctionCall->addParamAttr(4, AK);
1157 auto *EmitArcsCallArgsPtr =
1162 EmitArcsCallArgsTy->getElementType(0),
1164 Builder.
CreateLoad(EmitArcsCallArgsTy->getElementType(1),
1166 EmitArcsCallArgsPtr, 1))});
1170 auto *CounterLoopCond = Builder.
CreateICmpSLT(NextJV, NumCounters);
1171 Builder.
CreateCondBr(CounterLoopCond, CounterLoopHeader, FileLoopLatch);
1172 JV->addIncoming(NextJV, CounterLoopHeader);
1178 auto *FileLoopCond =
1180 Builder.
CreateCondBr(FileLoopCond, FileLoopHeader, ExitBB);
1190 insertFlush(
ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
1195 "__llvm_gcov_flush", M);
1200 if (Options.NoRedZone)
1201 FlushF->
addFnAttr(Attribute::NoRedZone);
1207 assert(WriteoutF &&
"Need to create the writeout function first!");
1213 for (
const auto &
I : CountersBySP) {
static StringRef getFunctionName(TargetLowering::CallLoweringInfo &CLI)
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
This routine provides some synthesis utilities to produce sequences of values.
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
MDNode * getOperand(unsigned i) const
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
Type * getElementType(unsigned N) const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
ModulePass * createGCOVProfilerPass(const GCOVOptions &Options=GCOVOptions::getDefault())
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
static cl::opt< bool > DefaultExitBlockBeforeBody("gcov-exit-block-before-body", cl::init(false), cl::Hidden)
A Module instance is used to store all the information related to an LLVM module. ...
BasicBlock * getSuccessor(unsigned Idx) const
Return the specified successor. This instruction must be a terminator.
static GCOVOptions getDefault()
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
size_t find(char C, size_t From=0) const
find - Search for the first character C in the string.
void push_back(const T &Elt)
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
static SmallString< 128 > getFilename(const DISubprogram *SP)
Extract a filename for a DISubprogram.
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
std::error_code current_path(SmallVectorImpl< char > &result)
Get the current path.
uint64_t getDWOId() const
const MDOperand & getOperand(unsigned I) const
static IntegerType * getInt64Ty(LLVMContext &C)
static PointerType * getInt64PtrTy(LLVMContext &C, unsigned AS=0)
static Constant * get(ArrayType *T, ArrayRef< Constant *> V)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
iterator begin()
Instruction iterator methods.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
bool isImplicitCode() const
Check if the DebugLoc corresponds to an implicit code.
Class to represent struct types.
LLVMContext & getContext() const
Get the global data context.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
ReturnInst * CreateRet(Value *V)
Create a 'ret <val>' instruction.
bool isIntegerTy() const
True if this is an instance of IntegerType.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
unsigned getNumOperands() const
static bool isUsingScopeBasedEH(Function &F)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
StringRef getFilename() const
Type * getVoidTy()
Fetch the type representing void.
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch, catchpad/ret, and cleanuppad/ret.
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
StringRef str() const
Explicit conversion to StringRef.
Class to represent function types.
This file provides the interface for the GCOV style profiler pass.
Class to represent array types.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
GCOVBlock - Collects block information.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
bool hasPersonalityFn() const
Check whether this function has a personality function.
static void addEdge(SmallVectorImpl< LazyCallGraph::Edge > &Edges, DenseMap< LazyCallGraph::Node *, int > &EdgeIndexMap, LazyCallGraph::Node &N, LazyCallGraph::Edge::Kind EK)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
unsigned getNumSuccessors() const
Return the number of successors that this instruction has.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
iterator find(const_arg_type_t< KeyT > Val)
StringRef getString() const
const BasicBlock & getEntryBlock() const
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
A set of analyses that are preserved following a run of a transformation pass.
iterator_range< iterator > functions()
LLVM Basic Block Representation.
LLVM_NODISCARD AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
DISubprogram * getSubprogram() const
Get the attached subprogram.
This is an important base class in LLVM.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
INITIALIZE_PASS_BEGIN(GCOVProfilerLegacyPass, "insert-gcov-profiling", "Insert instrumentation for GCOV profiling", false, false) INITIALIZE_PASS_END(GCOVProfilerLegacyPass
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Represent the analysis usage information of a pass.
static Type * getVoidTy(LLVMContext &C)
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Constant * get(StructType *T, ArrayRef< Constant *> V)
Interval::pred_iterator pred_end(Interval *I)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
MDNode * getScope() const
static void write(bool isBE, void *P, T V)
StringRef getDirectory() const
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
raw_ostream & write(unsigned char C)
void sort(IteratorTy Start, IteratorTy End)
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Iterator for intrusive lists based on ilist_node.
static bool functionHasLines(Function &F)
FileType
Defines the file type this file represents.
StringRef getName() const
Module.h This file contains the declarations for the Module class.
Provides information about what library functions are available for the current target.
void replace_extension(SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
Replace the file extension of path with extension.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
void initializeGCOVProfilerLegacyPassPass(PassRegistry &)
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, if any.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
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.
void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)
Append F to the list of global ctors of module M with the given Priority.
pred_range predecessors(BasicBlock *BB)
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
void setLinkage(LinkageTypes LT)
Constant * CreateGlobalStringPtr(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Same as CreateGlobalString, but return a pointer with "i8*" type instead of a pointer to array of i8...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
amdgpu Simplify well known AMD library false FunctionCallee Callee
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
static bool shouldKeepInEntry(BasicBlock::iterator It)
static cl::opt< std::string > DefaultGCOVVersion("default-gcov-version", cl::init("402*"), cl::Hidden, cl::ValueRequired)
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
GCOVFunction - Collects function information.
A raw_ostream that writes to a file descriptor.
void setUnnamedAddr(UnnamedAddr Val)
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_NODISCARD bool empty() const
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant *> IdxList)
Create an "inbounds" getelementptr.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
Rename collisions when linking (static functions).
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
BasicBlock * splitBasicBlock(iterator I, const Twine &BBName="")
Split the basic block into two basic blocks at the specified instruction.
void close()
Manually flush the stream and close the file.
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
succ_range successors(Instruction *I)
BranchInst * CreateBr(BasicBlock *Dest)
Create an unconditional 'br label X' instruction.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
This class implements an extremely fast bulk output stream that can only output to a stream...
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.
unsigned getNumOperands() const
Return number of MDNode operands.
bool exists(const basic_file_status &status)
Does file exist?
static IntegerType * getInt8Ty(LLVMContext &C)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...