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';
93 void emitProfileNotes();
97 bool emitProfileArcs();
101 Constant *getIncrementIndirectCounterFunc();
120 insertCounterWriteout(
ArrayRef<std::pair<GlobalVariable *, MDNode *>>);
122 void insertIndirectCounterIncrement();
124 enum class GCovFileType { GCNO, GCDA };
125 std::string mangleName(
const DICompileUnit *
CU, GCovFileType FileType);
130 char ReversedVersion[5];
140 class GCOVProfilerLegacyPass :
public ModulePass {
143 GCOVProfilerLegacyPass()
149 StringRef getPassName()
const override {
return "GCOV Profiler"; }
151 bool runOnModule(
Module &M)
override {
152 auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
153 return Profiler.runOnModule(M, TLI);
161 GCOVProfiler Profiler;
167 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
168 "Insert instrumentation for GCOV profiling",
false,
false)
171 GCOVProfilerLegacyPass,
"insert-gcov-profiling",
172 "Insert instrumentation for GCOV profiling",
false,
false)
175 return new GCOVProfilerLegacyPass(Options);
179 if (!SP->getLinkageName().empty())
180 return SP->getLinkageName();
187 static const char *
const LinesTag;
188 static const char *
const FunctionTag;
189 static const char *
const BlockTag;
190 static const char *
const EdgeTag;
192 GCOVRecord() =
default;
194 void writeBytes(
const char *Bytes,
int Size) {
195 os->write(Bytes, Size);
199 writeBytes(reinterpret_cast<char*>(&i), 4);
204 static unsigned lengthOfGCOVString(
StringRef s) {
208 return (s.
size() / 4) + 1;
212 uint32_t Len = lengthOfGCOVString(s);
219 writeBytes(
"\0\0\0\0", 4 - (s.
size() % 4));
224 const char *
const GCOVRecord::LinesTag =
"\0\0\x45\x01";
225 const char *
const GCOVRecord::FunctionTag =
"\0\0\0\1";
226 const char *
const GCOVRecord::BlockTag =
"\0\0\x41\x01";
227 const char *
const GCOVRecord::EdgeTag =
"\0\0\x43\x01";
235 class GCOVLines :
public GCOVRecord {
238 assert(Line != 0 &&
"Line zero is not a valid real line number.");
239 Lines.push_back(Line);
244 return lengthOfGCOVString(Filename) + 2 + Lines.size();
249 writeGCOVString(Filename);
250 for (
int i = 0, e = Lines.size(); i != e; ++i)
271 return LinesByFile.try_emplace(Filename, Filename, os).first->second;
275 OutEdges.push_back(&Successor);
281 for (
auto &
I : LinesByFile) {
282 Len +=
I.second.length();
286 writeBytes(LinesTag, 4);
291 SortedLinesByFile.
begin(), SortedLinesByFile.
end(),
293 return LHS->
getKey() < RHS->getKey();
295 for (
auto &
I : SortedLinesByFile)
296 I->getValue().writeOut();
305 assert(LinesByFile.empty());
329 : SP(SP), Ident(Ident),
UseCfgChecksum(UseCfgChecksum), CfgChecksum(0),
336 for (
auto &BB : *F) {
338 if (i == 1 && ExitBlockBeforeBody)
340 Blocks.insert(std::make_pair(&BB,
GCOVBlock(i++, os)));
342 if (!ExitBlockBeforeBody)
343 ReturnBlock.Number = i;
345 std::string FunctionNameAndLine;
349 FuncChecksum =
hash_value(FunctionNameAndLine);
353 return Blocks.find(BB)->second;
360 std::string getEdgeDestinations() {
361 std::string EdgeDestinations;
366 for (
int i = 0, e = Block.OutEdges.size(); i != e; ++i)
367 EDOS << Block.OutEdges[i]->Number;
369 return EdgeDestinations;
376 void setCfgChecksum(
uint32_t Checksum) {
377 CfgChecksum = Checksum;
381 writeBytes(FunctionTag, 4);
393 write(SP->getLine());
396 writeBytes(BlockTag, 4);
397 write(Blocks.size() + 1);
398 for (
int i = 0, e = Blocks.size() + 1; i != e; ++i) {
404 if (Blocks.empty())
return;
408 if (Block.OutEdges.empty())
continue;
410 writeBytes(EdgeTag, 4);
411 write(Block.OutEdges.size() * 2 + 1);
413 for (
int i = 0, e = Block.OutEdges.size(); i != e; ++i) {
415 << Block.OutEdges[i]->Number <<
"\n");
416 write(Block.OutEdges[i]->Number);
423 getBlock(&
I).writeOut();
438 GCovFileType OutputType) {
439 bool Notes = OutputType == GCovFileType::GCNO;
441 if (
NamedMDNode *GCov = M->getNamedMetadata(
"llvm.gcov")) {
442 for (
int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
443 MDNode *
N = GCov->getOperand(i);
447 if (dyn_cast<MDNode>(N->
getOperand(ThreeElement ? 2 : 1)) != CU)
455 if (!NotesFile || !DataFile)
457 return Notes ? NotesFile->
getString() : DataFile->getString();
466 return Filename.
str();
476 return CurPath.
str();
484 if (Options.EmitNotes) emitProfileNotes();
485 if (Options.EmitData)
return emitProfileArcs();
492 GCOVProfiler Profiler(GCOVOpts);
495 if (!Profiler.runOnModule(M, TLI))
508 if (isa<DbgInfoIntrinsic>(&
I))
continue;
515 if (Loc.
getLine() == 0)
continue;
531 if (isa<AllocaInst>(*It))
return true;
532 if (isa<DbgInfoIntrinsic>(*It))
return true;
533 if (
auto *II = dyn_cast<IntrinsicInst>(It)) {
534 if (II->getIntrinsicID() == llvm::Intrinsic::localescape)
return true;
540 void GCOVProfiler::emitProfileNotes() {
542 if (!CU_Nodes)
return;
544 for (
unsigned i = 0, e = CU_Nodes->
getNumOperands(); i != e; ++i) {
549 auto *CU = cast<DICompileUnit>(CU_Nodes->
getOperand(i));
558 Ctx->emitError(
Twine(
"failed to open coverage notes file for writing: ") +
563 std::string EdgeDestinations;
565 unsigned FunctionIdent = 0;
581 Funcs.push_back(make_unique<GCOVFunction>(SP, &
F, &out, FunctionIdent++,
582 Options.UseCfgChecksum,
583 Options.ExitBlockBeforeBody));
593 }
else if (isa<ReturnInst>(TI)) {
594 Block.addEdge(Func.getReturnBlock());
601 if (isa<DbgInfoIntrinsic>(&
I))
continue;
608 if (Loc.
getLine() == 0)
continue;
610 if (Line == Loc.
getLine())
continue;
615 GCOVLines &Lines = Block.getFile(SP->
getFilename());
619 EdgeDestinations += Func.getEdgeDestinations();
622 FileChecksums.push_back(
hash_value(EdgeDestinations));
623 out.
write(
"oncg", 4);
624 out.
write(ReversedVersion, 4);
625 out.
write(reinterpret_cast<char*>(&FileChecksums.back()), 4);
627 for (
auto &Func : Funcs) {
628 Func->setCfgChecksum(FileChecksums.back());
632 out.
write(
"\0\0\0\0\0\0\0\0", 8);
637 bool GCOVProfiler::emitProfileArcs() {
639 if (!CU_Nodes)
return false;
642 bool InsertIndCounterIncrCode =
false;
643 for (
unsigned i = 0, e = CU_Nodes->
getNumOperands(); i != e; ++i) {
651 if (!Result) Result =
true;
656 if (isa<ReturnInst>(TI))
669 CountersBySP.
push_back(std::make_pair(Counters, SP));
679 if (Successors == 1) {
681 Value *Counter = Builder.CreateConstInBoundsGEP2_64(Counters, 0,
683 Value *Count = Builder.CreateLoad(Counter);
684 Count = Builder.CreateAdd(Count, Builder.getInt64(1));
685 Builder.CreateStore(Count, Counter);
686 }
else if (
BranchInst *BI = dyn_cast<BranchInst>(TI)) {
697 ComplexEdgePreds.
insert(&BB);
698 for (
int i = 0; i != Successors; ++i)
706 if (!ComplexEdgePreds.
empty()) {
708 buildEdgeLookupTable(&F, Counters,
709 ComplexEdgePreds, ComplexEdgeSuccs);
712 for (
int i = 0, e = ComplexEdgePreds.
size(); i != e; ++i) {
713 IRBuilder<> Builder(&*ComplexEdgePreds[i + 1]->getFirstInsertionPt());
717 for (
int i = 0, e = ComplexEdgeSuccs.
size(); i != e; ++i) {
719 IRBuilder<> Builder(&*ComplexEdgeSuccs[i + 1]->getFirstInsertionPt());
720 Value *CounterPtrArray =
722 i * ComplexEdgePreds.
size());
725 InsertIndCounterIncrCode =
true;
726 Builder.
CreateCall(getIncrementIndirectCounterFunc(),
727 {EdgeState, CounterPtrArray});
732 Function *WriteoutF = insertCounterWriteout(CountersBySP);
733 Function *FlushF = insertFlush(CountersBySP);
740 "__llvm_gcov_init", M);
744 if (Options.NoRedZone)
760 Builder.
CreateCall(GCOVInit, {WriteoutF, FlushF});
766 if (InsertIndCounterIncrCode)
767 insertIndirectCounterIncrement();
784 size_t TableSize = Succs.
size() * Preds.
size();
788 std::unique_ptr<Constant * []> EdgeTable(
new Constant *[TableSize]);
790 for (
size_t i = 0; i != TableSize; ++i)
791 EdgeTable[i] = NullValue;
797 if (Successors > 1 && !isa<BranchInst>(TI) && !isa<ReturnInst>(TI)) {
798 for (
int i = 0; i != Successors; ++i) {
803 EdgeTable[((Succs.
idFor(Succ) - 1) * Preds.
size()) +
804 (Preds.
idFor(&BB) - 1)] = cast<Constant>(Counter);
815 "__llvm_gcda_edge_table");
820 Constant *GCOVProfiler::getStartFileFunc() {
828 if (
Function *FunRes = dyn_cast<Function>(Res))
830 FunRes->addParamAttr(2, AK);
835 Constant *GCOVProfiler::getIncrementIndirectCounterFunc() {
846 Constant *GCOVProfiler::getEmitFunctionFunc() {
856 if (
Function *FunRes = dyn_cast<Function>(Res))
858 FunRes->addParamAttr(0, AK);
859 FunRes->addParamAttr(2, AK);
860 FunRes->addParamAttr(3, AK);
861 FunRes->addParamAttr(4, AK);
866 Constant *GCOVProfiler::getEmitArcsFunc() {
873 if (
Function *FunRes = dyn_cast<Function>(Res))
875 FunRes->addParamAttr(0, AK);
879 Constant *GCOVProfiler::getSummaryInfoFunc() {
884 Constant *GCOVProfiler::getEndFileFunc() {
896 "__llvm_gcov_global_state_pred");
902 Function *GCOVProfiler::insertCounterWriteout(
903 ArrayRef<std::pair<GlobalVariable *, MDNode *> > CountersBySP) {
908 "__llvm_gcov_writeout", M);
910 WriteoutF->
addFnAttr(Attribute::NoInline);
911 if (Options.NoRedZone)
912 WriteoutF->
addFnAttr(Attribute::NoRedZone);
917 Constant *StartFile = getStartFileFunc();
918 Constant *EmitFunction = getEmitFunctionFunc();
919 Constant *EmitArcs = getEmitArcsFunc();
920 Constant *SummaryInfo = getSummaryInfoFunc();
921 Constant *EndFile = getEndFileFunc();
945 Constant *TwoZero32s[] = {Zero32, Zero32};
949 auto *CU = cast<DICompileUnit>(CUNodes->
getOperand(i));
955 std::string FilenameGcda = mangleName(CU, GCovFileType::GCDA);
956 uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
964 for (
int j : llvm::seq<int>(0, CountersBySP.size())) {
965 auto *
SP = cast_or_null<DISubprogram>(CountersBySP[j].second);
966 uint32_t FuncChecksum = Funcs.empty() ? 0 : Funcs[j]->getFuncChecksum();
968 EmitFunctionCallArgsTy,
970 Options.FunctionNamesInData
974 Builder.
getInt8(Options.UseCfgChecksum),
978 unsigned Arcs = cast<ArrayType>(GV->
getValueType())->getNumElements();
985 int CountersSize = CountersBySP.size();
986 assert(CountersSize == (
int)EmitFunctionCallArgsArray.size() &&
987 "Mismatched array size!");
988 assert(CountersSize == (
int)EmitArcsCallArgsArray.
size() &&
989 "Mismatched array size!");
990 auto *EmitFunctionCallArgsArrayTy =
993 *M, EmitFunctionCallArgsArrayTy,
true,
996 EmitFunctionCallArgsArray),
997 Twine(
"__llvm_internal_gcov_emit_function_args.") +
Twine(i));
998 auto *EmitArcsCallArgsArrayTy =
1000 EmitFunctionCallArgsArrayGV->setUnnamedAddr(
1003 *M, EmitArcsCallArgsArrayTy,
true,
1006 Twine(
"__llvm_internal_gcov_emit_arcs_args.") +
Twine(i));
1011 {StartFileCallArgs, Builder.
getInt32(CountersSize),
1013 EmitFunctionCallArgsArrayGV,
1016 EmitArcsCallArgsArrayTy, EmitArcsCallArgsArrayGV, TwoZero32s)}));
1020 if (FileInfos.
empty()) {
1030 if ((int64_t)FileInfos.
size() > (int64_t)INT_MAX)
1031 FileInfos.
resize(INT_MAX);
1039 "__llvm_internal_gcov_emit_file_info");
1043 auto *FileLoopHeader =
1045 auto *CounterLoopHeader =
1070 auto *EmitFunctionCallArgsArray =
1072 auto *EmitArcsCallArgsArray =
1074 auto *EnterCounterLoopCond =
1076 Builder.
CreateCondBr(EnterCounterLoopCond, CounterLoopHeader, FileLoopLatch);
1081 auto *EmitFunctionCallArgsPtr =
1093 EmitFunctionCall->addParamAttr(2, AK);
1094 EmitFunctionCall->addParamAttr(3, AK);
1095 EmitFunctionCall->addParamAttr(4, AK);
1097 auto *EmitArcsCallArgsPtr =
1106 auto *CounterLoopCond = Builder.
CreateICmpSLT(NextJV, NumCounters);
1107 Builder.
CreateCondBr(CounterLoopCond, CounterLoopHeader, FileLoopLatch);
1108 JV->addIncoming(NextJV, CounterLoopHeader);
1114 auto *FileLoopCond =
1116 Builder.
CreateCondBr(FileLoopCond, FileLoopHeader, ExitBB);
1125 void GCOVProfiler::insertIndirectCounterIncrement() {
1127 cast<Function>(GCOVProfiler::getIncrementIndirectCounterFunc());
1131 if (Options.NoRedZone)
1177 insertFlush(
ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
1182 "__llvm_gcov_flush", M);
1187 if (Options.NoRedZone)
1188 FlushF->
addFnAttr(Attribute::NoRedZone);
1194 assert(WriteoutF &&
"Need to create the writeout function first!");
1200 for (
const auto &
I : CountersBySP) {
static StringRef getFunctionName(TargetLowering::CallLoweringInfo &CLI)
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
void push_back(const T &Elt)
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...
This class represents an incoming formal argument to a Function.
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.
Compute iterated dominance frontiers using a linear time algorithm.
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.
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.
static GCOVOptions getDefault()
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 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
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
const MDOperand & getOperand(unsigned I) const
bool empty() const
empty - Returns true if the vector is empty.
static IntegerType * getInt64Ty(LLVMContext &C)
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
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.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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)
void setName(const Twine &Name)
Change the name of the value.
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.
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
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)...
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
bool hasPersonalityFn() const
Check whether this function has a personality function.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
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...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
StringRef getString() const
LoadInst * CreateLoad(Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ptr, "...")' correctly, instead of converting the string to 'bool' fo...
initializer< Ty > init(const Ty &Val)
Type * getReturnType() const
Returns the type of the ret val.
Subclasses of this class are all able to terminate a basic block.
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.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
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)
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
MDNode * getScope() const
static void write(bool isBE, void *P, T V)
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
size_t size() const
size - Returns the number of entries in the vector.
raw_ostream & write(unsigned char C)
void sort(IteratorTy Start, IteratorTy End)
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
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.
void initializeGCOVProfilerLegacyPassPass(PassRegistry &)
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.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
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.
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.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
static bool shouldKeepInEntry(BasicBlock::iterator It)
amdgpu Simplify well known AMD library false Value Value * Arg
static cl::opt< std::string > DefaultGCOVVersion("default-gcov-version", cl::init("402*"), cl::Hidden, cl::ValueRequired)
ReturnInst * CreateRetVoid()
Create a 'ret void' instruction.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
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)
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.
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).
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())
unsigned getNumSuccessors() const
Return the number of successors that this terminator has.
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(BasicBlock *BB)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
A container for analyses that lazily runs them and caches their results.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
unsigned getNumOperands() const
Return number of MDNode operands.
static IntegerType * getInt8Ty(LLVMContext &C)
UniqueVector - This class produces a sequential ID number (base 1) for each unique entry that is adde...
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
CallInst * CreateCall(Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)