[llvm-commits] CVS: llvm/tools/opt/Makefile opt.cpp

2007-05-06 Thread Chris Lattner


Changes in directory llvm/tools/opt:

Makefile updated: 1.62 - 1.63
opt.cpp updated: 1.139 - 1.140
---
Log message:

switch tools to bitcode from bytecode


---
Diffs of the changes:  (+12 -30)

 Makefile |2 +-
 opt.cpp  |   40 +++-
 2 files changed, 12 insertions(+), 30 deletions(-)


Index: llvm/tools/opt/Makefile
diff -u llvm/tools/opt/Makefile:1.62 llvm/tools/opt/Makefile:1.63
--- llvm/tools/opt/Makefile:1.62Sat May  5 21:42:03 2007
+++ llvm/tools/opt/Makefile Sun May  6 04:32:02 2007
@@ -10,6 +10,6 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation 
scalaropts ipo
+LINK_COMPONENTS := bitreader bitwriter instrumentation scalaropts ipo
 
 include $(LEVEL)/Makefile.common


Index: llvm/tools/opt/opt.cpp
diff -u llvm/tools/opt/opt.cpp:1.139 llvm/tools/opt/opt.cpp:1.140
--- llvm/tools/opt/opt.cpp:1.139Sat May  5 23:43:00 2007
+++ llvm/tools/opt/opt.cpp  Sun May  6 04:32:02 2007
@@ -14,8 +14,6 @@
 
 #include llvm/Module.h
 #include llvm/PassManager.h
-#include llvm/Bytecode/Reader.h
-#include llvm/Bytecode/WriteBytecodePass.h
 #include llvm/Bitcode/ReaderWriter.h
 #include llvm/Assembly/PrintModulePass.h
 #include llvm/Analysis/Verifier.h
@@ -37,17 +35,12 @@
 #include algorithm
 using namespace llvm;
 
-static cl::optbool Bitcode(bitcode);
-
 // The OptimizationList is automatically populated with registered Passes by 
the
 // PassNameParser.
 //
 static cl::listconst PassInfo*, bool, PassNameParser
 PassList(cl::desc(Optimizations available:));
 
