summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-12-17 23:55:04 +0000
committerJustin Bogner <mail@justinbogner.com>2014-12-17 23:55:04 +0000
commit8e015ff43bd844480fb33eb1ff0aec9826361f1a (patch)
tree2676feddc00ba39841a9c5aec9581586f073a38d /clang/lib/CodeGen/CoverageMappingGen.cpp
parentd1cdcb237713946e964c8de18759752697494227 (diff)
downloadbcm5719-llvm-8e015ff43bd844480fb33eb1ff0aec9826361f1a.tar.gz
bcm5719-llvm-8e015ff43bd844480fb33eb1ff0aec9826361f1a.zip
InstrProf: Simplify/reduce state in CoverageMapping (NFC)
This state object makes things harder to reason about and isn't really useful, since we can just emit the mappings before the state changes rather than holding on to it. llvm-svn: 224476
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp40
1 files changed, 2 insertions, 38 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index ac0c22cbebe..ada3a2de1db 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -117,19 +117,6 @@ public:
}
};
-/// \brief The state of the coverage mapping builder.
-struct SourceMappingState {
- Counter CurrentRegionCount;
- const Stmt *CurrentSourceGroup;
- const Stmt *CurrentUnreachableRegionInitiator;
-
- SourceMappingState(Counter CurrentRegionCount, const Stmt *CurrentSourceGroup,
- const Stmt *CurrentUnreachableRegionInitiator)
- : CurrentRegionCount(CurrentRegionCount),
- CurrentSourceGroup(CurrentSourceGroup),
- CurrentUnreachableRegionInitiator(CurrentUnreachableRegionInitiator) {}
-};
-
/// \brief Provides the common functionality for the different
/// coverage mapping region builders.
class CoverageMappingBuilder {
@@ -358,14 +345,6 @@ public:
Flags);
}
- void mapSourceCodeRange(const SourceMappingState &State,
- SourceLocation LocStart, SourceLocation LocEnd,
- unsigned Flags = 0) {
- mapSourceCodeRange(LocStart, LocEnd, State.CurrentRegionCount,
- State.CurrentUnreachableRegionInitiator,
- State.CurrentSourceGroup, Flags);
- }
-
/// \brief Generate the coverage counter mapping regions from collected
/// source regions.
void emitSourceRegions() {
@@ -597,12 +576,6 @@ struct CounterCoverageMappingBuilder
Writer.write(OS);
}
- /// \brief Return the current source mapping state.
- SourceMappingState getCurrentState() const {
- return SourceMappingState(CurrentRegionCount, CurrentSourceGroup,
- CurrentUnreachableRegionInitiator);
- }
-
/// \brief Associate the source code range with the current region count.
void mapSourceCodeRange(SourceLocation LocStart, SourceLocation LocEnd,
unsigned Flags = 0) {
@@ -625,11 +598,6 @@ struct CounterCoverageMappingBuilder
SourceMappingRegion::IgnoreIfNotExtended);
}
- void mapToken(const SourceMappingState &State, SourceLocation LocStart) {
- CoverageMappingBuilder::mapSourceCodeRange(
- State, LocStart, LocStart, SourceMappingRegion::IgnoreIfNotExtended);
- }
-
void VisitStmt(const Stmt *S) {
mapSourceCodeRange(S->getLocStart());
for (Stmt::const_child_range I = S->children(); I; ++I) {
@@ -658,14 +626,12 @@ struct CounterCoverageMappingBuilder
}
void VisitCompoundStmt(const CompoundStmt *S) {
- SourceMappingState State = getCurrentState();
mapSourceCodeRange(S->getLBracLoc());
+ mapSourceCodeRange(S->getRBracLoc());
for (Stmt::const_child_range I = S->children(); I; ++I) {
if (*I)
this->Visit(*I);
}
- CoverageMappingBuilder::mapSourceCodeRange(State, S->getRBracLoc(),
- S->getRBracLoc());
}
void VisitReturnStmt(const ReturnStmt *S) {
@@ -917,7 +883,7 @@ struct CounterCoverageMappingBuilder
void VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
Visit(E->getCond());
mapToken(E->getQuestionLoc());
- auto State = getCurrentState();
+ mapToken(E->getColonLoc());
// Counter tracks the "true" part of a conditional operator. The
// count in the "false" part will be calculated from this counter.
@@ -926,8 +892,6 @@ struct CounterCoverageMappingBuilder
Visit(E->getTrueExpr());
Cnt.adjustForControlFlow();
- mapToken(State, E->getColonLoc());
-
Cnt.beginElseRegion();
Visit(E->getFalseExpr());
Cnt.adjustForControlFlow();
OpenPOWER on IntegriCloud