19 #include "llvm/IR/Intrinsics.h"
20 #include "llvm/IR/MDBuilder.h"
21 #include "llvm/Support/Endian.h"
22 #include "llvm/Support/FileSystem.h"
23 #include "llvm/Support/MD5.h"
26 "enable-value-profiling", llvm::cl::ZeroOrMore,
27 llvm::cl::desc(
"Enable value profiling"), llvm::cl::init(
false));
29 using namespace clang;
30 using namespace CodeGen;
32 void CodeGenPGO::setFuncName(StringRef
Name,
33 llvm::GlobalValue::LinkageTypes
Linkage) {
34 llvm::IndexedInstrProfReader *PGOReader = CGM.
getPGOReader();
35 FuncName = llvm::getPGOFuncName(
37 PGOReader ? PGOReader->getVersion() : llvm::IndexedInstrProf::Version);
41 FuncNameVar = llvm::createPGOFuncNameVar(CGM.
getModule(),
Linkage, FuncName);
44 void CodeGenPGO::setFuncName(llvm::Function *Fn) {
45 setFuncName(Fn->getName(), Fn->getLinkage());
47 llvm::createPGOFuncNameMetadata(*Fn, FuncName);
66 static const int NumBitsPerType = 6;
67 static const unsigned NumTypesPerWord =
sizeof(uint64_t) * 8 / NumBitsPerType;
68 static const unsigned TooBig = 1u << NumBitsPerType;
78 enum HashType :
unsigned char {
100 static_assert(LastHashType <= TooBig,
"Too many types in HashType");
104 PGOHash() : Working(0),
Count(0) {}
105 void combine(HashType
Type);
108 const int PGOHash::NumBitsPerType;
109 const unsigned PGOHash::NumTypesPerWord;
110 const unsigned PGOHash::TooBig;
115 unsigned NextCounter;
119 llvm::DenseMap<const Stmt *, unsigned> &CounterMap;
121 MapRegionCounters(llvm::DenseMap<const Stmt *, unsigned> &CounterMap)
122 : NextCounter(0), CounterMap(CounterMap) {}
126 bool TraverseBlockExpr(
BlockExpr *BE) {
return true; }
127 bool TraverseLambdaBody(
LambdaExpr *LE) {
return true; }
128 bool TraverseCapturedStmt(
CapturedStmt *CS) {
return true; }
130 bool VisitDecl(
const Decl *D) {
131 switch (D->getKind()) {
135 case Decl::CXXMethod:
136 case Decl::CXXConstructor:
137 case Decl::CXXDestructor:
138 case Decl::CXXConversion:
139 case Decl::ObjCMethod:
142 CounterMap[D->getBody()] = NextCounter++;
148 bool VisitStmt(
const Stmt *
S) {
149 auto Type = getHashType(S);
153 CounterMap[
S] = NextCounter++;
157 PGOHash::HashType getHashType(
const Stmt *S) {
158 switch (S->getStmtClass()) {
161 case Stmt::LabelStmtClass:
162 return PGOHash::LabelStmt;
163 case Stmt::WhileStmtClass:
164 return PGOHash::WhileStmt;
165 case Stmt::DoStmtClass:
166 return PGOHash::DoStmt;
167 case Stmt::ForStmtClass:
168 return PGOHash::ForStmt;
169 case Stmt::CXXForRangeStmtClass:
170 return PGOHash::CXXForRangeStmt;
171 case Stmt::ObjCForCollectionStmtClass:
172 return PGOHash::ObjCForCollectionStmt;
173 case Stmt::SwitchStmtClass:
174 return PGOHash::SwitchStmt;
175 case Stmt::CaseStmtClass:
176 return PGOHash::CaseStmt;
177 case Stmt::DefaultStmtClass:
178 return PGOHash::DefaultStmt;
179 case Stmt::IfStmtClass:
180 return PGOHash::IfStmt;
181 case Stmt::CXXTryStmtClass:
182 return PGOHash::CXXTryStmt;
183 case Stmt::CXXCatchStmtClass:
184 return PGOHash::CXXCatchStmt;
185 case Stmt::ConditionalOperatorClass:
186 return PGOHash::ConditionalOperator;
187 case Stmt::BinaryConditionalOperatorClass:
188 return PGOHash::BinaryConditionalOperator;
189 case Stmt::BinaryOperatorClass: {
192 return PGOHash::BinaryOperatorLAnd;
194 return PGOHash::BinaryOperatorLOr;
210 bool RecordNextStmtCount;
213 uint64_t CurrentCount;
216 llvm::DenseMap<const Stmt *, uint64_t> &
CountMap;
219 struct BreakContinue {
221 uint64_t ContinueCount;
222 BreakContinue() : BreakCount(0), ContinueCount(0) {}
226 ComputeRegionCounts(llvm::DenseMap<const Stmt *, uint64_t> &
CountMap,
228 : PGO(PGO), RecordNextStmtCount(
false), CountMap(CountMap) {}
230 void RecordStmtCount(
const Stmt *S) {
231 if (RecordNextStmtCount) {
233 RecordNextStmtCount =
false;
238 uint64_t setCount(uint64_t
Count) {
239 CurrentCount =
Count;
243 void VisitStmt(
const Stmt *S) {
245 for (
const Stmt *Child : S->children())
252 uint64_t BodyCount = setCount(PGO.getRegionCount(D->
getBody()));
264 uint64_t BodyCount = setCount(PGO.getRegionCount(D->
getBody()));
271 uint64_t BodyCount = setCount(PGO.getRegionCount(D->
getBody()));
276 void VisitBlockDecl(
const BlockDecl *D) {
278 uint64_t BodyCount = setCount(PGO.getRegionCount(D->
getBody()));
288 RecordNextStmtCount =
true;
296 RecordNextStmtCount =
true;
299 void VisitGotoStmt(
const GotoStmt *S) {
302 RecordNextStmtCount =
true;
305 void VisitLabelStmt(
const LabelStmt *S) {
306 RecordNextStmtCount =
false;
308 uint64_t BlockCount = setCount(PGO.getRegionCount(S));
313 void VisitBreakStmt(
const BreakStmt *S) {
315 assert(!BreakContinueStack.empty() &&
"break not in a loop or switch!");
316 BreakContinueStack.back().BreakCount += CurrentCount;
318 RecordNextStmtCount =
true;
323 assert(!BreakContinueStack.empty() &&
"continue stmt not in a loop!");
324 BreakContinueStack.back().ContinueCount += CurrentCount;
326 RecordNextStmtCount =
true;
329 void VisitWhileStmt(
const WhileStmt *S) {
331 uint64_t ParentCount = CurrentCount;
333 BreakContinueStack.push_back(BreakContinue());
336 uint64_t BodyCount = setCount(PGO.getRegionCount(S));
337 CountMap[S->
getBody()] = CurrentCount;
339 uint64_t BackedgeCount = CurrentCount;
345 BreakContinue BC = BreakContinueStack.pop_back_val();
347 setCount(ParentCount + BackedgeCount + BC.ContinueCount);
348 CountMap[S->
getCond()] = CondCount;
350 setCount(BC.BreakCount + CondCount - BodyCount);
351 RecordNextStmtCount =
true;
354 void VisitDoStmt(
const DoStmt *S) {
356 uint64_t LoopCount = PGO.getRegionCount(S);
358 BreakContinueStack.push_back(BreakContinue());
360 uint64_t BodyCount = setCount(LoopCount + CurrentCount);
361 CountMap[S->
getBody()] = BodyCount;
363 uint64_t BackedgeCount = CurrentCount;
365 BreakContinue BC = BreakContinueStack.pop_back_val();
368 uint64_t CondCount = setCount(BackedgeCount + BC.ContinueCount);
369 CountMap[S->
getCond()] = CondCount;
371 setCount(BC.BreakCount + CondCount - LoopCount);
372 RecordNextStmtCount =
true;
375 void VisitForStmt(
const ForStmt *S) {
380 uint64_t ParentCount = CurrentCount;
382 BreakContinueStack.push_back(BreakContinue());
385 uint64_t BodyCount = setCount(PGO.getRegionCount(S));
386 CountMap[S->
getBody()] = BodyCount;
388 uint64_t BackedgeCount = CurrentCount;
389 BreakContinue BC = BreakContinueStack.pop_back_val();
394 uint64_t IncCount = setCount(BackedgeCount + BC.ContinueCount);
395 CountMap[S->
getInc()] = IncCount;
401 setCount(ParentCount + BackedgeCount + BC.ContinueCount);
403 CountMap[S->
getCond()] = CondCount;
406 setCount(BC.BreakCount + CondCount - BodyCount);
407 RecordNextStmtCount =
true;
417 uint64_t ParentCount = CurrentCount;
418 BreakContinueStack.push_back(BreakContinue());
421 uint64_t BodyCount = setCount(PGO.getRegionCount(S));
422 CountMap[S->
getBody()] = BodyCount;
424 uint64_t BackedgeCount = CurrentCount;
425 BreakContinue BC = BreakContinueStack.pop_back_val();
429 uint64_t IncCount = setCount(BackedgeCount + BC.ContinueCount);
430 CountMap[S->
getInc()] = IncCount;
435 setCount(ParentCount + BackedgeCount + BC.ContinueCount);
436 CountMap[S->
getCond()] = CondCount;
438 setCount(BC.BreakCount + CondCount - BodyCount);
439 RecordNextStmtCount =
true;
445 uint64_t ParentCount = CurrentCount;
446 BreakContinueStack.push_back(BreakContinue());
448 uint64_t BodyCount = setCount(PGO.getRegionCount(S));
449 CountMap[S->
getBody()] = BodyCount;
451 uint64_t BackedgeCount = CurrentCount;
452 BreakContinue BC = BreakContinueStack.pop_back_val();
454 setCount(BC.BreakCount + ParentCount + BackedgeCount + BC.ContinueCount -
456 RecordNextStmtCount =
true;
463 BreakContinueStack.push_back(BreakContinue());
466 BreakContinue BC = BreakContinueStack.pop_back_val();
467 if (!BreakContinueStack.empty())
468 BreakContinueStack.back().ContinueCount += BC.ContinueCount;
470 setCount(PGO.getRegionCount(S));
471 RecordNextStmtCount =
true;
475 RecordNextStmtCount =
false;
479 uint64_t CaseCount = PGO.getRegionCount(S);
480 setCount(CurrentCount + CaseCount);
483 CountMap[
S] = CaseCount;
484 RecordNextStmtCount =
true;
488 void VisitIfStmt(
const IfStmt *S) {
490 uint64_t ParentCount = CurrentCount;
495 uint64_t ThenCount = setCount(PGO.getRegionCount(S));
496 CountMap[S->
getThen()] = ThenCount;
498 uint64_t OutCount = CurrentCount;
500 uint64_t ElseCount = ParentCount - ThenCount;
503 CountMap[S->
getElse()] = ElseCount;
505 OutCount += CurrentCount;
507 OutCount += ElseCount;
509 RecordNextStmtCount =
true;
518 setCount(PGO.getRegionCount(S));
519 RecordNextStmtCount =
true;
523 RecordNextStmtCount =
false;
525 uint64_t CatchCount = setCount(PGO.getRegionCount(S));
526 CountMap[
S] = CatchCount;
532 uint64_t ParentCount = CurrentCount;
537 uint64_t TrueCount = setCount(PGO.getRegionCount(E));
540 uint64_t OutCount = CurrentCount;
542 uint64_t FalseCount = setCount(ParentCount - TrueCount);
545 OutCount += CurrentCount;
548 RecordNextStmtCount =
true;
553 uint64_t ParentCount = CurrentCount;
556 uint64_t RHSCount = setCount(PGO.getRegionCount(E));
557 CountMap[E->
getRHS()] = RHSCount;
559 setCount(ParentCount + RHSCount - CurrentCount);
560 RecordNextStmtCount =
true;
565 uint64_t ParentCount = CurrentCount;
568 uint64_t RHSCount = setCount(PGO.getRegionCount(E));
569 CountMap[E->
getRHS()] = RHSCount;
571 setCount(ParentCount + RHSCount - CurrentCount);
572 RecordNextStmtCount =
true;
577 void PGOHash::combine(HashType
Type) {
579 assert(Type &&
"Hash is invalid: unexpected type 0");
580 assert(
unsigned(Type) < TooBig &&
"Hash is invalid: too many types");
584 using namespace llvm::support;
585 uint64_t Swapped = endian::byte_swap<uint64_t, little>(Working);
586 MD5.update(llvm::makeArrayRef((uint8_t *)&Swapped,
sizeof(Swapped)));
592 Working = Working << NumBitsPerType | Type;
595 uint64_t PGOHash::finalize() {
597 if (
Count <= NumTypesPerWord)
608 llvm::MD5::MD5Result
Result;
610 using namespace llvm::support;
611 return endian::read<uint64_t, little, unaligned>(Result);
617 llvm::IndexedInstrProfReader *PGOReader = CGM.
getPGOReader();
618 if (!InstrumentRegions && !PGOReader)
626 ((isa<CXXConstructorDecl>(GD.
getDecl()) &&
628 (isa<CXXDestructorDecl>(GD.
getDecl()) &&
635 mapRegionCounters(D);
637 emitCounterRegionMapping(D);
640 loadRegionCounts(PGOReader, SM.
isInMainFile(D->getLocation()));
641 computeRegionCounts(D);
642 applyFunctionAttributes(PGOReader, Fn);
646 void CodeGenPGO::mapRegionCounters(
const Decl *D) {
647 RegionCounterMap.reset(
new llvm::DenseMap<const Stmt *, unsigned>);
648 MapRegionCounters Walker(*RegionCounterMap);
649 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
650 Walker.TraverseDecl(const_cast<FunctionDecl *>(FD));
651 else if (
const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
652 Walker.TraverseDecl(const_cast<ObjCMethodDecl *>(MD));
653 else if (
const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D))
654 Walker.TraverseDecl(const_cast<BlockDecl *>(BD));
655 else if (
const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D))
656 Walker.TraverseDecl(const_cast<CapturedDecl *>(CD));
657 assert(Walker.NextCounter > 0 &&
"no entry counter mapped for decl");
658 NumRegionCounters = Walker.NextCounter;
659 FunctionHash = Walker.Hash.finalize();
662 bool CodeGenPGO::skipRegionMappingForDecl(
const Decl *D) {
663 if (SkipCoverageMapping)
668 auto Loc = D->getBody()->getLocStart();
672 void CodeGenPGO::emitCounterRegionMapping(
const Decl *D) {
673 if (skipRegionMappingForDecl(D))
676 std::string CoverageMapping;
677 llvm::raw_string_ostream OS(CoverageMapping);
684 if (CoverageMapping.empty())
688 FuncNameVar, FuncName, FunctionHash, CoverageMapping);
693 llvm::GlobalValue::LinkageTypes Linkage) {
694 if (skipRegionMappingForDecl(D))
697 std::string CoverageMapping;
698 llvm::raw_string_ostream OS(CoverageMapping);
705 if (CoverageMapping.empty())
708 setFuncName(Name, Linkage);
710 FuncNameVar, FuncName, FunctionHash, CoverageMapping,
false);
713 void CodeGenPGO::computeRegionCounts(
const Decl *D) {
714 StmtCountMap.reset(
new llvm::DenseMap<const Stmt *, uint64_t>);
715 ComputeRegionCounts Walker(*StmtCountMap, *
this);
716 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
717 Walker.VisitFunctionDecl(FD);
718 else if (
const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
719 Walker.VisitObjCMethodDecl(MD);
720 else if (
const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D))
721 Walker.VisitBlockDecl(BD);
722 else if (
const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D))
723 Walker.VisitCapturedDecl(const_cast<CapturedDecl *>(CD));
727 CodeGenPGO::applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
728 llvm::Function *Fn) {
733 Fn->setEntryCount(FunctionCount);
739 if (!Builder.GetInsertBlock())
742 unsigned Counter = (*RegionCounterMap)[
S];
744 Builder.CreateCall(CGM.
getIntrinsic(llvm::Intrinsic::instrprof_increment),
745 {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
746 Builder.getInt64(FunctionHash),
747 Builder.getInt32(NumRegionCounters),
748 Builder.getInt32(Counter)});
754 llvm::Instruction *ValueSite,
llvm::Value *ValuePtr) {
759 if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock())
762 if (isa<llvm::Constant>(ValuePtr))
766 if (InstrumentValueSites && RegionCounterMap) {
767 auto BuilderInsertPoint = Builder.saveIP();
768 Builder.SetInsertPoint(ValueSite);
770 llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
771 Builder.getInt64(FunctionHash),
772 Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
773 Builder.getInt32(ValueKind),
774 Builder.getInt32(NumValueSites[ValueKind]++)
777 CGM.
getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
778 Builder.restoreIP(BuilderInsertPoint);
782 llvm::IndexedInstrProfReader *PGOReader = CGM.
getPGOReader();
790 if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind))
793 llvm::annotateValueSite(CGM.
getModule(), *ValueSite, *ProfRecord,
794 (llvm::InstrProfValueKind)ValueKind,
795 NumValueSites[ValueKind]);
797 NumValueSites[ValueKind]++;
801 void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
804 RegionCounts.clear();
805 llvm::Expected<llvm::InstrProfRecord> RecordExpected =
806 PGOReader->getInstrProfRecord(FuncName, FunctionHash);
807 if (
auto E = RecordExpected.takeError()) {
808 auto IPE = llvm::InstrProfError::take(std::move(E));
809 if (IPE == llvm::instrprof_error::unknown_function)
811 else if (IPE == llvm::instrprof_error::hash_mismatch)
813 else if (IPE == llvm::instrprof_error::malformed)
819 llvm::make_unique<llvm::InstrProfRecord>(std::move(RecordExpected.get()));
820 RegionCounts = ProfRecord->Counts;
828 return MaxWeight < UINT32_MAX ? 1 : MaxWeight / UINT32_MAX + 1;
841 assert(Scale &&
"scale by 0?");
842 uint64_t Scaled = Weight / Scale + 1;
843 assert(Scaled <= UINT32_MAX &&
"overflow 32-bits");
847 llvm::MDNode *CodeGenFunction::createProfileWeights(uint64_t TrueCount,
848 uint64_t FalseCount) {
850 if (!TrueCount && !FalseCount)
864 if (Weights.size() < 2)
868 uint64_t MaxWeight = *std::max_element(Weights.begin(), Weights.end());
876 ScaledWeights.reserve(Weights.size());
877 for (uint64_t W : Weights)
881 return MDHelper.createBranchWeights(ScaledWeights);
884 llvm::MDNode *CodeGenFunction::createProfileWeightsForLoop(
const Stmt *Cond,
885 uint64_t LoopCount) {
889 assert(CondCount.hasValue() &&
"missing expected loop condition count");
892 return createProfileWeights(LoopCount,
893 std::max(*CondCount, LoopCount) - LoopCount);
Optional< uint64_t > getStmtCount(const Stmt *S)
Check if an execution count is known for a given statement.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
CXXCtorType getCtorType() const
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
llvm::Module & getModule() const
static uint64_t calculateWeightScale(uint64_t MaxWeight)
Calculate what to divide by to scale weights.
llvm::LLVMContext & getLLVMContext()
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S)
Organizes the per-function state that is used while generating code coverage mapping data...
The base class of the type hierarchy.
static llvm::cl::opt< bool > EnableValueProfiling("enable-value-profiling", llvm::cl::ZeroOrMore, llvm::cl::desc("Enable value profiling"), llvm::cl::init(false))
const Stmt * getElse() const
ObjCMethodDecl - Represents an instance or class method declaration.
llvm::ImmutableMap< CountKey, unsigned > CountMap
A C++ throw-expression (C++ [except.throw]).
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
LabelStmt - Represents a label, which has a substatement.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
void addFunctionMappingRecord(llvm::GlobalVariable *FunctionName, StringRef FunctionNameValue, uint64_t FunctionHash, const std::string &CoverageMapping, bool IsUsed=true)
Add a function's coverage mapping record to the collection of the function mapping records...
Stmt * getBody() const override
const Decl * getDecl() const
Stmt * getBody() const override
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Expr * getTrueExpr() const
Stmt * getHandlerBlock() const
A builtin binary operation expression such as "x + y" or "x <= y".
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
This represents the body of a CapturedStmt, and serves as its DeclContext.
detail::InMemoryDirectory::const_iterator I
InstrProfStats & getPGOStats()
ConditionalOperator - The ?: ternary operator.
const TargetInfo & getTarget() const
bool hasConstructorVariants() const
Does this ABI have different entrypoints for complete-object and base-subobject constructors?
void valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, llvm::Instruction *ValueSite, llvm::Value *ValuePtr)
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
CXXDtorType getDtorType() const
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
bool haveRegionCounts() const
Whether or not we have PGO region data for the current function.
ASTContext & getContext() const
CXXTryStmt - A C++ try block, including all handlers.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
The result type of a method or function.
GlobalDecl - represents a global declaration.
DoStmt - This represents a 'do/while' stmt.
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file...
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
This captures a statement into a function.
const Expr * getCond() const
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
const CodeGenOptions & getCodeGenOpts() const
const LangOptions & getLangOpts() const
const Expr * getSubExpr() const
const Stmt * getBody() const
unsigned getNumHandlers() const
detail::InMemoryDirectory::const_iterator E
const Expr * getRetValue() const
const Stmt * getThen() const
void emitEmptyCounterMapping(const Decl *D, StringRef FuncName, llvm::GlobalValue::LinkageTypes Linkage)
Emit a coverage mapping range with a counter zero for an unused declaration.
SwitchStmt - This represents a 'switch' stmt.
Expr * getFalseExpr() const
Represents Objective-C's collection statement.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
SourceManager & getSourceManager()
DeclStmt * getRangeStmt()
GotoStmt - This represents a direct goto.
static uint32_t scaleBranchWeight(uint64_t Weight, uint64_t Scale)
Scale an individual branch weight (and add 1).
void emitCounterMapping(const Decl *D, llvm::raw_ostream &OS)
Emit the coverage mapping data which maps the regions of code to counters that will be used to find t...
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
ContinueStmt - This represents a continue.
std::string MainFileName
The user provided name for the "main file", if non-empty.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
CXXCatchStmt - This represents a C++ catch block.
WhileStmt - This represents a 'while' stmt.
const Expr * getCond() const
void ClearUnusedCoverageMapping(const Decl *D)
Remove the deferred empty coverage mapping as this declaration is actually instrumented.
CompoundStmt * getTryBlock()
uint64_t getRegionCount(const Stmt *S)
Return the region count for the counter at the given index.
BreakStmt - This represents a break.
CoverageMappingModuleGen * getCoverageMapping() const
DeclStmt * getLoopVarStmt()
llvm::IndexedInstrProfReader * getPGOReader() const
DeclStmt * getBeginStmt()
void emitEmptyMapping(const Decl *D, llvm::raw_ostream &OS)
Emit the coverage mapping data for an unused function.
This class handles loading and caching of source files into memory.