summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.h
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2014-08-04 18:41:51 +0000
committerAlex Lorenz <arphaman@gmail.com>2014-08-04 18:41:51 +0000
commitee02499a8fb64f9710b4543f2f46c5305dcb11fc (patch)
tree65514c3a36a4efeb1f20869ef94c33b107632ac2 /clang/lib/CodeGen/CodeGenPGO.h
parent1193b5e272db7aa969380e95503b2512d3f17270 (diff)
downloadbcm5719-llvm-ee02499a8fb64f9710b4543f2f46c5305dcb11fc.tar.gz
bcm5719-llvm-ee02499a8fb64f9710b4543f2f46c5305dcb11fc.zip
Add coverage mapping generation.
This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
Diffstat (limited to 'clang/lib/CodeGen/CodeGenPGO.h')
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h
index 2f4aa660bea..698b0c06965 100644
--- a/clang/lib/CodeGen/CodeGenPGO.h
+++ b/clang/lib/CodeGen/CodeGenPGO.h
@@ -42,11 +42,16 @@ private:
std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap;
std::unique_ptr<std::vector<uint64_t>> RegionCounts;
uint64_t CurrentRegionCount;
+ std::string CoverageMapping;
+ /// \brief A flag that is set to true when this function doesn't need
+ /// to have coverage mapping data.
+ bool SkipCoverageMapping;
public:
CodeGenPGO(CodeGenModule &CGM)
: CGM(CGM), NumRegionCounters(0), FunctionHash(0),
- RegionCounters(nullptr), CurrentRegionCount(0) {}
+ RegionCounters(nullptr), CurrentRegionCount(0),
+ SkipCoverageMapping(false) {}
/// Whether or not we have PGO region data for the current function. This is
/// false both when we have no data at all and when our data has been
@@ -99,6 +104,8 @@ public:
llvm::MDNode *createBranchWeights(ArrayRef<uint64_t> Weights);
llvm::MDNode *createLoopWeights(const Stmt *Cond, RegionCounter &Cnt);
+ /// Check if we need to emit coverage mapping for a given declaration
+ void checkGlobalDecl(GlobalDecl GD);
/// Assign counters to regions and configure them for PGO of a given
/// function. Does nothing if instrumentation is not enabled and either
/// generates global variables or associates PGO data with each of the
@@ -111,9 +118,14 @@ public:
void destroyRegionCounters();
/// Emit static initialization code, if any.
static llvm::Function *emitInitialization(CodeGenModule &CGM);
-
+ /// Emit a coverage mapping range with a counter zero
+ /// for an unused declaration.
+ void emitEmptyCounterMapping(const Decl *D, StringRef FuncName,
+ llvm::GlobalValue::LinkageTypes Linkage);
private:
void setFuncName(llvm::Function *Fn);
+ void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes Linkage);
+ void setVarLinkage(llvm::GlobalValue::LinkageTypes Linkage);
void mapRegionCounters(const Decl *D);
void computeRegionCounts(const Decl *D);
void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
@@ -122,6 +134,7 @@ private:
bool IsInMainFile);
void emitCounterVariables();
llvm::GlobalVariable *buildDataVar();
+ void emitCounterRegionMapping(const Decl *D);
/// Emit code to increment the counter at the given index
void emitCounterIncrement(CGBuilderTy &Builder, unsigned Counter);
OpenPOWER on IntegriCloud