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

Wende Tan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 14:50:07 PDT 2022


twd2 added a comment.

In D124878#3492365 <https://reviews.llvm.org/D124878#3492365>, @twd2 wrote:

> In D124878#3489625 <https://reviews.llvm.org/D124878#3489625>, @nickdesaulniers wrote:
>
>> Thanks for the patch! Indeed, the `users` _might_ be `Constant`s rather than just `Instructions`.  One thing to think about is that you can declare global `Constants`. I used the `dyn_cast<Instruction>` to check that this was not the case. I think you'll need to differentiate that, too. Meaning, if the user is a Constant, are the Constant's users Instructions (or not if simply GlobalVar).
>
> The users of `Constant`s are not only `Instruction`s and `GlobalValue`s, but also other `Constant`s.
> For example, in rickyz's original reproducing code, the only user of `i8* blockaddress(@repro, %label)` is a `ConstantExpr`, `i64 ptrtoint (i8* blockaddress(@repro, %label) to i64)`.
> This `ConstantExpr` will not pass the `dyn_cast<Instruction>` check, and no `Instruction` will be encoded in the bitcode.
> Further, the only user of `i64 ptrtoint (... to i64)` is also a `ConstantExpr`, `i64 add (i64 ptrtoint (i8* blockaddress(@repro, %label) to i64), i64 1)`.
> Finally, the only user of `i64 add (..., i64 1)` is the `tail call ...` `Instruction` in `Function` `@fun`.
> We should find this `Instruction` and add the `Function` into the bitcode.
>
> So, we might have to do a searching loop to first identify what `Constant`s (directly or recursively) use the given `BlockAddress`, and what `Instruction`s (`Function`s) use these `Constant`s, as my patch proposes.

This may visit some `Constant`s that are not used by `Instruction`s (e.g., used by `GlobalValue`s) at the end, but I'm afraid that we have to visit them before getting the ultimate users.


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

https://reviews.llvm.org/D124878



More information about the llvm-commits mailing list