mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-24 12:50:42 +00:00
remove the ABCD and SSI passes. They don't have any clients that
I'm aware of, aren't maintained, and LVI will be replacing their value. nlewycky approved this on irc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5f8a87dd76
commit
5f88af5376
@ -142,10 +142,7 @@ namespace {
|
||||
(void) llvm::createDbgInfoPrinterPass();
|
||||
(void) llvm::createModuleDebugInfoPrinterPass();
|
||||
(void) llvm::createPartialInliningPass();
|
||||
(void) llvm::createSSIPass();
|
||||
(void) llvm::createSSIEverythingPass();
|
||||
(void) llvm::createGEPSplitterPass();
|
||||
(void) llvm::createABCDPass();
|
||||
(void) llvm::createLintPass();
|
||||
(void) llvm::createSinkingPass();
|
||||
(void) llvm::createLowerAtomicPass();
|
||||
|
@ -305,32 +305,12 @@ FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
|
||||
FunctionPass *createInstructionNamerPass();
|
||||
extern char &InstructionNamerID;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// SSI - This pass converts instructions to Static Single Information form
|
||||
// on demand.
|
||||
//
|
||||
FunctionPass *createSSIPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// SSI - This pass converts every non-void instuction to Static Single
|
||||
// Information form.
|
||||
//
|
||||
FunctionPass *createSSIEverythingPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// GEPSplitter - Split complex GEPs into simple ones
|
||||
//
|
||||
FunctionPass *createGEPSplitterPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// ABCD - Elimination of Array Bounds Checks on Demand
|
||||
//
|
||||
FunctionPass *createABCDPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Sink - Code Sinking
|
||||
|
@ -1,93 +0,0 @@
|
||||
//===------------------- SSI.h - Creates SSI Representation -----*- C++ -*-===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_UTILS_SSI_H
|
||||
#define LLVM_TRANSFORMS_UTILS_SSI_H
|
||||
|
||||
#include "llvm/InstrTypes.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class DominatorTree;
|
||||
class PHINode;
|
||||
class Instruction;
|
||||
class CmpInst;
|
||||
|
||||
class SSI : public FunctionPass {
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid.
|
||||
SSI() :
|
||||
FunctionPass(ID) {
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||
|
||||
bool runOnFunction(Function&);
|
||||
|
||||
void createSSI(SmallVectorImpl<Instruction *> &value);
|
||||
|
||||
private:
|
||||
// Variables always live
|
||||
DominatorTree *DT_;
|
||||
|
||||
// Stores variables created by SSI
|
||||
SmallPtrSet<Instruction *, 16> created;
|
||||
|
||||
// Phis created by SSI
|
||||
DenseMap<PHINode *, Instruction*> phis;
|
||||
|
||||
// Sigmas created by SSI
|
||||
DenseMap<PHINode *, Instruction*> sigmas;
|
||||
|
||||
// Phi nodes that have a phi as operand and has to be fixed
|
||||
SmallPtrSet<PHINode *, 1> phisToFix;
|
||||
|
||||
// List of definition points for every variable
|
||||
DenseMap<Instruction*, SmallVector<BasicBlock*, 4> > defsites;
|
||||
|
||||
// Basic Block of the original definition of each variable
|
||||
DenseMap<Instruction*, BasicBlock*> value_original;
|
||||
|
||||
// Stack of last seen definition of a variable
|
||||
DenseMap<Instruction*, SmallVector<Instruction *, 1> > value_stack;
|
||||
|
||||
void insertSigmaFunctions(SmallPtrSet<Instruction*, 4> &value);
|
||||
void insertSigma(TerminatorInst *TI, Instruction *I);
|
||||
void insertPhiFunctions(SmallPtrSet<Instruction*, 4> &value);
|
||||
void renameInit(SmallPtrSet<Instruction*, 4> &value);
|
||||
void rename(BasicBlock *BB);
|
||||
|
||||
void substituteUse(Instruction *I);
|
||||
bool dominateAny(BasicBlock *BB, Instruction *value);
|
||||
void fixPhis();
|
||||
|
||||
Instruction* getPositionPhi(PHINode *PN);
|
||||
Instruction* getPositionSigma(PHINode *PN);
|
||||
|
||||
void init(SmallVectorImpl<Instruction *> &value);
|
||||
void clean();
|
||||
};
|
||||
} // end namespace
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,4 @@
|
||||
add_llvm_library(LLVMScalarOpts
|
||||
ABCD.cpp
|
||||
ADCE.cpp
|
||||
BasicBlockPlacement.cpp
|
||||
CodeGenPrepare.cpp
|
||||
|
@ -20,7 +20,6 @@ add_llvm_library(LLVMTransformUtils
|
||||
Mem2Reg.cpp
|
||||
PromoteMemoryToRegister.cpp
|
||||
SSAUpdater.cpp
|
||||
SSI.cpp
|
||||
SimplifyCFG.cpp
|
||||
UnifyFunctionExitNodes.cpp
|
||||
ValueMapper.cpp
|
||||
|
@ -1,433 +0,0 @@
|
||||
//===------------------- 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"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static const std::string SSI_PHI = "SSI_phi";
|
||||
static const std::string SSI_SIG = "SSI_sigma";
|
||||
|
||||
STATISTIC(NumSigmaInserted, "Number of sigma functions inserted");
|
||||
STATISTIC(NumPhiInserted, "Number of phi functions inserted");
|
||||
|
||||
void SSI::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequiredTransitive<DominanceFrontier>();
|
||||
AU.addRequiredTransitive<DominatorTree>();
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
|
||||
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
|
||||
/// to decide a branch. Repeated values are created only once.
|
||||
///
|
||||
void SSI::createSSI(SmallVectorImpl<Instruction *> &value) {
|
||||
init(value);
|
||||
|
||||
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);
|
||||
|
||||
// Test if there is a need to transform to SSI
|
||||
if (!needConstruction.empty()) {
|
||||
insertPhiFunctions(needConstruction);
|
||||
renameInit(needConstruction);
|
||||
rename(DT_->getRoot());
|
||||
fixPhis();
|
||||
}
|
||||
|
||||
clean();
|
||||
}
|
||||
|
||||
/// Insert sigma functions (a sigma function is a phi function with one
|
||||
/// operator)
|
||||
///
|
||||
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) {
|
||||
// Test if the Use of the Value is in a comparator
|
||||
if (CmpInst *CI = dyn_cast<CmpInst>(*begin)) {
|
||||
// Iterates through all uses of CmpInst
|
||||
for (Value::use_iterator begin_ci = CI->use_begin(),
|
||||
end_ci = CI->use_end(); begin_ci != end_ci; ++begin_ci) {
|
||||
// Test if any use of CmpInst is in a Terminator
|
||||
if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*begin_ci)) {
|
||||
insertSigma(TI, *I);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Inserts Sigma Functions in every BasicBlock successor to Terminator
|
||||
/// Instruction TI. All inserted Sigma Function are related to Instruction I.
|
||||
///
|
||||
void SSI::insertSigma(TerminatorInst *TI, Instruction *I) {
|
||||
// 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);
|
||||
sigmas[PN] = I;
|
||||
created.insert(PN);
|
||||
defsites[I].push_back(BB_next);
|
||||
++NumSigmaInserted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Insert phi functions when necessary
|
||||
///
|
||||
void SSI::insertPhiFunctions(SmallPtrSet<Instruction*, 4> &value) {
|
||||
DominanceFrontier *DF = &getAnalysis<DominanceFrontier>();
|
||||
for (SmallPtrSet<Instruction*, 4>::iterator I = value.begin(),
|
||||
E = value.end(); I != E; ++I) {
|
||||
// Test if there were any sigmas for this variable
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
BB_visited.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Some initialization for the rename part
|
||||
///
|
||||
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);
|
||||
}
|
||||
|
||||
/// Renames all variables in the specified BasicBlock.
|
||||
/// Only variables that need to be rename will be.
|
||||
///
|
||||
void SSI::rename(BasicBlock *BB) {
|
||||
SmallPtrSet<Instruction*, 8> defined;
|
||||
|
||||
// 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
|
||||
Instruction* position;
|
||||
|
||||
// Treat SSI_PHI
|
||||
if ((position = getPositionPhi(PN))) {
|
||||
value_stack[position].push_back(PN);
|
||||
defined.insert(position);
|
||||
// Treat SSI_SIG
|
||||
} else if ((position = getPositionSigma(PN))) {
|
||||
substituteUse(I);
|
||||
value_stack[position].push_back(PN);
|
||||
defined.insert(position);
|
||||
}
|
||||
|
||||
// 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;
|
||||
PHINode *PN = dyn_cast<PHINode>(I);
|
||||
Instruction* position;
|
||||
if (PN && ((position = getPositionPhi(PN)))) {
|
||||
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.
|
||||
for (SmallPtrSet<Instruction*, 8>::iterator DI = defined.begin(),
|
||||
DE = defined.end(); DI != DE; ++DI)
|
||||
value_stack[*DI].pop_back();
|
||||
}
|
||||
|
||||
/// 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);
|
||||
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()) {
|
||||
PHINode *PN_I = dyn_cast<PHINode>(I);
|
||||
PHINode *PN_vs = dyn_cast<PHINode>(VI->second.back());
|
||||
|
||||
// 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 &&
|
||||
VI->second.back()->getParent() == I->getParent()) {
|
||||
|
||||
phisToFix.insert(PN_I);
|
||||
}
|
||||
|
||||
I->setOperand(i, VI->second.back());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Test if the BasicBlock BB dominates any use or definition of value.
|
||||
/// If it dominates a phi instruction that is on the same BasicBlock,
|
||||
/// that does not count.
|
||||
///
|
||||
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();
|
||||
if (BB == BB_father && isa<PHINode>(I))
|
||||
continue;
|
||||
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
|
||||
/// it has for BasicBlock B. It also includes undef values for predecessors
|
||||
/// that were not included in the phi.
|
||||
///
|
||||
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) {
|
||||
PHINode *PN_father = dyn_cast<PHINode>(PN->getIncomingValue(i));
|
||||
if (PN_father && PN->getParent() == PN_father->getParent() &&
|
||||
!DT_->dominates(PN->getParent(), PN->getIncomingBlock(i))) {
|
||||
BasicBlock *BB = PN->getIncomingBlock(i);
|
||||
int pos = PN_father->getBasicBlockIndex(BB);
|
||||
PN->setIncomingValue(i, PN_father->getIncomingValue(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (DenseMapIterator<PHINode *, Instruction*> begin = phis.begin(),
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Return which variable (position on the vector of variables) this phi
|
||||
/// represents on the phis list.
|
||||
///
|
||||
Instruction* SSI::getPositionPhi(PHINode *PN) {
|
||||
DenseMap<PHINode *, Instruction*>::iterator val = phis.find(PN);
|
||||
if (val == phis.end())
|
||||
return 0;
|
||||
else
|
||||
return val->second;
|
||||
}
|
||||
|
||||
/// Return which variable (position on the vector of variables) this phi
|
||||
/// represents on the sigmas list.
|
||||
///
|
||||
Instruction* SSI::getPositionSigma(PHINode *PN) {
|
||||
DenseMap<PHINode *, Instruction*>::iterator val = sigmas.find(PN);
|
||||
if (val == sigmas.end())
|
||||
return 0;
|
||||
else
|
||||
return val->second;
|
||||
}
|
||||
|
||||
/// Initializes
|
||||
///
|
||||
void SSI::init(SmallVectorImpl<Instruction *> &value) {
|
||||
for (SmallVectorImpl<Instruction *>::iterator I = value.begin(),
|
||||
E = value.end(); I != E; ++I) {
|
||||
value_original[*I] = (*I)->getParent();
|
||||
defsites[*I].push_back((*I)->getParent());
|
||||
}
|
||||
}
|
||||
|
||||
/// 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;
|
||||
INITIALIZE_PASS(SSI, "ssi",
|
||||
"Static Single Information Construction", false, false);
|
||||
|
||||
/// SSIEverything - A pass that runs createSSI on every non-void variable,
|
||||
/// intended for debugging.
|
||||
namespace {
|
||||
struct SSIEverything : public FunctionPass {
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
SSIEverything() : FunctionPass(ID) {}
|
||||
|
||||
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)
|
||||
if (!I->getType()->isVoidTy())
|
||||
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;
|
||||
INITIALIZE_PASS(SSIEverything, "ssi-everything",
|
||||
"Static Single Information Construction", false, false);
|
@ -1,27 +0,0 @@
|
||||
; RUN: opt < %s -abcd -S | FileCheck %s
|
||||
|
||||
define void @test() {
|
||||
; CHECK: @test
|
||||
; CHECK-NOT: br i1 %tmp95
|
||||
; CHECK: ret void
|
||||
entry:
|
||||
br label %bb19
|
||||
|
||||
bb:
|
||||
br label %bb1
|
||||
|
||||
bb1:
|
||||
%tmp7 = icmp sgt i32 %tmp94, 1
|
||||
br i1 %tmp7, label %bb.i.i, label %return
|
||||
|
||||
bb.i.i:
|
||||
br label %return
|
||||
|
||||
bb19:
|
||||
%tmp94 = ashr i32 undef, 3
|
||||
%tmp95 = icmp sgt i32 %tmp94, 16
|
||||
br i1 %tmp95, label %bb, label %return
|
||||
|
||||
return:
|
||||
ret void
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
load_lib llvm.exp
|
||||
|
||||
RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
|
@ -1,71 +0,0 @@
|
||||
; RUN: opt < %s -ssi-everything -disable-output
|
||||
; PR4511
|
||||
|
||||
%"struct.std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >" = type { %"struct.std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_Vector_impl" }
|
||||
%"struct.std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_Vector_impl" = type { %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* }
|
||||
%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >" = type { %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider" }
|
||||
%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider" = type { i8* }
|
||||
%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Rep" = type { %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Rep_base" }
|
||||
%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Rep_base" = type { i32, i32, i32 }
|
||||
%"struct.std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >" = type { %"struct.std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >" }
|
||||
|
||||
declare void @_Unwind_Resume(i8*)
|
||||
|
||||
declare fastcc %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* @_ZSt24__uninitialized_copy_auxIPSsS0_ET0_T_S2_S1_St12__false_type(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*)
|
||||
|
||||
define fastcc void @_ZNSt6vectorISsSaISsEE9push_backERKSs(%"struct.std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >"* nocapture %this, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* nocapture %__x) {
|
||||
entry:
|
||||
br i1 undef, label %_ZNSt12_Vector_baseISsSaISsEE11_M_allocateEj.exit.i, label %bb
|
||||
|
||||
bb: ; preds = %entry
|
||||
ret void
|
||||
|
||||
_ZNSt12_Vector_baseISsSaISsEE11_M_allocateEj.exit.i: ; preds = %entry
|
||||
%0 = invoke fastcc %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* @_ZSt24__uninitialized_copy_auxIPSsS0_ET0_T_S2_S1_St12__false_type(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* undef, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* undef, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* undef)
|
||||
to label %invcont14.i unwind label %ppad81.i ; <%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*> [#uses=3]
|
||||
|
||||
invcont14.i: ; preds = %_ZNSt12_Vector_baseISsSaISsEE11_M_allocateEj.exit.i
|
||||
%1 = icmp eq %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %0, null ; <i1> [#uses=1]
|
||||
br i1 %1, label %bb19.i, label %bb.i17.i
|
||||
|
||||
bb.i17.i: ; preds = %invcont14.i
|
||||
%2 = invoke fastcc i8* @_ZNSs4_Rep8_M_cloneERKSaIcEj(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Rep"* undef, i32 0)
|
||||
to label %bb2.i25.i unwind label %ppad.i.i.i23.i ; <i8*> [#uses=0]
|
||||
|
||||
ppad.i.i.i23.i: ; preds = %bb.i17.i
|
||||
invoke void @_Unwind_Resume(i8* undef)
|
||||
to label %.noexc.i24.i unwind label %lpad.i29.i
|
||||
|
||||
.noexc.i24.i: ; preds = %ppad.i.i.i23.i
|
||||
unreachable
|
||||
|
||||
bb2.i25.i: ; preds = %bb.i17.i
|
||||
unreachable
|
||||
|
||||
lpad.i29.i: ; preds = %ppad.i.i.i23.i
|
||||
invoke void @_Unwind_Resume(i8* undef)
|
||||
to label %.noexc.i9 unwind label %ppad81.i
|
||||
|
||||
.noexc.i9: ; preds = %lpad.i29.i
|
||||
unreachable
|
||||
|
||||
bb19.i: ; preds = %invcont14.i
|
||||
%3 = getelementptr %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %0, i32 1 ; <%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*> [#uses=2]
|
||||
%4 = invoke fastcc %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* @_ZSt24__uninitialized_copy_auxIPSsS0_ET0_T_S2_S1_St12__false_type(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* undef, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* undef, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %3)
|
||||
to label %invcont20.i unwind label %ppad81.i ; <%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*> [#uses=0]
|
||||
|
||||
invcont20.i: ; preds = %bb19.i
|
||||
unreachable
|
||||
|
||||
invcont32.i: ; preds = %ppad81.i
|
||||
unreachable
|
||||
|
||||
ppad81.i: ; preds = %bb19.i, %lpad.i29.i, %_ZNSt12_Vector_baseISsSaISsEE11_M_allocateEj.exit.i
|
||||
%__new_finish.0.i = phi %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* [ %0, %lpad.i29.i ], [ undef, %_ZNSt12_Vector_baseISsSaISsEE11_M_allocateEj.exit.i ], [ %3, %bb19.i ] ; <%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"*> [#uses=0]
|
||||
br i1 undef, label %invcont32.i, label %bb.i.i.i.i
|
||||
|
||||
bb.i.i.i.i: ; preds = %bb.i.i.i.i, %ppad81.i
|
||||
br label %bb.i.i.i.i
|
||||
}
|
||||
|
||||
declare fastcc i8* @_ZNSs4_Rep8_M_cloneERKSaIcEj(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Rep"* nocapture, i32)
|
@ -1,19 +0,0 @@
|
||||
; RUN: opt < %s -ssi-everything -disable-output
|
||||
|
||||
declare fastcc i32 @ras_Empty(i8** nocapture) nounwind readonly
|
||||
|
||||
define i32 @cc_Tautology() nounwind {
|
||||
entry:
|
||||
unreachable
|
||||
|
||||
cc_InitData.exit: ; No predecessors!
|
||||
%0 = call fastcc i32 @ras_Empty(i8** undef) nounwind ; <i32> [#uses=1]
|
||||
%1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
|
||||
br i1 %1, label %bb2, label %bb6
|
||||
|
||||
bb2: ; preds = %cc_InitData.exit
|
||||
unreachable
|
||||
|
||||
bb6: ; preds = %cc_InitData.exit
|
||||
ret i32 undef
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
; RUN: opt < %s -ssi-everything -disable-output
|
||||
|
||||
define void @test(i32 %x) {
|
||||
entry:
|
||||
br label %label1
|
||||
label1:
|
||||
%A = phi i32 [ 0, %entry ], [ %A.1, %label2 ]
|
||||
%B = icmp slt i32 %A, %x
|
||||
br i1 %B, label %label2, label %label2
|
||||
label2:
|
||||
%A.1 = add i32 %A, 1
|
||||
br label %label1
|
||||
label3: ; No predecessors!
|
||||
ret void
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
; RUN: opt < %s -ssi-everything -disable-output
|
||||
|
||||
define void @foo() {
|
||||
entry:
|
||||
%tmp0 = load i64* undef, align 4 ; <i64> [#uses=3]
|
||||
br i1 undef, label %end_stmt_playback, label %bb16
|
||||
|
||||
readJournalHdr.exit: ; No predecessors!
|
||||
br label %end_stmt_playback
|
||||
|
||||
bb16: ; preds = %bb7
|
||||
%tmp1 = icmp slt i64 0, %tmp0 ; <i1> [#uses=1]
|
||||
br i1 %tmp1, label %bb16, label %bb17
|
||||
|
||||
bb17: ; preds = %bb16
|
||||
store i64 %tmp0, i64* undef, align 4
|
||||
br label %end_stmt_playback
|
||||
|
||||
end_stmt_playback: ; preds = %bb17, %readJournalHdr.exit, %bb6, %bb2
|
||||
store i64 %tmp0, i64* undef, align 4
|
||||
ret void
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
load_lib llvm.exp
|
||||
|
||||
RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
|
@ -1,22 +0,0 @@
|
||||
; RUN: opt < %s -ssi-everything -S | FileCheck %s
|
||||
|
||||
declare void @use(i32)
|
||||
declare i32 @create()
|
||||
|
||||
define i32 @foo() {
|
||||
entry:
|
||||
%x = call i32 @create()
|
||||
%y = icmp slt i32 %x, 10
|
||||
br i1 %y, label %T, label %F
|
||||
T:
|
||||
; CHECK: SSI_sigma
|
||||
call void @use(i32 %x)
|
||||
br label %join
|
||||
F:
|
||||
; CHECK: SSI_sigma
|
||||
call void @use(i32 %x)
|
||||
br label %join
|
||||
join:
|
||||
; CHECK: SSI_phi
|
||||
ret i32 %x
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user