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';
94 void emitProfileNotes();
98 bool emitProfileArcs();
100 bool isFunctionInstrumented(
const Function &
F);
101 std::vector<Regex> createRegexesFromString(
StringRef RegexesStr);
102 static bool doesFilenameMatchARegex(
StringRef Filename,
103 std::vector<Regex> &Regexes);
115 insertCounterWriteout(
ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
118 void AddFlushBeforeForkAndExec();
120 enum class GCovFileType { GCNO, GCDA };
121 std::string mangleName(
const DICompileUnit *
CU, GCovFileType FileType);
126 char ReversedVersion[5];
134 std::vector<Regex> FilterRe;
135 std::vector<Regex> ExcludeRe;
139 class GCOVProfilerLegacyPass :
public ModulePass {
142 GCOVProfilerLegacyPass()
148 StringRef getPassName()
const override {
return "GCOV Profiler"; }
150 bool runOnModule(
Module &M)
override {
151 auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
152 return Profiler.runOnModule(M, TLI);
160 GCOVProfiler Profiler;
166 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
167 "Insert instrumentation for GCOV profiling",
false,
false)
170 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
171 "Insert instrumentation for GCOV profiling",
false,
false)
174 return new GCOVProfilerLegacyPass(Options);
178 if (!SP->getLinkageName().empty())
179 return SP->getLinkageName();
201 static const char *
const LinesTag;
202 static const char *
const FunctionTag;
203 static const char *
const BlockTag;
204 static const char *
const EdgeTag;
206 GCOVRecord() =
default;
208 void writeBytes(
const char *Bytes,
int Size) {
209 os->write(Bytes, Size);
213 writeBytes(reinterpret_cast<char*>(&i), 4);
218 static unsigned lengthOfGCOVString(
StringRef s) {
222 return (s.
size() / 4) + 1;
226 uint32_t Len = lengthOfGCOVString(s);
233 writeBytes(
"\0\0\0\0", 4 - (s.
size() % 4));
238 const char *
const GCOVRecord::LinesTag =
"\0\0\x45\x01";
239 const char *
const GCOVRecord::FunctionTag =
"\0\0\0\1";
240 const char *
const GCOVRecord::BlockTag =
"\0\0\x41\x01";
241 const char *
const GCOVRecord::EdgeTag =
"\0\0\x43\x01";
249 class GCOVLines :
public GCOVRecord {
252 assert(Line != 0 &&
"Line zero is not a valid real line number.");
253 Lines.push_back(Line);
258 return lengthOfGCOVString(Filename) + 2 + Lines.size();
263 writeGCOVString(Filename);
264 for (
int i = 0, e = Lines.size(); i != e; ++i)
274 std::string Filename;
285 return LinesByFile.try_emplace(Filename, Filename, os).first->second;
289 OutEdges.push_back(&Successor);
295 for (
auto &
I : LinesByFile) {
296 Len +=
I.second.length();
300 writeBytes(LinesTag, 4);
308 for (
auto &
I : SortedLinesByFile)
309 I->getValue().writeOut();
318 assert(LinesByFile.empty());
342 : SP(SP), Ident(Ident),
UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
349 for (
auto &BB : *F) {
351 if (i == 1 && ExitBlockBeforeBody)
353 Blocks.insert(std::make_pair(&BB,
GCOVBlock(i++, os)));
355 if (!ExitBlockBeforeBody)
356 ReturnBlock.Number = i;
358 std::string FunctionNameAndLine;
362 FuncChecksum =
hash_value(FunctionNameAndLine);
366 return Blocks.find(BB)->second;
373 std::string getEdgeDestinations() {
374 std::string EdgeDestinations;
379 for (
int i = 0, e = Block.OutEdges.size(); i != e; ++i)
380 EDOS << Block.OutEdges[i]->Number;
382 return EdgeDestinations;
389 void setCfgChecksum(
uint32_t Checksum) {
390 CfgChecksum = Checksum;
394 writeBytes(FunctionTag, 4);
397 1 + lengthOfGCOVString(Filename) + 1;
406 writeGCOVString(Filename);
407 write(SP->getLine());
410 writeBytes(BlockTag, 4);
411 write(Blocks.size() + 1);
412 for (
int i = 0, e = Blocks.size() + 1; i != e; ++i) {
418 if (Blocks.empty())
return;
422 if (Block.OutEdges.empty())
continue;
424 writeBytes(EdgeTag, 4);
425 write(Block.OutEdges.size() * 2 + 1);
427 for (
int i = 0, e = Block.OutEdges.size(); i != e; ++i) {
429 << Block.OutEdges[i]->Number <<
"\n");
430 write(Block.OutEdges[i]->Number);
437 getBlock(&
I).writeOut();
453 std::vector<Regex> GCOVProfiler::createRegexesFromString(
StringRef RegexesStr) {
454 std::vector<Regex> Regexes;
455 while (!RegexesStr.
empty()) {
456 std::pair<StringRef, StringRef> HeadTail = RegexesStr.
split(
';');
457 if (!HeadTail.first.empty()) {
458 Regex Re(HeadTail.first);
461 Ctx->emitError(
Twine(
"Regex ") + HeadTail.first +
462 " is not valid: " + Err);
464 Regexes.emplace_back(std::move(Re));
466 RegexesStr = HeadTail.second;
471 bool GCOVProfiler::doesFilenameMatchARegex(
StringRef Filename,
472 std::vector<Regex> &Regexes) {
473 for (
Regex &Re : Regexes) {
474 if (Re.match(Filename)) {
481 bool GCOVProfiler::isFunctionInstrumented(
const Function &
F) {
482 if (FilterRe.empty() && ExcludeRe.empty()) {
486 auto It = InstrumentedFiles.
find(Filename);
487 if (It != InstrumentedFiles.end()) {
499 RealFilename = Filename;
501 RealFilename = RealPath;
504 bool ShouldInstrument;
505 if (FilterRe.empty()) {
506 ShouldInstrument = !doesFilenameMatchARegex(RealFilename, ExcludeRe);
507 }
else if (ExcludeRe.empty()) {
508 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe);
510 ShouldInstrument = doesFilenameMatchARegex(RealFilename, FilterRe) &&
511 !doesFilenameMatchARegex(RealFilename, ExcludeRe);
513 InstrumentedFiles[Filename] = ShouldInstrument;
514 return ShouldInstrument;
518 GCovFileType OutputType) {
519 bool Notes = OutputType == GCovFileType::GCNO;
521 if (
NamedMDNode *GCov = M->getNamedMetadata(
"llvm.gcov")) {
522 for (
int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
523 MDNode *
N = GCov->getOperand(i);
527 if (dyn_cast<MDNode>(N->
getOperand(ThreeElement ? 2 : 1)) != CU)
535 if (!NotesFile || !DataFile)
537 return Notes ? NotesFile->
getString() : DataFile->getString();
546 return Filename.
str();
556 return CurPath.
str();
564 AddFlushBeforeForkAndExec();
566 FilterRe = createRegexesFromString(Options.Filter);
567 ExcludeRe = createRegexesFromString(Options.Exclude);
569 if (Options.EmitNotes) emitProfileNotes();
570 if (Options.EmitData)
return emitProfileArcs();
577 GCOVProfiler Profiler(GCOVOpts);
580 if (!Profiler.runOnModule(M, TLI))
593 if (isa<DbgInfoIntrinsic>(&
I))
continue;
600 if (Loc.
getLine() == 0)
continue;
616 if (isa<AllocaInst>(*It))
return true;
617 if (isa<DbgInfoIntrinsic>(*It))
return true;
618 if (
auto *II = dyn_cast<IntrinsicInst>(It)) {
625 void GCOVProfiler::AddFlushBeforeForkAndExec() {
629 if (
CallInst *CI = dyn_cast<CallInst>(&
I)) {
633 (LF == LibFunc_fork || LF == LibFunc_execl ||
634 LF == LibFunc_execle || LF == LibFunc_execlp ||
635 LF == LibFunc_execv || LF == LibFunc_execvp ||
636 LF == LibFunc_execve || LF == LibFunc_execvpe ||
637 LF == LibFunc_execvP)) {
648 for (
auto I : ForkAndExecs) {
653 I->getParent()->splitBasicBlock(
I);
657 void GCOVProfiler::emitProfileNotes() {
659 if (!CU_Nodes)
return;
661 for (
unsigned i = 0, e = CU_Nodes->
getNumOperands(); i != e; ++i) {
666 auto *CU = cast<DICompileUnit>(CU_Nodes->
getOperand(i));
675 Ctx->emitError(
Twine(
"failed to open coverage notes file for writing: ") +
680 std::string EdgeDestinations;
682 unsigned FunctionIdent = 0;
699 Funcs.push_back(make_unique<GCOVFunction>(SP, &F, &out, FunctionIdent++,
700 Options.UseCfgChecksum,
701 Options.ExitBlockBeforeBody));
708 Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
717 }
else if (isa<ReturnInst>(TI)) {
718 Block.addEdge(Func.getReturnBlock());
724 if (isa<DbgInfoIntrinsic>(&
I))
continue;
734 if (Line == Loc.
getLine())
continue;
739 GCOVLines &Lines = Block.getFile(Filename);
744 EdgeDestinations += Func.getEdgeDestinations();
747 FileChecksums.push_back(
hash_value(EdgeDestinations));
748 out.
write(
"oncg", 4);
749 out.
write(ReversedVersion, 4);
750 out.
write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
752 for (
auto &Func : Funcs) {
753 Func->setCfgChecksum(FileChecksums.back());
757 out.
write(
"\0\0\0\0\0\0\0\0", 8);
762 bool GCOVProfiler::emitProfileArcs() {
764 if (!CU_Nodes)
return false;
767 for (
unsigned i = 0, e = CU_Nodes->
getNumOperands(); i != e; ++i) {
776 if (!Result) Result =
true;
782 if (isa<ReturnInst>(TI)) {
783 EdgeToCounter[{&BB,
nullptr}] = Edges++;
786 EdgeToCounter[{&BB, Succ}] = Edges++;
798 CountersBySP.
push_back(std::make_pair(Counters, SP));
803 const unsigned EdgeCount =
809 PHINode *Phi = BuilderForPhi.CreatePHI(Int64PtrTy, EdgeCount);
811 auto It = EdgeToCounter.
find({Pred, &BB});
813 const unsigned Edge = It->second;
815 BuilderForPhi.CreateConstInBoundsGEP2_64(Counters, 0, Edge);
821 Value *Count = Builder.CreateLoad(Phi);
823 Builder.CreateStore(Count, Phi);
826 if (isa<ReturnInst>(TI)) {
827 auto It = EdgeToCounter.
find({&BB,
nullptr});
829 const unsigned Edge = It->second;
831 Builder.CreateConstInBoundsGEP2_64(Counters, 0, Edge);
833 Count = Builder.CreateAdd(Count, Builder.getInt64(1));
834 Builder.CreateStore(Count, Counter);
840 Function *WriteoutF = insertCounterWriteout(CountersBySP);
841 Function *FlushF = insertFlush(CountersBySP);
848 "__llvm_gcov_init", M);
852 if (Options.NoRedZone)
868 Builder.
CreateCall(GCOVInit, {WriteoutF, FlushF});
877 Constant *GCOVProfiler::getStartFileFunc() {
885 if (
Function *FunRes = dyn_cast<Function>(Res))
887 FunRes->addParamAttr(2, AK);
892 Constant *GCOVProfiler::getEmitFunctionFunc() {
902 if (
Function *FunRes = dyn_cast<Function>(Res))
904 FunRes->addParamAttr(0, AK);
905 FunRes->addParamAttr(2, AK);
906 FunRes->addParamAttr(3, AK);
907 FunRes->addParamAttr(4, AK);
912 Constant *GCOVProfiler::getEmitArcsFunc() {
919 if (
Function *FunRes = dyn_cast<Function>(Res))
921 FunRes->addParamAttr(0, AK);
925 Constant *GCOVProfiler::getSummaryInfoFunc() {
930 Constant *GCOVProfiler::getEndFileFunc() {
935 Function *GCOVProfiler::insertCounterWriteout(
936 ArrayRef<std::pair<GlobalVariable *, MDNode *> > CountersBySP) {
941 "__llvm_gcov_writeout", M);
944 if (Options.NoRedZone)
950 Constant *StartFile = getStartFileFunc();
951 Constant *EmitFunction = getEmitFunctionFunc();
952 Constant *EmitArcs = getEmitArcsFunc();
953 Constant *SummaryInfo = getSummaryInfoFunc();
954 Constant *EndFile = getEndFileFunc();
978 Constant *TwoZero32s[] = {Zero32, Zero32};
982 auto *CU = cast<DICompileUnit>(CUNodes->
getOperand(i));
988 std::string FilenameGcda = mangleName(CU, GCovFileType::GCDA);
989 uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
997 for (
int j : llvm::seq<int>(0, CountersBySP.size())) {
998 auto *
SP = cast_or_null<DISubprogram>(CountersBySP[j].second);
999 uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
1001 EmitFunctionCallArgsTy,
1003 Options.FunctionNamesInData
1007 Builder.
getInt8(Options.UseCfgChecksum),
1011 unsigned Arcs = cast<ArrayType>(GV->
getValueType())->getNumElements();
1018 int CountersSize = CountersBySP.size();
1019 assert(CountersSize == (
int)EmitFunctionCallArgsArray.size() &&
1020 "Mismatched array size!");
1021 assert(CountersSize == (
int)EmitArcsCallArgsArray.
size() &&
1022 "Mismatched array size!");
1023 auto *EmitFunctionCallArgsArrayTy =
1026 *M, EmitFunctionCallArgsArrayTy,
true,
1029 EmitFunctionCallArgsArray),
1030 Twine(
"__llvm_internal_gcov_emit_function_args.") +
Twine(i));
1031 auto *EmitArcsCallArgsArrayTy =
1033 EmitFunctionCallArgsArrayGV->setUnnamedAddr(
1036 *M, EmitArcsCallArgsArrayTy,
true,
1039 Twine(
"__llvm_internal_gcov_emit_arcs_args.") +
Twine(i));
1044 {StartFileCallArgs, Builder.
getInt32(CountersSize),
1046 EmitFunctionCallArgsArrayGV,
1049 EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV, TwoZero32s)}));
1053 if (FileInfos.
empty()) {
1063 if ((int64_t)FileInfos.
size() > (int64_t)INT_MAX)
1064 FileInfos.
resize(INT_MAX);
1072 "__llvm_internal_gcov_emit_file_info");
1076 auto *FileLoopHeader =
1078 auto *CounterLoopHeader =
1103 auto *EmitFunctionCallArgsArray =
1105 auto *EmitArcsCallArgsArray =
1107 auto *EnterCounterLoopCond =
1109 Builder.
CreateCondBr(EnterCounterLoopCond, CounterLoopHeader, FileLoopLatch);
1114 auto *EmitFunctionCallArgsPtr =
1126 EmitFunctionCall->addParamAttr(2, AK);
1127 EmitFunctionCall->addParamAttr(3, AK);
1128 EmitFunctionCall->addParamAttr(4, AK);
1130 auto *EmitArcsCallArgsPtr =
1139 auto *CounterLoopCond = Builder.
CreateICmpSLT(NextJV, NumCounters);
1140 Builder.
CreateCondBr(CounterLoopCond, CounterLoopHeader, FileLoopLatch);
1141 JV->addIncoming(NextJV, CounterLoopHeader);
1147 auto *FileLoopCond =
1149 Builder.
CreateCondBr(FileLoopCond, FileLoopHeader, ExitBB);
1159 insertFlush(
ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
1164 "__llvm_gcov_flush", M);
1169 if (Options.NoRedZone)
1176 assert(WriteoutF &&
"Need to create the writeout function first!");
1182 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.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
ModulePass * createGCOVProfilerPass(const GCOVOptions &Options=GCOVOptions::getDefault())
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
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()
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)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
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.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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)...
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
bool hasPersonalityFn() const
Check whether this function has a personality function.
amdgpu Simplify well known AMD library false Value * Callee
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.
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)
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, or matching, 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)
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.
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
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.
Analysis pass providing the TargetLibraryInfo.
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.
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)