[GlobalISel] Finalize translated function on scope exit. NFC.

This is the compromise between having a per-function IRTranslator
and manually managing the per-function state.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296046 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ahmed Bougacha 2017-02-23 23:57:28 +00:00
parent d58d81ffa6
commit 141a873c65

View File

@ -12,6 +12,7 @@
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
@ -1033,6 +1034,9 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
assert(PendingPHIs.empty() && "stale PHIs");
// Release the per-function state when we return, whether we succeeded or not.
auto FinalizeOnReturn = make_scope_exit([this]() { finalizeFunction(); });
// Setup a separate basic-block for the arguments and constants, falling
// through to the IR-level Function's entry block.
MachineBasicBlock *EntryBB = MF->CreateMachineBasicBlock();
@ -1050,7 +1054,6 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
&MF->getFunction()->getEntryBlock());
R << "unable to lower arguments: " << ore::NV("Prototype", F.getType());
reportTranslationError(*MF, *TPC, *ORE, R);
finalizeFunction();
return false;
}
@ -1113,7 +1116,5 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
"New entry wasn't next in the list of basic block!");
}
finalizeFunction();
return false;
}