This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Bugfix in adjustSubwordCmp()
ClosedPublic

Authored by jonpa on Nov 28 2017, 12:07 AM.

Details

Reviewers
uweigand
Summary

When the new zero-extending load is created, the (chain) users of the original load must be updated, which was not done previously.

Csmith discovered a program where a following store to the same address did not get chained after the new load, and so performed an illegal overwrite of the expected value.

To me, it seems necessary to update all users with both the loaded value and chain. This is not done automatically, since the load is an operand of the node returned.

I have found one other similar case which I suspect should also be fixed (?): lowerBITCAST().

Diff Detail

Event Timeline

jonpa created this revision.Nov 28 2017, 12:07 AM
uweigand accepted this revision.Nov 28 2017, 11:54 AM

Yes, this looks good to me. I agree that lowerBITCAST probably needs to be fixed as well.

This revision is now accepted and ready to land.Nov 28 2017, 11:54 AM
uweigand requested changes to this revision.Nov 28 2017, 12:11 PM

Actually, I take it back, sorry ...

I think replacing the *value* of the load is wrong. Note that the new load may actually use a different result type, which wouldn't match the original user of the value. Now, normally, that user will get removed once we emit the new comparison. But (at least in principle) it is possible to call getCmp without calling emitCmp afterwards. And even if you do, the DAG would be somewhat inconsistent at least in the interim.

So I'm wondering if the right fix isn't to only replace the *chain* users? Then you'd have in the interim simply two loads chained together, and later on one of them will be eliminated again (the original one if emitCmp is called, the new one if it isn't).

This revision now requires changes to proceed.Nov 28 2017, 12:11 PM
jonpa updated this revision to Diff 124701.Nov 29 2017, 1:09 AM
jonpa edited edge metadata.

So I'm wondering if the right fix isn't to only replace the *chain* users?

Hmm, yes I think you are right. I must have missed the point that the original load may actually remain... (plus the fact that it only has one user)

Patch updated to only update the chain users, and also to do this in lowerBITCAST().

uweigand accepted this revision.Nov 29 2017, 9:48 AM

This LGTM now, thanks!

This revision is now accepted and ready to land.Nov 29 2017, 9:48 AM
jonpa closed this revision.Nov 30 2017, 12:20 AM

r319409