summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2017-02-23 23:57:28 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2017-02-23 23:57:28 +0000
commiteceabddcfd6ad653ee1acdcdd2b712343227d133 (patch)
treeb0b753016d71f40cf9cb221f75dfae21d0436ed2 /llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
parentfd37e79ae633b560ac8e03c194953037ffbba3d8 (diff)
downloadbcm5719-llvm-eceabddcfd6ad653ee1acdcdd2b712343227d133.tar.gz
bcm5719-llvm-eceabddcfd6ad653ee1acdcdd2b712343227d133.zip
[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. llvm-svn: 296046
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 2fb19e0d4de..c94e2955a1a 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -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;
}
OpenPOWER on IntegriCloud