[OpaquePtr] Support forward references in textual IR

Authored by nikic on Jun 25 2021, 1:14 PM.


[OpaquePtr] Support forward references in textual IR

Currently, LLParser will create a Function/GlobalVariable forward
reference based on the desired pointer type and then modify it when
it is declared. With opaque pointers, we generally do not know the
correct type to use until we see the declaration.

Solve this by creating the forward reference with a dummy type, and
then performing a RAUW with the correct Function/GlobalVariable when
it is declared. The approach is adopted from

This results in a change to the use list order, which is why we see
test changes on some module passes that are not stable under use list

Differential Revision: https://reviews.llvm.org/D104950