This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Fix enumeration of entry basic blocks when using GlobalISel
AbandonedPublic

Authored by matejam on Sep 18 2020, 6:45 AM.

Details

Reviewers
djtodoro
arsenm
Summary

IRTranslator's method runOnMachineFunction is used to translate from IR to MIR when using GlobalISel as an instruction selector.
When all IR instructions are translated, we move all the instructions from the current entry block to it's only successor, which leaves the current entry block empty and useless, we then delete it from the machine function.
The only issue is that the surviving entry block's number is greater by 1 than the minimal entry block number, which is fixed by assigning the number of the deleted entry block to the surviving entry block's number.
Entry blocks should be serialized (starting from 0) so that an entry block's number wouldn't be greater than the size of the machine function (number of entry blocks in the MF) in which it resides.
Specifically an error will occur in MIRParserImpl::initializeCallSiteInfo when asked if the call site's block number (1 without this patch, 0 with this patch) is greater or equal to the number of entry blocks (1, because the second entry block has been removed).

Diff Detail

Event Timeline

matejam created this revision.Sep 18 2020, 6:45 AM
matejam requested review of this revision.Sep 18 2020, 6:45 AM

Why is a new entry block added in the first place?

llvm/test/CodeGen/X86/rename-new-entry.ll
3

stop-after=irtranslator. This also doesn't need to use a temporary file and should directly pipe to FIleCheck

12–15

Remove these and move triple to llc argument list

24

Remove these comments

45–49

Don't need this metadata

LGTM, thanks. The motivation is D87903?

djtodoro requested changes to this revision.Sep 18 2020, 7:03 AM

Please investigate the test failures.
($ make check-all)

This revision now requires changes to proceed.Sep 18 2020, 7:03 AM
matejam abandoned this revision.Oct 1 2020, 4:45 AM