[PATCH] D124878: [Bitcode] Include indirect users of BlockAddresses in bitcode

Wende Tan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 15:43:50 PDT 2022


twd2 added a comment.

In D124878#3492498 <https://reviews.llvm.org/D124878#3492498>, @dexonsmith wrote:

> At a high-level, the design for writing bitcode is a two-pass traversal algorithm:
>
> - First pass in ValueEnumerator indexes everything
> - Second pass in BitcodeWriter writes things
>
> It feels like this new logic could be put into the first pass in ValueEnumerator. (Probably the previous patch, which this builds on, should have done that as well, to avoid iterating over `users()` in BitcodeWriter, but I guess I didn't notice!)

I just tried your advice to update this patch (not uploaded yet) but found the existing logic is

  for each function
      incorporateFunction, which enumerates function-local constants, including BlockAddresses, and maintains the users of referred foreign functions
      writeFunction, which emits BLOCKADDR_USERS records and the function-local constants

However, for every function, before emitting BLOCKADDR_USERS records, we should expect that we have visited all the constants, including function-local ones, and thus we have collected all the users of the blockaddresses in the function.

Can we enumerate (and thus emit) all the constants at the beginning, or add a traversing loop dedicated to collecting the users of blockaddresses?
The latter will touch all the constants one more time.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124878/new/

https://reviews.llvm.org/D124878



More information about the llvm-commits mailing list