[llvm] r296046 - [GlobalISel] Finalize translated function on scope exit. NFC.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 15:57:29 PST 2017
Author: ab
Date: Thu Feb 23 17:57:28 2017
New Revision: 296046
URL: http://llvm.org/viewvc/llvm-project?rev=296046&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=296046&r1=296045&r2=296046&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Thu Feb 23 17:57:28 2017
@@ -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(
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(
&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(
"New entry wasn't next in the list of basic block!");
}
- finalizeFunction();
-
return false;
}
More information about the llvm-commits
mailing list