aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/NaCl/PNaClABISimplify.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-05-24 17:05:15 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-05-24 17:05:15 -0700
commit33f698a2d1a30e31fb494922e3e6df8e643dc7b5 (patch)
treeda30ffef663e43c2a5b82cc9f2bf8e06e81dba03 /lib/Transforms/NaCl/PNaClABISimplify.cpp
parentde078f629ea70df5987a28390c1d3a0da5c844d5 (diff)
PNaCl: Add "-pnacl-abi-simplify-{pre,post}opt" meta-passes to "opt"
These meta-passes will be used to replace the pass lists that are currently in the pnacl-ld.py driver script in the NaCl repo. I've moved the comments across from pnacl-ld.py and added a couple more comments for ExpandByVal and StripMetadata. Fix the declaration of createResolveAliasesPass(). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3435 TEST=new *.ll tests + tested with change to pnacl-ld.py Review URL: https://codereview.chromium.org/15669002
Diffstat (limited to 'lib/Transforms/NaCl/PNaClABISimplify.cpp')
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
new file mode 100644
index 0000000000..9d7713139a
--- /dev/null
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -0,0 +1,65 @@
+//===-- PNaClABISimplify.cpp - Lists PNaCl ABI simplification passes ------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the meta-passes "-pnacl-abi-simplify-preopt"
+// and "-pnacl-abi-simplify-postopt". It lists their constituent
+// passes.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/NaCl.h"
+#include "llvm/PassManager.h"
+#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/NaCl.h"
+#include "llvm/Transforms/Scalar.h"
+
+using namespace llvm;
+
+void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
+ // 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());
+
+ PM.add(createExpandVarArgsPass());
+ PM.add(createExpandCtorsPass());
+ PM.add(createResolveAliasesPass());
+ PM.add(createExpandTlsPass());
+ // GlobalCleanup needs to run after ExpandTls because
+ // __tls_template_start etc. are extern_weak before expansion
+ PM.add(createGlobalCleanupPass());
+ // Strip dead prototytes to appease the intrinsic ABI checks
+ // (ExpandVarArgs leaves around var-arg intrinsics).
+ PM.add(createStripDeadPrototypesPass());
+}
+
+void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
+ // We place ExpandByVal after optimization passes because some byval
+ // arguments can be expanded away by the ArgPromotion pass. Leaving
+ // in "byval" during optimization also allows some dead stores to be
+ // eliminated, because "byval" is a stronger constraint than what
+ // ExpandByVal expands it to.
+ PM.add(createExpandByValPass());
+
+ // We place StripMetadata after optimization passes because
+ // optimizations depend on the metadata.
+ PM.add(createStripMetadataPass());
+
+ // FlattenGlobals introduces ConstantExpr bitcasts of globals which
+ // are expanded out later.
+ PM.add(createFlattenGlobalsPass());
+
+ // We should not place arbitrary passes after ExpandConstantExpr
+ // because they might reintroduce ConstantExprs. However,
+ // ExpandGetElementPtr must follow ExpandConstantExpr to expand the
+ // getelementptr instructions it creates.
+ PM.add(createExpandConstantExprPass());
+ PM.add(createExpandGetElementPtrPass());
+}