Skip to content

Commit

Permalink
Revert 100204. It broke a bunch of tests and apparently changed what …
Browse files Browse the repository at this point in the history
…passes are run during codegen.

llvm-svn: 100207
  • Loading branch information
Evan Cheng committed Apr 2, 2010
1 parent 71bd071 commit 389525b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 283 deletions.
4 changes: 0 additions & 4 deletions llvm/include/llvm/Analysis/LoopPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class LoopPass : public Pass {
explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {}
explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {}

/// getPrinterPass - Get a pass to print the function corresponding
/// to a Loop.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

// runOnLoop - This method should be implemented by the subclass to perform
// whatever action is necessary for the specified Loop.
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0;
Expand Down
4 changes: 1 addition & 3 deletions llvm/include/llvm/Assembly/PrintModulePass.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ namespace llvm {

/// createPrintModulePass - Create and return a pass that writes the
/// module to the specified raw_ostream.
ModulePass *createPrintModulePass(raw_ostream *OS,
bool DeleteStream=false,
const std::string &Banner = "");
ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false);

/// createPrintFunctionPass - Create and return a pass that prints
/// functions to the specified raw_ostream as they are processed.
Expand Down
4 changes: 0 additions & 4 deletions llvm/include/llvm/CallGraphSCCPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ struct CallGraphSCCPass : public Pass {
explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {}
explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {}

/// createPrinterPass - Get a pass that prints the Module
/// corresponding to a CallGraph.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

/// doInitialization - This method is called before the SCC's of the program
/// has been processed, allowing the pass to do initialization as necessary.
virtual bool doInitialization(CallGraph &CG) {
Expand Down
3 changes: 0 additions & 3 deletions llvm/include/llvm/CodeGen/MachineFunctionPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class MachineFunctionPass : public FunctionPass {
explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}

/// createPrinterPass - Get a machine function printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

/// runOnMachineFunction - This method must be overloaded to perform the
/// desired machine code transformation or analysis.
///
Expand Down
6 changes: 2 additions & 4 deletions llvm/include/llvm/CodeGen/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
namespace llvm {

class FunctionPass;
class MachineFunctionPass;
class PassInfo;
class TargetLowering;
class RegisterCoalescer;
Expand All @@ -37,9 +36,8 @@ namespace llvm {

/// MachineFunctionPrinter pass - This pass prints out the machine function to
/// the given stream, as a debugging tool.
MachineFunctionPass *
createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner ="");
FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner ="");

/// MachineLoopInfo pass - This pass is a loop analysis pass.
///
Expand Down
16 changes: 0 additions & 16 deletions llvm/include/llvm/Pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
#define LLVM_PASS_H

#include "llvm/System/DataTypes.h"

#include <cassert>
#include <string>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -122,11 +120,6 @@ class Pass {
virtual void print(raw_ostream &O, const Module *M) const;
void dump() const; // dump - Print to stderr.

/// createPrinterPass - Get a Pass appropriate to print the IR this
/// pass operates one (Module, Function or MachineFunction).
virtual Pass *createPrinterPass(raw_ostream &O,
const std::string &Banner) const = 0;

/// Each pass is responsible for assigning a pass manager to itself.
/// PMS is the stack of available pass manager.
virtual void assignPassManager(PMStack &,
Expand Down Expand Up @@ -240,9 +233,6 @@ class Pass {
///
class ModulePass : public Pass {
public:
/// createPrinterPass - Get a module printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

/// runOnModule - Virtual method overriden by subclasses to process the module
/// being operated on.
virtual bool runOnModule(Module &M) = 0;
Expand Down Expand Up @@ -303,9 +293,6 @@ class FunctionPass : public Pass {
explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {}
explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {}

/// createPrinterPass - Get a function printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
///
Expand Down Expand Up @@ -356,9 +343,6 @@ class BasicBlockPass : public Pass {
explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {}
explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {}

/// createPrinterPass - Get a function printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;

/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
///
Expand Down
35 changes: 0 additions & 35 deletions llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,10 @@ class CGPassManager : public ModulePass, public PMDataManager {
bool IsCheckingMode);
};

/// PrintCallGraphPass - Print a Module corresponding to a call graph.
///
class PrintCallGraphPass : public CallGraphSCCPass {
private:
std::string Banner;
raw_ostream &Out; // raw_ostream to print on.

public:
static char ID;
PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {}
PrintCallGraphPass(const std::string &B, raw_ostream &o)
: CallGraphSCCPass(&ID), Banner(B), Out(o) {}

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}

bool runOnSCC(std::vector<CallGraphNode *> &SCC) {
Out << Banner;
for (std::vector<CallGraphNode *>::iterator n = SCC.begin(), ne = SCC.end();
n != ne;
++n) {
(*n)->getFunction()->print(Out);
}
return false;
}
};

} // end anonymous namespace.

char CGPassManager::ID = 0;

char PrintCallGraphPass::ID = 0;

bool CGPassManager::RunPassOnSCC(Pass *P, std::vector<CallGraphNode*> &CurSCC,
CallGraph &CG, bool &CallGraphUpToDate) {
bool Changed = false;
Expand Down Expand Up @@ -426,11 +396,6 @@ bool CGPassManager::doFinalization(CallGraph &CG) {
return Changed;
}

Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return new PrintCallGraphPass(Banner, O);
}

/// Assign pass manager to manage this pass.
void CallGraphSCCPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
Expand Down
40 changes: 0 additions & 40 deletions llvm/lib/Analysis/LoopPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,9 @@
//===----------------------------------------------------------------------===//

#include "llvm/Analysis/LoopPass.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
using namespace llvm;

namespace {

/// PrintLoopPass - Print a Function corresponding to a Loop.
///
class PrintLoopPass : public LoopPass {
private:
std::string Banner;
raw_ostream &Out; // raw_ostream to print on.

public:
static char ID;
PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {}
PrintLoopPass(const std::string &B, raw_ostream &o)
: LoopPass(&ID), Banner(B), Out(o) {}

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}

bool runOnLoop(Loop *L, LPPassManager &) {
Out << Banner;
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
b != be;
++b) {
(*b)->print(Out);
}
return false;
}
};

char PrintLoopPass::ID = 0;
}

//===----------------------------------------------------------------------===//
// LPPassManager
//
Expand Down Expand Up @@ -341,11 +306,6 @@ void LPPassManager::dumpPassStructure(unsigned Offset) {
//===----------------------------------------------------------------------===//
// LoopPass

Pass *LoopPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return new PrintLoopPass(Banner, O);
}

// Check if this pass is suitable for the current LPPassManager, if
// available. This pass P is not suitable for a LPPassManager if P
// is not preserving higher level analysis info used by other
Expand Down
34 changes: 34 additions & 0 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,40 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;

namespace {
struct Printer : public MachineFunctionPass {
static char ID;

raw_ostream &OS;
const std::string Banner;

Printer(raw_ostream &os, const std::string &banner)
: MachineFunctionPass(&ID), OS(os), Banner(banner) {}

const char *getPassName() const { return "MachineFunction Printer"; }

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
MachineFunctionPass::getAnalysisUsage(AU);
}

bool runOnMachineFunction(MachineFunction &MF) {
OS << "# " << Banner << ":\n";
MF.print(OS);
return false;
}
};
char Printer::ID = 0;
}

/// Returns a newly-created MachineFunction Printer pass. The default banner is
/// empty.
///
FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner){
return new Printer(OS, Banner);
}

//===----------------------------------------------------------------------===//
// MachineFunction implementation
//===----------------------------------------------------------------------===//
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/CodeGen/MachineFunctionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
using namespace llvm;

Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return createMachineFunctionPrinterPass(O, Banner);
}

