mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Removed #include <iostream> and replaced with llvm_* streams.
llvm-svn: 31923
This commit is contained in:
parent
f2fadcee85
commit
1b3a86000a
@ -27,7 +27,6 @@
|
|||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -92,12 +91,12 @@ private:
|
|||||||
|
|
||||||
inline void markInstructionLive(Instruction *I) {
|
inline void markInstructionLive(Instruction *I) {
|
||||||
if (!LiveSet.insert(I).second) return;
|
if (!LiveSet.insert(I).second) return;
|
||||||
DEBUG(std::cerr << "Insn Live: " << *I);
|
DOUT << "Insn Live: " << *I;
|
||||||
WorkList.push_back(I);
|
WorkList.push_back(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void markTerminatorLive(const BasicBlock *BB) {
|
inline void markTerminatorLive(const BasicBlock *BB) {
|
||||||
DEBUG(std::cerr << "Terminator Live: " << *BB->getTerminator());
|
DOUT << "Terminator Live: " << *BB->getTerminator();
|
||||||
markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
|
markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -260,7 +259,7 @@ bool ADCE::doADCE() {
|
|||||||
for (pred_iterator PI = pred_begin(I), E = pred_end(I); PI != E; ++PI)
|
for (pred_iterator PI = pred_begin(I), E = pred_end(I); PI != E; ++PI)
|
||||||
markInstructionLive((*PI)->getTerminator());
|
markInstructionLive((*PI)->getTerminator());
|
||||||
|
|
||||||
DEBUG(std::cerr << "Processing work list\n");
|
DOUT << "Processing work list\n";
|
||||||
|
|
||||||
// AliveBlocks - Set of basic blocks that we know have instructions that are
|
// AliveBlocks - Set of basic blocks that we know have instructions that are
|
||||||
// alive in them...
|
// alive in them...
|
||||||
@ -309,13 +308,13 @@ bool ADCE::doADCE() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(
|
DEBUG(
|
||||||
std::cerr << "Current Function: X = Live\n";
|
DOUT << "Current Function: X = Live\n";
|
||||||
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I){
|
for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I){
|
||||||
std::cerr << I->getName() << ":\t"
|
DOUT << I->getName() << ":\t"
|
||||||
<< (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
|
<< (AliveBlocks.count(I) ? "LIVE\n" : "DEAD\n");
|
||||||
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
|
for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){
|
||||||
if (LiveSet.count(BI)) std::cerr << "X ";
|
if (LiveSet.count(BI)) DOUT << "X ";
|
||||||
std::cerr << *BI;
|
DOUT << *BI;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include <iostream>
|
#include "llvm/Support/Streams.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -52,7 +52,6 @@
|
|||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::PatternMatch;
|
using namespace llvm::PatternMatch;
|
||||||
|
|
||||||
@ -5551,7 +5550,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
|
|||||||
// Add operands to the worklist.
|
// Add operands to the worklist.
|
||||||
AddUsesToWorkList(*User);
|
AddUsesToWorkList(*User);
|
||||||
++NumDeadInst;
|
++NumDeadInst;
|
||||||
DEBUG(std::cerr << "IC: DCE: " << *User);
|
DOUT << "IC: DCE: " << *User;
|
||||||
|
|
||||||
User->eraseFromParent();
|
User->eraseFromParent();
|
||||||
removeFromWorkList(User);
|
removeFromWorkList(User);
|
||||||
@ -6867,7 +6866,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
// If we are removing arguments to the function, emit an obnoxious warning...
|
// If we are removing arguments to the function, emit an obnoxious warning...
|
||||||
if (FT->getNumParams() < NumActualArgs)
|
if (FT->getNumParams() < NumActualArgs)
|
||||||
if (!FT->isVarArg()) {
|
if (!FT->isVarArg()) {
|
||||||
std::cerr << "WARNING: While resolving call to function '"
|
llvm_cerr << "WARNING: While resolving call to function '"
|
||||||
<< Callee->getName() << "' arguments were dropped!\n";
|
<< Callee->getName() << "' arguments were dropped!\n";
|
||||||
} else {
|
} else {
|
||||||
// Add all of the arguments in their promoted form to the arg list...
|
// Add all of the arguments in their promoted form to the arg list...
|
||||||
@ -8556,7 +8555,7 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
|
|||||||
// DCE instruction if trivially dead.
|
// DCE instruction if trivially dead.
|
||||||
if (isInstructionTriviallyDead(Inst)) {
|
if (isInstructionTriviallyDead(Inst)) {
|
||||||
++NumDeadInst;
|
++NumDeadInst;
|
||||||
DEBUG(std::cerr << "IC: DCE: " << *Inst);
|
DOUT << "IC: DCE: " << *Inst;
|
||||||
Inst->eraseFromParent();
|
Inst->eraseFromParent();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -8565,7 +8564,7 @@ static void AddReachableCodeToWorklist(BasicBlock *BB,
|
|||||||
if (Constant *C = ConstantFoldInstruction(Inst)) {
|
if (Constant *C = ConstantFoldInstruction(Inst)) {
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||||
C = OptimizeConstantExpr(CE, TD);
|
C = OptimizeConstantExpr(CE, TD);
|
||||||
DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *Inst);
|
DOUT << "IC: ConstFold to: " << *C << " from: " << *Inst;
|
||||||
Inst->replaceAllUsesWith(C);
|
Inst->replaceAllUsesWith(C);
|
||||||
++NumConstProp;
|
++NumConstProp;
|
||||||
Inst->eraseFromParent();
|
Inst->eraseFromParent();
|
||||||
@ -8624,7 +8623,7 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
while (Term != BB->begin()) { // Remove instrs bottom-up
|
while (Term != BB->begin()) { // Remove instrs bottom-up
|
||||||
BasicBlock::iterator I = Term; --I;
|
BasicBlock::iterator I = Term; --I;
|
||||||
|
|
||||||
DEBUG(std::cerr << "IC: DCE: " << *I);
|
DOUT << "IC: DCE: " << *I;
|
||||||
++NumDeadInst;
|
++NumDeadInst;
|
||||||
|
|
||||||
if (!I->use_empty())
|
if (!I->use_empty())
|
||||||
@ -8645,7 +8644,7 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
AddUsesToWorkList(*I);
|
AddUsesToWorkList(*I);
|
||||||
++NumDeadInst;
|
++NumDeadInst;
|
||||||
|
|
||||||
DEBUG(std::cerr << "IC: DCE: " << *I);
|
DOUT << "IC: DCE: " << *I;
|
||||||
|
|
||||||
I->eraseFromParent();
|
I->eraseFromParent();
|
||||||
removeFromWorkList(I);
|
removeFromWorkList(I);
|
||||||
@ -8656,7 +8655,7 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
if (Constant *C = ConstantFoldInstruction(I)) {
|
if (Constant *C = ConstantFoldInstruction(I)) {
|
||||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
|
||||||
C = OptimizeConstantExpr(CE, TD);
|
C = OptimizeConstantExpr(CE, TD);
|
||||||
DEBUG(std::cerr << "IC: ConstFold to: " << *C << " from: " << *I);
|
DOUT << "IC: ConstFold to: " << *C << " from: " << *I;
|
||||||
|
|
||||||
// Add operands to the worklist.
|
// Add operands to the worklist.
|
||||||
AddUsesToWorkList(*I);
|
AddUsesToWorkList(*I);
|
||||||
@ -8696,8 +8695,8 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
++NumCombined;
|
++NumCombined;
|
||||||
// Should we replace the old instruction with a new one?
|
// Should we replace the old instruction with a new one?
|
||||||
if (Result != I) {
|
if (Result != I) {
|
||||||
DEBUG(std::cerr << "IC: Old = " << *I
|
DOUT << "IC: Old = " << *I
|
||||||
<< " New = " << *Result);
|
<< " New = " << *Result;
|
||||||
|
|
||||||
// Everything uses the new instruction now.
|
// Everything uses the new instruction now.
|
||||||
I->replaceAllUsesWith(Result);
|
I->replaceAllUsesWith(Result);
|
||||||
@ -8733,7 +8732,7 @@ bool InstCombiner::runOnFunction(Function &F) {
|
|||||||
// Erase the old instruction.
|
// Erase the old instruction.
|
||||||
InstParent->getInstList().erase(I);
|
InstParent->getInstList().erase(I);
|
||||||
} else {
|
} else {
|
||||||
DEBUG(std::cerr << "IC: MOD = " << *I);
|
DOUT << "IC: MOD = " << *I;
|
||||||
|
|
||||||
// If the instruction was modified, it's possible that it is now dead.
|
// If the instruction was modified, it's possible that it is now dead.
|
||||||
// if so, remove it.
|
// if so, remove it.
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -430,7 +429,7 @@ bool LICM::isLoopInvariantInst(Instruction &I) {
|
|||||||
/// position, and may either delete it or move it to outside of the loop.
|
/// position, and may either delete it or move it to outside of the loop.
|
||||||
///
|
///
|
||||||
void LICM::sink(Instruction &I) {
|
void LICM::sink(Instruction &I) {
|
||||||
DEBUG(std::cerr << "LICM sinking instruction: " << I);
|
DOUT << "LICM sinking instruction: " << I;
|
||||||
|
|
||||||
std::vector<BasicBlock*> ExitBlocks;
|
std::vector<BasicBlock*> ExitBlocks;
|
||||||
CurLoop->getExitBlocks(ExitBlocks);
|
CurLoop->getExitBlocks(ExitBlocks);
|
||||||
@ -565,8 +564,7 @@ void LICM::sink(Instruction &I) {
|
|||||||
/// that is safe to hoist, this instruction is called to do the dirty work.
|
/// that is safe to hoist, this instruction is called to do the dirty work.
|
||||||
///
|
///
|
||||||
void LICM::hoist(Instruction &I) {
|
void LICM::hoist(Instruction &I) {
|
||||||
DEBUG(std::cerr << "LICM hoisting to " << Preheader->getName()
|
DOUT << "LICM hoisting to " << Preheader->getName() << ": " << I;
|
||||||
<< ": " << I);
|
|
||||||
|
|
||||||
// Remove the instruction from its current basic block... but don't delete the
|
// Remove the instruction from its current basic block... but don't delete the
|
||||||
// instruction.
|
// instruction.
|
||||||
@ -785,7 +783,7 @@ void LICM::FindPromotableValuesInLoop(
|
|||||||
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
||||||
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
|
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
|
||||||
|
|
||||||
DEBUG(std::cerr << "LICM: Promoting value: " << *V << "\n");
|
DOUT << "LICM: Promoting value: " << *V << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Target/TargetLowering.h"
|
#include "llvm/Target/TargetLowering.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -322,8 +321,8 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
|
|||||||
Start = SCEVAddExpr::get(Start, AddRec->getOperand(0));
|
Start = SCEVAddExpr::get(Start, AddRec->getOperand(0));
|
||||||
|
|
||||||
if (!isa<SCEVConstant>(AddRec->getOperand(1)))
|
if (!isa<SCEVConstant>(AddRec->getOperand(1)))
|
||||||
DEBUG(std::cerr << "[" << L->getHeader()->getName()
|
DOUT << "[" << L->getHeader()->getName()
|
||||||
<< "] Variable stride: " << *AddRec << "\n");
|
<< "] Variable stride: " << *AddRec << "\n";
|
||||||
|
|
||||||
Stride = AddRec->getOperand(1);
|
Stride = AddRec->getOperand(1);
|
||||||
// Check that all constant strides are the unsigned type, we don't want to
|
// Check that all constant strides are the unsigned type, we don't want to
|
||||||
@ -422,12 +421,12 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
|
|||||||
// don't recurse into it.
|
// don't recurse into it.
|
||||||
bool AddUserToIVUsers = false;
|
bool AddUserToIVUsers = false;
|
||||||
if (LI->getLoopFor(User->getParent()) != L) {
|
if (LI->getLoopFor(User->getParent()) != L) {
|
||||||
DEBUG(std::cerr << "FOUND USER in other loop: " << *User
|
DOUT << "FOUND USER in other loop: " << *User
|
||||||
<< " OF SCEV: " << *ISE << "\n");
|
<< " OF SCEV: " << *ISE << "\n";
|
||||||
AddUserToIVUsers = true;
|
AddUserToIVUsers = true;
|
||||||
} else if (!AddUsersIfInteresting(User, L, Processed)) {
|
} else if (!AddUsersIfInteresting(User, L, Processed)) {
|
||||||
DEBUG(std::cerr << "FOUND USER: " << *User
|
DOUT << "FOUND USER: " << *User
|
||||||
<< " OF SCEV: " << *ISE << "\n");
|
<< " OF SCEV: " << *ISE << "\n";
|
||||||
AddUserToIVUsers = true;
|
AddUserToIVUsers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +444,7 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
|
|||||||
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
|
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
|
||||||
StrideUses.addUser(NewStart, User, I);
|
StrideUses.addUser(NewStart, User, I);
|
||||||
StrideUses.Users.back().isUseOfPostIncrementedValue = true;
|
StrideUses.Users.back().isUseOfPostIncrementedValue = true;
|
||||||
DEBUG(std::cerr << " USING POSTINC SCEV, START=" << *NewStart<< "\n");
|
DOUT << " USING POSTINC SCEV, START=" << *NewStart<< "\n";
|
||||||
} else {
|
} else {
|
||||||
StrideUses.addUser(Start, User, I);
|
StrideUses.addUser(Start, User, I);
|
||||||
}
|
}
|
||||||
@ -508,12 +507,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BasedUser::dump() const {
|
void BasedUser::dump() const {
|
||||||
std::cerr << " Base=" << *Base;
|
llvm_cerr << " Base=" << *Base;
|
||||||
std::cerr << " Imm=" << *Imm;
|
llvm_cerr << " Imm=" << *Imm;
|
||||||
if (EmittedBase)
|
if (EmittedBase)
|
||||||
std::cerr << " EB=" << *EmittedBase;
|
llvm_cerr << " EB=" << *EmittedBase;
|
||||||
|
|
||||||
std::cerr << " Inst: " << *Inst;
|
llvm_cerr << " Inst: " << *Inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
|
Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
|
||||||
@ -561,7 +560,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
|
|||||||
Value *NewVal = InsertCodeForBaseAtPosition(NewBase, Rewriter, Inst, L);
|
Value *NewVal = InsertCodeForBaseAtPosition(NewBase, Rewriter, Inst, L);
|
||||||
// Replace the use of the operand Value with the new Phi we just created.
|
// Replace the use of the operand Value with the new Phi we just created.
|
||||||
Inst->replaceUsesOfWith(OperandValToReplace, NewVal);
|
Inst->replaceUsesOfWith(OperandValToReplace, NewVal);
|
||||||
DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
|
DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,7 +609,7 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
|
|||||||
Rewriter.clear();
|
Rewriter.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG(std::cerr << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst);
|
DOUT << " CHANGED: IMM =" << *Imm << " Inst = " << *Inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -961,8 +960,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
|
|||||||
unsigned RewriteFactor = CheckForIVReuse(Stride, ReuseIV,
|
unsigned RewriteFactor = CheckForIVReuse(Stride, ReuseIV,
|
||||||
CommonExprs->getType());
|
CommonExprs->getType());
|
||||||
if (RewriteFactor != 0) {
|
if (RewriteFactor != 0) {
|
||||||
DEBUG(std::cerr << "BASED ON IV of STRIDE " << *ReuseIV.Stride
|
DOUT << "BASED ON IV of STRIDE " << *ReuseIV.Stride
|
||||||
<< " and BASE " << *ReuseIV.Base << " :\n");
|
<< " and BASE " << *ReuseIV.Base << " :\n";
|
||||||
NewPHI = ReuseIV.PHI;
|
NewPHI = ReuseIV.PHI;
|
||||||
IncV = ReuseIV.IncV;
|
IncV = ReuseIV.IncV;
|
||||||
}
|
}
|
||||||
@ -996,8 +995,8 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
|
|||||||
|
|
||||||
// Now that we know what we need to do, insert the PHI node itself.
|
// Now that we know what we need to do, insert the PHI node itself.
|
||||||
//
|
//
|
||||||
DEBUG(std::cerr << "INSERTING IV of STRIDE " << *Stride << " and BASE "
|
DOUT << "INSERTING IV of STRIDE " << *Stride << " and BASE "
|
||||||
<< *CommonExprs << " :\n");
|
<< *CommonExprs << " :\n";
|
||||||
|
|
||||||
SCEVExpander Rewriter(*SE, *LI);
|
SCEVExpander Rewriter(*SE, *LI);
|
||||||
SCEVExpander PreheaderRewriter(*SE, *LI);
|
SCEVExpander PreheaderRewriter(*SE, *LI);
|
||||||
@ -1085,7 +1084,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride,
|
|||||||
while (!UsersToProcess.empty()) {
|
while (!UsersToProcess.empty()) {
|
||||||
SCEVHandle Base = UsersToProcess.back().Base;
|
SCEVHandle Base = UsersToProcess.back().Base;
|
||||||
|
|
||||||
DEBUG(std::cerr << " INSERTING code for BASE = " << *Base << ":\n");
|
DOUT << " INSERTING code for BASE = " << *Base << ":\n";
|
||||||
|
|
||||||
// Emit the code for Base into the preheader.
|
// Emit the code for Base into the preheader.
|
||||||
Value *BaseV = PreheaderRewriter.expandCodeFor(Base, PreInsertPt,
|
Value *BaseV = PreheaderRewriter.expandCodeFor(Base, PreInsertPt,
|
||||||
@ -1302,7 +1301,7 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
|
|||||||
bool HasOneStride = IVUsesByStride.size() == 1;
|
bool HasOneStride = IVUsesByStride.size() == 1;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
DEBUG(std::cerr << "\nLSR on ");
|
DOUT << "\nLSR on ";
|
||||||
DEBUG(L->dump());
|
DEBUG(L->dump());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -134,7 +133,7 @@ BasicBlock* LoopUnroll::FoldBlockIntoPredecessor(BasicBlock* BB) {
|
|||||||
if (OnlyPred->getTerminator()->getNumSuccessors() != 1)
|
if (OnlyPred->getTerminator()->getNumSuccessors() != 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DEBUG(std::cerr << "Merging: " << *BB << "into: " << *OnlyPred);
|
DOUT << "Merging: " << *BB << "into: " << *OnlyPred;
|
||||||
|
|
||||||
// Resolve any PHI nodes at the start of the block. They are all
|
// Resolve any PHI nodes at the start of the block. They are all
|
||||||
// guaranteed to have exactly one entry if they exist, unless there are
|
// guaranteed to have exactly one entry if they exist, unless there are
|
||||||
@ -194,15 +193,15 @@ bool LoopUnroll::visitLoop(Loop *L) {
|
|||||||
return Changed; // More than 2^32 iterations???
|
return Changed; // More than 2^32 iterations???
|
||||||
|
|
||||||
unsigned LoopSize = ApproximateLoopSize(L);
|
unsigned LoopSize = ApproximateLoopSize(L);
|
||||||
DEBUG(std::cerr << "Loop Unroll: F[" << Header->getParent()->getName()
|
DOUT << "Loop Unroll: F[" << Header->getParent()->getName()
|
||||||
<< "] Loop %" << Header->getName() << " Loop Size = "
|
<< "] Loop %" << Header->getName() << " Loop Size = "
|
||||||
<< LoopSize << " Trip Count = " << TripCountFull << " - ");
|
<< LoopSize << " Trip Count = " << TripCountFull << " - ";
|
||||||
uint64_t Size = (uint64_t)LoopSize*TripCountFull;
|
uint64_t Size = (uint64_t)LoopSize*TripCountFull;
|
||||||
if (Size > UnrollThreshold) {
|
if (Size > UnrollThreshold) {
|
||||||
DEBUG(std::cerr << "TOO LARGE: " << Size << ">" << UnrollThreshold << "\n");
|
DOUT << "TOO LARGE: " << Size << ">" << UnrollThreshold << "\n";
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
DEBUG(std::cerr << "UNROLLING!\n");
|
DOUT << "UNROLLING!\n";
|
||||||
|
|
||||||
std::vector<BasicBlock*> LoopBlocks = L->getBlocks();
|
std::vector<BasicBlock*> LoopBlocks = L->getBlocks();
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -369,9 +368,9 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){
|
|||||||
// FIXME: this should estimate growth by the amount of code shared by the
|
// FIXME: this should estimate growth by the amount of code shared by the
|
||||||
// resultant unswitched loops.
|
// resultant unswitched loops.
|
||||||
//
|
//
|
||||||
DEBUG(std::cerr << "NOT unswitching loop %"
|
DOUT << "NOT unswitching loop %"
|
||||||
<< L->getHeader()->getName() << ", cost too high: "
|
<< L->getHeader()->getName() << ", cost too high: "
|
||||||
<< L->getBlocks().size() << "\n");
|
<< L->getBlocks().size() << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,10 +507,10 @@ static void EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
|
|||||||
void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
|
void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
|
||||||
Constant *Val,
|
Constant *Val,
|
||||||
BasicBlock *ExitBlock) {
|
BasicBlock *ExitBlock) {
|
||||||
DEBUG(std::cerr << "loop-unswitch: Trivial-Unswitch loop %"
|
DOUT << "loop-unswitch: Trivial-Unswitch loop %"
|
||||||
<< L->getHeader()->getName() << " [" << L->getBlocks().size()
|
<< L->getHeader()->getName() << " [" << L->getBlocks().size()
|
||||||
<< " blocks] in Function " << L->getHeader()->getParent()->getName()
|
<< " blocks] in Function " << L->getHeader()->getParent()->getName()
|
||||||
<< " on cond: " << *Val << " == " << *Cond << "\n");
|
<< " on cond: " << *Val << " == " << *Cond << "\n";
|
||||||
|
|
||||||
// First step, split the preheader, so that we know that there is a safe place
|
// First step, split the preheader, so that we know that there is a safe place
|
||||||
// to insert the conditional branch. We will change 'OrigPH' to have a
|
// to insert the conditional branch. We will change 'OrigPH' to have a
|
||||||
@ -553,10 +552,10 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond,
|
|||||||
void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
|
void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
|
||||||
Loop *L) {
|
Loop *L) {
|
||||||
Function *F = L->getHeader()->getParent();
|
Function *F = L->getHeader()->getParent();
|
||||||
DEBUG(std::cerr << "loop-unswitch: Unswitching loop %"
|
DOUT << "loop-unswitch: Unswitching loop %"
|
||||||
<< L->getHeader()->getName() << " [" << L->getBlocks().size()
|
<< L->getHeader()->getName() << " [" << L->getBlocks().size()
|
||||||
<< " blocks] in Function " << F->getName()
|
<< " blocks] in Function " << F->getName()
|
||||||
<< " when '" << *Val << "' == " << *LIC << "\n");
|
<< " when '" << *Val << "' == " << *LIC << "\n";
|
||||||
|
|
||||||
// LoopBlocks contains all of the basic blocks of the loop, including the
|
// LoopBlocks contains all of the basic blocks of the loop, including the
|
||||||
// preheader of the loop, the body of the loop, and the exit blocks of the
|
// preheader of the loop, the body of the loop, and the exit blocks of the
|
||||||
@ -721,7 +720,7 @@ static void RemoveFromWorklist(Instruction *I,
|
|||||||
/// program, replacing all uses with V and update the worklist.
|
/// program, replacing all uses with V and update the worklist.
|
||||||
static void ReplaceUsesOfWith(Instruction *I, Value *V,
|
static void ReplaceUsesOfWith(Instruction *I, Value *V,
|
||||||
std::vector<Instruction*> &Worklist) {
|
std::vector<Instruction*> &Worklist) {
|
||||||
DEBUG(std::cerr << "Replace with '" << *V << "': " << *I);
|
DOUT << "Replace with '" << *V << "': " << *I;
|
||||||
|
|
||||||
// Add uses to the worklist, which may be dead now.
|
// Add uses to the worklist, which may be dead now.
|
||||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
||||||
@ -780,7 +779,7 @@ void LoopUnswitch::RemoveBlockIfDead(BasicBlock *BB,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(std::cerr << "Nuking dead block: " << *BB);
|
DOUT << "Nuking dead block: " << *BB;
|
||||||
|
|
||||||
// Remove the instructions in the basic block from the worklist.
|
// Remove the instructions in the basic block from the worklist.
|
||||||
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
|
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
|
||||||
@ -1013,7 +1012,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
|
|||||||
|
|
||||||
// Simple DCE.
|
// Simple DCE.
|
||||||
if (isInstructionTriviallyDead(I)) {
|
if (isInstructionTriviallyDead(I)) {
|
||||||
DEBUG(std::cerr << "Remove dead instruction '" << *I);
|
DOUT << "Remove dead instruction '" << *I;
|
||||||
|
|
||||||
// Add uses to the worklist, which may be dead now.
|
// Add uses to the worklist, which may be dead now.
|
||||||
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
|
||||||
@ -1066,8 +1065,8 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
|
|||||||
if (!SinglePred) continue; // Nothing to do.
|
if (!SinglePred) continue; // Nothing to do.
|
||||||
assert(SinglePred == Pred && "CFG broken");
|
assert(SinglePred == Pred && "CFG broken");
|
||||||
|
|
||||||
DEBUG(std::cerr << "Merging blocks: " << Pred->getName() << " <- "
|
DOUT << "Merging blocks: " << Pred->getName() << " <- "
|
||||||
<< Succ->getName() << "\n");
|
<< Succ->getName() << "\n";
|
||||||
|
|
||||||
// Resolve any single entry PHI nodes in Succ.
|
// Resolve any single entry PHI nodes in Succ.
|
||||||
while (PHINode *PN = dyn_cast<PHINode>(Succ->begin()))
|
while (PHINode *PN = dyn_cast<PHINode>(Succ->begin()))
|
||||||
@ -1092,7 +1091,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist) {
|
|||||||
// remove dead blocks.
|
// remove dead blocks.
|
||||||
break; // FIXME: Enable.
|
break; // FIXME: Enable.
|
||||||
|
|
||||||
DEBUG(std::cerr << "Folded branch: " << *BI);
|
DOUT << "Folded branch: " << *BI;
|
||||||
BasicBlock *DeadSucc = BI->getSuccessor(CB->getValue());
|
BasicBlock *DeadSucc = BI->getSuccessor(CB->getValue());
|
||||||
BasicBlock *LiveSucc = BI->getSuccessor(!CB->getValue());
|
BasicBlock *LiveSucc = BI->getSuccessor(!CB->getValue());
|
||||||
DeadSucc->removePredecessor(BI->getParent(), true);
|
DeadSucc->removePredecessor(BI->getParent(), true);
|
||||||
|
@ -20,12 +20,11 @@
|
|||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
|
#include "llvm/Support/Streams.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iostream>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -72,12 +71,10 @@ public:
|
|||||||
///
|
///
|
||||||
/// @brief Asserts if PackedType instruction is not handled elsewhere.
|
/// @brief Asserts if PackedType instruction is not handled elsewhere.
|
||||||
/// @param I the unhandled instruction
|
/// @param I the unhandled instruction
|
||||||
void visitInstruction(Instruction &I)
|
void visitInstruction(Instruction &I) {
|
||||||
{
|
if (isa<PackedType>(I.getType()))
|
||||||
if(isa<PackedType>(I.getType())) {
|
llvm_cerr << "Unhandled Instruction with Packed ReturnType: "
|
||||||
std::cerr << "Unhandled Instruction with Packed ReturnType: " <<
|
<< I << '\n';
|
||||||
I << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
/// @brief Retrieves lowered values for a packed value.
|
/// @brief Retrieves lowered values for a packed value.
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ public:
|
|||||||
/// MarkBlockExecutable - This method can be used by clients to mark all of
|
/// 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.
|
/// the blocks that are known to be intrinsically live in the processed unit.
|
||||||
void MarkBlockExecutable(BasicBlock *BB) {
|
void MarkBlockExecutable(BasicBlock *BB) {
|
||||||
DEBUG(std::cerr << "Marking Block Executable: " << BB->getName() << "\n");
|
DOUT << "Marking Block Executable: " << BB->getName() << "\n";
|
||||||
BBExecutable.insert(BB); // Basic block is executable!
|
BBExecutable.insert(BB); // Basic block is executable!
|
||||||
BBWorkList.push_back(BB); // Add the block to the work list!
|
BBWorkList.push_back(BB); // Add the block to the work list!
|
||||||
}
|
}
|
||||||
@ -204,7 +203,7 @@ private:
|
|||||||
//
|
//
|
||||||
inline void markConstant(LatticeVal &IV, Value *V, Constant *C) {
|
inline void markConstant(LatticeVal &IV, Value *V, Constant *C) {
|
||||||
if (IV.markConstant(C)) {
|
if (IV.markConstant(C)) {
|
||||||
DEBUG(std::cerr << "markConstant: " << *C << ": " << *V);
|
DOUT << "markConstant: " << *C << ": " << *V;
|
||||||
InstWorkList.push_back(V);
|
InstWorkList.push_back(V);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,11 +217,11 @@ private:
|
|||||||
|
|
||||||
inline void markOverdefined(LatticeVal &IV, Value *V) {
|
inline void markOverdefined(LatticeVal &IV, Value *V) {
|
||||||
if (IV.markOverdefined()) {
|
if (IV.markOverdefined()) {
|
||||||
DEBUG(std::cerr << "markOverdefined: ";
|
DEBUG(DOUT << "markOverdefined: ";
|
||||||
if (Function *F = dyn_cast<Function>(V))
|
if (Function *F = dyn_cast<Function>(V))
|
||||||
std::cerr << "Function '" << F->getName() << "'\n";
|
DOUT << "Function '" << F->getName() << "'\n";
|
||||||
else
|
else
|
||||||
std::cerr << *V);
|
DOUT << *V);
|
||||||
// Only instructions go on the work list
|
// Only instructions go on the work list
|
||||||
OverdefinedInstWorkList.push_back(V);
|
OverdefinedInstWorkList.push_back(V);
|
||||||
}
|
}
|
||||||
@ -276,8 +275,8 @@ private:
|
|||||||
return; // This edge is already known to be executable!
|
return; // This edge is already known to be executable!
|
||||||
|
|
||||||
if (BBExecutable.count(Dest)) {
|
if (BBExecutable.count(Dest)) {
|
||||||
DEBUG(std::cerr << "Marking Edge Executable: " << Source->getName()
|
DOUT << "Marking Edge Executable: " << Source->getName()
|
||||||
<< " -> " << Dest->getName() << "\n");
|
<< " -> " << Dest->getName() << "\n";
|
||||||
|
|
||||||
// The destination is already executable, but we just made an edge
|
// The destination is already executable, but we just made an edge
|
||||||
// feasible that wasn't before. Revisit the PHI nodes in the block
|
// feasible that wasn't before. Revisit the PHI nodes in the block
|
||||||
@ -351,7 +350,7 @@ private:
|
|||||||
|
|
||||||
void visitInstruction(Instruction &I) {
|
void visitInstruction(Instruction &I) {
|
||||||
// If a new instruction is added to LLVM that we don't handle...
|
// If a new instruction is added to LLVM that we don't handle...
|
||||||
std::cerr << "SCCP: Don't know how to handle: " << I;
|
llvm_cerr << "SCCP: Don't know how to handle: " << I;
|
||||||
markOverdefined(&I); // Just in case
|
markOverdefined(&I); // Just in case
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -401,7 +400,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
|
|||||||
Succs[0] = true;
|
Succs[0] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "SCCP: Don't know how to handle: " << TI;
|
llvm_cerr << "SCCP: Don't know how to handle: " << TI;
|
||||||
Succs.assign(TI.getNumSuccessors(), true);
|
Succs.assign(TI.getNumSuccessors(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,7 +459,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Unknown terminator instruction: " << *TI;
|
llvm_cerr << "Unknown terminator instruction: " << *TI;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -971,7 +970,7 @@ void SCCPSolver::Solve() {
|
|||||||
Value *I = OverdefinedInstWorkList.back();
|
Value *I = OverdefinedInstWorkList.back();
|
||||||
OverdefinedInstWorkList.pop_back();
|
OverdefinedInstWorkList.pop_back();
|
||||||
|
|
||||||
DEBUG(std::cerr << "\nPopped off OI-WL: " << *I);
|
DOUT << "\nPopped off OI-WL: " << *I;
|
||||||
|
|
||||||
// "I" got into the work list because it either made the transition from
|
// "I" got into the work list because it either made the transition from
|
||||||
// bottom to constant
|
// bottom to constant
|
||||||
@ -989,7 +988,7 @@ void SCCPSolver::Solve() {
|
|||||||
Value *I = InstWorkList.back();
|
Value *I = InstWorkList.back();
|
||||||
InstWorkList.pop_back();
|
InstWorkList.pop_back();
|
||||||
|
|
||||||
DEBUG(std::cerr << "\nPopped off I-WL: " << *I);
|
DOUT << "\nPopped off I-WL: " << *I;
|
||||||
|
|
||||||
// "I" got into the work list because it either made the transition from
|
// "I" got into the work list because it either made the transition from
|
||||||
// bottom to constant
|
// bottom to constant
|
||||||
@ -1009,7 +1008,7 @@ void SCCPSolver::Solve() {
|
|||||||
BasicBlock *BB = BBWorkList.back();
|
BasicBlock *BB = BBWorkList.back();
|
||||||
BBWorkList.pop_back();
|
BBWorkList.pop_back();
|
||||||
|
|
||||||
DEBUG(std::cerr << "\nPopped off BBWL: " << *BB);
|
DOUT << "\nPopped off BBWL: " << *BB;
|
||||||
|
|
||||||
// Notify all instructions in this basic block that they are newly
|
// Notify all instructions in this basic block that they are newly
|
||||||
// executable.
|
// executable.
|
||||||
@ -1098,7 +1097,7 @@ FunctionPass *llvm::createSCCPPass() {
|
|||||||
// and return true if the function was modified.
|
// and return true if the function was modified.
|
||||||
//
|
//
|
||||||
bool SCCP::runOnFunction(Function &F) {
|
bool SCCP::runOnFunction(Function &F) {
|
||||||
DEBUG(std::cerr << "SCCP on function '" << F.getName() << "'\n");
|
DOUT << "SCCP on function '" << F.getName() << "'\n";
|
||||||
SCCPSolver Solver;
|
SCCPSolver Solver;
|
||||||
|
|
||||||
// Mark the first block of the function as being executable.
|
// Mark the first block of the function as being executable.
|
||||||
@ -1113,7 +1112,7 @@ bool SCCP::runOnFunction(Function &F) {
|
|||||||
bool ResolvedBranches = true;
|
bool ResolvedBranches = true;
|
||||||
while (ResolvedBranches) {
|
while (ResolvedBranches) {
|
||||||
Solver.Solve();
|
Solver.Solve();
|
||||||
DEBUG(std::cerr << "RESOLVING UNDEF BRANCHES\n");
|
DOUT << "RESOLVING UNDEF BRANCHES\n";
|
||||||
ResolvedBranches = Solver.ResolveBranchesIn(F);
|
ResolvedBranches = Solver.ResolveBranchesIn(F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1126,7 +1125,7 @@ bool SCCP::runOnFunction(Function &F) {
|
|||||||
std::set<BasicBlock*> &ExecutableBBs = Solver.getExecutableBlocks();
|
std::set<BasicBlock*> &ExecutableBBs = Solver.getExecutableBlocks();
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||||
if (!ExecutableBBs.count(BB)) {
|
if (!ExecutableBBs.count(BB)) {
|
||||||
DEBUG(std::cerr << " BasicBlock Dead:" << *BB);
|
DOUT << " BasicBlock Dead:" << *BB;
|
||||||
++NumDeadBlocks;
|
++NumDeadBlocks;
|
||||||
|
|
||||||
// Delete the instructions backwards, as it has a reduced likelihood of
|
// Delete the instructions backwards, as it has a reduced likelihood of
|
||||||
@ -1156,7 +1155,7 @@ bool SCCP::runOnFunction(Function &F) {
|
|||||||
!isa<TerminatorInst>(Inst)) {
|
!isa<TerminatorInst>(Inst)) {
|
||||||
Constant *Const = IV.isConstant()
|
Constant *Const = IV.isConstant()
|
||||||
? IV.getConstant() : UndefValue::get(Inst->getType());
|
? IV.getConstant() : UndefValue::get(Inst->getType());
|
||||||
DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
|
DOUT << " Constant: " << *Const << " = " << *Inst;
|
||||||
|
|
||||||
// Replaces all of the uses of a variable with uses of the constant.
|
// Replaces all of the uses of a variable with uses of the constant.
|
||||||
Inst->replaceAllUsesWith(Const);
|
Inst->replaceAllUsesWith(Const);
|
||||||
@ -1258,7 +1257,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
while (ResolvedBranches) {
|
while (ResolvedBranches) {
|
||||||
Solver.Solve();
|
Solver.Solve();
|
||||||
|
|
||||||
DEBUG(std::cerr << "RESOLVING UNDEF BRANCHES\n");
|
DOUT << "RESOLVING UNDEF BRANCHES\n";
|
||||||
ResolvedBranches = false;
|
ResolvedBranches = false;
|
||||||
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
|
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
|
||||||
ResolvedBranches |= Solver.ResolveBranchesIn(*F);
|
ResolvedBranches |= Solver.ResolveBranchesIn(*F);
|
||||||
@ -1278,7 +1277,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
if (IV.isConstant() || IV.isUndefined()) {
|
if (IV.isConstant() || IV.isUndefined()) {
|
||||||
Constant *CST = IV.isConstant() ?
|
Constant *CST = IV.isConstant() ?
|
||||||
IV.getConstant() : UndefValue::get(AI->getType());
|
IV.getConstant() : UndefValue::get(AI->getType());
|
||||||
DEBUG(std::cerr << "*** Arg " << *AI << " = " << *CST <<"\n");
|
DOUT << "*** Arg " << *AI << " = " << *CST <<"\n";
|
||||||
|
|
||||||
// Replaces all of the uses of a variable with uses of the
|
// Replaces all of the uses of a variable with uses of the
|
||||||
// constant.
|
// constant.
|
||||||
@ -1290,7 +1289,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
std::vector<BasicBlock*> BlocksToErase;
|
std::vector<BasicBlock*> BlocksToErase;
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
|
||||||
if (!ExecutableBBs.count(BB)) {
|
if (!ExecutableBBs.count(BB)) {
|
||||||
DEBUG(std::cerr << " BasicBlock Dead:" << *BB);
|
DOUT << " BasicBlock Dead:" << *BB;
|
||||||
++IPNumDeadBlocks;
|
++IPNumDeadBlocks;
|
||||||
|
|
||||||
// Delete the instructions backwards, as it has a reduced likelihood of
|
// Delete the instructions backwards, as it has a reduced likelihood of
|
||||||
@ -1333,7 +1332,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
!isa<TerminatorInst>(Inst)) {
|
!isa<TerminatorInst>(Inst)) {
|
||||||
Constant *Const = IV.isConstant()
|
Constant *Const = IV.isConstant()
|
||||||
? IV.getConstant() : UndefValue::get(Inst->getType());
|
? IV.getConstant() : UndefValue::get(Inst->getType());
|
||||||
DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
|
DOUT << " Constant: " << *Const << " = " << *Inst;
|
||||||
|
|
||||||
// Replaces all of the uses of a variable with uses of the
|
// Replaces all of the uses of a variable with uses of the
|
||||||
// constant.
|
// constant.
|
||||||
@ -1415,7 +1414,7 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
GlobalVariable *GV = I->first;
|
GlobalVariable *GV = I->first;
|
||||||
assert(!I->second.isOverdefined() &&
|
assert(!I->second.isOverdefined() &&
|
||||||
"Overdefined values should have been taken out of the map!");
|
"Overdefined values should have been taken out of the map!");
|
||||||
DEBUG(std::cerr << "Found that GV '" << GV->getName()<< "' is constant!\n");
|
DOUT << "Found that GV '" << GV->getName()<< "' is constant!\n";
|
||||||
while (!GV->use_empty()) {
|
while (!GV->use_empty()) {
|
||||||
StoreInst *SI = cast<StoreInst>(GV->use_back());
|
StoreInst *SI = cast<StoreInst>(GV->use_back());
|
||||||
SI->eraseFromParent();
|
SI->eraseFromParent();
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -170,7 +169,7 @@ bool SROA::performScalarRepl(Function &F) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(std::cerr << "Found inst to xform: " << *AI);
|
DOUT << "Found inst to xform: " << *AI;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
|
|
||||||
std::vector<AllocaInst*> ElementAllocas;
|
std::vector<AllocaInst*> ElementAllocas;
|
||||||
@ -265,7 +264,7 @@ int SROA::isSafeElementUse(Value *Ptr) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
DEBUG(std::cerr << " Transformation preventing inst: " << *User);
|
DOUT << " Transformation preventing inst: " << *User;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,8 +357,7 @@ int SROA::isSafeAllocaToScalarRepl(AllocationInst *AI) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
isSafe &= isSafeUseOfAllocation(cast<Instruction>(*I));
|
isSafe &= isSafeUseOfAllocation(cast<Instruction>(*I));
|
||||||
if (isSafe == 0) {
|
if (isSafe == 0) {
|
||||||
DEBUG(std::cerr << "Cannot transform: " << *AI << " due to user: "
|
DOUT << "Cannot transform: " << *AI << " due to user: " << **I;
|
||||||
<< **I);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -572,8 +570,8 @@ const Type *SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial) {
|
|||||||
/// predicate and is non-trivial. Convert it to something that can be trivially
|
/// predicate and is non-trivial. Convert it to something that can be trivially
|
||||||
/// promoted into a register by mem2reg.
|
/// promoted into a register by mem2reg.
|
||||||
void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
|
void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
|
||||||
DEBUG(std::cerr << "CONVERT TO SCALAR: " << *AI << " TYPE = "
|
DOUT << "CONVERT TO SCALAR: " << *AI << " TYPE = "
|
||||||
<< *ActualTy << "\n");
|
<< *ActualTy << "\n";
|
||||||
++NumConverted;
|
++NumConverted;
|
||||||
|
|
||||||
BasicBlock *EntryBlock = AI->getParent();
|
BasicBlock *EntryBlock = AI->getParent();
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/ADT/Statistic.h"
|
#include "llvm/ADT/Statistic.h"
|
||||||
#include <iostream>
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -215,14 +214,13 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
|
|||||||
BasicBlock *DestBlock = Branch->getSuccessor(0);
|
BasicBlock *DestBlock = Branch->getSuccessor(0);
|
||||||
assert(SourceBlock != DestBlock && "Our predicate is broken!");
|
assert(SourceBlock != DestBlock && "Our predicate is broken!");
|
||||||
|
|
||||||
DEBUG(std::cerr << "TailDuplication[" << SourceBlock->getParent()->getName()
|
DOUT << "TailDuplication[" << SourceBlock->getParent()->getName()
|
||||||
<< "]: Eliminating branch: " << *Branch);
|
<< "]: Eliminating branch: " << *Branch;
|
||||||
|
|
||||||
// See if we can avoid duplicating code by moving it up to a dominator of both
|
// See if we can avoid duplicating code by moving it up to a dominator of both
|
||||||
// blocks.
|
// blocks.
|
||||||
if (BasicBlock *DomBlock = FindObviousSharedDomOf(SourceBlock, DestBlock)) {
|
if (BasicBlock *DomBlock = FindObviousSharedDomOf(SourceBlock, DestBlock)) {
|
||||||
DEBUG(std::cerr << "Found shared dominator: " << DomBlock->getName()
|
DOUT << "Found shared dominator: " << DomBlock->getName() << "\n";
|
||||||
<< "\n");
|
|
||||||
|
|
||||||
// If there are non-phi instructions in DestBlock that have no operands
|
// If there are non-phi instructions in DestBlock that have no operands
|
||||||
// defined in DestBlock, and if the instruction has no side effects, we can
|
// defined in DestBlock, and if the instruction has no side effects, we can
|
||||||
@ -245,7 +243,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
|
|||||||
// Remove from DestBlock, move right before the term in DomBlock.
|
// Remove from DestBlock, move right before the term in DomBlock.
|
||||||
DestBlock->getInstList().remove(I);
|
DestBlock->getInstList().remove(I);
|
||||||
DomBlock->getInstList().insert(DomBlock->getTerminator(), I);
|
DomBlock->getInstList().insert(DomBlock->getTerminator(), I);
|
||||||
DEBUG(std::cerr << "Hoisted: " << *I);
|
DOUT << "Hoisted: " << *I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user