When replacing a value that's referred to by module metadata, one needs to use RAUW to update that metadata. RAUW however doesn't work when the type of the value changes, e.g., when replacing a function with one that takes an additional argument. This kind of IR happens with e.g. the nvvm.annotations metadata, which contains a reference to a LLVM::Function value. It seems to make sense to relax the type equality assertion when only replacing values in metadata (see also: https://discourse.llvm.org/t/replacing-module-metadata-uses-of-function/62431). This change does exactly that, while additionally exposing that functionality to C.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Since there have been no other reactions and I think this is a reasonable patch, I’ll accept it.
Please wait a day before submitting it in case others have comments.
Comment Actions
I don't think this change makes sense on a couple of levels:
- I don't believe that ValueAsMetadata::handleRAUW() is intended as a public API at all.
- The original problem seems like a bug in GlobalDCE -- did anyone investigate why it happens?
- With opaque pointers the replacement doesn't use a bitcast anyway, so the issue is "fixed" as a side-effect. As this API will only go into LLVM 15, it would not be useful.