freebsd-nq/lib/Analysis/PostDominators.cpp

66 lines
2.1 KiB
C++
Raw Normal View History

2009-06-02 17:52:33 +00:00
//===- PostDominators.cpp - Post-Dominator Calculation --------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the post-dominator construction algorithms.
//
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/PostDominators.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SetOperations.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GenericDomTreeConstruction.h"
2009-06-02 17:52:33 +00:00
using namespace llvm;
#define DEBUG_TYPE "postdomtree"
2009-06-02 17:52:33 +00:00
//===----------------------------------------------------------------------===//
// PostDominatorTree Implementation
//===----------------------------------------------------------------------===//
char PostDominatorTreeWrapperPass::ID = 0;
INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree",
"Post-Dominator Tree Construction", true, true)
2009-06-02 17:52:33 +00:00
bool PostDominatorTreeWrapperPass::runOnFunction(Function &F) {
DT.recalculate(F);
2009-06-02 17:52:33 +00:00
return false;
}
void PostDominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
DT.print(OS);
2009-06-02 17:52:33 +00:00
}
FunctionPass* llvm::createPostDomTree() {
return new PostDominatorTreeWrapperPass();
2009-10-14 17:57:32 +00:00
}
AnalysisKey PostDominatorTreeAnalysis::Key;
2009-10-14 17:57:32 +00:00
PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
FunctionAnalysisManager &) {
PostDominatorTree PDT;
PDT.recalculate(F);
return PDT;
2009-06-02 17:52:33 +00:00
}
PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS)
: OS(OS) {}
PreservedAnalyses
PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
OS << "PostDominatorTree for function: " << F.getName() << "\n";
AM.getResult<PostDominatorTreeAnalysis>(F).print(OS);
return PreservedAnalyses::all();
}