diff options
| author | Tim Northover <tnorthover@apple.com> | 2016-12-07 21:05:38 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2016-12-07 21:05:38 +0000 |
| commit | 05cc4859ad289948175382daae0f3ef8c214a8f5 (patch) | |
| tree | ec252f4fba40a3c82067d11f935e84362315d197 /llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | |
| parent | 64a055549a976c5c30c57cbb7ff696e809c79a2e (diff) | |
| download | bcm5719-llvm-05cc4859ad289948175382daae0f3ef8c214a8f5.tar.gz bcm5719-llvm-05cc4859ad289948175382daae0f3ef8c214a8f5.zip | |
GlobalISel: simplify MachineIRBuilder interface.
MachineIRBuilder had weird before/after and beginning/end flags for the insert
point. Unfortunately the non-default means that instructions will be inserted
in reverse order which is almost never what anyone wants.
Really, I think we just want (like IRBuilder has) the ability to insert at any
C++ iterator-style point (i.e. before any instruction or before MBB.end()). So
this fixes MIRBuilders to behave like IRBuilders in this respect.
llvm-svn: 288980
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index c986e65049f..726e89826c5 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -744,13 +744,18 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &MF) { assert(PendingPHIs.empty() && "stale PHIs"); - // Setup the arguments. - MachineBasicBlock &MBB = getOrCreateBB(F.front()); - MIRBuilder.setMBB(MBB); + // Setup a separate basic-block for the arguments and constants, falling + // through to the IR-level Function's entry block. + MachineBasicBlock *EntryBB = MF.CreateMachineBasicBlock(); + MF.push_back(EntryBB); + EntryBB->addSuccessor(&getOrCreateBB(F.front())); + EntryBuilder.setMBB(*EntryBB); + + // Lower the actual args into this basic block. SmallVector<unsigned, 8> VRegArgs; for (const Argument &Arg: F.args()) VRegArgs.push_back(getOrCreateVReg(Arg)); - bool Succeeded = CLI->lowerFormalArguments(MIRBuilder, F, VRegArgs); + bool Succeeded = CLI->lowerFormalArguments(EntryBuilder, F, VRegArgs); if (!Succeeded) { if (!TPC->isGlobalISelAbortEnabled()) { MIRBuilder.getMF().getProperties().set( @@ -761,13 +766,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &MF) { report_fatal_error("Unable to lower arguments"); } - // Now that we've got the ABI handling code, it's safe to set a location for - // any Constants we find in the IR. - if (MBB.empty()) - EntryBuilder.setMBB(MBB, /* Beginning */ true); - else - EntryBuilder.setInstr(MBB.back(), /* Before */ false); - + // And translate the function! for (const BasicBlock &BB: F) { MachineBasicBlock &MBB = getOrCreateBB(BB); // Set the insertion point of all the following translations to |

