aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-10-29 10:10:26 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-10-29 10:10:26 -0700
commita6df9e3ab2ab7b43a6097edec19990b25ccf15b7 (patch)
treeeb7b106e95940f25f6211a3e20350adb02beb142
parentdbd6c566dc997e7e023c86034cbf4d4821ffbc9b (diff)
PNaCl: Add option to PNaClABISimplify for enabling the PNaClSjLjEH pass
Making this an 'enable' option (rather than using the pass name, "-pnacl-sjlj-eh") will allow us to reorder the passes within PNaClABISimplify.cpp later without having to change pnacl-ld.py (which lives outside the pnacl-llvm repo). It also means that the option can turn off LowerInvoke, which might reduce the link time a little. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3696 TEST=tested with PNaCl-side plumbing in pnacl-ld.py etc. Review URL: https://codereview.chromium.org/33743010
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 5d64b088ce..d695f61203 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -21,7 +21,27 @@
using namespace llvm;
+static cl::opt<bool>
+EnableSjLjEH("enable-pnacl-sjlj-eh",
+ cl::desc("Enable use of SJLJ-based C++ exception handling "
+ "as part of the pnacl-abi-simplify passes"),
+ cl::init(false));
+
void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
+ if (EnableSjLjEH) {
+ // This comes before ExpandTls because it introduces references to
+ // a TLS variable, __pnacl_eh_stack. This comes before
+ // InternalizePass because it assumes various variables (including
+ // __pnacl_eh_stack) have not been internalized yet.
+ PM.add(createPNaClSjLjEHPass());
+ } else {
+ // LowerInvoke prevents use of C++ exception handling by removing
+ // references to BasicBlocks which handle exceptions.
+ PM.add(createLowerInvokePass());
+ // Remove landingpad blocks made unreachable by LowerInvoke.
+ PM.add(createCFGSimplificationPass());
+ }
+
// Internalize all symbols in the module except _start, which is the only
// symbol a stable PNaCl pexe is allowed to export.
const char *SymbolsToPreserve[] = { "_start" };
@@ -32,11 +52,6 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
PM.add(createLowerExpectIntrinsicPass());
// Rewrite unsupported intrinsics to simpler and portable constructs.
PM.add(createRewriteLLVMIntrinsicsPass());
- // LowerInvoke prevents use of C++ exception handling, which is not
- // yet supported in the PNaCl ABI.
- PM.add(createLowerInvokePass());
- // Remove landingpad blocks made unreachable by LowerInvoke.
- PM.add(createCFGSimplificationPass());
// Expand out some uses of struct types.
PM.add(createExpandArithWithOverflowPass());