The current condition looks overly conservative.
I don't see why an IMPLICIT_DEF, for instance, should clear the folding candidate set, and the same for KILL.
Two things I'm not sure of:
- Should isPosition() be a barrier?
- Is the explicit check for isInlineAsm() really necessary? (InlineAsm should correctly report mayStore()/hasUnmodeledSideEffects(), right?)
Andrew, I've added you to the review because of the rdar mentioned in the test-case. The folding there currently didn't happen due to an intervening IMPLICIT_DEF, and not because of any scheduling issues. Am I missing something?