[llvm] [IR] Allow type change in ValueAsMetadata::handleRAUW (PR #76969)

Jannik Silvanus via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 07:45:47 PST 2024


jasilvanus wrote:

> Would it be possible for you to add unittest showing this in action? Otherwise SGTM.

Will do.

> though if your case only involves poison types, it might be safer to change the assert to: `assert((isa<PoisonValue>(To->getType()) || From->getType() == To->getType()) && "Expected same or poison type");` This wouldn't weaken the existing guarantees very much, while enabling your use case if I understand correctly 

I considered this, but I think such a constraint would be a bit arbitrary.  What about `undef`? Zero?  There doesn't seem to be a fundamental reason to forbid such type changes.

> - if it's necessary or more convenient to use the existing approach though then I have no objections, though as above adding a motivating test case would be good.

I'll add a test case, but it'll only exercise usage rather then giving a true motivation.

To put our application outlined in the PR description in other words, we are using `poison` ValueAsMetadata values to essentially build a fake `TypeAsMetadata`, and changing such type metadata requires to change the type of the used underlying `ValueAsMetadata` nodes.

https://github.com/llvm/llvm-project/pull/76969


More information about the llvm-commits mailing list