aboutsummaryrefslogtreecommitdiff
path: root/tools/opt
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 /tools/opt
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 'tools/opt')
-rw-r--r--tools/opt/opt.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 3179e17733..35e18d02ad 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -45,6 +45,7 @@
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/NaCl.h" // @LOCALMOD
#include <algorithm>
#include <memory>
using namespace llvm;
@@ -127,6 +128,18 @@ static cl::opt<bool>
OptLevelO3("O3",
cl::desc("Optimization level 3. Similar to clang -O3"));
+// @LOCALMOD-BEGIN
+static cl::opt<bool>
+PNaClABISimplifyPreOpt(
+ "pnacl-abi-simplify-preopt",
+ cl::desc("PNaCl ABI simplifications for before optimizations"));
+
+static cl::opt<bool>
+PNaClABISimplifyPostOpt(
+ "pnacl-abi-simplify-postopt",
+ cl::desc("PNaCl ABI simplifications for after optimizations"));
+// @LOCALMOD-END
+
static cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
@@ -760,6 +773,20 @@ int main(int argc, char **argv) {
OptLevelO3 = false;
}
+ // @LOCALMOD-BEGIN
+ if (PNaClABISimplifyPreOpt &&
+ PNaClABISimplifyPreOpt.getPosition() < PassList.getPosition(i)) {
+ PNaClABISimplifyAddPreOptPasses(Passes);
+ PNaClABISimplifyPreOpt = false;
+ }
+
+ if (PNaClABISimplifyPostOpt &&
+ PNaClABISimplifyPostOpt.getPosition() < PassList.getPosition(i)) {
+ PNaClABISimplifyAddPostOptPasses(Passes);
+ PNaClABISimplifyPostOpt = false;
+ }
+ // @LOCALMOD-END
+
const PassInfo *PassInf = PassList[i];
Pass *P = 0;
if (PassInf->getNormalCtor())
@@ -832,6 +859,14 @@ int main(int argc, char **argv) {
FPasses->doFinalization();
}
+ // @LOCALMOD-BEGIN
+ if (PNaClABISimplifyPreOpt)
+ PNaClABISimplifyAddPreOptPasses(Passes);
+
+ if (PNaClABISimplifyPostOpt)
+ PNaClABISimplifyAddPostOptPasses(Passes);
+ // @LOCALMOD-END
+
// Check that the module is well formed on completion of optimization
if (!NoVerify && !VerifyEach)
Passes.add(createVerifierPass());