[PATCH] D120781: [IRLinker] materialize Functions before moving any

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 4 14:51:18 PST 2022


dexonsmith added a comment.

In D120781#3358338 <https://reviews.llvm.org/D120781#3358338>, @tejohnson wrote:

> I'm having a difficult time figuring out how to solve the issue in the face of new functions being added to the worklist during mapping, without either passing the value map down to the bitcode reader, or maybe it would be better to add a callback that can be used to have the IRLinker tell the bitcode reader block address parsing what to do and do the mapping if the function has been materialized?

I think the callback option would work. One concern (with either solution) is we need to be sure that the function we point the `blockaddress` at actually came from this bitcode file (otherwise, I think it could lead to hard-to-reason about miscompiles).

A related idea: when the IRMover moves content from one function to another, leave behind a `Function*` in the moved-from function that the bitcodereader knows how to find (not sure exactly where to store it, but I think the place to do the work is in `IRLinker::linkFunctionBody()`, something like `Src.recordMovedToFunction(Dst)`). Unlike ValueMapper, this would not have a mapping in the "function replaced" case where it seems more likely to lead to miscompiles.

But maybe your callback option is better. I'm not sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120781



More information about the llvm-commits mailing list