This is an archive of the discontinued LLVM Phabricator instance.

[JumpThreading] Fix an incorrect Modified status
ClosedPublic

Authored by dstenb on Sep 9 2020, 9:30 AM.

Details

Summary

This fixes PR47297.

When ProcessBlock() was able to constant fold the terminator's
condition, but not do any more transformations, the function would
return false, which would lead to the JumpThreading pass returning an
incorrect modified status. This patch makes so that ProcessBlock()
returns true in such cases. This will trigger an unnecessary invocation
of ProcessBlock() in such cases, but this should be rare to occur.

This was caught using the check introduced by D80916.

Diff Detail

Event Timeline

dstenb created this revision.Sep 9 2020, 9:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 9:30 AM
dstenb requested review of this revision.Sep 9 2020, 9:30 AM
dstenb edited the summary of this revision. (Show Details)

I assume that we in such cases don't want to return true from ProcessBlock(), which would trigger another iteration of the function.

Theoretically, it's unnecessary, so we'd want to avoid it the extra analysis cost. But in practice this should be really rare, so I'd prefer to keep the code simpler and continue using a bool return.

dstenb updated this revision to Diff 290894.Sep 10 2020, 12:27 AM
dstenb edited the summary of this revision. (Show Details)

Continue using a bool return instead of a tri-state.

This revision is now accepted and ready to land.Sep 10 2020, 6:55 PM

Thanks for the review!

And for reference, I compiled 100,000 Csmith programs for x86-64 and I only ran into this case 15 times.

This revision was automatically updated to reflect the committed changes.