bool MachineFunctionPass::runOnFunction(Function &F) {
// Do not codegen any 'available_externally' functions at all, they have
// definitions outside the translation unit.
Expand Down
60 changes: 0 additions & 60 deletions llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp
Original file line number Diff line number Diff line change
@@ -1,60 +0,0 @@
//===-- MachineFunctionPrinterPass.cpp ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// MachineFunctionPrinterPass implementation.
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
/// MachineFunctionPrinterPass - This is a pass to dump the IR of a
/// MachineFunction.
///
struct MachineFunctionPrinterPass : public MachineFunctionPass {
static char ID;

raw_ostream &OS;
const std::string Banner;

MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner)
: MachineFunctionPass(&ID), OS(os), Banner(banner) {}

const char *getPassName() const { return "MachineFunction Printer"; }

virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
MachineFunctionPass::getAnalysisUsage(AU);
}

bool runOnMachineFunction(MachineFunction &MF) {
OS << "# " << Banner << ":\n";
MF.print(OS);
return false;
}
};

char MachineFunctionPrinterPass::ID = 0;
}

namespace llvm {
/// Returns a newly-created MachineFunction Printer pass. The
/// default banner is empty.
///
MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS,
const std::string &Banner){
return new MachineFunctionPrinterPass(OS, Banner);
}

}
18 changes: 0 additions & 18 deletions llvm/lib/VMCore/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "llvm/Module.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PassNameParser.h"
Expand All @@ -43,11 +42,6 @@ Pass::~Pass() {
// Force out-of-line virtual method.
ModulePass::~ModulePass() { }

Pass *ModulePass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return createPrintModulePass(&O, false, Banner);
}

PassManagerType ModulePass::getPotentialPassManagerType() const {
return PMT_ModulePassManager;
}
Expand Down Expand Up @@ -119,11 +113,6 @@ void ImmutablePass::initializePass() {
// FunctionPass Implementation
//

Pass *FunctionPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {
return createPrintFunctionPass(Banner, &O);
}

// run - On a module, we run this pass by initializing, runOnFunction'ing once
// for every function in the module, then by finalizing.
//
Expand Down Expand Up @@ -166,13 +155,6 @@ PassManagerType FunctionPass::getPotentialPassManagerType() const {
// BasicBlockPass Implementation
//

Pass *BasicBlockPass::createPrinterPass(raw_ostream &O,
const std::string &Banner) const {

llvm_unreachable("BasicBlockPass printing unsupported.");
return 0;
}

// To run this pass on a function, we simply call runOnBasicBlock once for each
// function.
//
Expand Down
Loading

0 comments on commit 389525b

Please sign in to comment.