-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Coverage] Introduce the type CounterPair for RegionCounterMap. NFC.
#112724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
e4172ca
03cfce1
afc8481
ce7c17d
63dbfb3
306d77f
a4f05c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -362,6 +362,8 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, | |
| return GV; | ||
| } | ||
|
|
||
| PGO.markStmtMaybeUsed(D.getInit()); // FIXME: Too lazy | ||
|
|
||
| #ifndef NDEBUG | ||
| CharUnits VarSize = CGM.getContext().getTypeSizeInChars(D.getType()) + | ||
| D.getFlexibleArrayInitChars(getContext()); | ||
|
|
@@ -1869,7 +1871,10 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { | |
| // If we are at an unreachable point, we don't need to emit the initializer | ||
| // unless it contains a label. | ||
| if (!HaveInsertPoint()) { | ||
| if (!Init || !ContainsLabel(Init)) return; | ||
| if (!Init || !ContainsLabel(Init)) { | ||
| PGO.markStmtMaybeUsed(Init); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't remember why I marked here. I was just suppressing checks when I met an issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be removed then?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be compiled as an empty body and will be pruned. I will introduce debug facility that is enabled only in +Asserts. I prioritized implementing the debug facility as low. |
||
| return; | ||
| } | ||
| EnsureInsertPoint(); | ||
| } | ||
|
|
||
|
|
@@ -1978,6 +1983,8 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { | |
| return EmitExprAsInit(Init, &D, lv, capturedByInit); | ||
| } | ||
|
|
||
| PGO.markStmtMaybeUsed(Init); | ||
|
|
||
| if (!emission.IsConstantAggregate) { | ||
| // For simple scalar/complex initialization, store the value directly. | ||
| LValue lv = MakeAddrLValue(Loc, type); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,25 @@ enum ForDefinition_t : bool { | |
| ForDefinition = true | ||
| }; | ||
|
|
||
| class CounterPair : public std::pair<uint32_t, uint32_t> { | ||
|
||
| private: | ||
| static constexpr uint32_t None = (1u << 31); /// None is set | ||
|
|
||
| public: | ||
| static constexpr uint32_t Mask = None - 1; | ||
|
|
||
| public: | ||
| CounterPair(unsigned Val = 0) { | ||
| assert(!(Val & ~Mask)); | ||
| first = Val; | ||
| second = None; | ||
| } | ||
|
|
||
| std::pair<bool, bool> getIsCounterPair() const { | ||
| return {!(first & None), !(second & None)}; | ||
| } | ||
| }; | ||
|
|
||
| struct OrderGlobalInitsOrStermFinalizers { | ||
| unsigned int priority; | ||
| unsigned int lex_order; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ class CodeGenPGO { | |
| std::array <unsigned, llvm::IPVK_Last + 1> NumValueSites; | ||
| unsigned NumRegionCounters; | ||
| uint64_t FunctionHash; | ||
| std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>> RegionCounterMap; | ||
| std::unique_ptr<llvm::DenseMap<const Stmt *, CounterPair>> RegionCounterMap; | ||
| std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap; | ||
| std::unique_ptr<llvm::InstrProfRecord> ProfRecord; | ||
| std::unique_ptr<MCDC::State> RegionMCDCState; | ||
|
|
@@ -110,6 +110,7 @@ class CodeGenPGO { | |
| bool canEmitMCDCCoverage(const CGBuilderTy &Builder); | ||
|
|
||
| public: | ||
| std::pair<bool, bool> getIsCounterPair(const Stmt *S) const; | ||
| void emitCounterSetOrIncrement(CGBuilderTy &Builder, const Stmt *S, | ||
| llvm::Value *StepV); | ||
| void emitMCDCTestVectorBitmapUpdate(CGBuilderTy &Builder, const Expr *S, | ||
|
|
@@ -122,6 +123,18 @@ class CodeGenPGO { | |
| Address MCDCCondBitmapAddr, llvm::Value *Val, | ||
| CodeGenFunction &CGF); | ||
|
|
||
| void markStmtAsUsed(bool Skipped, const Stmt *S) { | ||
| // Do nothing. | ||
| } | ||
|
|
||
| void markStmtMaybeUsed(const Stmt *S) { | ||
| // Do nothing. | ||
| } | ||
|
|
||
| void verifyCounterMap() { | ||
|
||
| // Do nothing. | ||
| } | ||
|
|
||
| /// Return the region count for the counter at the given index. | ||
| uint64_t getRegionCount(const Stmt *S) { | ||
| if (!RegionCounterMap) | ||
|
|
@@ -130,7 +143,7 @@ class CodeGenPGO { | |
| return 0; | ||
| // With profiles from a differing version of clang we can have mismatched | ||
| // decl counts. Don't crash in such a case. | ||
| auto Index = (*RegionCounterMap)[S]; | ||
| auto Index = (*RegionCounterMap)[S].first; | ||
| if (Index >= RegionCounts.size()) | ||
| return 0; | ||
| return RegionCounts[Index]; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.