-static cl::optbool NoCompress(disable-compression, cl::init(true),
-   cl::desc(Don't compress the generated bytecode));
-
 // Other command line options...
 //
 static cl::optstd::string
@@ -267,21 +260,15 @@
 
 // Load the input module...
 std::auto_ptrModule M;
-if (Bitcode) {
-  MemoryBuffer *Buffer
-= MemoryBuffer::getFileOrSTDIN(InputFilename[0], 
InputFilename.size());
-  
-  if (Buffer == 0)
-ErrorMessage = Error reading file ' + InputFilename + ';
-  else
-M.reset(ParseBitcodeFile(Buffer, ErrorMessage));
-  
-  delete Buffer;
-} else {
-  M.reset(ParseBytecodeFile(InputFilename, 
-Compressor::decompressToNewBuffer,
-ErrorMessage));
-}
+MemoryBuffer *Buffer
+  = MemoryBuffer::getFileOrSTDIN(InputFilename[0], InputFilename.size());
+
+if (Buffer == 0)
+  ErrorMessage = Error reading file ' + InputFilename + ';
+else
+  M.reset(ParseBitcodeFile(Buffer, ErrorMessage));
+
+delete Buffer;
 if (M.get() == 0) {
   cerr  argv[0]  : ;
   if (ErrorMessage.size())
@@ -372,13 +359,8 @@
   Passes.add(createVerifierPass());
 
 // Write bytecode out to disk or cout as the last step...
-OStream L(*Out);
-if (!NoOutput  !AnalyzeOnly) {
-  if (Bitcode)
-Passes.add(CreateBitcodeWriterPass(*Out));
-  else
-Passes.add(new WriteBytecodePass(L, false, !NoCompress));
-}
+if (!NoOutput  !AnalyzeOnly)
+  Passes.add(CreateBitcodeWriterPass(*Out));
 
 // Now that we have all of the passes ready, run them.
 Passes.run(*M.get());



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/tools/opt/Makefile opt.cpp

2007-05-05 Thread Chris Lattner


Changes in directory llvm/tools/opt:

Makefile updated: 1.61 - 1.62
opt.cpp updated: 1.137 - 1.138
---
Log message:

if -bitcode is specified, read and write a bitcode file instead of a bytecode 
file.


---
Diffs of the changes:  (+31 -5)

 Makefile |2 +-
 opt.cpp  |   34 ++
 2 files changed, 31 insertions(+), 5 deletions(-)


Index: llvm/tools/opt/Makefile
diff -u llvm/tools/opt/Makefile:1.61 llvm/tools/opt/Makefile:1.62
--- llvm/tools/opt/Makefile:1.61Sat Feb  3 17:15:56 2007
+++ llvm/tools/opt/Makefile Sat May  5 21:42:03 2007
@@ -10,6 +10,6 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-LINK_COMPONENTS := bcreader bcwriter instrumentation scalaropts ipo
+LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation 
scalaropts ipo
 
 include $(LEVEL)/Makefile.common


Index: llvm/tools/opt/opt.cpp
diff -u llvm/tools/opt/opt.cpp:1.137 llvm/tools/opt/opt.cpp:1.138
--- llvm/tools/opt/opt.cpp:1.137Wed May  2 20:11:54 2007
+++ llvm/tools/opt/opt.cpp  Sat May  5 21:42:03 2007
@@ -16,6 +16,7 @@
 #include llvm/PassManager.h
 #include llvm/Bytecode/Reader.h
 #include llvm/Bytecode/WriteBytecodePass.h
+#include llvm/Bitcode/ReaderWriter.h
 #include llvm/Assembly/PrintModulePass.h
 #include llvm/Analysis/Verifier.h
 #include llvm/Analysis/LoopPass.h
@@ -24,6 +25,7 @@
 #include llvm/Support/PassNameParser.h
 #include llvm/System/Signals.h
 #include llvm/Support/ManagedStatic.h
+#include llvm/Support/MemoryBuffer.h
 #include llvm/Support/PluginLoader.h
 #include llvm/Support/Streams.h
 #include llvm/Support/SystemUtils.h
@@ -35,6 +37,8 @@
 #include algorithm
 using namespace llvm;
 
+static cl::optbool Bitcode(bitcode);
+
 // The OptimizationList is automatically populated with registered Passes by 
the
 // PassNameParser.
 //
@@ -262,8 +266,26 @@
 std::string ErrorMessage;
 
 // Load the input module...
-std::auto_ptrModule M(ParseBytecodeFile(InputFilename, 
-Compressor::decompressToNewBuffer, ErrorMessage));
+std::auto_ptrModule M;
+if (Bitcode) {
+  MemoryBuffer *Buffer;
+  if (InputFilename == -) {
+Buffer = MemoryBuffer::getSTDIN();
+  } else {
+Buffer = MemoryBuffer::getFile(InputFilename[0], 
InputFilename.size());
+  }
+  
+  if (Buffer == 0)
+ErrorMessage = Error reading file ' + InputFilename + ';
+  else
+M.reset(ParseBitcodeFile(Buffer, ErrorMessage));
+  
+  delete Buffer;
+} else {
+  M.reset(ParseBytecodeFile(InputFilename, 
+Compressor::decompressToNewBuffer,
+ErrorMessage));
+}
 if (M.get() == 0) {
   cerr  argv[0]  : ;
   if (ErrorMessage.size())
@@ -355,8 +377,12 @@
 
 // Write bytecode out to disk or cout as the last step...
 OStream L(*Out);
-if (!NoOutput  !AnalyzeOnly)
-  Passes.add(new WriteBytecodePass(L, false, !NoCompress));
+if (!NoOutput  !AnalyzeOnly) {
+  if (Bitcode)
+Passes.add(CreateBitcodeWriterPass(*Out));
+  else
+Passes.add(new WriteBytecodePass(L, false, !NoCompress));
+}
 
 // Now that we have all of the passes ready, run them.
 Passes.run(*M.get());



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/tools/opt/Makefile opt.cpp

2007-02-03 Thread Reid Spencer


Changes in directory llvm/tools/opt:

Makefile updated: 1.60 - 1.61
opt.cpp updated: 1.128 - 1.129
---
Log message:

For PR1072: http://llvm.org/PR1072 :
Removing -raise has neglible positive or negative side effects so we are
opting to remove it. See the PR for comparison details.


---
Diffs of the changes:  (+1 -3)

 Makefile |3 +--
 opt.cpp  |1 -
 2 files changed, 1 insertion(+), 3 deletions(-)


Index: llvm/tools/opt/Makefile
diff -u llvm/tools/opt/Makefile:1.60 llvm/tools/opt/Makefile:1.61
--- llvm/tools/opt/Makefile:1.60Wed Dec 13 10:54:05 2006
+++ llvm/tools/opt/Makefile Sat Feb  3 17:15:56 2007
@@ -10,7 +10,6 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-LINK_COMPONENTS := bcreader bcwriter instrumentation scalaropts ipo \
-   transforms
+LINK_COMPONENTS := bcreader bcwriter instrumentation scalaropts ipo
 
 include $(LEVEL)/Makefile.common


Index: llvm/tools/opt/opt.cpp
diff -u llvm/tools/opt/opt.cpp:1.128 llvm/tools/opt/opt.cpp:1.129
--- llvm/tools/opt/opt.cpp:1.128Fri Feb  2 08:46:29 2007
+++ llvm/tools/opt/opt.cpp  Sat Feb  3 17:15:56 2007
@@ -202,7 +202,6 @@
 addPass(PM, createFunctionInliningPass());   // Inline small functions
   addPass(PM, createArgumentPromotionPass());// Scalarize uninlined fn args
 
-  addPass(PM, createRaisePointerReferencesPass());// Recover type information
   addPass(PM, createTailDuplicationPass());  // Simplify cfg by copying 
code
   addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
   addPass(PM, createCFGSimplificationPass());// Merge  remove BBs



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/tools/opt/Makefile opt.cpp

2006-08-27 Thread Chris Lattner


Changes in directory llvm/tools/opt:

Makefile updated: 1.57 - 1.58
opt.cpp updated: 1.115 - 1.116
---
Log message:

Merge the 'analyze' mode code with the 'opt' mode code.  Eliminate the 
'autodetect .ll files' functionality.


---
Diffs of the changes:  (+26 -76)

 Makefile |2 -
 opt.cpp  |  100 +++
 2 files changed, 26 insertions(+), 76 deletions(-)


Index: llvm/tools/opt/Makefile
diff -u llvm/tools/opt/Makefile:1.57 llvm/tools/opt/Makefile:1.58
--- llvm/tools/opt/Makefile:1.57Fri Aug 18 01:34:30 2006
+++ llvm/tools/opt/Makefile Sun Aug 27 17:07:01 2006
@@ -10,7 +10,7 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-USEDLIBS = LLVMAsmParser.a LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a 
\
+USEDLIBS = LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a \
   LLVMScalarOpts.a LLVMipo.a LLVMipa.a LLVMDataStructure \
   LLVMTransforms.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \
   LLVMCore.a LLVMSupport.a LLVMbzip2.a LLVMSystem.a 


Index: llvm/tools/opt/opt.cpp
diff -u llvm/tools/opt/opt.cpp:1.115 llvm/tools/opt/opt.cpp:1.116
--- llvm/tools/opt/opt.cpp:1.115Mon Aug 21 00:34:03 2006
+++ llvm/tools/opt/opt.cpp  Sun Aug 27 17:07:01 2006
@@ -13,7 +13,6 @@
 
//===--===//
 
 #include llvm/Module.h
-#include llvm/Assembly/Parser.h
 #include llvm/PassManager.h
 #include llvm/Bytecode/Reader.h
 #include llvm/Bytecode/WriteBytecodePass.h
@@ -37,9 +36,8 @@
 // The OptimizationList is automatically populated with registered Passes by 
the
 // PassNameParser.
 //
-static cl::listconst PassInfo*, bool,
-FilteredPassNameParserPassInfo::Optimization 
-OptimizationList(cl::desc(Optimizations available:));
+static cl::listconst PassInfo*, bool, PassNameParser
+PassList(cl::desc(Optimizations available:));
 
 
 // Other command line options...
@@ -74,12 +72,6 @@
 static cl::optbool
 AnalyzeOnly(analyze, cl::desc(Only perform analysis, no optimization));
 
-// The AnalysesList is automatically populated with registered Passes by the
-// PassNameParser.
-static 
-  cl::listconst PassInfo*, bool, FilteredPassNameParserPassInfo::Analysis 
-  AnalysesList(cl::desc(Analyses available:));
-
 static Timer BytecodeLoadTimer(Bytecode Loader);
 
 // -- Define Printers for module and function passes 
@@ -166,57 +158,7 @@
llvm .bc - .bc modular optimizer and analysis printer \n);
 sys::PrintStackTraceOnErrorSignal();
 
-if (AnalyzeOnly) {
-  Module *CurMod = 0;
-#if 0
-  TimeRegion RegionTimer(BytecodeLoadTimer);
-#endif
-  CurMod = ParseBytecodeFile(InputFilename);
-  ParseError Err;
-  if (!CurMod  !(CurMod = ParseAssemblyFile(InputFilename,Err))){
-std::cerr  argv[0]  :   Err.getMessage()  \n; 
-return 1;
-  }
-
-  // Create a PassManager to hold and optimize the collection of passes we 
-  // are about to build...
-  PassManager Passes;
-
-  // Add an appropriate TargetData instance for this module...
-  Passes.add(new TargetData(CurMod));
-
-  // Make sure the input LLVM is well formed.
-  if (!NoVerify)
-Passes.add(createVerifierPass());
-
-  // Create a new optimization pass for each one specified on the 
-  // command line
-  for (unsigned i = 0; i  AnalysesList.size(); ++i) {
-const PassInfo *Analysis = AnalysesList[i];
-
-if (Analysis-getNormalCtor()) {
-  Pass *P = Analysis-getNormalCtor()();
-  Passes.add(P);
-
-  if (BasicBlockPass *BBP = dynamic_castBasicBlockPass*(P))
-Passes.add(new BasicBlockPassPrinter(Analysis));
-  else if (FunctionPass *FP = dynamic_castFunctionPass*(P))
-Passes.add(new FunctionPassPrinter(Analysis));
-  else
-Passes.add(new ModulePassPrinter(Analysis));
-
-} else
-  std::cerr  argv[0]  : cannot create pass: 
- Analysis-getPassName()  \n;
-  }
-
-  Passes.run(*CurMod);
-
-  delete CurMod;
-  return 0;
-}
-
-// Allocate a full target machine description only if necessary...
+// Allocate a full target machine description only if necessary.
 // FIXME: The choice of target should be controllable on the command line.
 std::auto_ptrTargetMachine target;
 
@@ -275,22 +217,30 @@
 Passes.add(new TargetData(M.get()));
 
 // Create a new optimization pass for each one specified on the command 
line
-for (unsigned i = 0; i  OptimizationList.size(); ++i) {
-  const PassInfo *Opt = OptimizationList[i];
-
-  if (Opt-getNormalCtor())
-Passes.add(Opt-getNormalCtor()());
-  else if (Opt-getTargetCtor()) {
-#if 0
-if (target.get() == NULL)
-  target.reset(allocateSparcTargetMachine()); // FIXME: target option
-#endif
+for (unsigned i = 0; i  PassList.size(); ++i) {
+  const 

[llvm-commits] CVS: llvm/tools/opt/Makefile opt.cpp

2006-08-18 Thread Reid Spencer


Changes in directory llvm/tools/opt:

Makefile updated: 1.56 - 1.57
opt.cpp updated: 1.110 - 1.111
---
Log message:

For PR872: http://llvm.org/PR872 :
Shrinkify LLVM's footprint by removing the analyze tool and moving its
functionality into the opt tool. THis eliminates one of the largest tools
from LLVM and doesn't make opt much bigger because it already included 
most of the analysis passes.  To get the old analyze functionality pass 
the -analyze option to opt. Note that the integeration here is dead
simple. The main of analyze was just copied to opt and invoked if the
-analyze option was given. There may be opportunities for further 
integration such as removing the distinction between transform passes
and analysis passes.

To use the analysis functionality, if you previously did this:
  analyze $FNAME -domset -disable-verify
you would now do this:
  opt -analyze $FNAME -domset -disable-verify
Pretty simple.


---
Diffs of the changes:  (+151 -7)

 Makefile |8 +--
 opt.cpp  |  150 +--
 2 files changed, 151 insertions(+), 7 deletions(-)


Index: llvm/tools/opt/Makefile
diff -u llvm/tools/opt/Makefile:1.56 llvm/tools/opt/Makefile:1.57
--- llvm/tools/opt/Makefile:1.56Thu Jul  6 19:46:19 2006
+++ llvm/tools/opt/Makefile Fri Aug 18 01:34:30 2006
@@ -10,9 +10,9 @@
 TOOLNAME = opt
 REQUIRES_EH := 1
 
-USEDLIBS = LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a \
-  LLVMScalarOpts.a LLVMipo.a LLVMipa.a LLVMDataStructure 
LLVMTransforms.a \
-  LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a LLVMCore.a 
LLVMSupport.a \
-  LLVMbzip2.a LLVMSystem.a 
+USEDLIBS = LLVMAsmParser.a LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a 
\
+  LLVMScalarOpts.a LLVMipo.a LLVMipa.a LLVMDataStructure \
+  LLVMTransforms.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \
+  LLVMCore.a LLVMSupport.a LLVMbzip2.a LLVMSystem.a 
 
 include $(LEVEL)/Makefile.common


Index: llvm/tools/opt/opt.cpp
diff -u llvm/tools/opt/opt.cpp:1.110 llvm/tools/opt/opt.cpp:1.111
--- llvm/tools/opt/opt.cpp:1.110Fri Jun 16 13:23:49 2006
+++ llvm/tools/opt/opt.cpp  Fri Aug 18 01:34:30 2006
@@ -8,11 +8,12 @@
 
//===--===//
 //
 // Optimizations may be specified an arbitrary number of times on the command
-// line, they are run in the order specified.
+// line, They are run in the order specified.
 //
 
//===--===//
 
 #include llvm/Module.h
+#include llvm/Assembly/Parser.h
 #include llvm/PassManager.h
 #include llvm/Bytecode/Reader.h
 #include llvm/Bytecode/WriteBytecodePass.h
@@ -24,6 +25,8 @@
 #include llvm/System/Signals.h
 #include llvm/Support/PluginLoader.h
 #include llvm/Support/SystemUtils.h
+#include llvm/Support/Timer.h
+#include llvm/Analysis/LinkAllAnalyses.h
 #include llvm/Transforms/LinkAllPasses.h
 #include llvm/LinkAllVMCore.h
 #include fstream
@@ -43,7 +46,8 @@
 // Other command line options...
 //
 static cl::optstd::string
-InputFilename(cl::Positional, cl::desc(input bytecode), cl::init(-));
+InputFilename(cl::Positional, cl::desc(input bytecode file), 
+cl::init(-), cl::value_desc(filename));
 
 static cl::optstd::string
 OutputFilename(o, cl::desc(Override output filename),
@@ -68,6 +72,91 @@
 static cl::alias
 QuietA(quiet, cl::desc(Alias for -q), cl::aliasopt(Quiet));
 
+static cl::optbool
+AnalyzeOnly(analyze, cl::desc(Only perform analysis, no optimization));
+
+// The AnalysesList is automatically populated with registered Passes by the
+// PassNameParser.
+static 
+  cl::listconst PassInfo*, bool, FilteredPassNameParserPassInfo::Analysis 
+  AnalysesList(cl::desc(Analyses available:));
+
+static Timer BytecodeLoadTimer(Bytecode Loader);
+
+// -- Define Printers for module and function passes 
+namespace {
+
+struct ModulePassPrinter : public ModulePass {
+  const PassInfo *PassToPrint;
+  ModulePassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
+
+  virtual bool runOnModule(Module M) {
+if (!Quiet) {
+  std::cout  Printing analysis '  PassToPrint-getPassName() 
+ ':\n;
+  getAnalysisIDPass(PassToPrint).print(std::cout, M);
+}
+
+// Get and print pass...
+return false;
+  }
+
+  virtual const char *getPassName() const { return 'Pass' Printer; }
+
+  virtual void getAnalysisUsage(AnalysisUsage AU) const {
+AU.addRequiredID(PassToPrint);
+AU.setPreservesAll();
+  }
+};
+
+struct FunctionPassPrinter : public FunctionPass {
+  const PassInfo *PassToPrint;
+  FunctionPassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
+
+  virtual bool runOnFunction(Function F) {
+if (!Quiet) {
+  std::cout  Printing analysis '  PassToPrint-getPassName()
+' for function '  F.getName()  ':\n;
+}
+// Get and print pass...
+