================
@@ -36,6 +36,8 @@ class CodeGenPGO {
unsigned NumRegionCounters;
uint64_t FunctionHash;
std::unique_ptr<llvm::DenseMap<const Stmt *, CounterPair>> RegionCounterMap;
+ std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>>
+ CallContinuationCounterMap;
----------------
ankurrj7 wrote:
I started looking into this direction, and I think I see one case that makes
the direct fold
into RegionCounterMap tricky.
For a simple call like:
f();
return 1;
I agree the continuation counter can naturally be the Executed side of a
CounterPair, with
Skipped left as None. That part makes sense.
The problem I hit is when the same CallExpr already needs a normal counter
for condition/
branch coverage. For example:
if (returns_twice() && g())
return 1;
Here the RHS call `g()` already uses RegionCounterMap today so coverage can
model the
logical operator result. Roughly, that counter is about whether the RHS
condition evaluated
true/false.
But the call-continuation counter is a different thing: it means ?control
returned normally
after `g()`?. If `g()` returns 0, the call did return normally, but the
condition is false.
So the continuation count is not the same as the branch executed count.
That gives us two different meanings for the same CallExpr: the existing
condition counter,
and the continuation-after-call counter. Since RegionCounterMap is keyed by
Stmt*, a direct
`RegionCounterMap[CallExpr] = CounterPair(continuation)` would
overwrite/confuse the
existing condition counter in this case.
Maybe there is still a cleaner region-based way to represent this, but this
is the case that
made me hesitate before collapsing the separate map directly.
https://github.com/llvm/llvm-project/pull/201079
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits