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 changing the condition in MIRParserImpl::initializeCallSiteInfo, the idea is to have a special case when using GlobalISel. One way to figure out is GlobalISel the current selector is by not finding "bb.0" in the body of the machine function, the reason for that is beacuse GlobalISel will always start from bb.1, unlike SDAGISel or FastISel.
Details
Diff Detail
Unit Tests
Time | Test | |
---|---|---|
1,100 ms | linux > libarcher.parallel::parallel-nosuppression.c |
Event Timeline
llvm/lib/CodeGen/MIRParser/MIRParser.cpp | ||
---|---|---|
372–373 | I think treating this as some difference to tolerate is the wrong approach. There's no reason the block numbers should change based on the selector | |
llvm/test/CodeGen/X86/globalisel-entry-block-enumeration.ll | ||
2–3 | A pure input MIR test in test/CodeGen/MIR would be preferable |
llvm/lib/CodeGen/MIRParser/MIRParser.cpp | ||
---|---|---|
372–373 | I agree with @djtodoro , entry bb number in GlobalISel start from 1 by default, unlike in other selectors where they start from 0. In case of a machine function which has only one entry bb it's number will be 1 and the MF.size() will also be 1 which will result in an error "if (BlockNum >= MF.size())". | |
llvm/test/CodeGen/X86/globalisel-entry-block-enumeration.ll | ||
2–3 | It's an .ll test because in the translation process from IR to MIR (IRTranslator in case of using GlobalISel) the generated MIR code won't start from entry bb.0, that is what this test is checking. |
llvm/lib/CodeGen/MIRParser/MIRParser.cpp | ||
---|---|---|
372–373 | It's the same MIR. The numbering doesn't change. There's something pointlessly inconsistent if the block numbering ends up different |
I think the block numbering is meaningless and shouldn't be any different between selectors
I think treating this as some difference to tolerate is the wrong approach. There's no reason the block numbers should change based on the selector