[PATCH] D141579: [PGO] incorrect classof in InstrProfIncrementInst
ZhouKui via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 16 23:03:31 PST 2023
KuiChou added a comment.
In D141579#4047994 <https://reviews.llvm.org/D141579#4047994>, @ellis wrote:
> Ah, I see the `dyn_cast` you are talking about is here <https://github.com/llvm/llvm-project/blob/9f1bb307da6fec6fc8123bdec79ecec28fced874/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L548-L549>. I think this is only a problem if `InstrProfIncrementInstStep` is the only InstrProf instruction in a function **and** it has an `llvm.instrprof.value.profile` instruction, which explains why we didn't catch this bug for so long. In that case, the later call to `getOrCreateRegionCounters()` will be skipped and, according to the comment, this is required for value profiling. Is that what you observed? If so it should be easy to add a small test case, probably similar to `llvm/test/Instrumentation/InstrProfiling/early-exit.ll`, but this could be followed up in another patch. Thanks for fixing!
Yes. But even if `InstrProfIncrementInstStep` is the only InstrProf instruction in a function, `getOrCreateRegionCounters` will still be called through `InstrProfiling::run` -> `lowerIntrinsics` -> `lowerIncrement` -> `getCounterAddress` -> `getOrCreateRegionCounters`. So, to reproduce this problem, we should satisfy two conditions:
1. `InstrProfIncrementInstStep` is the only InstrProf instruction in a function **and** it has `InstrProfValueProfileInst` instruction
2. `InstrProfValueProfileInst` must be **in front of** `InstrProfIncrementInstStep` instruction
PGO will always generate an `InstrProfIncrementInst` instruction in the front of a function so normally, this bug cannot happen
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141579/new/
https://reviews.llvm.org/D141579
More information about the llvm-commits
mailing list