This is an archive of the discontinued LLVM Phabricator instance.

[LSR] If no Use is interesting, early return.
ClosedPublic

Authored by timshen on Jul 6 2018, 5:46 PM.

Details

Summary

By looking at the callers of getUse(), we can see that even though
IVUsers may offer uses, but they may not be interesting to
LSR. It's possible that none of them is interesting.

Diff Detail

Repository
rL LLVM

Event Timeline

timshen created this revision.Jul 6 2018, 5:46 PM
sanjoy requested changes to this revision.Jul 6 2018, 6:57 PM

Do you have a test case for this?

This revision now requires changes to proceed.Jul 6 2018, 6:57 PM
timshen updated this revision to Diff 154710.Jul 9 2018, 3:06 PM

Added test case.

Do you have a test case for this?

I added the crasher. I haven't take a close look at the IR, but it's sufficient to reproduce the crash. Let me know if you think it's helpful to fully study the test and justify the cause.

sanjoy accepted this revision.Jul 11 2018, 6:22 AM

I'd debug this a bit further, perhaps with some logging statements to figure out what happened (what use did we discard as non-interesting and why?). But if that looks like too much work then this change as-is is fine too.

llvm/test/CodeGen/X86/lsr-crash-empty-uses.ll
1 ↗(On Diff #154710)

Can't you run LSR directly using opt?

39 ↗(On Diff #154710)

Would be nice to clean up these names. Maybe use opt -metarenamer?

This revision is now accepted and ready to land.Jul 11 2018, 6:22 AM
timshen updated this revision to Diff 155524.Jul 13 2018, 3:50 PM
timshen marked an inline comment as done.

TIL -metarenamer.

llvm/test/CodeGen/X86/lsr-crash-empty-uses.ll
1 ↗(On Diff #154710)

It's weird. When I switch to opt it doesn't crash.

timshen added inline comments.Jul 13 2018, 4:41 PM
llvm/test/CodeGen/X86/lsr-crash-empty-uses.ll
1 ↗(On Diff #154710)

LSR has lots of target-specific logic, so maybe it makes sense to use llc in this case.

This revision was automatically updated to reflect the committed changes.