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) {
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) {
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) {
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;
465 BreakContinueStack.push_back(BreakContinue());
468 BreakContinue BC = BreakContinueStack.pop_back_val();
469 if (!BreakContinueStack.empty())
470 BreakContinueStack.back().ContinueCount += BC.ContinueCount;
472 setCount(PGO.getRegionCount(S));
473 RecordNextStmtCount =
true;
477 RecordNextStmtCount =
false;
481 uint64_t CaseCount = PGO.getRegionCount(S);
482 setCount(CurrentCount + CaseCount);
485 CountMap[
S] = CaseCount;
486 RecordNextStmtCount =
true;
490 void VisitIfStmt(
const IfStmt *S) {
492 uint64_t ParentCount = CurrentCount;
499 uint64_t ThenCount = setCount(PGO.getRegionCount(S));
500 CountMap[S->
getThen()] = ThenCount;
502 uint64_t OutCount = CurrentCount;
504 uint64_t ElseCount = ParentCount - ThenCount;
507 CountMap[S->
getElse()] = ElseCount;
509 OutCount += CurrentCount;
511 OutCount += ElseCount;
513 RecordNextStmtCount =
true;
522 setCount(PGO.getRegionCount(S));
523 RecordNextStmtCount =
true;
527 RecordNextStmtCount =
false;
529 uint64_t CatchCount = setCount(PGO.getRegionCount(S));
530 CountMap[
S] = CatchCount;
536 uint64_t ParentCount = CurrentCount;
541 uint64_t TrueCount = setCount(PGO.getRegionCount(E));
544 uint64_t OutCount = CurrentCount;
546 uint64_t FalseCount = setCount(ParentCount - TrueCount);
549 OutCount += CurrentCount;
552 RecordNextStmtCount =
true;
557 uint64_t ParentCount = CurrentCount;
560 uint64_t RHSCount = setCount(PGO.getRegionCount(E));
561 CountMap[E->
getRHS()] = RHSCount;
563 setCount(ParentCount + RHSCount - CurrentCount);
564 RecordNextStmtCount =
true;
569 uint64_t ParentCount = CurrentCount;
572 uint64_t RHSCount = setCount(PGO.getRegionCount(E));
573 CountMap[E->
getRHS()] = RHSCount;
575 setCount(ParentCount + RHSCount - CurrentCount);
576 RecordNextStmtCount =
true;
581 void PGOHash::combine(HashType
Type) {
583 assert(Type &&
"Hash is invalid: unexpected type 0");
584 assert(
unsigned(Type) < TooBig &&
"Hash is invalid: too many types");
587 if (Count && Count % NumTypesPerWord == 0) {
588 using namespace llvm::support;
589 uint64_t Swapped = endian::byte_swap<uint64_t, little>(Working);
590 MD5.update(llvm::makeArrayRef((uint8_t *)&Swapped,
sizeof(Swapped)));
596 Working = Working << NumBitsPerType | Type;
599 uint64_t PGOHash::finalize() {
601 if (Count <= NumTypesPerWord)
612 llvm::MD5::MD5Result
Result;
614 using namespace llvm::support;
624 llvm::IndexedInstrProfReader *PGOReader = CGM.
getPGOReader();
625 if (!InstrumentRegions && !PGOReader)
636 if (
const auto *CCD = dyn_cast<CXXConstructorDecl>(D))
644 mapRegionCounters(D);
646 emitCounterRegionMapping(D);
650 computeRegionCounts(D);
651 applyFunctionAttributes(PGOReader, Fn);
655 void CodeGenPGO::mapRegionCounters(
const Decl *D) {
656 RegionCounterMap.reset(
new llvm::DenseMap<const Stmt *, unsigned>);
657 MapRegionCounters Walker(*RegionCounterMap);
658 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
659 Walker.TraverseDecl(const_cast<FunctionDecl *>(FD));
660 else if (
const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
661 Walker.TraverseDecl(const_cast<ObjCMethodDecl *>(MD));
662 else if (
const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D))
663 Walker.TraverseDecl(const_cast<BlockDecl *>(BD));
664 else if (
const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D))
665 Walker.TraverseDecl(const_cast<CapturedDecl *>(CD));
666 assert(Walker.NextCounter > 0 &&
"no entry counter mapped for decl");
667 NumRegionCounters = Walker.NextCounter;
668 FunctionHash = Walker.Hash.finalize();
671 bool CodeGenPGO::skipRegionMappingForDecl(
const Decl *D) {
681 void CodeGenPGO::emitCounterRegionMapping(
const Decl *D) {
682 if (skipRegionMappingForDecl(D))
685 std::string CoverageMapping;
686 llvm::raw_string_ostream OS(CoverageMapping);
693 if (CoverageMapping.empty())
697 FuncNameVar, FuncName, FunctionHash, CoverageMapping);
702 llvm::GlobalValue::LinkageTypes Linkage) {
703 if (skipRegionMappingForDecl(D))
706 std::string CoverageMapping;
707 llvm::raw_string_ostream OS(CoverageMapping);
714 if (CoverageMapping.empty())
717 setFuncName(Name, Linkage);
719 FuncNameVar, FuncName, FunctionHash, CoverageMapping,
false);
722 void CodeGenPGO::computeRegionCounts(
const Decl *D) {
723 StmtCountMap.reset(
new llvm::DenseMap<const Stmt *, uint64_t>);
724 ComputeRegionCounts Walker(*StmtCountMap, *
this);
725 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
726 Walker.VisitFunctionDecl(FD);
727 else if (
const ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(D))
728 Walker.VisitObjCMethodDecl(MD);
729 else if (
const BlockDecl *BD = dyn_cast_or_null<BlockDecl>(D))
730 Walker.VisitBlockDecl(BD);
731 else if (
const CapturedDecl *CD = dyn_cast_or_null<CapturedDecl>(D))
732 Walker.VisitCapturedDecl(const_cast<CapturedDecl *>(CD));
736 CodeGenPGO::applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
737 llvm::Function *Fn) {
742 Fn->setEntryCount(FunctionCount);
749 if (!Builder.GetInsertBlock())
752 unsigned Counter = (*RegionCounterMap)[
S];
755 llvm::Value *Args[] = {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
756 Builder.getInt64(FunctionHash),
757 Builder.getInt32(NumRegionCounters),
758 Builder.getInt32(Counter), StepV};
760 Builder.CreateCall(CGM.
getIntrinsic(llvm::Intrinsic::instrprof_increment),
761 makeArrayRef(Args, 4));
764 CGM.
getIntrinsic(llvm::Intrinsic::instrprof_increment_step),
771 llvm::Instruction *ValueSite,
llvm::Value *ValuePtr) {
776 if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock())
779 if (isa<llvm::Constant>(ValuePtr))
783 if (InstrumentValueSites && RegionCounterMap) {
784 auto BuilderInsertPoint = Builder.saveIP();
785 Builder.SetInsertPoint(ValueSite);
787 llvm::ConstantExpr::getBitCast(FuncNameVar, Builder.getInt8PtrTy()),
788 Builder.getInt64(FunctionHash),
789 Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()),
790 Builder.getInt32(ValueKind),
791 Builder.getInt32(NumValueSites[ValueKind]++)
794 CGM.
getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args);
795 Builder.restoreIP(BuilderInsertPoint);
799 llvm::IndexedInstrProfReader *PGOReader = CGM.
getPGOReader();
807 if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind))
810 llvm::annotateValueSite(CGM.
getModule(), *ValueSite, *ProfRecord,
811 (llvm::InstrProfValueKind)ValueKind,
812 NumValueSites[ValueKind]);
814 NumValueSites[ValueKind]++;
818 void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
821 RegionCounts.clear();
823 PGOReader->getInstrProfRecord(FuncName, FunctionHash);
824 if (
auto E = RecordExpected.takeError()) {
825 auto IPE = llvm::InstrProfError::take(std::move(E));
826 if (IPE == llvm::instrprof_error::unknown_function)
828 else if (IPE == llvm::instrprof_error::hash_mismatch)
830 else if (IPE == llvm::instrprof_error::malformed)
836 llvm::make_unique<llvm::InstrProfRecord>(std::move(RecordExpected.get()));
837 RegionCounts = ProfRecord->Counts;
845 return MaxWeight < UINT32_MAX ? 1 : MaxWeight / UINT32_MAX + 1;
858 assert(Scale &&
"scale by 0?");
859 uint64_t Scaled = Weight / Scale + 1;
860 assert(Scaled <= UINT32_MAX &&
"overflow 32-bits");
864 llvm::MDNode *CodeGenFunction::createProfileWeights(uint64_t TrueCount,
865 uint64_t FalseCount) {
867 if (!TrueCount && !FalseCount)
881 if (Weights.size() < 2)
885 uint64_t MaxWeight = *std::max_element(Weights.begin(), Weights.end());
893 ScaledWeights.reserve(Weights.size());
894 for (uint64_t W : Weights)
898 return MDHelper.createBranchWeights(ScaledWeights);
901 llvm::MDNode *CodeGenFunction::createProfileWeightsForLoop(
const Stmt *Cond,
902 uint64_t LoopCount) {
906 assert(CondCount.hasValue() &&
"missing expected loop condition count");
909 return createProfileWeights(LoopCount,
910 std::max(*CondCount, LoopCount) - LoopCount);
Optional< uint64_t > getStmtCount(const Stmt *S)
Check if an execution count is known for a given statement.
StmtClass getStmtClass() const
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()
Stmt - This represents one statement.
CXXCatchStmt * getHandler(unsigned i)
IfStmt - This represents an if/then/else.
Organizes the per-function state that is used while generating code coverage mapping data...
Decl - This represents one declaration (or definition), e.g.
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
void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S, llvm::Value *StepV)
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.
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
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
const Decl * getDecl() const
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Expr * getTrueExpr() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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)
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.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
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.
static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor)
Checks whether the given constructor is a valid subject for the complete-to-base constructor delegati...
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()
SourceLocation getLocation() const
llvm::IndexedInstrProfReader * getPGOReader() const
DeclStmt * getBeginStmt()
void emitEmptyMapping(const Decl *D, llvm::raw_ostream &OS)
Emit the coverage mapping data for an unused function.
SourceLocation getLocStart() const LLVM_READONLY
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
This class handles loading and caching of source files into memory.