On Fri Apr 5 12:22:58 2024 +0000, Giovanni Mascellani wrote:
Could you copy the source as well? I would like to assume anything at all about what later passes will do on the program. For example, suppose that we have a program like this:
add sr3, sr2, |sr1| ... add sr5, sr4, |sr1|
Now imagine that we later introduce a pass that wants to rewrite the abs operation as a separate operator. It should be legitimate to change the above code to:
add sr3, sr2, |sr1| ... abs sr6, sr1 add sr5, sr4, sr6
If the two occurrences of `|sr1|` happen to be pointers to the same object, the code would actually become this, which is invalid:
add sr3, sr2, sr6 ... abs sr6, sr1 add sr5, sr4, sr6
Of course it might be pointed out that this pass might as well move the abs operation above the first `sr1` usage, since if you're changing one of them you probably want to change all of them, but my point is that I wouldn't want to assume it. The change I said is sound and a pass should legitimately be able to do it without making the program invalid. For this to be reasonably ensured, there must be no aliasing between different parameters.
In other words, assuming they are unrelated would itself be an error.
This is a concern for any other pass that touches that parameter. And, as I said, the fact that two parameters are related doesn't mean you'll want to do the same changes on all of them.
The sources were allocated as part of the phi instruction, so they are not shared once the phi is deleted.