This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Protect against more poison in SimplifyWithOpReplaced (PR47322)
ClosedPublic

Authored by nikic on Aug 29 2020, 2:00 AM.

Details

Summary

Replace the check for poison-producing instructions in SimplifyWithOpReplaced() with the generic helper canCreatePoison() that properly handles poisonous shifts and thus avoids the problem from PR47322.

I should say that this is not really a full solution, more a minimal fix that is easy to backport to the release branch.

Diff Detail

Event Timeline

nikic created this revision.Aug 29 2020, 2:00 AM
nikic requested review of this revision.Aug 29 2020, 2:00 AM
aqjune added inline comments.Aug 29 2020, 2:43 AM
llvm/lib/Analysis/InstructionSimplify.cpp
3799

This diff has a side effect when IIQ's UseInstrInfo is false (and I think it is okay because this change leads to less potential poison-related problems, but) when is the flag set to false?

nikic added a subscriber: fhahn.Aug 29 2020, 4:06 AM
nikic added inline comments.
llvm/lib/Analysis/InstructionSimplify.cpp
3799

Yes, this is intentional. UseInstrInfo=false should result in less folds, not more. It may be even more correct to check for || !Q.IIQ.UseInstrInfo here, i.e. make the conservative assumption that the instruction does have poison flags, if we are not allowed to inspect the actual poison flags on the instruction.

Maybe @fhahn can tell whether this is necessary.

fhahn added inline comments.Aug 29 2020, 4:09 AM
llvm/lib/Analysis/InstructionSimplify.cpp
3799

when is the flag set to false?

It was added for NewGVN, which uses the Simplify* helpers with leader values from the corresponding congruence classes, but there is no guarantee that the final of the simplified instruction is dominated by those particular instructions which has this metadata.

aqjune accepted this revision.Aug 29 2020, 8:32 AM

The change looks good to me.

llvm/lib/Analysis/InstructionSimplify.cpp
3799

Thanks for the explanation! :)
For people who's seeing this patch - a relevant bug is https://llvm.org/pr37540 .

This revision is now accepted and ready to land.Aug 29 2020, 8:32 AM