50 #define DEBUG_TYPE "insert-gcov-profiling" 81 GCOVProfiler(
const GCOVOptions &Opts) : Options(Opts) {
82 assert((Options.EmitNotes || Options.EmitData) &&
83 "GCOVProfiler asked to do nothing?");
84 ReversedVersion[0] = Options.Version[3];
85 ReversedVersion[1] = Options.Version[2];
86 ReversedVersion[2] = Options.Version[1];
87 ReversedVersion[3] = Options.Version[0];
88 ReversedVersion[4] =
'\0';
96 void emitProfileNotes();
100 bool emitProfileArcs();
102 bool isFunctionInstrumented(
const Function &F);
103 std::vector<Regex> createRegexesFromString(
StringRef RegexesStr);
104 static bool doesFilenameMatchARegex(
StringRef Filename,
105 std::vector<Regex> &Regexes);
117 insertCounterWriteout(
ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
120 void AddFlushBeforeForkAndExec();
122 enum class GCovFileType { GCNO, GCDA };
128 char ReversedVersion[5];
133 std::function<const TargetLibraryInfo &(Function &F)> GetTLI;
136 std::vector<Regex> FilterRe;
137 std::vector<Regex> ExcludeRe;
141 class GCOVProfilerLegacyPass :
public ModulePass {
144 GCOVProfilerLegacyPass()
150 StringRef getPassName()
const override {
return "GCOV Profiler"; }
152 bool runOnModule(
Module &M)
override {
154 return getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
163 GCOVProfiler Profiler;
169 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
170 "Insert instrumentation for GCOV profiling",
false,
false)
173 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
174 "Insert instrumentation for GCOV profiling",
false,
false)
177 return new GCOVProfilerLegacyPass(Options);
181 if (!SP->getLinkageName().empty())
182 return SP->getLinkageName();
204 static const char *
const LinesTag;
205 static const char *
const FunctionTag;
206 static const char *
const BlockTag;
207 static const char *
const EdgeTag;
209 GCOVRecord() =
default;
211 void writeBytes(
const char *Bytes,
int Size) {
212 os->write(Bytes, Size);
216 writeBytes(reinterpret_cast<char*>(&i), 4);
221 static unsigned lengthOfGCOVString(
StringRef s) {
225 return (s.
size() / 4) + 1;
229 uint32_t Len = lengthOfGCOVString(s);
236 writeBytes(
"\0\0\0\0", 4 - (s.
size() % 4));
241 const char *
const GCOVRecord::LinesTag =
"\0\0\x45\x01";
242 const char *
const GCOVRecord::FunctionTag =
"\0\0\0\1";
243 const char *
const GCOVRecord::BlockTag =
"\0\0\x41\x01";
244 const char *
const GCOVRecord::EdgeTag =
"\0\0\x43\x01";
252 class GCOVLines :
public GCOVRecord {
255 assert(Line != 0 &&
"Line zero is not a valid real line number.");
256 Lines.push_back(Line);
261 return lengthOfGCOVString(Filename) + 2 + Lines.size();
266 writeGCOVString(Filename);
267 for (
int i = 0,
e = Lines.size(); i !=
e; ++i)
277 std::string Filename;
288 return LinesByFile.try_emplace(Filename, Filename, os).first->second;
292 OutEdges.push_back(&Successor);
298 for (
auto &
I : LinesByFile) {
299 Len +=
I.second.length();
303 writeBytes(LinesTag, 4);
311 for (
auto &
I : SortedLinesByFile)
312 I->getValue().writeOut();
321 assert(LinesByFile.empty());
345 : SP(SP), Ident(Ident),
UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
352 for (
auto &BB : *F) {
354 if (i == 1 && ExitBlockBeforeBody)
356 Blocks.insert(std::make_pair(&BB,
GCOVBlock(i++, os)));
358 if (!ExitBlockBeforeBody)
359 ReturnBlock.Number = i;
361 std::string FunctionNameAndLine;
365 FuncChecksum =
hash_value(FunctionNameAndLine);
369 return Blocks.find(BB)->second;
376 std::string getEdgeDestinations() {
377 std::string EdgeDestinations;
382 for (
int i = 0,
e = Block.OutEdges.size(); i !=
e; ++i)
383 EDOS << Block.OutEdges[i]->Number;
385 return EdgeDestinations;
392 void setCfgChecksum(
uint32_t Checksum) {
393 CfgChecksum = Checksum;
397 writeBytes(FunctionTag, 4);
400 1 + lengthOfGCOVString(Filename) + 1;
409 writeGCOVString(Filename);
410 write(SP->getLine());
413 writeBytes(BlockTag, 4);
414 write(Blocks.size() + 1);
415 for (
int i = 0,
e = Blocks.size() + 1; i !=
e; ++i) {
421 if (Blocks.empty())
return;
425 if (Block.OutEdges.empty())
continue;
427 writeBytes(EdgeTag, 4);
428 write(Block.OutEdges.size() * 2 + 1);
430 for (
int i = 0,
e = Block.OutEdges.size(); i !=
e; ++i) {
432 << Block.OutEdges[i]->Number <<
"\n");
433 write(Block.OutEdges[i]->Number);
440 getBlock(&
I).writeOut();
456 std::vector<Regex> GCOVProfiler::createRegexesFromString(
StringRef RegexesStr) {
457 std::vector<Regex> Regexes;
458 while (!RegexesStr.
empty()) {
459 std::pair<StringRef, StringRef> HeadTail = RegexesStr.
split(
';');
460 if (!HeadTail.first.empty()) {
461 Regex Re(HeadTail.first);
464 Ctx->emitError(
Twine(
"Regex ") + HeadTail.first +
465 " is not valid: " + Err);
467 Regexes.emplace_back(std::move(Re));
469 RegexesStr = HeadTail.second;
474 bool GCOVProfiler::doesFilenameMatchARegex(
StringRef Filename,
475 std::vector<Regex> &Regexes) {
476 for (
Regex &Re : Regexes) {
477 if (Re.match(Filename)) {
484 bool GCOVProfiler::isFunctionInstrumented(
const Function &
F) {
485 if (FilterRe.empty() && ExcludeRe.empty()) {
489 auto It = InstrumentedFiles.
find(Filename);
490 if (It != InstrumentedFiles.end()) {
502 RealFilename = Filename;
504 RealFilename = RealPath;
507 bool ShouldInstrument;
508 if (FilterRe.empty()) {
509 ShouldInstrument = !doesFilenameMatchARegex(RealFilename, ExcludeRe);
510 }
else if (ExcludeRe.empty()) {
511 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe);
513 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe) &&
514 !doesFilenameMatchARegex(RealFilename, ExcludeRe);
516 InstrumentedFiles[Filename] = ShouldInstrument;
517 return ShouldInstrument;
521 GCovFileType OutputType) {
522 bool Notes = OutputType == GCovFileType::GCNO;
524 if (
NamedMDNode *GCov = M->getNamedMetadata(
"llvm.gcov")) {
525 for (
int i = 0,
e = GCov->getNumOperands(); i !=
e; ++i) {
526 MDNode *
N = GCov->getOperand(i);
530 if (dyn_cast<MDNode>(N->
getOperand(ThreeElement ? 2 : 1)) != CU)
538 if (!NotesFile || !DataFile)
540 return Notes ? NotesFile->
getString() : DataFile->getString();
549 return Filename.
str();
559 return CurPath.
str();
562 bool GCOVProfiler::runOnModule(
565 this->GetTLI = std::move(GetTLI);
568 AddFlushBeforeForkAndExec();
570 FilterRe = createRegexesFromString(Options.Filter);
571 ExcludeRe = createRegexesFromString(Options.Exclude);
573 if (Options.EmitNotes) emitProfileNotes();
574 if (Options.EmitData)
return emitProfileArcs();
581 GCOVProfiler Profiler(GCOVOpts);
586 return FAM.getResult<TargetLibraryAnalysis>(F);
600 if (isa<DbgInfoIntrinsic>(&
I))
continue;
607 if (Loc.
getLine() == 0)
continue;
623 if (isa<AllocaInst>(*It))
return true;
624 if (isa<DbgInfoIntrinsic>(*It))
return true;
625 if (
auto *II = dyn_cast<IntrinsicInst>(It)) {
626 if (II->getIntrinsicID() == llvm::Intrinsic::localescape)
return true;
632 void GCOVProfiler::AddFlushBeforeForkAndExec() {
635 auto *TLI = &GetTLI(F);
637 if (
CallInst *CI = dyn_cast<CallInst>(&
I)) {
640 if (TLI->getLibFunc(*
Callee, LF) &&
641 (LF == LibFunc_fork || LF == LibFunc_execl ||
642 LF == LibFunc_execle || LF == LibFunc_execlp ||
643 LF == LibFunc_execv || LF == LibFunc_execvp ||
644 LF == LibFunc_execve || LF == LibFunc_execvpe ||
645 LF == LibFunc_execvP)) {
656 for (
auto I : ForkAndExecs) {
661 I->getParent()->splitBasicBlock(
I);
665 void GCOVProfiler::emitProfileNotes() {
667 if (!CU_Nodes)
return;
674 auto *CU = cast<DICompileUnit>(CU_Nodes->
getOperand(i));
684 Ctx->emitError(
Twine(
"failed to open coverage notes file for writing: ") +
689 std::string EdgeDestinations;
691 unsigned FunctionIdent = 0;
708 Funcs.push_back(std::make_unique<GCOVFunction>(SP, &F, &out, FunctionIdent++,
709 Options.UseCfgChecksum,
710 Options.ExitBlockBeforeBody));
719 if (!SP->isArtificial())
720 Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
729 }
else if (isa<ReturnInst>(TI)) {
730 Block.addEdge(Func.getReturnBlock());
736 if (isa<DbgInfoIntrinsic>(&
I))
continue;
746 if (Line == Loc.
getLine())
continue;
751 GCOVLines &Lines = Block.getFile(Filename);
756 EdgeDestinations += Func.getEdgeDestinations();
759 FileChecksums.push_back(
hash_value(EdgeDestinations));
760 out.
write(
"oncg", 4);
761 out.
write(ReversedVersion, 4);
762 out.
write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
764 for (
auto &Func : Funcs) {
765 Func->setCfgChecksum(FileChecksums.back());
769 out.
write(
"\0\0\0\0\0\0\0\0", 8);
774 bool GCOVProfiler::emitProfileArcs() {
776 if (!CU_Nodes)
return false;
788 if (!Result) Result =
true;
794 if (isa<ReturnInst>(TI)) {
795 EdgeToCounter[{&BB,
nullptr}] = Edges++;
798 EdgeToCounter[{&BB, Succ}] = Edges++;
810 CountersBySP.
push_back(std::make_pair(Counters, SP));
815 const unsigned EdgeCount =
821 PHINode *Phi = BuilderForPhi.CreatePHI(Int64PtrTy, EdgeCount);
823 auto It = EdgeToCounter.
find({Pred, &BB});
825 const unsigned Edge = It->second;
826 Value *EdgeCounter = BuilderForPhi.CreateConstInBoundsGEP2_64(
833 Value *Count = Builder.CreateLoad(Builder.getInt64Ty(), Phi);
835 Builder.CreateStore(Count, Phi);
838 if (isa<ReturnInst>(TI)) {
839 auto It = EdgeToCounter.
find({&BB,
nullptr});
841 const unsigned Edge = It->second;
842 Value *Counter = Builder.CreateConstInBoundsGEP2_64(
845 Count = Builder.CreateAdd(Count, Builder.getInt64(1));
846 Builder.CreateStore(Count, Counter);
852 Function *WriteoutF = insertCounterWriteout(CountersBySP);
853 Function *FlushF = insertFlush(CountersBySP);
860 "__llvm_gcov_init", M);
864 if (Options.NoRedZone)
880 Builder.
CreateCall(GCOVInit, {WriteoutF, FlushF});
944 Function *GCOVProfiler::insertCounterWriteout(
945 ArrayRef<std::pair<GlobalVariable *, MDNode *> > CountersBySP) {
950 "__llvm_gcov_writeout", M);
952 WriteoutF->
addFnAttr(Attribute::NoInline);
953 if (Options.NoRedZone)
954 WriteoutF->
addFnAttr(Attribute::NoRedZone);
959 auto *TLI = &GetTLI(*WriteoutF);
989 Constant *TwoZero32s[] = {Zero32, Zero32};
993 auto *CU = cast<DICompileUnit>(CUNodes->
getOperand(i));
999 std::string FilenameGcda = mangleName(CU, GCovFileType::GCDA);
1000 uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
1008 for (
int j : llvm::seq<int>(0, CountersBySP.size())) {
1009 auto *
SP = cast_or_null<DISubprogram>(CountersBySP[j].second);
1010 uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
1012 EmitFunctionCallArgsTy,
1014 Options.FunctionNamesInData
1018 Builder.
getInt8(Options.UseCfgChecksum),
1022 unsigned Arcs = cast<ArrayType>(GV->
getValueType())->getNumElements();
1029 int CountersSize = CountersBySP.size();
1030 assert(CountersSize == (
int)EmitFunctionCallArgsArray.size() &&
1031 "Mismatched array size!");
1032 assert(CountersSize == (
int)EmitArcsCallArgsArray.
size() &&
1033 "Mismatched array size!");
1034 auto *EmitFunctionCallArgsArrayTy =
1037 *M, EmitFunctionCallArgsArrayTy,
true,
1040 EmitFunctionCallArgsArray),
1041 Twine(
"__llvm_internal_gcov_emit_function_args.") +
Twine(i));
1042 auto *EmitArcsCallArgsArrayTy =
1044 EmitFunctionCallArgsArrayGV->setUnnamedAddr(
1047 *M, EmitArcsCallArgsArrayTy,
true,
1050 Twine(
"__llvm_internal_gcov_emit_arcs_args.") +
Twine(i));
1055 {StartFileCallArgs, Builder.
getInt32(CountersSize),
1057 EmitFunctionCallArgsArrayGV,
1060 EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV, TwoZero32s)}));
1064 if (FileInfos.
empty()) {
1074 if ((int64_t)FileInfos.
size() > (int64_t)INT_MAX)
1075 FileInfos.
resize(INT_MAX);
1083 "__llvm_internal_gcov_emit_file_info");
1087 auto *FileLoopHeader =
1089 auto *CounterLoopHeader =
1103 FileInfoArrayTy, FileInfoArrayGV, {Builder.
getInt32(0), IV});
1104 auto *StartFileCallArgsPtr =
1110 StartFileCallArgsPtr, 0)),
1113 StartFileCallArgsPtr, 1)),
1116 StartFileCallArgsPtr, 2))});
1120 Builder.
CreateLoad(FileInfoTy->getElementType(1),
1122 auto *EmitFunctionCallArgsArray =
1123 Builder.
CreateLoad(FileInfoTy->getElementType(2),
1125 auto *EmitArcsCallArgsArray =
1126 Builder.
CreateLoad(FileInfoTy->getElementType(3),
1128 auto *EnterCounterLoopCond =
1130 Builder.
CreateCondBr(EnterCounterLoopCond, CounterLoopHeader, FileLoopLatch);
1136 EmitFunctionCallArgsTy, EmitFunctionCallArgsArray, JV);
1139 {Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(0),
1141 EmitFunctionCallArgsPtr, 0)),
1142 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(1),
1144 EmitFunctionCallArgsPtr, 1)),
1145 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(2),
1147 EmitFunctionCallArgsPtr, 2)),
1148 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(3),
1150 EmitFunctionCallArgsPtr, 3)),
1151 Builder.
CreateLoad(EmitFunctionCallArgsTy->getElementType(4),
1153 EmitFunctionCallArgsPtr,
1157 EmitFunctionCall->addParamAttr(2, AK);
1158 EmitFunctionCall->addParamAttr(3, AK);
1159 EmitFunctionCall->addParamAttr(4, AK);
1161 auto *EmitArcsCallArgsPtr =
1166 EmitArcsCallArgsTy->getElementType(0),
1168 Builder.
CreateLoad(EmitArcsCallArgsTy->getElementType(1),
1170 EmitArcsCallArgsPtr, 1))});
1174 auto *CounterLoopCond = Builder.
CreateICmpSLT(NextJV, NumCounters);
1175 Builder.
CreateCondBr(CounterLoopCond, CounterLoopHeader, FileLoopLatch);
1176 JV->addIncoming(NextJV, CounterLoopHeader);
1182 auto *FileLoopCond =
1184 Builder.
CreateCondBr(FileLoopCond, FileLoopHeader, ExitBB);
1194 insertFlush(
ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
1199 "__llvm_gcov_flush", M);
1204 if (Options.NoRedZone)
1205 FlushF->
addFnAttr(Attribute::NoRedZone);
1211 assert(WriteoutF &&
"Need to create the writeout function first!");
1217 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.
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...