This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Set Changed when we delete dead instructions. PR38855
ClosedPublic

Authored by mkazantsev on Sep 6 2018, 10:55 PM.

Details

Summary

IndVars does not set Changed flag when it eliminates dead instructions. As result,
it may make IR modifications and report that it has done nothing. It leads to inconsistent
preserved analyzes results.

Diff Detail

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.Sep 6 2018, 10:55 PM
mkazantsev edited the summary of this revision. (Show Details)
mkazantsev edited the summary of this revision. (Show Details)

I'm not sure if I'm allowed to LGTM this but it does look good to me and it solves PR38855 so thumbs up.

skatkov added inline comments.Sep 6 2018, 11:28 PM
lib/Transforms/Scalar/IndVarSimplify.cpp
2494 ↗(On Diff #164354)

Changed |= ...?
RecursivelyDeleteTriviallyDeadInstructions may return false indicating that it did not remove anything...

2502 ↗(On Diff #164354)

should it be fixed as well? And other places?

mkazantsev marked an inline comment as done.Sep 7 2018, 12:12 AM
mkazantsev added inline comments.
lib/Transforms/Scalar/IndVarSimplify.cpp
2494 ↗(On Diff #164354)

Not sure if it's happening in any real case (i.e. considering how DeadInsts is formed), but OK.

2502 ↗(On Diff #164354)

Maybe. It needs comprehensive analysis. I need to revisit any single place separately, let's not do it in this patch. It is to address a particular crash, however I agree that we might take a closer look into how Changed is sad.

mkazantsev marked an inline comment as done.
mkazantsev added inline comments.
lib/Transforms/Scalar/IndVarSimplify.cpp
2502 ↗(On Diff #164354)
skatkov accepted this revision.Sep 7 2018, 12:15 AM

LGTM with follow-up handling of Changed. If you do not have cycles for handling Changed, please file a bug at least.

This revision is now accepted and ready to land.Sep 7 2018, 12:15 AM
This revision was automatically updated to reflect the committed changes.