aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-11-26 18:18:53 +0000
committerChris Lattner <sabre@nondot.org>2001-11-26 18:18:53 +0000
commitee6826b5e3f92d2c6cc9d1d7c53bf27ca2bc4e29 (patch)
treeef518c5c3f401e4b16cdbd1c06f3591be974ab7a /tools
parent782b939db105c1ead1ee9420d95fae8c341dbf47 (diff)
downloadexternal_llvm-ee6826b5e3f92d2c6cc9d1d7c53bf27ca2bc4e29.zip
external_llvm-ee6826b5e3f92d2c6cc9d1d7c53bf27ca2bc4e29.tar.gz
external_llvm-ee6826b5e3f92d2c6cc9d1d7c53bf27ca2bc4e29.tar.bz2
Change swapstructs itf
Add nasty hack to be removed later git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/opt/opt.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index dcd1c90..f43ad24 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -36,6 +36,7 @@ struct {
enum Opts OptID;
Pass *ThePass;
} OptTable[] = {
+ { swapstructs, 0 },
{ dce , new opt::DeadCodeElimination() },
{ constprop, new opt::ConstantPropogation() },
{ inlining , new opt::MethodInlining() },
@@ -50,7 +51,6 @@ struct {
{ tracem , new InsertTraceCode(false, true) },
{ print , new PrintModulePass("Current Method: \n",&cerr) },
{ cleangcc , new CleanupGCCOutput() },
- { swapstructs, new SwapStructContents() },
};
cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-");
@@ -81,20 +81,24 @@ cl::EnumList<enum Opts> OptimizationList(cl::NoFlags,
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv,
" llvm .bc -> .bc modular optimizer\n");
-
- Module *C = ParseBytecodeFile(InputFilename);
- if (C == 0) {
+
+ // FIXME: Use smartptr
+ Module *M = ParseBytecodeFile(InputFilename);
+ if (M == 0) {
cerr << "bytecode didn't read correctly.\n";
return 1;
}
+ // FIXME: Absurdly nasty hack.
+ OptTable[0].ThePass = new PrebuiltStructMutation(M, PrebuiltStructMutation::SortElements);
+
for (unsigned i = 0; i < OptimizationList.size(); ++i) {
enum Opts Opt = OptimizationList[i];
unsigned j;
for (j = 0; j < sizeof(OptTable)/sizeof(OptTable[0]); ++j) {
if (Opt == OptTable[j].OptID) {
- if (OptTable[j].ThePass->run(C) && !Quiet)
+ if (OptTable[j].ThePass->run(M) && !Quiet)
cerr << OptimizationList.getArgName(Opt)
<< " pass made modifications!\n";
break;
@@ -111,14 +115,14 @@ int main(int argc, char **argv) {
(Force ? 0 : ios::noreplace)|ios::out);
if (!Out->good()) {
cerr << "Error opening " << OutputFilename << "!\n";
- delete C;
+ delete M;
return 1;
}
}
// Okay, we're done now... write out result...
- WriteBytecodeToFile(C, *Out);
- delete C;
+ WriteBytecodeToFile(M, *Out);
+ delete M;
if (Out != &cout) delete Out;
return 0;