mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-31 15:53:42 +00:00
Fix PR 1526.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b42bcdd1a
commit
28552da9c3
5
test/Other/2007-06-28-PassManager.ll
Normal file
5
test/Other/2007-06-28-PassManager.ll
Normal file
@ -0,0 +1,5 @@
|
||||
; RUN: llvm-as < %s | opt -analyze -inline -disable-output
|
||||
; PR 1526
|
||||
define i32 @test1() {
|
||||
ret i32 0;
|
||||
}
|
@ -14,10 +14,12 @@
|
||||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/CallGraphSCCPass.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Assembly/PrintModulePass.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/CallGraph.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Support/PassNameParser.h"
|
||||
@ -94,6 +96,36 @@ AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
|
||||
// ---------- Define Printers for module and function passes ------------
|
||||
namespace {
|
||||
|
||||
struct CallGraphSCCPassPrinter : public CallGraphSCCPass {
|
||||
static char ID;
|
||||
const PassInfo *PassToPrint;
|
||||
CallGraphSCCPassPrinter(const PassInfo *PI) :
|
||||
CallGraphSCCPass((intptr_t)&ID), PassToPrint(PI) {}
|
||||
|
||||
virtual bool runOnSCC(const std::vector<CallGraphNode *>&SCC) {
|
||||
if (!Quiet) {
|
||||
cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
|
||||
|
||||
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
|
||||
Function *F = SCC[i]->getFunction();
|
||||
if (F)
|
||||
getAnalysisID<Pass>(PassToPrint).print(cout, F->getParent());
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
}
|
||||
};
|
||||
|
||||
char CallGraphSCCPassPrinter::ID = 0;
|
||||
|
||||
struct ModulePassPrinter : public ModulePass {
|
||||
static char ID;
|
||||
const PassInfo *PassToPrint;
|
||||
@ -342,6 +374,8 @@ int main(int argc, char **argv) {
|
||||
Passes.add(new BasicBlockPassPrinter(PassInf));
|
||||
else if (dynamic_cast<FunctionPass*>(P))
|
||||
Passes.add(new FunctionPassPrinter(PassInf));
|
||||
else if (dynamic_cast<CallGraphSCCPass*>(P))
|
||||
Passes.add(new CallGraphSCCPassPrinter(PassInf));
|
||||
else
|
||||
Passes.add(new ModulePassPrinter(PassInf));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user