projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add two thresholds lvi-overdefined-BB-threshold and lvi-overdefined-threshold
[oota-llvm.git]
/
lib
/
Analysis
/
SparsePropagation.cpp
diff --git
a/lib/Analysis/SparsePropagation.cpp
b/lib/Analysis/SparsePropagation.cpp
index 8a74745dd3fb62c379f3e9bbc0079117fd10234d..edd82f5fe296081f635da4713ac27b0043f14d59 100644
(file)
--- a/
lib/Analysis/SparsePropagation.cpp
+++ b/
lib/Analysis/SparsePropagation.cpp
@@
-12,16
+12,16
@@
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
-#define DEBUG_TYPE "sparseprop"
#include "llvm/Analysis/SparsePropagation.h"
#include "llvm/Analysis/SparsePropagation.h"
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+#define DEBUG_TYPE "sparseprop"
+
//===----------------------------------------------------------------------===//
// AbstractLatticeFunction Implementation
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// AbstractLatticeFunction Implementation
//===----------------------------------------------------------------------===//
@@
-89,7
+89,7
@@
void SparseSolver::UpdateState(Instruction &Inst, LatticeVal V) {
/// MarkBlockExecutable - This method can be used by clients to mark all of
/// the blocks that are known to be intrinsically live in the processed unit.
void SparseSolver::MarkBlockExecutable(BasicBlock *BB) {
/// MarkBlockExecutable - This method can be used by clients to mark all of
/// the blocks that are known to be intrinsically live in the processed unit.
void SparseSolver::MarkBlockExecutable(BasicBlock *BB) {
- DEBUG(
err
s() << "Marking Block Executable: " << BB->getName() << "\n");
+ DEBUG(
dbg
s() << "Marking Block Executable: " << BB->getName() << "\n");
BBExecutable.insert(BB); // Basic block is executable!
BBWorkList.push_back(BB); // Add the block to the work list!
}
BBExecutable.insert(BB); // Basic block is executable!
BBWorkList.push_back(BB); // Add the block to the work list!
}
@@
-100,7
+100,7
@@
void SparseSolver::markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) {
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
return; // This edge is already known to be executable!
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
return; // This edge is already known to be executable!
- DEBUG(
err
s() << "Marking Edge Executable: " << Source->getName()
+ DEBUG(
dbg
s() << "Marking Edge Executable: " << Source->getName()
<< " -> " << Dest->getName() << "\n");
if (BBExecutable.count(Dest)) {
<< " -> " << Dest->getName() << "\n");
if (BBExecutable.count(Dest)) {
@@
-148,14
+148,14
@@
void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI,
return;
Constant *C = LatticeFunc->GetConstant(BCValue, BI->getCondition(), *this);
return;
Constant *C = LatticeFunc->GetConstant(BCValue, BI->getCondition(), *this);
- if (
C == 0
|| !isa<ConstantInt>(C)) {
+ if (
!C
|| !isa<ConstantInt>(C)) {
// Non-constant values can go either way.
Succs[0] = Succs[1] = true;
return;
}
// Constant condition variables mean the branch can only go a single way
// Non-constant values can go either way.
Succs[0] = Succs[1] = true;
return;
}
// Constant condition variables mean the branch can only go a single way
- Succs[C
== ConstantInt::getFalse(*Context
)] = true;
+ Succs[C
->isNullValue(
)] = true;
return;
}
return;
}
@@
-166,6
+166,11
@@
void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI,
return;
}
return;
}
+ if (isa<IndirectBrInst>(TI)) {
+ Succs.assign(Succs.size(), true);
+ return;
+ }
+
SwitchInst &SI = cast<SwitchInst>(TI);
LatticeVal SCValue;
if (AggressiveUndef)
SwitchInst &SI = cast<SwitchInst>(TI);
LatticeVal SCValue;
if (AggressiveUndef)
@@
-185,13
+190,13
@@
void SparseSolver::getFeasibleSuccessors(TerminatorInst &TI,
return;
Constant *C = LatticeFunc->GetConstant(SCValue, SI.getCondition(), *this);
return;
Constant *C = LatticeFunc->GetConstant(SCValue, SI.getCondition(), *this);
- if (
C == 0
|| !isa<ConstantInt>(C)) {
+ if (
!C
|| !isa<ConstantInt>(C)) {
// All destinations are executable!
Succs.assign(TI.getNumSuccessors(), true);
return;
}
// All destinations are executable!
Succs.assign(TI.getNumSuccessors(), true);
return;
}
-
- Succs[
SI.findCaseValue(cast<ConstantInt>(C)
)] = true;
+ SwitchInst::CaseIt Case = SI.findCaseValue(cast<ConstantInt>(C));
+ Succs[
Case.getSuccessorIndex(
)] = true;
}
}
@@
-223,6
+228,9
@@
void SparseSolver::visitTerminatorInst(TerminatorInst &TI) {
}
void SparseSolver::visitPHINode(PHINode &PN) {
}
void SparseSolver::visitPHINode(PHINode &PN) {
+ // The lattice function may store more information on a PHINode than could be
+ // computed from its incoming values. For example, SSI form stores its sigma
+ // functions as PHINodes with a single incoming value.
if (LatticeFunc->IsSpecialCasedPHI(&PN)) {
LatticeVal IV = LatticeFunc->ComputeInstructionState(PN, *this);
if (IV != LatticeFunc->getUntrackedVal())
if (LatticeFunc->IsSpecialCasedPHI(&PN)) {
LatticeVal IV = LatticeFunc->ComputeInstructionState(PN, *this);
if (IV != LatticeFunc->getUntrackedVal())
@@
-292,15
+300,14
@@
void SparseSolver::Solve(Function &F) {
Instruction *I = InstWorkList.back();
InstWorkList.pop_back();
Instruction *I = InstWorkList.back();
InstWorkList.pop_back();
- DEBUG(
err
s() << "\nPopped off I-WL: " << *I << "\n");
+ DEBUG(
dbg
s() << "\nPopped off I-WL: " << *I << "\n");
// "I" got into the work list because it made a transition. See if any
// users are both live and in need of updating.
// "I" got into the work list because it made a transition. See if any
// users are both live and in need of updating.
- for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
- UI != E; ++UI) {
- Instruction *U = cast<Instruction>(*UI);
- if (BBExecutable.count(U->getParent())) // Inst is executable?
- visitInst(*U);
+ for (User *U : I->users()) {
+ Instruction *UI = cast<Instruction>(U);
+ if (BBExecutable.count(UI->getParent())) // Inst is executable?
+ visitInst(*UI);
}
}
}
}
@@
-309,7
+316,7
@@
void SparseSolver::Solve(Function &F) {
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
- DEBUG(
err
s() << "\nPopped off BBWL: " << *BB);
+ DEBUG(
dbg
s() << "\nPopped off BBWL: " << *BB);
// Notify all instructions in this basic block that they are newly
// executable.
// Notify all instructions in this basic block that they are newly
// executable.
@@
-320,13
+327,13
@@
void SparseSolver::Solve(Function &F) {
}
void SparseSolver::Print(Function &F, raw_ostream &OS) const {
}
void SparseSolver::Print(Function &F, raw_ostream &OS) const {
- OS << "\nFUNCTION: " << F.getName
Str
() << "\n";
+ OS << "\nFUNCTION: " << F.getName() << "\n";
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
if (!BBExecutable.count(BB))
OS << "INFEASIBLE: ";
OS << "\t";
if (BB->hasName())
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
if (!BBExecutable.count(BB))
OS << "INFEASIBLE: ";
OS << "\t";
if (BB->hasName())
- OS << BB->getName
Str
() << ":\n";
+ OS << BB->getName() << ":\n";
else
OS << "; anon bb\n";
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
else
OS << "; anon bb\n";
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {