[llvm] r289891 - [IRTranslator] Merge the entry and ABI lowering blocks.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 10:21:33 PST 2016

On 16 December 2016 at 09:57, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:
> I find this quite awkward;

Admittedly not quite so elegant now that we have to merge the blocks
again, I really like the split-block solution personally (and am not
really convinced by "maximality"). I tried to make the single-block
solution work in various forms, and each had problems.

> - after that (for constant lowering): insert after
> std::prev(EntryBB.end())

This has a couple of issues.

First, you need to insert directly after the ABI lowering code
(conceptually) because some of the entry block may use the constants
you're inserting. That's sort of fixable by recording where
ABI-lowering ends, though dealing with the possibility for no
ABI-lowering instructions makes it ugly (essentially you need to
either repurpose MBB::end to mean "actually put the constants at the
beginning" or add a "bool NoABICode").

Second, insert-after is problematic. It reverses the order things get
emitted which causes dependencies to break (e.g. for inttoptr(i32 0 to
i8*) the G_CONSTANT would come after the G_INTTOPTR). Again the no-ABI
case is worse since there's no way to set a MachineIRBuilder to insert
at the beginning of a block in sane order.

None of it insurmountable, but splitting the block is just so pretty
and lets us side-step the issues entirely.


More information about the llvm-commits mailing list