2009-07-03 19:28:36 +00:00
|
|
|
//===------------------- SSI.cpp - Creates SSI Representation -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This pass converts a list of variables to the Static Single Information
|
|
|
|
// form. This is a program representation described by Scott Ananian in his
|
|
|
|
// Master Thesis: "The Static Single Information Form (1999)".
|
|
|
|
// We are building an on-demand representation, that is, we do not convert
|
|
|
|
// every single variable in the target function to SSI form. Rather, we receive
|
|
|
|
// a list of target variables that must be converted. We also do not
|
|
|
|
// completely convert a target variable to the SSI format. Instead, we only
|
|
|
|
// change the variable in the points where new information can be attached
|
|
|
|
// to its live range, that is, at branch points.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "ssi"
|
|
|
|
|
|
|
|
#include "llvm/Transforms/Scalar.h"
|
|
|
|
#include "llvm/Transforms/Utils/SSI.h"
|
2009-07-09 15:33:14 +00:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2009-07-03 19:28:36 +00:00
|
|
|
#include "llvm/Analysis/Dominators.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
static const std::string SSI_PHI = "SSI_phi";
|
|
|
|
static const std::string SSI_SIG = "SSI_sigma";
|
|
|
|
|
2009-07-09 15:33:14 +00:00
|
|
|
STATISTIC(NumSigmaInserted, "Number of sigma functions inserted");
|
|
|
|
STATISTIC(NumPhiInserted, "Number of phi functions inserted");
|
|
|
|
|
2009-07-03 19:28:36 +00:00
|
|
|
void SSI::getAnalysisUsage(AnalysisUsage &AU) const {
|
2009-10-04 17:47:39 +00:00
|
|
|
AU.addRequiredTransitive<DominanceFrontier>();
|
|
|
|
AU.addRequiredTransitive<DominatorTree>();
|
|
|
|
AU.setPreservesAll();
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SSI::runOnFunction(Function &F) {
|
|
|
|
DT_ = &getAnalysis<DominatorTree>();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This methods creates the SSI representation for the list of values
|
|
|
|
/// received. It will only create SSI representation if a value is used
|
2009-10-04 17:52:13 +00:00
|
|
|
/// to decide a branch. Repeated values are created only once.
|
2009-07-03 19:28:36 +00:00
|
|
|
///
|
|
|
|
void SSI::createSSI(SmallVectorImpl<Instruction *> &value) {
|
|
|
|
init(value);
|
|
|
|
|
2009-10-04 18:49:55 +00:00
|
|
|
SmallPtrSet<Instruction*, 4> needConstruction;
|
|
|
|
for (SmallVectorImpl<Instruction*>::iterator I = value.begin(),
|
|
|
|
E = value.end(); I != E; ++I)
|
|
|
|
if (created.insert(*I))
|
|
|
|
needConstruction.insert(*I);
|
|
|
|
|
|
|
|
insertSigmaFunctions(needConstruction);
|
2009-07-03 19:28:36 +00:00
|
|
|
|
|
|
|
// Test if there is a need to transform to SSI
|
2009-10-04 18:49:55 +00:00
|
|
|
if (!needConstruction.empty()) {
|
|
|
|
insertPhiFunctions(needConstruction);
|
|
|
|
renameInit(needConstruction);
|
2009-07-03 19:28:36 +00:00
|
|
|
rename(DT_->getRoot());
|
|
|
|
fixPhis();
|
|
|
|
}
|
|
|
|
|
|
|
|
clean();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Insert sigma functions (a sigma function is a phi function with one
|
|
|
|
/// operator)
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
void SSI::insertSigmaFunctions(SmallPtrSet<Instruction*, 4> &value) {
|
|
|
|
for (SmallPtrSet<Instruction*, 4>::iterator I = value.begin(),
|
|
|
|
E = value.end(); I != E; ++I) {
|
|
|
|
for (Value::use_iterator begin = (*I)->use_begin(),
|
|
|
|
end = (*I)->use_end(); begin != end; ++begin) {
|
2009-07-03 19:28:36 +00:00
|
|
|
// Test if the Use of the Value is in a comparator
|
2009-09-10 07:02:09 +00:00
|
|
|
if (CmpInst *CI = dyn_cast<CmpInst>(begin)) {
|
|
|
|
// Iterates through all uses of CmpInst
|
2009-10-04 18:49:55 +00:00
|
|
|
for (Value::use_iterator begin_ci = CI->use_begin(),
|
|
|
|
end_ci = CI->use_end(); begin_ci != end_ci; ++begin_ci) {
|
2009-09-10 07:02:09 +00:00
|
|
|
// Test if any use of CmpInst is in a Terminator
|
|
|
|
if (TerminatorInst *TI = dyn_cast<TerminatorInst>(begin_ci)) {
|
2009-10-04 18:49:55 +00:00
|
|
|
insertSigma(TI, *I);
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 07:02:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Inserts Sigma Functions in every BasicBlock successor to Terminator
|
|
|
|
/// Instruction TI. All inserted Sigma Function are related to Instruction I.
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
void SSI::insertSigma(TerminatorInst *TI, Instruction *I) {
|
2009-09-10 07:02:09 +00:00
|
|
|
// Basic Block of the Terminator Instruction
|
|
|
|
BasicBlock *BB = TI->getParent();
|
|
|
|
for (unsigned i = 0, e = TI->getNumSuccessors(); i < e; ++i) {
|
|
|
|
// Next Basic Block
|
|
|
|
BasicBlock *BB_next = TI->getSuccessor(i);
|
|
|
|
if (BB_next != BB &&
|
|
|
|
BB_next->getSinglePredecessor() != NULL &&
|
|
|
|
dominateAny(BB_next, I)) {
|
|
|
|
PHINode *PN = PHINode::Create(I->getType(), SSI_SIG, BB_next->begin());
|
|
|
|
PN->addIncoming(I, BB);
|
2009-10-04 18:49:55 +00:00
|
|
|
sigmas[PN] = I;
|
2009-09-10 07:02:09 +00:00
|
|
|
created.insert(PN);
|
2009-10-04 18:49:55 +00:00
|
|
|
defsites[I].push_back(BB_next);
|
2009-09-10 07:02:09 +00:00
|
|
|
++NumSigmaInserted;
|
|
|
|
}
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Insert phi functions when necessary
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
void SSI::insertPhiFunctions(SmallPtrSet<Instruction*, 4> &value) {
|
2009-07-03 19:28:36 +00:00
|
|
|
DominanceFrontier *DF = &getAnalysis<DominanceFrontier>();
|
2009-10-04 18:49:55 +00:00
|
|
|
for (SmallPtrSet<Instruction*, 4>::iterator I = value.begin(),
|
|
|
|
E = value.end(); I != E; ++I) {
|
2009-07-03 19:28:36 +00:00
|
|
|
// Test if there were any sigmas for this variable
|
2009-10-04 18:49:55 +00:00
|
|
|
SmallPtrSet<BasicBlock *, 16> BB_visited;
|
|
|
|
|
|
|
|
// Insert phi functions if there is any sigma function
|
|
|
|
while (!defsites[*I].empty()) {
|
|
|
|
|
|
|
|
BasicBlock *BB = defsites[*I].back();
|
|
|
|
|
|
|
|
defsites[*I].pop_back();
|
|
|
|
DominanceFrontier::iterator DF_BB = DF->find(BB);
|
|
|
|
|
|
|
|
// The BB is unreachable. Skip it.
|
|
|
|
if (DF_BB == DF->end())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Iterates through all the dominance frontier of BB
|
|
|
|
for (std::set<BasicBlock *>::iterator DF_BB_begin =
|
|
|
|
DF_BB->second.begin(), DF_BB_end = DF_BB->second.end();
|
|
|
|
DF_BB_begin != DF_BB_end; ++DF_BB_begin) {
|
|
|
|
BasicBlock *BB_dominated = *DF_BB_begin;
|
|
|
|
|
|
|
|
// Test if has not yet visited this node and if the
|
|
|
|
// original definition dominates this node
|
|
|
|
if (BB_visited.insert(BB_dominated) &&
|
|
|
|
DT_->properlyDominates(value_original[*I], BB_dominated) &&
|
|
|
|
dominateAny(BB_dominated, *I)) {
|
|
|
|
PHINode *PN = PHINode::Create(
|
|
|
|
(*I)->getType(), SSI_PHI, BB_dominated->begin());
|
|
|
|
phis.insert(std::make_pair(PN, *I));
|
|
|
|
created.insert(PN);
|
|
|
|
|
|
|
|
defsites[*I].push_back(BB_dominated);
|
|
|
|
++NumPhiInserted;
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-04 18:49:55 +00:00
|
|
|
BB_visited.clear();
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Some initialization for the rename part
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
void SSI::renameInit(SmallPtrSet<Instruction*, 4> &value) {
|
|
|
|
for (SmallPtrSet<Instruction*, 4>::iterator I = value.begin(),
|
|
|
|
E = value.end(); I != E; ++I)
|
|
|
|
value_stack[*I].push_back(*I);
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Renames all variables in the specified BasicBlock.
|
|
|
|
/// Only variables that need to be rename will be.
|
|
|
|
///
|
|
|
|
void SSI::rename(BasicBlock *BB) {
|
2009-10-04 18:49:55 +00:00
|
|
|
SmallPtrSet<Instruction*, 8> defined;
|
2009-07-03 19:28:36 +00:00
|
|
|
|
|
|
|
// Iterate through instructions and make appropriate renaming.
|
|
|
|
// For SSI_PHI (b = PHI()), store b at value_stack as a new
|
|
|
|
// definition of the variable it represents.
|
|
|
|
// For SSI_SIG (b = PHI(a)), substitute a with the current
|
|
|
|
// value of a, present in the value_stack.
|
|
|
|
// Then store bin the value_stack as the new definition of a.
|
|
|
|
// For all other instructions (b = OP(a, c, d, ...)), we need to substitute
|
|
|
|
// all operands with its current value, present in value_stack.
|
|
|
|
for (BasicBlock::iterator begin = BB->begin(), end = BB->end();
|
|
|
|
begin != end; ++begin) {
|
|
|
|
Instruction *I = begin;
|
|
|
|
if (PHINode *PN = dyn_cast<PHINode>(I)) { // Treat PHI functions
|
2009-10-04 18:49:55 +00:00
|
|
|
Instruction* position;
|
2009-07-03 19:28:36 +00:00
|
|
|
|
|
|
|
// Treat SSI_PHI
|
2009-10-04 18:49:55 +00:00
|
|
|
if ((position = getPositionPhi(PN))) {
|
2009-07-03 19:28:36 +00:00
|
|
|
value_stack[position].push_back(PN);
|
2009-10-04 18:49:55 +00:00
|
|
|
defined.insert(position);
|
2009-07-03 19:28:36 +00:00
|
|
|
// Treat SSI_SIG
|
2009-10-04 18:49:55 +00:00
|
|
|
} else if ((position = getPositionSigma(PN))) {
|
2009-07-03 19:28:36 +00:00
|
|
|
substituteUse(I);
|
|
|
|
value_stack[position].push_back(PN);
|
2009-10-04 18:49:55 +00:00
|
|
|
defined.insert(position);
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Treat all other PHI functions
|
|
|
|
else {
|
|
|
|
substituteUse(I);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Treat all other functions
|
|
|
|
else {
|
|
|
|
substituteUse(I);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This loop iterates in all BasicBlocks that are successors of the current
|
|
|
|
// BasicBlock. For each SSI_PHI instruction found, insert an operand.
|
|
|
|
// This operand is the current operand in value_stack for the variable
|
|
|
|
// in "position". And the BasicBlock this operand represents is the current
|
|
|
|
// BasicBlock.
|
|
|
|
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI) {
|
|
|
|
BasicBlock *BB_succ = *SI;
|
|
|
|
|
|
|
|
for (BasicBlock::iterator begin = BB_succ->begin(),
|
|
|
|
notPhi = BB_succ->getFirstNonPHI(); begin != *notPhi; ++begin) {
|
|
|
|
Instruction *I = begin;
|
2009-08-19 07:16:57 +00:00
|
|
|
PHINode *PN = dyn_cast<PHINode>(I);
|
2009-10-04 18:49:55 +00:00
|
|
|
Instruction* position;
|
|
|
|
if (PN && ((position = getPositionPhi(PN)))) {
|
2009-07-03 19:28:36 +00:00
|
|
|
PN->addIncoming(value_stack[position].back(), BB);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This loop calls rename on all children from this block. This time children
|
|
|
|
// refers to a successor block in the dominance tree.
|
|
|
|
DomTreeNode *DTN = DT_->getNode(BB);
|
|
|
|
for (DomTreeNode::iterator begin = DTN->begin(), end = DTN->end();
|
|
|
|
begin != end; ++begin) {
|
|
|
|
DomTreeNodeBase<BasicBlock> *DTN_children = *begin;
|
|
|
|
BasicBlock *BB_children = DTN_children->getBlock();
|
|
|
|
rename(BB_children);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we remove all inserted definitions of a variable from the top of
|
|
|
|
// the stack leaving the previous one as the top.
|
2009-10-04 18:49:55 +00:00
|
|
|
for (SmallPtrSet<Instruction*, 8>::iterator DI = defined.begin(),
|
|
|
|
DE = defined.end(); DI != DE; ++DI)
|
|
|
|
value_stack[*DI].pop_back();
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Substitute any use in this instruction for the last definition of
|
|
|
|
/// the variable
|
|
|
|
///
|
|
|
|
void SSI::substituteUse(Instruction *I) {
|
|
|
|
for (unsigned i = 0, e = I->getNumOperands(); i < e; ++i) {
|
|
|
|
Value *operand = I->getOperand(i);
|
2009-10-04 18:49:55 +00:00
|
|
|
for (DenseMap<Instruction*, SmallVector<Instruction*, 1> >::iterator
|
|
|
|
VI = value_stack.begin(), VE = value_stack.end(); VI != VE; ++VI) {
|
|
|
|
if (operand == VI->second.front() &&
|
|
|
|
I != VI->second.back()) {
|
2009-07-03 19:28:36 +00:00
|
|
|
PHINode *PN_I = dyn_cast<PHINode>(I);
|
2009-10-04 18:49:55 +00:00
|
|
|
PHINode *PN_vs = dyn_cast<PHINode>(VI->second.back());
|
2009-07-03 19:28:36 +00:00
|
|
|
|
|
|
|
// If a phi created in a BasicBlock is used as an operand of another
|
|
|
|
// created in the same BasicBlock, this step marks this second phi,
|
|
|
|
// to fix this issue later. It cannot be fixed now, because the
|
|
|
|
// operands of the first phi are not final yet.
|
|
|
|
if (PN_I && PN_vs &&
|
2009-10-04 18:49:55 +00:00
|
|
|
VI->second.back()->getParent() == I->getParent()) {
|
2009-07-03 19:28:36 +00:00
|
|
|
|
|
|
|
phisToFix.insert(PN_I);
|
|
|
|
}
|
|
|
|
|
2009-10-04 18:49:55 +00:00
|
|
|
I->setOperand(i, VI->second.back());
|
2009-07-03 19:28:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Test if the BasicBlock BB dominates any use or definition of value.
|
2009-07-09 15:59:27 +00:00
|
|
|
/// If it dominates a phi instruction that is on the same BasicBlock,
|
|
|
|
/// that does not count.
|
2009-07-03 19:28:36 +00:00
|
|
|
///
|
|
|
|
bool SSI::dominateAny(BasicBlock *BB, Instruction *value) {
|
|
|
|
for (Value::use_iterator begin = value->use_begin(),
|
|
|
|
end = value->use_end(); begin != end; ++begin) {
|
|
|
|
Instruction *I = cast<Instruction>(*begin);
|
|
|
|
BasicBlock *BB_father = I->getParent();
|
2009-07-09 15:59:27 +00:00
|
|
|
if (BB == BB_father && isa<PHINode>(I))
|
|
|
|
continue;
|
2009-07-03 19:28:36 +00:00
|
|
|
if (DT_->dominates(BB, BB_father)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// When there is a phi node that is created in a BasicBlock and it is used
|
|
|
|
/// as an operand of another phi function used in the same BasicBlock,
|
|
|
|
/// LLVM looks this as an error. So on the second phi, the first phi is called
|
|
|
|
/// P and the BasicBlock it incomes is B. This P will be replaced by the value
|
2009-08-19 07:16:57 +00:00
|
|
|
/// it has for BasicBlock B. It also includes undef values for predecessors
|
|
|
|
/// that were not included in the phi.
|
2009-07-03 19:28:36 +00:00
|
|
|
///
|
|
|
|
void SSI::fixPhis() {
|
|
|
|
for (SmallPtrSet<PHINode *, 1>::iterator begin = phisToFix.begin(),
|
|
|
|
end = phisToFix.end(); begin != end; ++begin) {
|
|
|
|
PHINode *PN = *begin;
|
|
|
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i < e; ++i) {
|
2009-08-19 07:16:57 +00:00
|
|
|
PHINode *PN_father = dyn_cast<PHINode>(PN->getIncomingValue(i));
|
|
|
|
if (PN_father && PN->getParent() == PN_father->getParent() &&
|
2009-08-19 06:24:33 +00:00
|
|
|
!DT_->dominates(PN->getParent(), PN->getIncomingBlock(i))) {
|
2009-07-03 19:28:36 +00:00
|
|
|
BasicBlock *BB = PN->getIncomingBlock(i);
|
|
|
|
int pos = PN_father->getBasicBlockIndex(BB);
|
|
|
|
PN->setIncomingValue(i, PN_father->getIncomingValue(pos));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-19 07:16:57 +00:00
|
|
|
|
2009-10-04 18:49:55 +00:00
|
|
|
for (DenseMapIterator<PHINode *, Instruction*> begin = phis.begin(),
|
2009-08-19 07:16:57 +00:00
|
|
|
end = phis.end(); begin != end; ++begin) {
|
|
|
|
PHINode *PN = begin->first;
|
|
|
|
BasicBlock *BB = PN->getParent();
|
|
|
|
pred_iterator PI = pred_begin(BB), PE = pred_end(BB);
|
|
|
|
SmallVector<BasicBlock*, 8> Preds(PI, PE);
|
|
|
|
for (unsigned size = Preds.size();
|
|
|
|
PI != PE && PN->getNumIncomingValues() != size; ++PI) {
|
|
|
|
bool found = false;
|
|
|
|
for (unsigned i = 0, pn_end = PN->getNumIncomingValues();
|
|
|
|
i < pn_end; ++i) {
|
|
|
|
if (PN->getIncomingBlock(i) == *PI) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
PN->addIncoming(UndefValue::get(PN->getType()), *PI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Return which variable (position on the vector of variables) this phi
|
|
|
|
/// represents on the phis list.
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
Instruction* SSI::getPositionPhi(PHINode *PN) {
|
|
|
|
DenseMap<PHINode *, Instruction*>::iterator val = phis.find(PN);
|
2009-07-03 19:28:36 +00:00
|
|
|
if (val == phis.end())
|
2009-10-04 18:49:55 +00:00
|
|
|
return 0;
|
2009-07-03 19:28:36 +00:00
|
|
|
else
|
|
|
|
return val->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return which variable (position on the vector of variables) this phi
|
|
|
|
/// represents on the sigmas list.
|
|
|
|
///
|
2009-10-04 18:49:55 +00:00
|
|
|
Instruction* SSI::getPositionSigma(PHINode *PN) {
|
|
|
|
DenseMap<PHINode *, Instruction*>::iterator val = sigmas.find(PN);
|
2009-07-03 19:28:36 +00:00
|
|
|
if (val == sigmas.end())
|
2009-10-04 18:49:55 +00:00
|
|
|
return 0;
|
2009-07-03 19:28:36 +00:00
|
|
|
else
|
|
|
|
return val->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Initializes
|
|
|
|
///
|
|
|
|
void SSI::init(SmallVectorImpl<Instruction *> &value) {
|
2009-10-04 18:49:55 +00:00
|
|
|
for (SmallVectorImpl<Instruction *>::iterator I = value.begin(),
|
|
|
|
E = value.end(); I != E; ++I) {
|
|
|
|
value_original[*I] = (*I)->getParent();
|
|
|
|
defsites[*I].push_back((*I)->getParent());
|
2009-07-03 19:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clean all used resources in this creation of SSI
|
|
|
|
///
|
|
|
|
void SSI::clean() {
|
|
|
|
phis.clear();
|
|
|
|
sigmas.clear();
|
|
|
|
phisToFix.clear();
|
|
|
|
|
|
|
|
defsites.clear();
|
|
|
|
value_stack.clear();
|
|
|
|
value_original.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// createSSIPass - The public interface to this file...
|
|
|
|
///
|
|
|
|
FunctionPass *llvm::createSSIPass() { return new SSI(); }
|
|
|
|
|
|
|
|
char SSI::ID = 0;
|
|
|
|
static RegisterPass<SSI> X("ssi", "Static Single Information Construction");
|
|
|
|
|
2009-07-09 15:33:14 +00:00
|
|
|
/// SSIEverything - A pass that runs createSSI on every non-void variable,
|
|
|
|
/// intended for debugging.
|
|
|
|
namespace {
|
2009-10-25 06:33:48 +00:00
|
|
|
struct SSIEverything : public FunctionPass {
|
2009-07-09 15:33:14 +00:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2009-08-11 15:15:10 +00:00
|
|
|
SSIEverything() : FunctionPass(&ID) {}
|
2009-07-09 15:33:14 +00:00
|
|
|
|
|
|
|
bool runOnFunction(Function &F);
|
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.addRequired<SSI>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SSIEverything::runOnFunction(Function &F) {
|
|
|
|
SmallVector<Instruction *, 16> Insts;
|
|
|
|
SSI &ssi = getAnalysis<SSI>();
|
|
|
|
|
|
|
|
if (F.isDeclaration() || F.isIntrinsic()) return false;
|
|
|
|
|
|
|
|
for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B)
|
|
|
|
for (BasicBlock::iterator I = B->begin(), E = B->end(); I != E; ++I)
|
2010-01-05 13:12:22 +00:00
|
|
|
if (!I->getType()->isVoidTy())
|
2009-07-09 15:33:14 +00:00
|
|
|
Insts.push_back(I);
|
|
|
|
|
|
|
|
ssi.createSSI(Insts);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// createSSIEverythingPass - The public interface to this file...
|
|
|
|
///
|
|
|
|
FunctionPass *llvm::createSSIEverythingPass() { return new SSIEverything(); }
|
|
|
|
|
|
|
|
char SSIEverything::ID = 0;
|
|
|
|
static RegisterPass<SSIEverything>
|
|
|
|
Y("ssi-everything", "Static Single Information Construction");
|