This is an archive of the discontinued LLVM Phabricator instance.

[InlineSpiller] simplify insertReload() NFC
ClosedPublic

Authored by nickdesaulniers on Apr 20 2020, 3:23 PM.

Details

Summary

The repeated use of std::next() on a MachineBasicBlock::iterator was
clever, but we only need to reconstruct the iterator post creation of
the spill instruction.

This helps simplifying where we plan to place the spill, as discussed in
D77849.

From here, we can simplify the code a little by flipping the return code
of a helper.

Diff Detail

Event Timeline

efriedma accepted this revision.Apr 20 2020, 4:17 PM

LGTM with one minor comment.

llvm/lib/CodeGen/InlineSpiller.cpp
934

Not sure renaming this helper is really useful; the old name is the property it's actually computing, which makes more sense than naming it after what you plan to do with the result.

Not a big deal either way.

This revision is now accepted and ready to land.Apr 20 2020, 4:17 PM

Thanks for the review!

llvm/lib/CodeGen/InlineSpiller.cpp
934

If we keep the old name, then we should not negate the return values as done in this diff. Instead, we'd negate the return value at the call site, which looks funny (just return what you want, no negation required).

bool IsRealSpill = !isFullUndefDef(*MI);

Thoughts? Also, doesn't matter to me. This way just has fewer negations in it.

efriedma added inline comments.Apr 20 2020, 5:38 PM
llvm/lib/CodeGen/InlineSpiller.cpp
934

If you might want to use this helper elsewhere, then making the helper positive makes more sense. But thinking about it a bit more, probably fine to leave your patch as-is, and we can reconsider if we ever find some other place that wants to use it.

nickdesaulniers marked 4 inline comments as done.Apr 21 2020, 8:32 AM
nickdesaulniers added inline comments.
llvm/lib/CodeGen/InlineSpiller.cpp
934

Sure, I'm not opposed to changing it back later if needed. Thanks again for the review.

This revision was automatically updated to reflect the committed changes.
nickdesaulniers marked an inline comment as done.