This is an archive of the discontinued LLVM Phabricator instance.

Don't try to legalize Intermediate instructions (with generic types)
ClosedPublic

Authored by aditya_nandakumar on Apr 26 2017, 5:32 PM.

Details

Summary

During legalization, targets can create Pseudo Instructions with generic types. We shouldn't try to legalize them.

Diff Detail

Event Timeline

qcolombet edited edge metadata.Apr 27 2017, 9:28 AM

Hi Aditya,

It seems weird to me to have elements in the work list that we shouldn't process. Could we change the way we insert in the work list instead?
E.g., having the check you added within the lambda for recordInsertions.

Cheers,
-Quentin

Updated based on feedback - now we don't add to the list

Updated based on feedback.

dsanders added inline comments.Apr 28 2017, 1:37 AM
lib/CodeGen/GlobalISel/Legalizer.cpp
183

This line needs to happen unconditionally so that --debug-only=legalize reports the instruction.

lib/CodeGen/GlobalISel/Legalizer.cpp
183

Yes - for -debug-only printing output we would need it in the list but not process - but would disagree with Quentin's comment of not having the Instructions that are not needed in the work list.

dsanders added inline comments.Apr 28 2017, 3:59 PM
lib/CodeGen/GlobalISel/Legalizer.cpp
183

Incrementing NumNewInsns is just about how many instructions to print in the --debug-only=legalize output for that call to legalizeInstrStep(). The correlation with the growth of the work list is a coincidence.

dsanders added inline comments.May 2 2017, 3:58 AM
lib/CodeGen/GlobalISel/Legalizer.cpp
183

As you rightly pointed out, they are connected in implementation right now because it's printing from the work list iterators instead of the BB iterators. I've looked into refactoring this away and I believe I've fixed this locally. I'll post the patch on-list once I've tested it.

dsanders added inline comments.May 2 2017, 5:19 AM
lib/CodeGen/GlobalISel/Legalizer.cpp
183

The refactor is in D32744

qcolombet accepted this revision.May 4 2017, 2:04 PM

LGTM

lib/CodeGen/GlobalISel/Legalizer.cpp
183

With @dsanders follow-on patch we don't need to push the NumNewInsns out of the if statement anymore. Thus, it sounds to me that all the concerns were solved.

This revision is now accepted and ready to land.May 4 2017, 2:04 PM

Committed in r302199