[PATCH] D84378: [PGO] Fix incorrect function entry count
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 09:53:52 PDT 2020
davidxl added inline comments.
================
Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:1144
+ // Fix it if necessary.
+ if (InstrBB == FuncEntry && CountValue == 0)
+ CountValue = 1;
----------------
xur wrote:
> davidxl wrote:
> > add comment here about the root cause: counter cleared before dump.
> >
> > If counter promotion is disabled, in what situation entry count can not be recovered with propagation?
> >
> This is independent of count promotion. Usually the entry count is not promoted (unless it's inlined to a callsite inside a loop).
>
> This code here is for the case when we instrument the entry BB. If the entry BB is instrumented, it cannot be computed from propagation. (MST does not have the redundancy to recover)
>
> Typically, it happens this way: for a func with a long running loop, after we reset the counter, the entry counters of this func are also zeroed out. If we dump the counters in the middle of the loop, the entry count will still be 0.
>
> If we promote the counters inside the loop, the counter value inside the loop will be 0 (because the updates are in the exit block -- never exercised). If we disable the promote, the counter value insides the loop are OK.
ok. what if entry is not instrumented, but two post-dom successors? If they are zeroed out, is there a way to recover?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84378/new/
https://reviews.llvm.org/D84378
More information about the llvm-commits
mailing list