[PATCH] D75341: [BFI] Use CallbackVH to notify BFI about deletion of basic blocks

Daniil Suchkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 04:59:57 PST 2020


DaniilSuchkov created this revision.
DaniilSuchkov added reviewers: davidxl, yamauchi, asbirlea, fhahn, fedor.sergeev.
Herald added a project: LLVM.

With AssertingVHs instead of bare pointers in BlockFrequencyInfoImpl::Nodes (but without CallbackVHs) ~1/36 of all tests ran by `make check` fail (in my setup it's 1042 out of 36257). It means that there are users of BFI that delete basic blocks while keeping BFI. Some of those transformations add new basic blocks, so if a new basic block happens to be allocated at address where an already deleted block was and we don't explicitly set block frequency for that new block, BFI will report some non-default frequency for the block even though frequency for the block was never set. Inliner is an example of a transformation that adds and removes BBs while querying and updating BFI, however I can't provide a test case that would show non-deterministic inlining caused by this issue.

About considerable amount of const_casts in this patch: any ideas on how they can be avoided or at least reduced in number are welcome. Problem is that many users of BFI have only const references to Function, so the amount of changes required to pass non-const references/pointers to Function/BasicBlocks to BFI is pretty large and involves things like giving MachineFunction non-const reference to Function.


https://reviews.llvm.org/D75341

Files:
  llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75341.247200.patch
Type: text/x-patch
Size: 4922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200228/c07759f5/attachment.bin>


More information about the llvm-commits mailing list