summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2005-04-21 23:48:37 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2005-04-21 23:48:37 +0000
commitfd93908ae8b9684fe71c239e3c6cfe13ff6a2663 (patch)
tree4d0726d997a629d08765d11a705a42c4f48690af /lib/Transforms/Scalar
parent0e0a7a45d3d0a8c865a078459d2e1c6d8967a100 (diff)
downloadllvm-fd93908ae8b9684fe71c239e3c6cfe13ff6a2663.tar.gz
llvm-fd93908ae8b9684fe71c239e3c6cfe13ff6a2663.tar.bz2
llvm-fd93908ae8b9684fe71c239e3c6cfe13ff6a2663.tar.xz
Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp28
-rw-r--r--lib/Transforms/Scalar/BasicBlockPlacement.cpp14
-rw-r--r--lib/Transforms/Scalar/CondPropagate.cpp6
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp6
-rw-r--r--lib/Transforms/Scalar/CorrelatedExprs.cpp44
-rw-r--r--lib/Transforms/Scalar/DCE.cpp10
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp12
-rw-r--r--lib/Transforms/Scalar/GCSE.cpp10
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp26
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp270
-rw-r--r--lib/Transforms/Scalar/LICM.cpp52
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp26
-rw-r--r--lib/Transforms/Scalar/LoopUnroll.cpp16
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp18
-rw-r--r--lib/Transforms/Scalar/LowerConstantExprs.cpp46
-rw-r--r--lib/Transforms/Scalar/LowerGC.cpp18
-rw-r--r--lib/Transforms/Scalar/LowerPacked.cpp88
-rw-r--r--lib/Transforms/Scalar/PRE.cpp20
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp10
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp68
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp24
-rw-r--r--lib/Transforms/Scalar/SimplifyCFG.cpp6
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp12
-rw-r--r--lib/Transforms/Scalar/TailRecursionElimination.cpp14
24 files changed, 422 insertions, 422 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index 089124a87f..a2ca367c45 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -1,14 +1,14 @@
//===- ADCE.cpp - Code to perform aggressive dead code elimination --------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements "aggressive" dead code elimination. ADCE is DCe where
-// values are assumed to be dead until proven otherwise. This is similar to
+// values are assumed to be dead until proven otherwise. This is similar to
// SCCP, except applied to the liveness of values.
//
//===----------------------------------------------------------------------===//
@@ -116,11 +116,11 @@ void ADCE::markBlockAlive(BasicBlock *BB) {
if (It != CDG.end()) {
// Get the blocks that this node is control dependent on...
const PostDominanceFrontier::DomSetType &CDB = It->second;
- for (PostDominanceFrontier::DomSetType::const_iterator I =
+ for (PostDominanceFrontier::DomSetType::const_iterator I =
CDB.begin(), E = CDB.end(); I != E; ++I)
markTerminatorLive(*I); // Mark all their terminators as live
}
-
+
// If this basic block is live, and it ends in an unconditional branch, then
// the branch is alive as well...
if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator()))
@@ -162,7 +162,7 @@ TerminatorInst *ADCE::convertToUnconditionalBranch(TerminatorInst *TI) {
// Remove entries from PHI nodes to avoid confusing ourself later...
for (unsigned i = 1, e = TI->getNumSuccessors(); i != e; ++i)
TI->getSuccessor(i)->removePredecessor(BB);
-
+
// Delete the old branch itself...
BB->getInstList().erase(TI);
return NB;
@@ -203,7 +203,7 @@ bool ADCE::doADCE() {
}
// Iterate over all of the instructions in the function, eliminating trivially
- // dead instructions, and marking instructions live that are known to be
+ // dead instructions, and marking instructions live that are known to be
// needed. Perform the walk in depth first order so that we avoid marking any
// instructions live in basic blocks that are unreachable. These blocks will
// be eliminated later, along with the instructions inside.
@@ -338,7 +338,7 @@ bool ADCE::doADCE() {
return MadeChanges;
}
-
+
// If the entry node is dead, insert a new entry node to eliminate the entry
// node as a special case.
@@ -350,7 +350,7 @@ bool ADCE::doADCE() {
AliveBlocks.insert(NewEntry); // This block is always alive!
LiveSet.insert(NewEntry->getTerminator()); // The branch is live
}
-
+
// Loop over all of the alive blocks in the function. If any successor
// blocks are not alive, we adjust the outgoing branches to branch to the
// first live postdominator of the live block, adjusting any PHI nodes in
@@ -360,7 +360,7 @@ bool ADCE::doADCE() {
if (AliveBlocks.count(I)) {
BasicBlock *BB = I;
TerminatorInst *TI = BB->getTerminator();
-
+
// If the terminator instruction is alive, but the block it is contained
// in IS alive, this means that this terminator is a conditional branch on
// a condition that doesn't matter. Make it an unconditional branch to
@@ -392,7 +392,7 @@ bool ADCE::doADCE() {
break;
}
}
- }
+ }
// There is a special case here... if there IS no post-dominator for
// the block we have nowhere to point our branch to. Instead, convert
@@ -411,12 +411,12 @@ bool ADCE::doADCE() {
// branch into an infinite loop into a return instruction!
//
RemoveSuccessor(TI, i);
-
+
// RemoveSuccessor may replace TI... make sure we have a fresh
// pointer.
//
TI = BB->getTerminator();
-
+
// Rescan this successor...
--i;
} else {
@@ -443,7 +443,7 @@ bool ADCE::doADCE() {
int OldIdx = PN->getBasicBlockIndex(LastDead);
assert(OldIdx != -1 &&"LastDead is not a pred of NextAlive!");
Value *InVal = PN->getIncomingValue(OldIdx);
-
+
// Add an incoming value for BB now...
PN->addIncoming(InVal, BB);
}
diff --git a/lib/Transforms/Scalar/BasicBlockPlacement.cpp b/lib/Transforms/Scalar/BasicBlockPlacement.cpp
index ec31bbf87e..c926c561d8 100644
--- a/lib/Transforms/Scalar/BasicBlockPlacement.cpp
+++ b/lib/Transforms/Scalar/BasicBlockPlacement.cpp
@@ -1,10 +1,10 @@
//===-- BasicBlockPlacement.cpp - Basic Block Code Layout optimization ----===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements a very simple profile guided basic block placement
@@ -37,7 +37,7 @@ using namespace llvm;
namespace {
Statistic<> NumMoved("block-placement", "Number of basic blocks moved");
-
+
struct BlockPlacement : public FunctionPass {
virtual bool runOnFunction(Function &F);
@@ -78,11 +78,11 @@ bool BlockPlacement::runOnFunction(Function &F) {
PI = &getAnalysis<ProfileInfo>();
NumMovedBlocks = 0;
- InsertPos = F.begin();
+ InsertPos = F.begin();
// Recursively place all blocks.
PlaceBlocks(F.begin());
-
+
PlacedBlocks.clear();
NumMoved += NumMovedBlocks;
return NumMovedBlocks != 0;
@@ -115,12 +115,12 @@ void BlockPlacement::PlaceBlocks(BasicBlock *BB) {
while (1) {
// Okay, now place any unplaced successors.
succ_iterator SI = succ_begin(BB), E = succ_end(BB);
-
+
// Scan for the first unplaced successor.
for (; SI != E && PlacedBlocks.count(*SI); ++SI)
/*empty*/;
if (SI == E) return; // No more successors to place.
-
+
unsigned MaxExecutionCount = PI->getExecutionCount(*SI);
BasicBlock *MaxSuccessor = *SI;
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp
index 0e63b51bb7..d3ad5778bb 100644
--- a/lib/Transforms/Scalar/CondPropagate.cpp
+++ b/lib/Transforms/Scalar/CondPropagate.cpp
@@ -1,10 +1,10 @@
//===-- CondPropagate.cpp - Propagate Conditional Expressions -------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass propagates information about conditional expressions through the
@@ -73,7 +73,7 @@ void CondProp::SimplifyBlock(BasicBlock *BB) {
if (BI->isConditional() && isa<PHINode>(BI->getCondition()) &&
cast<PHINode>(BI->getCondition())->getParent() == BB)
SimplifyPredecessors(BI);
-
+
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->getTerminator())) {
if (isa<PHINode>(SI->getCondition()) &&
cast<PHINode>(SI->getCondition())->getParent() == BB)
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index a3fa4a9665..8955aee281 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -1,10 +1,10 @@
//===- ConstantProp.cpp - Code to perform Simple Constant Propagation -----===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements constant propagation and merging:
@@ -66,7 +66,7 @@ bool ConstantPropagation::runOnFunction(Function &F) {
for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
UI != UE; ++UI)
WorkList.insert(cast<Instruction>(*UI));
-
+
// Replace all of the uses of a variable with uses of the constant.
I->replaceAllUsesWith(C);
diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp
index da8c500e21..f529502da9 100644
--- a/lib/Transforms/Scalar/CorrelatedExprs.cpp
+++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp
@@ -1,10 +1,10 @@
//===- CorrelatedExprs.cpp - Pass to detect and eliminated c.e.'s ---------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// Correlated Expression Elimination propagates information from conditional
@@ -178,7 +178,7 @@ namespace {
// empty - return true if this region has no information known about it.
bool empty() const { return ValueMap.empty(); }
-
+
const RegionInfo &operator=(const RegionInfo &RI) {
ValueMap = RI.ValueMap;
return *this;
@@ -204,7 +204,7 @@ namespace {
if (I != ValueMap.end()) return &I->second;
return 0;
}
-
+
/// removeValueInfo - Remove anything known about V from our records. This
/// works whether or not we know anything about V.
///
@@ -281,7 +281,7 @@ namespace {
bool SimplifyBasicBlock(BasicBlock &BB, const RegionInfo &RI);
bool SimplifyInstruction(Instruction *Inst, const RegionInfo &RI);
- };
+ };
RegisterOpt<CEE> X("cee", "Correlated Expression Elimination");
}
@@ -299,7 +299,7 @@ bool CEE::runOnFunction(Function &F) {
// blocks.
DS = &getAnalysis<DominatorSet>();
DT = &getAnalysis<DominatorTree>();
-
+
std::set<BasicBlock*> VisitedBlocks;
bool Changed = TransformRegion(&F.getEntryBlock(), VisitedBlocks);
@@ -458,13 +458,13 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo,
for (BasicBlock::iterator I = OldSucc->begin(), E = OldSucc->end(); I!=E; ++I)
if (I->getType() != Type::VoidTy)
NewRI.removeValueInfo(I);
-
+
// Put the newly discovered information into the RegionInfo...
for (BasicBlock::iterator I = OldSucc->begin(), E = OldSucc->end(); I!=E; ++I)
if (PHINode *PN = dyn_cast<PHINode>(I)) {
int OpNum = PN->getBasicBlockIndex(BB);
assert(OpNum != -1 && "PHI doesn't have incoming edge for predecessor!?");
- PropagateEquality(PN, PN->getIncomingValue(OpNum), NewRI);
+ PropagateEquality(PN, PN->getIncomingValue(OpNum), NewRI);
} else if (SetCondInst *SCI = dyn_cast<SetCondInst>(I)) {
Relation::KnownResult Res = getSetCCResult(SCI, NewRI);
if (Res == Relation::Unknown) return false;
@@ -472,7 +472,7 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo,
} else {
assert(isa<BranchInst>(*I) && "Unexpected instruction type!");
}
-
+
// Compute the facts implied by what we have discovered...
ComputeReplacements(NewRI);
@@ -486,7 +486,7 @@ bool CEE::ForwardCorrelatedEdgeDestination(TerminatorInst *TI, unsigned SuccNo,
ForwardSuccessorTo(TI, SuccNo, BI->getSuccessor(!CB->getValue()), NewRI);
return true;
}
-
+
return false;
}
@@ -582,7 +582,7 @@ void CEE::ForwardSuccessorTo(TerminatorInst *TI, unsigned SuccNo,
// node yet though if this is the last edge into it.
Value *EdgeValue = PN->removeIncomingValue(BB, false);
- // Make sure that anything that used to use PN now refers to EdgeValue
+ // Make sure that anything that used to use PN now refers to EdgeValue
ReplaceUsesOfValueInRegion(PN, EdgeValue, Dest);
// If there is only one value left coming into the PHI node, replace the PHI
@@ -603,7 +603,7 @@ void CEE::ForwardSuccessorTo(TerminatorInst *TI, unsigned SuccNo,
++I; // Otherwise, move on to the next PHI node
}
}
-
+
// Actually revector the branch now...
TI->setSuccessor(SuccNo, Dest);
@@ -689,7 +689,7 @@ static void CalcRegionExitBlocks(BasicBlock *Header, BasicBlock *BB,
} else {
// Header does not dominate this block, but we have a predecessor that does
// dominate us. Add ourself to the list.
- RegionExitBlocks.push_back(BB);
+ RegionExitBlocks.push_back(BB);
}
}
@@ -703,7 +703,7 @@ void CEE::CalculateRegionExitBlocks(BasicBlock *BB, BasicBlock *OldSucc,
// Recursively calculate blocks we are interested in...
CalcRegionExitBlocks(BB, BB, Visited, *DS, RegionExitBlocks);
-
+
// Filter out blocks that are not dominated by OldSucc...
for (unsigned i = 0; i != RegionExitBlocks.size(); ) {
if (DS->dominates(OldSucc, RegionExitBlocks[i]))
@@ -738,7 +738,7 @@ void CEE::InsertRegionExitMerges(PHINode *BBVal, Instruction *OldVal,
// otherwise use OldVal.
NewPN->addIncoming(DS->dominates(BB, *PI) ? BBVal : OldVal, *PI);
}
-
+
// Now make everyone dominated by this block use this new value!
ReplaceUsesOfValueInRegion(OldVal, NewPN, FBlock);
}
@@ -783,7 +783,7 @@ void CEE::PropagateBranchInfo(BranchInst *BI) {
//
PropagateEquality(BI->getCondition(), ConstantBool::True,
getRegionInfo(BI->getSuccessor(0)));
-
+
// Propagate information into the false block...
//
PropagateEquality(BI->getCondition(), ConstantBool::False,
@@ -825,7 +825,7 @@ void CEE::PropagateEquality(Value *Op0, Value *Op1, RegionInfo &RI) {
PropagateEquality(Inst->getOperand(0), CB, RI);
PropagateEquality(Inst->getOperand(1), CB, RI);
}
-
+
// If we know that this instruction is an OR instruction, and the result
// is false, this means that both operands to the OR are know to be false
// as well.
@@ -834,7 +834,7 @@ void CEE::PropagateEquality(Value *Op0, Value *Op1, RegionInfo &RI) {
PropagateEquality(Inst->getOperand(0), CB, RI);
PropagateEquality(Inst->getOperand(1), CB, RI);
}
-
+
// If we know that this instruction is a NOT instruction, we know that the
// operand is known to be the inverse of whatever the current value is.
//
@@ -857,7 +857,7 @@ void CEE::PropagateEquality(Value *Op0, Value *Op1, RegionInfo &RI) {
} else { // If we know the condition is false...
// We know the opposite of the condition is true...
Instruction::BinaryOps C = SCI->getInverseCondition();
-
+
PropagateRelation(C, SCI->getOperand(0), SCI->getOperand(1), RI);
PropagateRelation(SetCondInst::getSwappedCondition(C),
SCI->getOperand(1), SCI->getOperand(0), RI);
@@ -1065,7 +1065,7 @@ Relation::KnownResult CEE::getSetCCResult(SetCondInst *SCI,
const RegionInfo &RI) {
Value *Op0 = SCI->getOperand(0), *Op1 = SCI->getOperand(1);
Instruction::BinaryOps Opcode = SCI->getOpcode();
-
+
if (isa<Constant>(Op0)) {
if (isa<Constant>(Op1)) {
if (Constant *Result = ConstantFoldInstruction(SCI)) {
@@ -1098,7 +1098,7 @@ Relation::KnownResult CEE::getSetCCResult(SetCondInst *SCI,
// If the intersection of the two ranges is empty, then the condition
// could never be true!
- //
+ //
if (Int.isEmptySet()) {
Result = Relation::KnownFalse;
@@ -1254,7 +1254,7 @@ Relation::getImpliedResult(Instruction::BinaryOps Op) const {
// print - Implement the standard print form to print out analysis information.
void CEE::print(std::ostream &O, const Module *M) const {
O << "\nPrinting Correlated Expression Info:\n";
- for (std::map<BasicBlock*, RegionInfo>::const_iterator I =
+ for (std::map<BasicBlock*, RegionInfo>::const_iterator I =
RegionInfoMap.begin(), E = RegionInfoMap.end(); I != E; ++I)
I->second.print(O);
}
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index ae61208b52..759180a371 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -1,10 +1,10 @@
//===- DCE.cpp - Code to perform dead code elimination --------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements dead inst elimination and dead code elimination.
@@ -49,7 +49,7 @@ namespace {
AU.setPreservesCFG();
}
};
-
+
RegisterOpt<DeadInstElimination> X("die", "Dead Instruction Elimination");
}
@@ -81,7 +81,7 @@ bool DCE::runOnFunction(Function &F) {
WorkList.push_back(&*i);
}
std::set<Instruction*> DeadInsts;
-
+
// Loop over the worklist finding instructions that are dead. If they are
// dead make them drop all of their uses, making other instructions
// potentially dead, and work until the worklist is empty.
@@ -89,7 +89,7 @@ bool DCE::runOnFunction(Function &F) {
while (!WorkList.empty()) {
Instruction *I = WorkList.back();
WorkList.pop_back();
-
+
if (isInstructionTriviallyDead(I)) { // If the instruction is dead...
// Loop over all of the values that the instruction uses, if there are
// instructions being used, add them to the worklist, because they might
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index a823e14c0d..07d5c65520 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1,10 +1,10 @@
//===- DeadStoreElimination.cpp - Dead Store Elimination ------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements a trivial dead store elimination that only considers
@@ -39,9 +39,9 @@ namespace {
Changed |= runOnBasicBlock(*I);
return Changed;
}
-
+
bool runOnBasicBlock(BasicBlock &BB);
-
+
void DeleteDeadInstructionChains(Instruction *I,
SetVector<Instruction*> &DeadInsts);
@@ -87,7 +87,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
bool MadeChange = false;
for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ) {
Instruction *I = --BBI; // Keep moving iterator backwards
-
+
// If this is a free instruction, it makes the free'd location dead!
if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
// Free instructions make any stores to the free'd location dead.
@@ -161,7 +161,7 @@ void DSE::DeleteDeadInstructionChains(Instruction *I,
DeadInsts.insert(Op); // Attempt to nuke it later.
I->setOperand(i, 0); // Drop from the operand list.
}
-
+
I->eraseFromParent();
++NumOther;
}
diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp
index dbabe2686b..a785685b2c 100644
--- a/lib/Transforms/Scalar/GCSE.cpp
+++ b/lib/Transforms/Scalar/GCSE.cpp
@@ -1,10 +1,10 @@
//===-- GCSE.cpp - SSA-based Global Common Subexpression Elimination ------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass is designed to be a very quick global transformation that
@@ -116,7 +116,7 @@ bool GCSE::runOnFunction(Function &F) {
else {
I = Inst; --I;
}
-
+
// First check to see if we were able to value number this instruction
// to a non-instruction value. If so, prefer that value over other
// instructions which may compute the same thing.
@@ -186,14 +186,14 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) {
getAnalysis<ValueNumbering>().deleteValue(I);
I->replaceAllUsesWith(V);
-
+
if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
// Removing an invoke instruction requires adding a branch to the normal
// destination and removing PHI node entries in the exception destination.
new BranchInst(II->getNormalDest(), II);
II->getUnwindDest()->removePredecessor(II->getParent());
}
-
+
// Erase the instruction from the program.
I->getParent()->getInstList().erase(I);
}
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index aabc96c8f2..88ad6d206a 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1,10 +1,10 @@
//===- IndVarSimplify.cpp - Induction Variable Elimination ----------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This transformation analyzes and transforms the induction variables (and
@@ -76,7 +76,7 @@ namespace {
bool isInsertedInstruction(Instruction *I) const {
return InsertedInstructions.count(I);
}
-
+
/// getOrInsertCanonicalInductionVariable - This method returns the
/// canonical induction variable of the specified type for the specified
/// loop (inserting one if there is none). A canonical induction variable
@@ -128,7 +128,7 @@ namespace {
return ConstantExpr::getCast(C, Ty);
else if (Instruction *I = dyn_cast<Instruction>(V)) {
// Check to see if there is already a cast. If there is, use it.
- for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
+ for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI) {
if ((*UI)->getType() == Ty)
if (CastInst *CI = dyn_cast<CastInst>(cast<Instruction>(*UI))) {
@@ -206,10 +206,10 @@ Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) {
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getOperand(0)))
if (SC->getValue()->isAllOnesValue())
FirstOp = 1;
-
+
int i = S->getNumOperands()-2;
Value *V = expandInTy(S->getOperand(i+1), Ty);
-
+
// Emit a bunch of multiply instructions
for (; i >= FirstOp; --i)
V = BinaryOperator::createMul(V, expandInTy(S->getOperand(i), Ty),
@@ -358,7 +358,7 @@ DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) {
/// EliminatePointerRecurrence - Check to see if this is a trivial GEP pointer
/// recurrence. If so, change it into an integer recurrence, permitting
/// analysis by the SCEV routines.
-void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
+void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
BasicBlock *Preheader,
std::set<Instruction*> &DeadInsts) {
assert(PN->getNumIncomingValues() == 2 && "Noncanonicalized loop!");
@@ -368,7 +368,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx)))
if (GEPI->getOperand(0) == PN) {
assert(GEPI->getNumOperands() == 2 && "GEP types must mismatch!");
-
+
// Okay, we found a pointer recurrence. Transform this pointer
// recurrence into an integer recurrence. Compute the value that gets
// added to the pointer at every iteration.
@@ -383,10 +383,10 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
Value *NewAdd = BinaryOperator::createAdd(NewPhi, AddedVal,
GEPI->getName()+".rec", GEPI);
NewPhi->addIncoming(NewAdd, PN->getIncomingBlock(BackedgeIdx));
-
+
// Update the existing GEP to use the recurrence.
GEPI->setOperand(0, PN->getIncomingValue(PreheaderIdx));
-
+
// Update the GEP to use the new recurrence we just inserted.
GEPI->setOperand(1, NewAdd);
@@ -547,7 +547,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
bool HasConstantItCount = isa<SCEVConstant>(SE->getIterationCount(L));
std::set<Instruction*> InstructionsToDelete;
-
+
for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i)
if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop...
BasicBlock *BB = L->getBlocks()[i];
@@ -599,7 +599,7 @@ void IndVarSimplify::runOnLoop(Loop *L) {
//
BasicBlock *Header = L->getHeader();
BasicBlock *Preheader = L->getLoopPreheader();
-
+
std::set<Instruction*> DeadInsts;
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I);
@@ -748,7 +748,7 @@ void IndVarSimplify::runOnLoop(Loop *L) {
DeadInsts.insert(I);
++NumRemoved;
Changed = true;
- }
+ }
}
}
#endif
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index fcdd73d0a6..5a2e4ef177 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1,10 +1,10 @@
//===- InstructionCombining.cpp - Combine multiple instructions -----------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// InstructionCombining - Combine instructions to form fewer, simple
@@ -103,7 +103,7 @@ namespace {
// null - No change was made
// I - Change was made, I is still valid, I may be dead though
// otherwise - Change was made, replace I with returned instruction
- //
+ //
Instruction *visitAdd(BinaryOperator &I);
Instruction *visitSub(BinaryOperator &I);
Instruction *visitMul(BinaryOperator &I);
@@ -159,7 +159,7 @@ namespace {
/// cast.
Value *InsertCastBefore(Value *V, const Type *Ty, Instruction &Pos) {
if (V->getType() == Ty) return V;
-
+
Instruction *C = new CastInst(V, Ty, V->getName(), &Pos);
WorkList.push_back(C);
return C;
@@ -275,7 +275,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) {
bool Changed = false;
if (getComplexity(I.getOperand(0)) < getComplexity(I.getOperand(1)))
Changed = !I.swapOperands();
-
+
if (!I.isAssociative()) return Changed;
Instruction::BinaryOps Opcode = I.getOpcode();
if (BinaryOperator *Op = dyn_cast<BinaryOperator>(I.getOperand(0)))
@@ -302,7 +302,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) {
I.setOperand(0, New);
I.setOperand(1, Folded);
return true;
- }
+ }
}
return Changed;
}
@@ -427,7 +427,7 @@ Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F) {
// reassociate the expression from ((? op A) op B) to (? op (A op B))
if (ShouldApply) {
BasicBlock *BB = Root.getParent();
-
+
// Now all of the instructions are in the current basic block, go ahead
// and perform the reassociation.
Instruction *TmpLHSI = cast<Instruction>(Root.getOperand(0));
@@ -463,12 +463,12 @@ Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F) {
TmpLHSI = NextLHSI;
ExtraOperand = NextOp;
}
-
+
// Now that the instructions are reassociated, have the functor perform
// the transformation...
return F.apply(Root);
}
-
+
LHSI = dyn_cast<Instruction>(LHSI->getOperand(0));
}
return 0;
@@ -493,7 +493,7 @@ struct AddMaskingAnd {
AddMaskingAnd(Constant *c) : C2(c) {}
bool shouldApply(Value *LHS) const {
ConstantInt *C1;
- return match(LHS, m_And(m_Value(), m_ConstantInt(C1))) &&
+ return match(LHS, m_And(m_Value(), m_ConstantInt(C1))) &&
ConstantExpr::getAnd(C1, C2)->isNullValue();
}
Instruction *apply(BinaryOperator &Add) const {
@@ -506,7 +506,7 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
if (isa<CastInst>(I)) {
if (Constant *SOC = dyn_cast<Constant>(SO))
return ConstantExpr::getCast(SOC, I.getType());
-
+
return IC->InsertNewInstBefore(new CastInst(SO, I.getType(),
SO->getName() + ".cast"), I);
}
@@ -615,7 +615,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
if (!I.getType()->isFloatingPoint() && // -0 + +0 = +0, so it's not a noop
RHSC->isNullValue())
return ReplaceInstUsesWith(I, LHS);
-
+
// X + (signbit) --> X ^ signbit
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHSC)) {
unsigned NumBits = CI->getType()->getPrimitiveSize()*8;
@@ -654,7 +654,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
if (Value *V = dyn_castNegVal(RHS))
return BinaryOperator::createSub(LHS, V);
-
+
ConstantInt *C2;
if (Value *X = dyn_castFoldableMul(LHS, C2)) {
if (X == RHS) // X*C + X --> X * (C+1)
@@ -696,7 +696,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
// See if the and mask includes all of these bits.
uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getRawValue();
-
+
if (AddRHSHighBits == AddRHSHighBitsAnd) {
// Okay, the xform is safe. Insert the new add pronto.
Value *NewAdd = InsertNewInstBefore(BinaryOperator::createAdd(X, CRHS,
@@ -832,7 +832,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
Value *IIOp0 = Op1I->getOperand(0), *IIOp1 = Op1I->getOperand(1);
Op1I->setOperand(0, IIOp1);
Op1I->setOperand(1, IIOp0);
-
+
// Create the new top level add instruction...
return BinaryOperator::createAdd(Op0, Op1);
}
@@ -853,13 +853,13 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0))
if (CSI->isNullValue())
if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1)))
- return BinaryOperator::createDiv(Op1I->getOperand(0),
+ return BinaryOperator::createDiv(Op1I->getOperand(0),
ConstantExpr::getNeg(DivRHS));
// X - X*C --> X * (1-C)
ConstantInt *C2;
if (dyn_castFoldableMul(Op1I, C2) == Op0) {
- Constant *CP1 =
+ Constant *CP1 =
ConstantExpr::getSub(ConstantInt::get(I.getType(), 1), C2);
return BinaryOperator::createMul(Op0, CP1);
}
@@ -877,7 +877,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
if (Op0I->getOperand(0) == Op1) // (X-Y)-X == -Y
return BinaryOperator::createNeg(Op0I->getOperand(1), I.getName());
}
-
+
ConstantInt *C1;
if (Value *X = dyn_castFoldableMul(Op0, C1)) {
if (X == Op1) { // X*C - X --> X * (C-1)
@@ -929,7 +929,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
if (Constant *ShOp = dyn_cast<Constant>(SI->getOperand(1)))
return BinaryOperator::createMul(SI->getOperand(0),
ConstantExpr::getShl(CI, ShOp));
-
+
if (CI->isNullValue())
return ReplaceInstUsesWith(I, Op1); // X * 0 == 0
if (CI->equalsInt(1)) // X * 1 == X
@@ -1004,7 +1004,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// or truncate to the multiply type.
if (I.getType() != V->getType())
V = InsertNewInstBefore(new CastInst(V, I.getType(), V->getName()),I);
-
+
Value *OtherOp = Op0 == BoolCast ? I.getOperand(1) : Op0;
return BinaryOperator::createAnd(V, OtherOp);
}
@@ -1069,10 +1069,10 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) {
if (STO->getValue() == 0) { // Couldn't be this argument.
I.setOperand(1, SFO);
- return &I;
+ return &I;
} else if (SFO->getValue() == 0) {
I.setOperand(2, STO);
- return &I;
+ return &I;
}
uint64_t TVA = STO->getValue(), FVA = SFO->getValue();
@@ -1083,7 +1083,7 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
TC, SI->getName()+".t");
TSI = InsertNewInstBefore(TSI, I);
-
+
Constant *FC = ConstantUInt::get(Type::UByteTy, FSA);
Instruction *FSI = new ShiftInst(Instruction::Shr, Op0,
FC, SI->getName()+".f");
@@ -1091,7 +1091,7 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
return new SelectInst(SI->getOperand(0), TSI, FSI);
}
}
-
+
// 0 / X == 0, we don't need to preserve faults!
if (ConstantInt *LHS = dyn_cast<ConstantInt>(Op0))
if (LHS->equalsInt(0))
@@ -1147,10 +1147,10 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) {
if (STO->getValue() == 0) { // Couldn't be this argument.
I.setOperand(1, SFO);
- return &I;
+ return &I;
} else if (SFO->getValue() == 0) {
I.setOperand(1, STO);
- return &I;
+ return &I;
}
if (!(STO->getValue() & (STO->getValue()-1)) &&
@@ -1162,7 +1162,7 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd);
}
}
-
+
// 0 % X == 0, we don't need to preserve faults!
if (ConstantInt *LHS = dyn_cast<ConstantInt>(Op0))
if (LHS->equalsInt(0))
@@ -1182,7 +1182,7 @@ static bool isMaxValueMinusOne(const ConstantInt *C) {
}
const ConstantSInt *CS = cast<ConstantSInt>(C);
-
+
// Calculate 0111111111..11111
unsigned TypeBits = C->getType()->getPrimitiveSize()*8;
int64_t Val = INT64_MAX; // All ones
@@ -1196,8 +1196,8 @@ static bool isMinValuePlusOne(const ConstantInt *C) {
return CU->getValue() == 1;
const ConstantSInt *CS = cast<ConstantSInt>(C);
-
- // Calculate 1111111111000000000000
+
+ // Calculate 1111111111000000000000
unsigned TypeBits = C->getType()->getPrimitiveSize()*8;
int64_t Val = -1; // All ones
Val <<= TypeBits-1; // Shift over to the right spot
@@ -1325,7 +1325,7 @@ static bool MaskedValueIsZero(Value *V, ConstantIntegral *Mask) {
return true;
if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V))
return ConstantExpr::getAnd(CI, Mask)->isNullValue();
-
+
if (Instruction *I = dyn_cast<Instruction>(V)) {
switch (I->getOpcode()) {
case Instruction::And:
@@ -1336,11 +1336,11 @@ static bool MaskedValueIsZero(Value *V, ConstantIntegral *Mask) {
break;
case Instruction::Or:
// If the LHS and the RHS are MaskedValueIsZero, the result is also zero.
- return MaskedValueIsZero(I->getOperand(1), Mask) &&
+ return MaskedValueIsZero(I->getOperand(1), Mask) &&
MaskedValueIsZero(I->getOperand(0), Mask);
case Instruction::Select:
// If the T and F values are MaskedValueIsZero, the result is also zero.
- return MaskedValueIsZero(I->getOperand(2), Mask) &&
+ return MaskedValueIsZero(I->getOperand(2), Mask) &&
MaskedValueIsZero(I->getOperand(1), Mask);
case Instruction::Cast: {
const Type *SrcTy = I->getOperand(0)->getType();
@@ -1414,7 +1414,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
case Instruction::Or:
if (Together == AndRHS) // (X | C) & C --> C
return ReplaceInstUsesWith(TheAnd, AndRHS);
-
+
if (Op->hasOneUse() && Together != OpRHS) {
// (X | C1) & C2 --> (X | (C1&C2)) & C2
std::string Op0Name = Op->getName(); Op->setName("");
@@ -1439,7 +1439,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
// ADD down to exactly one bit. If the constant we are adding has
// no bits set below this bit, then we can eliminate the ADD.
uint64_t AddRHS = cast<ConstantInt>(OpRHS)->getRawValue();
-
+
// Check to see if any bits below the one bit set in AndRHSV are set.
if ((AddRHS & (AndRHSV-1)) == 0) {
// If not, the only thing that can effect the output of the AND is
@@ -1468,7 +1468,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
Constant *ShlMask = ConstantExpr::getShl(AllOne, OpRHS);
Constant *CI = ConstantExpr::getAnd(AndRHS, ShlMask);
-
+
if (CI == ShlMask) { // Masking out bits that the shift already masks
return ReplaceInstUsesWith(TheAnd, Op); // No need for the and.
} else if (CI != AndRHS) { // Reducing bits set in and.
@@ -1476,7 +1476,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
return &TheAnd;
}
break;
- }
+ }
case Instruction::Shr:
// We know that the AND will not produce any of the bits shifted in, so if
// the anded constant includes them, clear them now! This only applies to
@@ -1536,7 +1536,7 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
return new SetCondInst(Instruction::SetNE, V, V);
if (cast<ConstantIntegral>(Lo)->isMinValue())
return new SetCondInst(Instruction::SetLT, V, Hi);
-
+
Constant *AddCST = ConstantExpr::getNeg(Lo);
Instruction *Add = BinaryOperator::createAdd(V, AddCST,V->getName()+".off");
InsertNewInstBefore(Add, IB);
@@ -1589,9 +1589,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
// If the mask is not masking out any bits, there is no reason to do the
// and in the first place.
- ConstantIntegral *NotAndRHS =
+ ConstantIntegral *NotAndRHS =
cast<ConstantIntegral>(ConstantExpr::getNot(AndRHS));
- if (MaskedValueIsZero(Op0, NotAndRHS))
+ if (MaskedValueIsZero(Op0, NotAndRHS))
return ReplaceInstUsesWith(I, Op0);
// Optimize a variety of ((val OP C1) & C2) combinations...
@@ -1605,9 +1605,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
// (X ^ V) & C2 --> (X & C2) iff (V & C2) == 0
// (X | V) & C2 --> (X & C2) iff (V & C2) == 0
if (MaskedValueIsZero(Op0LHS, AndRHS))
- return BinaryOperator::createAnd(Op0RHS, AndRHS);
+ return BinaryOperator::createAnd(Op0RHS, AndRHS);
if (MaskedValueIsZero(Op0RHS, AndRHS))
- return BinaryOperator::createAnd(Op0LHS, AndRHS);
+ return BinaryOperator::createAnd(Op0LHS, AndRHS);
// If the mask is only needed on one incoming arm, push it up.
if (Op0I->hasOneUse()) {
@@ -1618,7 +1618,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
InsertNewInstBefore(NewRHS, I);
return BinaryOperator::create(
cast<BinaryOperator>(Op0I)->getOpcode(), Op0LHS, NewRHS);
- }
+ }
if (!isa<Constant>(NotAndRHS) &&
MaskedValueIsZero(Op0RHS, NotAndRHS)) {
// Not masking anything out for the RHS, move to LHS.
@@ -1727,7 +1727,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
if (match(RHS, m_SetCond(RHSCC, m_Value(RHSVal), m_ConstantInt(RHSCst))))
if (LHSVal == RHSVal && // Found (X setcc C1) & (X setcc C2)
// Set[GL]E X, CST is folded to Set[GL]T elsewhere.
- LHSCC != Instruction::SetGE && LHSCC != Instruction::SetLE &&
+ LHSCC != Instruction::SetGE && LHSCC != Instruction::SetLE &&
RHSCC != Instruction::SetGE && RHSCC != Instruction::SetLE) {
// Ensure that the larger constant is on the RHS.
Constant *Cmp = ConstantExpr::getSetGT(LHSCst, RHSCst);
@@ -1869,7 +1869,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
if (match(Op0, m_Not(m_Value(A)))) { // ~A | Op1
if (A == Op1) // ~A | A == -1
- return ReplaceInstUsesWith(I,
+ return ReplaceInstUsesWith(I,
ConstantIntegral::getAllOnesValue(I.getType()));
} else {
A = 0;
@@ -1877,7 +1877,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
if (match(Op1, m_Not(m_Value(B)))) { // Op0 | ~B
if (Op0 == B)
- return ReplaceInstUsesWith(I,
+ return ReplaceInstUsesWith(I,
ConstantIntegral::getAllOnesValue(I.getType()));
// (~A | ~B) == (~(A & B)) - De Morgan's Law
@@ -1900,7 +1900,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
if (match(RHS, m_SetCond(RHSCC, m_Value(RHSVal), m_ConstantInt(RHSCst))))
if (LHSVal == RHSVal && // Found (X setcc C1) | (X setcc C2)
// Set[GL]E X, CST is folded to Set[GL]T elsewhere.
- LHSCC != Instruction::SetGE && LHSCC != Instruction::SetLE &&
+ LHSCC != Instruction::SetGE && LHSCC != Instruction::SetLE &&
RHSCC != Instruction::SetGE && RHSCC != Instruction::SetLE) {
// Ensure that the larger constant is on the RHS.
Constant *Cmp = ConstantExpr::getSetGT(LHSCst, RHSCst);
@@ -2035,13 +2035,13 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
if (dyn_castNotVal(Op0I->getOperand(1))) Op0I->swapOperands();
if (Value *Op0NotVal = dyn_castNotVal(Op0I->getOperand(0))) {
Instruction *NotY =
- BinaryOperator::createNot(Op0I->getOperand(1),
+ BinaryOperator::createNot(Op0I->getOperand(1),
Op0I->getOperand(1)->getName()+".not");
InsertNewInstBefore(NotY, I);
return BinaryOperator::createOr(Op0NotVal, NotY);
}
}
-
+
if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1)))
switch (Op0I->getOpcode()) {
case Instruction::Add:
@@ -2096,7 +2096,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
} else if (Op1I->getOperand(1) == Op0) { // B^(A|B) == (A|B)^B
I.swapOperands();
std::swap(Op0, Op1);
- }
+ }
} else if (Op1I->getOpcode() == Instruction::Xor) {
if (Op0 == Op1I->getOperand(0)) // A^(A^B) == B
return ReplaceInstUsesWith(I, Op1I->getOperand(1));
@@ -2242,13 +2242,13 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
EmitIt = false;
else if (TD->getTypeSize(GTI.getIndexedType()) == 0) {
EmitIt = false; // This is indexing into a zero sized array?
- } else if (isa<ConstantInt>(C))
+ } else if (isa<ConstantInt>(C))
return ReplaceInstUsesWith(I, // No comparison is needed here.
ConstantBool::get(Cond == Instruction::SetNE));
}
if (EmitIt) {
- Instruction *Comp =
+ Instruction *Comp =
new SetCondInst(Cond, GEPLHS->getOperand(i),
Constant::getNullValue(GEPLHS->getOperand(i)->getType()));
if (InVal == 0)
@@ -2312,7 +2312,7 @@ Instruction *InstCombiner::FoldGEPSetCC(User *GEPLHS, Value *RHS,
unsigned DiffOperand = 0; // The operand that differs.
for (unsigned i = 1, e = GEPRHS->getNumOperands(); i != e; ++i)
if (GEPLHS->getOperand(i) != GEPRHS->getOperand(i)) {
- if (GEPLHS->getOperand(i)->getType()->getPrimitiveSize() !=
+ if (GEPLHS->getOperand(i)->getType()->getPrimitiveSize() !=
GEPRHS->getOperand(i)->getType()->getPrimitiveSize()) {
// Irreconcilable differences.
NumDifferences = 2;
@@ -2364,9 +2364,9 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// setcc <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
// addresses never equal each other! We already know that Op0 != Op1.
- if ((isa<GlobalValue>(Op0) || isa<AllocaInst>(Op0) ||
- isa<ConstantPointerNull>(Op0)) &&
- (isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
+ if ((isa<GlobalValue>(Op0) || isa<AllocaInst>(Op0) ||
+ isa<ConstantPointerNull>(Op0)) &&
+ (isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
isa<ConstantPointerNull>(Op1)))
return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
@@ -2466,7 +2466,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
ShAmt = Shift ? dyn_cast<ConstantUInt>(Shift->getOperand(1)) : 0;
ConstantInt *AndCST = cast<ConstantInt>(LHSI->getOperand(1));
const Type *Ty = LHSI->getType();
-
+
// We can fold this as long as we can't shift unknown bits
// into the mask. This can only happen with signed shift
// rights, as they sign-extend.
@@ -2476,14 +2476,14 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
if (!CanFold) {
// To test for the bad case of the signed shr, see if any
// of the bits shifted in could be tested after the mask.
- Constant *OShAmt = ConstantUInt::get(Type::UByteTy,
+ Constant *OShAmt = ConstantUInt::get(Type::UByteTy,
Ty->getPrimitiveSize()*8-ShAmt->getValue());
- Constant *ShVal =
+ Constant *ShVal =
ConstantExpr::getShl(ConstantInt::getAllOnesValue(Ty), OShAmt);
if (ConstantExpr::getAnd(ShVal, AndCST)->isNullValue())
CanFold = true;
}
-
+
if (CanFold) {
Constant *NewCst;
if (Shift->getOpcode() == Instruction::Shl)
@@ -2521,7 +2521,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// (setcc (cast X to larger), CI)
case Instruction::Cast:
- if (Instruction *R =
+ if (Instruction *R =
visitSetCondInstWithCastAndConstant(I,cast<CastInst>(LHSI),CI))
return R;
break;
@@ -2534,7 +2534,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
case Instruction::SetNE: {
// If we are comparing against bits always shifted out, the
// comparison cannot succeed.
- Constant *Comp =
+ Constant *Comp =
ConstantExpr::getShl(ConstantExpr::getShr(CI, ShAmt), ShAmt);
if (Comp != CI) {// Comparing against a bit that we know is zero.
bool IsSetNE = I.getOpcode() == Instruction::SetNE;
@@ -2556,7 +2556,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
} else {
Mask = ConstantInt::getAllOnesValue(CI->getType());
}
-
+
Instruction *AndI =
BinaryOperator::createAnd(LHSI->getOperand(0),
Mask, LHSI->getName()+".mask");
@@ -2577,15 +2577,15 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
case Instruction::SetNE: {
// If we are comparing against bits always shifted out, the
// comparison cannot succeed.
- Constant *Comp =
+ Constant *Comp =
ConstantExpr::getShr(ConstantExpr::getShl(CI, ShAmt), ShAmt);
-
+
if (Comp != CI) {// Comparing against a bit that we know is zero.
bool IsSetNE = I.getOpcode() == Instruction::SetNE;
Constant *Cst = ConstantBool::get(IsSetNE);
return ReplaceInstUsesWith(I, Cst);
}
-
+
if (LHSI->hasOneUse() || CI->isNullValue()) {
unsigned ShAmtVal = (unsigned)ShAmt->getValue();
@@ -2602,7 +2602,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
} else {
Mask = ConstantSInt::get(CI->getType(), Val);
}
-
+
Instruction *AndI =
BinaryOperator::createAnd(LHSI->getOperand(0),
Mask, LHSI->getName()+".mask");
@@ -2727,12 +2727,12 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
I.getName()), I);
}
}
-
+
if (Op1)
return new SelectInst(LHSI->getOperand(0), Op1, Op2);
break;
}
-
+
// Simplify seteq and setne instructions...
if (I.getOpcode() == Instruction::SetEQ ||
I.getOpcode() == Instruction::SetNE) {
@@ -2758,7 +2758,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
return BinaryOperator::create(I.getOpcode(), NewRem,
Constant::getNullValue(UTy));
}
- break;
+ break;
case Instruction::Add:
// Replace ((add A, B) != C) with (A != C-B) if B & C are constants.
@@ -2770,7 +2770,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// Replace ((add A, B) != 0) with (A != -B) if A or B is
// efficiently invertible, or if the add has just this one use.
Value *BOp0 = BO->getOperand(0), *BOp1 = BO->getOperand(1);
-
+
if (Value *NegVal = dyn_castNegVal(BOp1))
return new SetCondInst(I.getOpcode(), BOp0, NegVal);
else if (Value *NegVal = dyn_castNegVal(BOp0))
@@ -2835,7 +2835,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
Instruction::SetGE, X,
Constant::getNullValue(X->getType()));
}
-
+
// ((X & ~7) == 0) --> X < 8
if (CI->isNullValue() && isHighOnes(BOC)) {
Value *X = BO->getOperand(0);
@@ -2857,14 +2857,14 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
}
}
} else { // Not a SetEQ/SetNE
- // If the LHS is a cast from an integral value of the same size,
+ // If the LHS is a cast from an integral value of the same size,
if (CastInst *Cast = dyn_cast<CastInst>(Op0)) {
Value *CastOp = Cast->getOperand(0);
const Type *SrcTy = CastOp->getType();
unsigned SrcTySize = SrcTy->getPrimitiveSize();
if (SrcTy != Cast->getType() && SrcTy->isInteger() &&
SrcTySize == Cast->getType()->getPrimitiveSize()) {
- assert((SrcTy->isSigned() ^ Cast->getType()->isSigned()) &&
+ assert((SrcTy->isSigned() ^ Cast->getType()->isSigned()) &&
"Source and destination signednesses should differ!");
if (Cast->getType()->isSigned()) {
// If this is a signed comparison, check for comparisons in the
@@ -2916,14 +2916,14 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// We keep moving the cast from the left operand over to the right
// operand, where it can often be eliminated completely.
Op0 = CastOp0;
-
+
// If operand #1 is a cast instruction, see if we can eliminate it as
// well.
if (CastInst *CI2 = dyn_cast<CastInst>(Op1))
if (CI2->getOperand(0)->getType()->isLosslesslyConvertibleTo(
Op0->getType()))
Op1 = CI2->getOperand(0);
-
+
// If Op1 is a constant, we can fold the cast into the constant.
if (Op1->getType() != Op0->getType())
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
@@ -2978,7 +2978,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
return ReplaceInstUsesWith(I, ConstantBool::False);
}
}
-
+
// Otherwise, we can replace the setcc with a setcc of the smaller
// operand value.
Op1 = ConstantExpr::getCast(cast<Constant>(Op1), SrcTy);
@@ -2989,10 +2989,10 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
return Changed ? &I : 0;
}
-// visitSetCondInstWithCastAndConstant - this method is part of the
+// visitSetCondInstWithCastAndConstant - this method is part of the
// visitSetCondInst method. It handles the situation where we have:
// (setcc (cast X to larger), CI)
-// It tries to remove the cast and even the setcc if the CI value
+// It tries to remove the cast and even the setcc if the CI value
// and range of the cast allow it.
Instruction *
InstCombiner::visitSetCondInstWithCastAndConstant(BinaryOperator&I,
@@ -3005,9 +3005,9 @@ InstCombiner::visitSetCondInstWithCastAndConstant(BinaryOperator&I,
unsigned SrcBits = SrcTy->getPrimitiveSize()*8;
unsigned DestBits = DestTy->getPrimitiveSize()*8;
- if (SrcTy == Type::BoolTy)
+ if (SrcTy == Type::BoolTy)
SrcBits = 1;
- if (DestTy == Type::BoolTy)
+ if (DestTy == Type::BoolTy)
DestBits = 1;
if (SrcBits < DestBits) {
// There are fewer bits in the source of the cast than in the result
@@ -3015,25 +3015,25 @@ InstCombiner::visitSetCondInstWithCastAndConstant(BinaryOperator&I,
// value won't have changed due to sign extension.
Constant *NewCst = ConstantExpr::getCast(CI, SrcTy);
if (ConstantExpr::getCast(NewCst, DestTy) == CI) {
- // The constant value operand of the setCC before and after a
- // cast to the source type of the cast instruction is the same
- // value, so we just replace with the same setcc opcode, but
- // using the source value compared to the constant casted to the
- // source type.
+ // The constant value operand of the setCC before and after a
+ // cast to the source type of the cast instruction is the same
+ // value, so we just replace with the same setcc opcode, but
+ // using the source value compared to the constant casted to the
+ // source type.
if (SrcTy->isSigned() && DestTy->isUnsigned()) {
CastInst* Cst = new CastInst(LHSI->getOperand(0),
SrcTy->getUnsignedVersion(),
LHSI->getName());
InsertNewInstBefore(Cst,I);
- return new SetCondInst(I.getOpcode(), Cst,
+ return new SetCondInst(I.getOpcode(), Cst,
ConstantExpr::getCast(CI,
SrcTy->getUnsignedVersion()));
}
return new SetCondInst(I.getOpcode(), LHSI->getOperand(0),NewCst);
}
- // The constant value before and after a cast to the source type
- // is different, so various cases are possible depending on the
+ // The constant value before and after a cast to the source type
+ // is different, so various cases are possible depending on the
// opcode and the signs of the types involved in the cast.
switch (I.getOpcode()) {
case Instruction::SetLT: {
@@ -3052,14 +3052,14 @@ InstCombiner::visitSetCondInstWithCastAndConstant(BinaryOperator&I,
// We're looking for equality, and we know the values are not
// equal so replace with constant False.
return ReplaceInstUsesWith(I, ConstantBool::False);
- case Instruction::SetNE:
+ case Instruction::SetNE:
// We're testing for inequality, and we know the values are not
// equal so replace with constant True.
return ReplaceInstUsesWith(I, ConstantBool::True);
- case Instruction::SetLE:
- case Instruction::SetGE:
+ case Instruction::SetLE:
+ case Instruction::SetGE:
assert(0 && "SetLE and SetGE should be handled elsewhere");
- default:
+ default:
assert(0 && "unknown integer comparison");
}
}
@@ -3123,7 +3123,7 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
if (Constant *BOOp = dyn_cast<Constant>(BO->getOperand(1)))
return BinaryOperator::createMul(BO->getOperand(0),
ConstantExpr::getShl(BOOp, CUI));
-
+
// Try to fold constant and into select arguments.
if (SelectInst *SI = dyn_cast<SelectInst>(Op0))
if (Instruction *R = FoldOpIntoSelect(I, SI, this))
@@ -3219,7 +3219,7 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
dyn_cast<ConstantUInt>(Op0SI->getOperand(1))) {
unsigned ShiftAmt1 = (unsigned)ShiftAmt1C->getValue();
unsigned ShiftAmt2 = (unsigned)CUI->getValue();
-
+
// Check for (A << c1) << c2 and (A >> c1) >> c2
if (I.getOpcode() == Op0SI->getOpcode()) {
unsigned Amt = ShiftAmt1+ShiftAmt2; // Fold into one big shift...
@@ -3228,7 +3228,7 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
return new ShiftInst(I.getOpcode(), Op0SI->getOperand(0),
ConstantUInt::get(Type::UByteTy, Amt));
}
-
+
// Check for (A << c1) >> c2 or visaversa. If we are dealing with
// signed types, we can only support the (A >> c1) << c2 configuration,
// because it can not turn an arbitrary bit of A into a sign bit.
@@ -3239,12 +3239,12 @@ Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
C = ConstantExpr::getShl(C, ShiftAmt1C);
else
C = ConstantExpr::getShr(C, ShiftAmt1C);
-
+
Instruction *Mask =
BinaryOperator::createAnd(Op0SI->getOperand(0), C,
Op0SI->getOperand(0)->getName()+".mask");
InsertNewInstBefore(Mask, I);
-
+
// Figure out what flavor of shift we should use...
if (ShiftAmt1 == ShiftAmt2)
return ReplaceInstUsesWith(I, Mask); // (A << c) >> c === A & c2
@@ -3293,7 +3293,7 @@ static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy,
const Type *DstTy, TargetData *TD) {
// It is legal to eliminate the instruction if casting A->B->A if the sizes
- // are identical and the bits don't get reinterpreted (for example
+ // are identical and the bits don't get reinterpreted (for example
// int->float->int would not be allowed).
if (SrcTy == DstTy && SrcTy->isLosslesslyConvertibleTo(MidTy))
return true;
@@ -3341,7 +3341,7 @@ static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy,
CastType ResultCast = getCastType(SrcTy, DstTy);
if (ResultCast == Noop || ResultCast == Truncate)
return true;
- // Otherwise we are still growing the value, we are only safe if the
+ // Otherwise we are still growing the value, we are only safe if the
// result will match the sign/zeroextendness of the result.
return ResultCast == FirstCast;
}
@@ -3402,7 +3402,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
// If this is an A->B->A cast, and we are dealing with integral types, try
// to convert this into a logical 'and' instruction.
//
- if (A->getType()->isInteger() &&
+ if (A->getType()->isInteger() &&
CI.getType()->isInteger() && CSrc->getType()->isInteger() &&
CSrc->getType()->isUnsigned() && // B->A cast must zero extend
CSrc->getType()->getPrimitiveSize() < CI.getType()->getPrimitiveSize()&&
@@ -3422,7 +3422,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
return And;
}
}
-
+
// If this is a cast to bool, turn it into the appropriate setne instruction.
if (CI.getType() == Type::BoolTy)
return BinaryOperator::createSetNE(CI.getOperand(0),
@@ -3460,7 +3460,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
// If the allocation is for an even multiple of the cast type size
if (CastElTySize && (AllocElTySize % CastElTySize == 0)) {
- Value *Amt = ConstantUInt::get(Type::UIntTy,
+ Value *Amt = ConstantUInt::get(Type::UIntTy,
AllocElTySize/CastElTySize);
std::string Name = AI->getName(); AI->setName("");
AllocationInst *New;
@@ -3527,7 +3527,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
break;
}
}
-
+
return 0;
}
@@ -3553,7 +3553,7 @@ static unsigned GetSelectFoldableOperands(Instruction *I) {
case Instruction::Sub: // Can only fold on the amount subtracted.
case Instruction::Shl: // Can only fold on the shift amount.
case Instruction::Shr:
- return 1;
+ return 1;
default:
return 0; // Cannot fold
}
@@ -3592,7 +3592,7 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
} else {
return 0; // unknown unary op.
}
-
+
// Fold this by inserting a select from the input values.
SelectInst *NewSI = new SelectInst(SI.getCondition(), TI->getOperand(0),
FI->getOperand(0), SI.getName()+".v");
@@ -3732,9 +3732,9 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
cast<Constant>(IC->getOperand(1))->isNullValue())
if (Instruction *ICA = dyn_cast<Instruction>(IC->getOperand(0)))
if (ICA->getOpcode() == Instruction::And &&
- isa<ConstantInt>(ICA->getOperand(1)) &&
- (ICA->getOperand(1) == TrueValC ||
- ICA->getOperand(1) == FalseValC) &&
+ isa<ConstantInt>(ICA->getOperand(1)) &&
+ (ICA->getOperand(1) == TrueValC ||
+ ICA->getOperand(1) == FalseValC) &&
isOneBitSet(cast<ConstantInt>(ICA->getOperand(1)))) {
// Okay, now we know that everything is set up, we just don't
// know whether we have a setne or seteq and whether the true or
@@ -3770,7 +3770,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
// NOTE: if we wanted to, this is where to detect MIN/MAX/ABS/etc.
}
}
-
+
if (Instruction *TI = dyn_cast<Instruction>(TrueVal))
if (Instruction *FI = dyn_cast<Instruction>(FalseVal))
if (TI->hasOneUse() && FI->hasOneUse()) {
@@ -3821,14 +3821,14 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
std::swap(NewTrueOp, NewFalseOp);
Instruction *NewSel =
new SelectInst(CondVal, NewTrueOp,NewFalseOp,SI.getName()+".p");
-
+
NewSel = InsertNewInstBefore(NewSel, SI);
return BinaryOperator::createAdd(SubOp->getOperand(0), NewSel);
}
}
}
}
-
+
// See if we can fold the select into one of our operands.
if (SI.getType()->isInteger()) {
// See the comment above GetSelectFoldableOperands for a description of the
@@ -3906,7 +3906,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
if (NumBytes->isNullValue()) return EraseInstFromFunction(CI);
// FIXME: Increase alignment here.
-
+
if (ConstantInt *CI = dyn_cast<ConstantInt>(NumBytes))
if (CI->getRawValue() == 1) {
// Replace the instruction with just byte operations. We would
@@ -3998,7 +3998,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
}
}
}
-
+
return Changed ? CS.getInstruction() : 0;
}
@@ -4043,12 +4043,12 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
unsigned NumActualArgs = unsigned(CS.arg_end()-CS.arg_begin());
unsigned NumCommonArgs = std::min(FT->getNumParams(), NumActualArgs);
-
+
CallSite::arg_iterator AI = CS.arg_begin();
for (unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) {
const Type *ParamTy = FT->getParamType(i);
bool isConvertible = (*AI)->getType()->isLosslesslyConvertibleTo(ParamTy);
- if (Callee->isExternal() && !isConvertible) return false;
+ if (Callee->isExternal() && !isConvertible) return false;
}
if (FT->getNumParams() < NumActualArgs && !FT->isVarArg() &&
@@ -4200,7 +4200,7 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) {
InsertNewInstBefore(NewPN, PN);
PhiVal = NewPN;
}
-
+
// Insert and return the new operation.
if (isa<CastInst>(FirstInst))
return new CastInst(PhiVal, PN.getType());
@@ -4223,7 +4223,7 @@ static bool DeadPHICycle(PHINode *PN, std::set<PHINode*> &PotentiallyDeadPHIs) {
if (PHINode *PU = dyn_cast<PHINode>(PN->use_back()))
return DeadPHICycle(PU, PotentiallyDeadPHIs);
-
+
return false;
}
@@ -4295,7 +4295,7 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
if (DeadPHICycle(PU, PotentiallyDeadPHIs))
return ReplaceInstUsesWith(PN, UndefValue::get(PN.getType()));
}
-
+
return 0;
}
@@ -4353,7 +4353,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
// We can always eliminate a cast from int to [u]long. We can
// eliminate a cast from uint to [u]long iff the target is a 32-bit
// pointer target.
- if (SrcTy->isSigned() ||
+ if (SrcTy->isSigned() ||
SrcTy->getPrimitiveSize() >= TD->getPointerSize()) {
MadeChange = true;
GEP.setOperand(i, Src);
@@ -4412,7 +4412,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
for (gep_type_iterator I = gep_type_begin(*cast<User>(PtrOp)),
E = gep_type_end(*cast<User>(PtrOp)); I != E; ++I)
EndsWithSequential = !isa<StructType>(*I);
-
+
// Can we combine the two pointer arithmetics offsets?
if (EndsWithSequential) {
// Replace: gep (gep %P, long B), long A, ...
@@ -4466,9 +4466,9 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
Indices.push_back(Sum);
Indices.insert(Indices.end(), GEP.op_begin()+2, GEP.op_end());
}
- } else if (isa<Constant>(*GEP.idx_begin()) &&
+ } else if (isa<Constant>(*GEP.idx_begin()) &&
cast<Constant>(*GEP.idx_begin())->isNullValue() &&
- SrcGEPOperands.size() != 1) {
+ SrcGEPOperands.size() != 1) {
// Otherwise we can do the fold if the first index of the GEP is a zero
Indices.insert(Indices.end(), SrcGEPOperands.begin()+1,
SrcGEPOperands.end());
@@ -4526,7 +4526,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
const Type *SrcElTy = cast<PointerType>(X->getType())->getElementType();
const Type *ResElTy =cast<PointerType>(CE->getType())->getElementType();
if (isa<ArrayType>(SrcElTy) &&
- TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
+ TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
TD->getTypeSize(ResElTy)) {
Value *V = InsertNewInstBefore(
new GetElementPtrInst(X, Constant::getNullValue(Type::IntTy),
@@ -4556,7 +4556,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
}
InsertNewInstBefore(New, AI);
-
+
// Scan to the end of the allocation instructions, to skip over a block of
// allocas if possible...
//
@@ -4579,7 +4579,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// If alloca'ing a zero byte object, replace the alloca with a null pointer.
// Note that we only do this for alloca's, because malloc should allocate and
// return a unique pointer, even for a zero byte allocation.
- if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized() &&
+ if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized() &&
TD->getTypeSize(AI.getAllocatedType()) == 0)
return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
@@ -4682,9 +4682,9 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) {
// Do not allow turning this into a load of an integer, which is then
// casted to a pointer, this pessimizes pointer analysis a lot.
(isa<PointerType>(SrcPTy) == isa<PointerType>(LI.getType())) &&
- IC.getTargetData().getTypeSize(SrcPTy) ==
+ IC.getTargetData().getTypeSize(SrcPTy) ==
IC.getTargetData().getTypeSize(DestPTy)) {
-
+
// Okay, we are casting from one integer or pointer type to another of
// the same size. Instead of casting the pointer before the load, cast
// the result of the loaded value.
@@ -4721,7 +4721,7 @@ static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) {
if (LI->getOperand(0) == V) return true;
} else if (StoreInst *SI = dyn_cast<StoreInst>(BBI))
if (SI->getOperand(1) == V) return true;
-
+
}
return false;
}
@@ -4743,7 +4743,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
if (GV->isConstant() && !GV->isExternal())
return ReplaceInstUsesWith(LI, GV->getInitializer());
-
+
// Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded.
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Op))
if (CE->getOpcode() == Instruction::GetElementPtr) {
@@ -4867,7 +4867,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
}
if ((SrcPTy->isInteger() || isa<PointerType>(SrcPTy)) &&
- IC.getTargetData().getTypeSize(SrcPTy) ==
+ IC.getTargetData().getTypeSize(SrcPTy) ==
IC.getTargetData().getTypeSize(DestPTy)) {
// Okay, we are casting from one integer or pointer type to another of
@@ -4967,7 +4967,7 @@ Instruction *InstCombiner::visitBranchInst(BranchInst &BI) {
WorkList.push_back(cast<Instruction>(NewSCC));
return &BI;
}
-
+
return 0;
}
@@ -5004,7 +5004,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
// Cannot move control-flow-involving instructions.
if (isa<PHINode>(I) || isa<InvokeInst>(I) || isa<CallInst>(I)) return false;
-
+
// Do not sink alloca instructions out of the entry block.
if (isa<AllocaInst>(I) && I->getParent() == &DestBlock->getParent()->front())
return false;
@@ -5024,7 +5024,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
while (isa<PHINode>(InsertPos)) ++InsertPos;
BasicBlock *SrcBlock = I->getParent();
- DestBlock->getInstList().splice(InsertPos, SrcBlock->getInstList(), I);
+ DestBlock->getInstList().splice(InsertPos, SrcBlock->getInstList(), I);
++NumSunkInst;
return true;
}
@@ -5165,7 +5165,7 @@ bool InstCombiner::runOnFunction(Function &F) {
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (Instruction *OpI = dyn_cast<Instruction>(I->getOperand(i)))
WorkList.push_back(OpI);
-
+
// Instructions may end up in the worklist more than once. Erase all
// occurrances of this instruction.
removeFromWorkList(I);
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index 880739849e..3f1905156d 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -1,10 +1,10 @@
//===-- LICM.cpp - Loop Invariant Code Motion Pass ------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass performs loop invariant code motion, attempting to remove as much
@@ -89,7 +89,7 @@ namespace {
Loop *CurLoop; // The current loop we are working on...
AliasSetTracker *CurAST; // AliasSet information for the current loop...
- /// visitLoop - Hoist expressions out of the specified loop...
+ /// visitLoop - Hoist expressions out of the specified loop...
///
void visitLoop(Loop *L, AliasSetTracker &AST);
@@ -131,21 +131,21 @@ namespace {
BasicBlock *LoopHeader = CurLoop->getHeader();
if (BlockInLoop == LoopHeader)
return true;
-
+
DominatorTree::Node *BlockInLoopNode = DT->getNode(BlockInLoop);
DominatorTree::Node *IDom = DT->getNode(ExitBlock);
-
+
// Because the exit block is not in the loop, we know we have to get _at
// least_ its immediate dominator.
do {
// Get next Immediate Dominator.
IDom = IDom->getIDom();
-
+
// If we have got to the header of the loop, then the instructions block
// did not dominate the exit node, so we can't hoist it.
if (IDom->getBlock() == LoopHeader)
return false;
-
+
} while (IDom != BlockInLoopNode);
return true;
@@ -170,7 +170,7 @@ namespace {
/// pointerInvalidatedByLoop - Return true if the body of this loop may
/// store into the memory location pointed to by V.
- ///
+ ///
bool pointerInvalidatedByLoop(Value *V, unsigned Size) {
// Check to see if any of the basic blocks in CurLoop invalidate *V.
return CurAST->getAliasSetForPointer(V, Size).isMod();
@@ -222,7 +222,7 @@ bool LICM::runOnFunction(Function &) {
}
-/// visitLoop - Hoist expressions out of the specified loop...
+/// visitLoop - Hoist expressions out of the specified loop...
///
void LICM::visitLoop(Loop *L, AliasSetTracker &AST) {
// Recurse through all subloops before we process this loop...
@@ -296,7 +296,7 @@ void LICM::SinkRegion(DominatorTree::Node *N) {
for (BasicBlock::iterator II = BB->end(); II != BB->begin(); ) {
Instruction &I = *--II;
-
+
// Check to see if we can sink this instruction to the exit blocks
// of the loop. We can do this if the all users of the instruction are
// outside of the loop. In this case, it doesn't even matter if the
@@ -327,12 +327,12 @@ void LICM::HoistRegion(DominatorTree::Node *N) {
if (!inSubLoop(BB))
for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ) {
Instruction &I = *II++;
-
+
// Try hoisting the instruction out to the preheader. We can only do this
// if all of the operands of the instruction are loop invariant and if it
// is safe to hoist the instruction.
//
- if (isLoopInvariantInst(I) && canSinkOrHoistInst(I) &&
+ if (isLoopInvariantInst(I) && canSinkOrHoistInst(I) &&
isSafeToExecuteUnconditionally(I))
hoist(I);
}
@@ -380,11 +380,11 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
// FIXME: This should use mod/ref information to see if we can hoist or sink
// the call.
-
+
return false;
}
- return isa<BinaryOperator>(I) || isa<ShiftInst>(I) || isa<CastInst>(I) ||
+ return isa<BinaryOperator>(I) || isa<ShiftInst>(I) || isa<CastInst>(I) ||
isa<SelectInst>(I) ||
isa<GetElementPtrInst>(I) || isa<VANextInst>(I) || isa<VAArgInst>(I);
}
@@ -452,7 +452,7 @@ void LICM::sink(Instruction &I) {
// Move the instruction to the start of the exit block, after any PHI
// nodes in it.
I.getParent()->getInstList().remove(&I);
-
+
BasicBlock::iterator InsertPt = ExitBlocks[0]->begin();
while (isa<PHINode>(InsertPt)) ++InsertPt;
ExitBlocks[0]->getInstList().insert(InsertPt, &I);
@@ -472,7 +472,7 @@ void LICM::sink(Instruction &I) {
if (I.getType() != Type::VoidTy)
AI = new AllocaInst(I.getType(), 0, I.getName(),
I.getParent()->getParent()->front().begin());
-
+
// Secondly, insert load instructions for each use of the instruction
// outside of the loop.
while (!I.use_empty()) {
@@ -519,7 +519,7 @@ void LICM::sink(Instruction &I) {
// Insert the code after the last PHI node...
BasicBlock::iterator InsertPt = ExitBlock->begin();
while (isa<PHINode>(InsertPt)) ++InsertPt;
-
+
// If this is the first exit block processed, just move the original
// instruction, otherwise clone the original instruction and insert
// the copy.
@@ -535,7 +535,7 @@ void LICM::sink(Instruction &I) {
New->setName(I.getName()+".le");
ExitBlock->getInstList().insert(InsertPt, New);
}
-
+
// Now that we have inserted the instruction, store it into the alloca
if (AI) new StoreInst(New, AI, InsertPt);
}
@@ -547,7 +547,7 @@ void LICM::sink(Instruction &I) {
CurAST->deleteValue(&I);
I.getParent()->getInstList().erase(&I);
}
-
+
// Finally, promote the fine value to SSA form.
if (AI) {
std::vector<AllocaInst*> Allocas;
@@ -561,7 +561,7 @@ void LICM::sink(Instruction &I) {
/// that is safe to hoist, this instruction is called to do the dirty work.
///
void LICM::hoist(Instruction &I) {
- DEBUG(std::cerr << "LICM hoisting to " << Preheader->getName()
+ DEBUG(std::cerr << "LICM hoisting to " << Preheader->getName()
<< ": " << I);
// Remove the instruction from its current basic block... but don't delete the
@@ -570,7 +570,7 @@ void LICM::hoist(Instruction &I) {
// Insert the new node in Preheader, before the terminator.
Preheader->getInstList().insert(Preheader->getTerminator(), &I);
-
+
if (isa<LoadInst>(I)) ++NumMovedLoads;
else if (isa<CallInst>(I)) ++NumMovedCalls;
++NumHoisted;
@@ -584,7 +584,7 @@ void LICM::hoist(Instruction &I) {
bool LICM::isSafeToExecuteUnconditionally(Instruction &Inst) {
// If it is not a trapping instruction, it is always safe to hoist.
if (!Inst.isTrapping()) return true;
-
+
// Otherwise we have to check to make sure that the instruction dominates all
// of the exit blocks. If it doesn't, then there is a path out of the loop
// which does not execute this instruction, so we can't hoist it.
@@ -610,7 +610,7 @@ bool LICM::isSafeToExecuteUnconditionally(Instruction &Inst) {
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[i], Inst.getParent()))
return false;
-
+
return true;
}
@@ -672,7 +672,7 @@ void LICM::PromoteValuesInLoop() {
// Store into the temporary alloca.
new StoreInst(LI, PromotedValues[i].first, LoopPredInst);
}
-
+
// Scan the basic blocks in the loop, replacing uses of our pointers with
// uses of the allocas in question.
//
@@ -777,10 +777,10 @@ void LICM::FindPromotableValuesInLoop(
// Update the AST and alias analysis.
CurAST->copyValue(V, AI);
-
+
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
-
+
DEBUG(std::cerr << "LICM: Promoting value: " << *V << "\n");
}
}
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 6c0290ae8c..28ecb98e5e 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1,10 +1,10 @@
//===- LoopStrengthReduce.cpp - Strength Reduce GEPs in Loops -------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by Nate Begeman and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass performs a strength reduction on array references inside loops that
@@ -85,7 +85,7 @@ namespace {
std::set<Instruction*> &DeadInsts);
void DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts);
};
- RegisterOpt<LoopStrengthReduce> X("loop-reduce",
+ RegisterOpt<LoopStrengthReduce> X("loop-reduce",
"Strength Reduce GEP Uses of Ind. Vars");
}
@@ -170,7 +170,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
Cache = Cache->get(operand);
}
assert(indvar > 0 && "Indvar used by GEP not found in operand list");
-
+
// Ensure the pointer base is loop invariant. While strength reduction
// makes sense even if the pointer changed on every iteration, there is no
// realistic way of handling it unless GEPs were completely decomposed into
@@ -185,9 +185,9 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
if (sz && (sz & (sz-1)) == 0) // Power of two?
if (sz <= (1ULL << (MaxTargetAMSize-1)))
return;
-
+
// If all operands of the GEP we are going to insert into the preheader
- // are constants, generate a GEP ConstantExpr instead.
+ // are constants, generate a GEP ConstantExpr instead.
//
// If there is only one operand after the initial non-constant one, we know
// that it was the induction variable, and has been replaced by a constant
@@ -202,7 +202,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
PreGEP = GEPI->getOperand(0);
} else {
PreGEP = new GetElementPtrInst(GEPI->getOperand(0),
- pre_op_vector, GEPI->getName()+".pre",
+ pre_op_vector, GEPI->getName()+".pre",
Preheader->getTerminator());
}
@@ -210,15 +210,15 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
// choose between the initial GEP we created and inserted into the
// preheader, and the incremented GEP that we will create below and insert
// into the loop body.
- NewPHI = new PHINode(PreGEP->getType(),
+ NewPHI = new PHINode(PreGEP->getType(),
GEPI->getName()+".str", InsertBefore);
NewPHI->addIncoming(PreGEP, Preheader);
-
+
// Now, create the GEP instruction to increment by one the value selected
// by the PHI instruction we just created above, and add it as the second
// incoming Value/BasicBlock pair to the PHINode. It is inserted before
// the increment of the canonical induction variable.
- Instruction *IncrInst =
+ Instruction *IncrInst =
const_cast<Instruction*>(L->getCanonicalInductionVariableIncrement());
GetElementPtrInst *StrGEP = new GetElementPtrInst(NewPHI, inc_op_vector,
GEPI->getName()+".inc",
@@ -233,7 +233,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
// about to create.
NewPHI = Cache->CachedPHINode;
}
-
+
if (GEPI->getNumOperands() - 1 == indvar) {
// If there were no operands following the induction variable, replace all
// uses of the old GEP instruction with the new PHI.
@@ -252,7 +252,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
GEPI);
GEPI->replaceAllUsesWith(newGEP);
}
-
+
// The old GEP is now dead.
DeadInsts.insert(GEPI);
++NumReduced;
@@ -273,7 +273,7 @@ void LoopStrengthReduce::runOnLoop(Loop *L) {
// pass creates code like this, which we can't currently detect:
// %tmp.1 = sub uint 2000, %indvar
// %tmp.8 = getelementptr int* %y, uint %tmp.1
-
+
// Strength reduce all GEPs in the Loop. Insert secondary PHI nodes for the
// strength reduced pointers we'll be creating after the canonical induction
// variable's PHI.
diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp
index da80ee342b..45b81f7e39 100644
--- a/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -1,10 +1,10 @@
//===-- LoopUnroll.cpp - Loop unroller pass -------------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass implements a simple loop unroller. It works best when loops have
@@ -88,7 +88,7 @@ static unsigned ApproximateLoopSize(const Loop *L) {
} else if (I->hasOneUse() && I->use_back() == Term) {
// Ignore instructions only used by the loop terminator.
} else if (DbgInfoIntrinsic *DbgI = dyn_cast<DbgInfoIntrinsic>(I)) {
- // Ignore debug instructions
+ // Ignore debug instructions
} else {
++Size;
}
@@ -102,10 +102,10 @@ static unsigned ApproximateLoopSize(const Loop *L) {
return Size;
}
-// RemapInstruction - Convert the instruction operands from referencing the
+// RemapInstruction - Convert the instruction operands from referencing the
// current values into those specified by ValueMap.
//
-static inline void RemapInstruction(Instruction *I,
+static inline void RemapInstruction(Instruction *I,
std::map<const Value *, Value*> &ValueMap) {
for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
Value *Op = I->getOperand(op);
@@ -150,7 +150,7 @@ bool LoopUnroll::visitLoop(Loop *L) {
return Changed;
}
DEBUG(std::cerr << "UNROLLING!\n");
-
+
unsigned TripCount = (unsigned)TripCountFull;
BasicBlock *LoopExit = BI->getSuccessor(L->contains(BI->getSuccessor(0)));
@@ -235,7 +235,7 @@ bool LoopUnroll::visitLoop(Loop *L) {
PN->replaceAllUsesWith(PN->getIncomingValueForBlock(Preheader));
BB->getInstList().erase(PN);
}
-
+
// Finally, add an unconditional branch to the block to continue into the exit
// block.
new BranchInst(LoopExit, BB);
@@ -245,7 +245,7 @@ bool LoopUnroll::visitLoop(Loop *L) {
// go.
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
Instruction *Inst = I++;
-
+
if (isInstructionTriviallyDead(Inst))
BB->getInstList().erase(Inst);
else if (Constant *C = ConstantFoldInstruction(Inst)) {
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 434b75bff6..e51e7f2e20 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -1,10 +1,10 @@
//===-- LoopUnswitch.cpp - Hoist loop-invariant conditionals in loop ------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass transforms loops that contain branches on loop-invariant conditions
@@ -116,15 +116,15 @@ bool LoopUnswitch::visitLoop(Loop *L) {
} else {
// FIXME: check for profitability.
//std::cerr << "BEFORE:\n"; LI->dump();
-
+
VersionLoop(BI->getCondition(), L);
-
+
//std::cerr << "AFTER:\n"; LI->dump();
return true;
}
}
}
-
+
return Changed;
}
@@ -152,10 +152,10 @@ BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *BB, bool SplitAtTop) {
}
-// RemapInstruction - Convert the instruction operands from referencing the
+// RemapInstruction - Convert the instruction operands from referencing the
// current values into those specified by ValueMap.
//
-static inline void RemapInstruction(Instruction *I,
+static inline void RemapInstruction(Instruction *I,
std::map<const Value *, Value*> &ValueMap) {
for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
Value *Op = I->getOperand(op);
@@ -185,7 +185,7 @@ static Loop *CloneLoop(Loop *L, Loop *PL, std::map<const Value*, Value*> &VM,
// Add all of the subloops to the new loop.
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
CloneLoop(*I, New, VM, LI);
-
+
return New;
}
@@ -210,7 +210,7 @@ InsertPHINodesForUsesOutsideLoop(Instruction *OI, Instruction *NI,
!NL->contains(cast<Instruction>(*UI)->getParent()))
goto UsedOutsideOfLoop;
return 0;
-
+
UsedOutsideOfLoop:
// Okay, this instruction is used outside of the current loop. Insert a PHI
// nodes for the instruction merging the values together.
diff --git a/lib/Transforms/Scalar/LowerConstantExprs.cpp b/lib/Transforms/Scalar/LowerConstantExprs.cpp
index 6de6c0d3c3..cccf9e08d8 100644
--- a/lib/Transforms/Scalar/LowerConstantExprs.cpp
+++ b/lib/Transforms/Scalar/LowerConstantExprs.cpp
@@ -1,14 +1,14 @@
//===-- lib/Transforms/Scalar/LowerConstantExprs.cpp ------------*- C++ -*-===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was written by Vladimir Prus and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file defines the LowerConstantExpression pass, which converts all
-// constant expressions into instructions. This is primarily usefull for
+// constant expressions into instructions. This is primarily usefull for
// code generators which don't yet want or don't have a need to handle
// constant expressions themself.
//
@@ -29,18 +29,18 @@ namespace {
class ConstantExpressionsLower : public FunctionPass {
private: // FunctionPass overrides
-
+
bool runOnFunction(Function& f);
private: // internal methods
/// For all operands of 'insn' which are constant expressions, generates
- /// an appropriate instruction and replaces the use of constant
+ /// an appropriate instruction and replaces the use of constant
/// expression with the use of the generated instruction.
bool runOnInstruction(Instruction& insn);
/// Given an constant expression 'c' which occures in 'instruction',
- /// at position 'pos',
+ /// at position 'pos',
/// generates instruction to compute 'c' and replaces the use of 'c'
/// with the use of that instruction. This handles only top-level
/// expression in 'c', any subexpressions are not handled.
@@ -48,7 +48,7 @@ namespace {
};
RegisterOpt<ConstantExpressionsLower> X(
- "lowerconstantexprs", "Lower constant expressions");
+ "lowerconstantexprs", "Lower constant expressions");
}
bool ConstantExpressionsLower::runOnFunction(Function& f)
@@ -66,14 +66,14 @@ bool ConstantExpressionsLower::runOnInstruction(Instruction& instruction)
bool modified = false;
for (unsigned pos = 0; pos < instruction.getNumOperands(); ++pos)
{
- if (ConstantExpr* ce
+ if (ConstantExpr* ce
= dyn_cast<ConstantExpr>(instruction.getOperand(pos))) {
// Decide where to insert the new instruction
Instruction* where = &instruction;
- // For PHI nodes we can't insert new instruction before phi,
- // since phi should always come at the beginning of the
+ // For PHI nodes we can't insert new instruction before phi,
+ // since phi should always come at the beginning of the
// basic block.
// So, we need to insert it in the predecessor, right before
// the terminating instruction.
@@ -92,12 +92,12 @@ bool ConstantExpressionsLower::runOnInstruction(Instruction& instruction)
// Note: we can't call replaceAllUsesWith, since
// that might replace uses in another functions,
// where the instruction(s) we've generated are not
- // available.
-
- // Moreover, we can't replace all the users in the same
- // function, because we can't be sure the definition
+ // available.
+
+ // Moreover, we can't replace all the users in the same
+ // function, because we can't be sure the definition
// made in this block will be available in other
- // places where the constant is used.
+ // places where the constant is used.
instruction.setOperand(pos, n);
// The new instruction might have constant expressions in
@@ -105,11 +105,11 @@ bool ConstantExpressionsLower::runOnInstruction(Instruction& instruction)
runOnInstruction(*n);
modified = true;
}
- }
+ }
return modified;
}
-Instruction*
+Instruction*
ConstantExpressionsLower::convert(const ConstantExpr& c, Instruction* where)
{
Instruction* result = 0;
@@ -118,13 +118,13 @@ ConstantExpressionsLower::convert(const ConstantExpr& c, Instruction* where)
c.getOpcode() < Instruction::BinaryOpsEnd)
{
result = BinaryOperator::create(
- static_cast<Instruction::BinaryOps>(c.getOpcode()),
+ static_cast<Instruction::BinaryOps>(c.getOpcode()),
c.getOperand(0), c.getOperand(1), "", where);
}
else
{
switch(c.getOpcode()) {
- case Instruction::GetElementPtr:
+ case Instruction::GetElementPtr:
{
vector<Value*> idx;
for (unsigned i = 1; i < c.getNumOperands(); ++i)
@@ -135,7 +135,7 @@ ConstantExpressionsLower::convert(const ConstantExpr& c, Instruction* where)
}
case Instruction::Cast:
- result = new CastInst(c.getOperand(0), c.getType(), "",
+ result = new CastInst(c.getOperand(0), c.getType(), "",
where);
break;
@@ -143,15 +143,15 @@ ConstantExpressionsLower::convert(const ConstantExpr& c, Instruction* where)
case Instruction::Shl:
case Instruction::Shr:
result = new ShiftInst(
- static_cast<Instruction::OtherOps>(c.getOpcode()),
+ static_cast<Instruction::OtherOps>(c.getOpcode()),
c.getOperand(0), c.getOperand(1), "", where);
break;
-
+
case Instruction::Select:
result = new SelectInst(c.getOperand(0), c.getOperand(1),
c.getOperand(2), "", where);
break;
-
+
default:
std::cerr << "Offending expr: " << c << "\n";
assert(0 && "Constant expression not yet handled!\n");
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp
index b3463340c1..345fafbe4f 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -47,7 +47,7 @@ namespace {
/// had zero roots.
const Type *MainRootRecordType;
public:
- LowerGC() : GCRootInt(0), GCReadInt(0), GCWriteInt(0),
+ LowerGC() : GCRootInt(0), GCReadInt(0), GCWriteInt(0),
GCRead(0), GCWrite(0), RootChain(0), MainRootRecordType(0) {}
virtual bool doInitialization(Module &M);
virtual bool runOnFunction(Function &F);
@@ -125,7 +125,7 @@ bool LowerGC::doInitialization(Module &M) {
if (RootChain == 0) {
// If the root chain does not exist, insert a new one with linkonce
// linkage!
- RootChain = new GlobalVariable(PRLTy, false,
+ RootChain = new GlobalVariable(PRLTy, false,
GlobalValue::LinkOnceLinkage,
Constant::getNullValue(PRLTy),
"llvm_gc_root_chain", &M);
@@ -141,7 +141,7 @@ bool LowerGC::doInitialization(Module &M) {
/// not have the specified type, insert a cast.
static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) {
if (I->getOperand(OpNum)->getType() != Ty) {
- if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum)))
+ if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum)))
I->setOperand(OpNum, ConstantExpr::getCast(C, Ty));
else {
CastInst *CI = new CastInst(I->getOperand(OpNum), Ty, "", I);
@@ -152,7 +152,7 @@ static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) {
/// runOnFunction - If the program is using GC intrinsics, replace any
/// read/write intrinsics with the appropriate read/write barrier calls, then
-/// inline them. Finally, build the data structures for
+/// inline them. Finally, build the data structures for
bool LowerGC::runOnFunction(Function &F) {
// Quick exit for programs that are not using GC mechanisms.
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
@@ -192,7 +192,7 @@ bool LowerGC::runOnFunction(Function &F) {
CI->setOperand(0, GCRead);
} else {
// Create a whole new call to replace the old one.
- CallInst *NC = new CallInst(GCRead, CI->getOperand(1),
+ CallInst *NC = new CallInst(GCRead, CI->getOperand(1),
CI->getOperand(2),
CI->getName(), CI);
Value *NV = new CastInst(NC, CI->getType(), "", CI);
@@ -208,7 +208,7 @@ bool LowerGC::runOnFunction(Function &F) {
MadeChange = true;
}
}
-
+
// If there are no GC roots in this function, then there is no need to create
// a GC list record for it.
if (GCRoots.empty()) return MadeChange;
@@ -263,7 +263,7 @@ bool LowerGC::runOnFunction(Function &F) {
Par[3] = Zero;
Value *RootPtrPtr = new GetElementPtrInst(AI, Par, "RootEntPtr", IP);
new StoreInst(Null, RootPtrPtr, IP);
-
+
// Each occurrance of the llvm.gcroot intrinsic now turns into an
// initialization of the slot with the address and a zeroing out of the
// address specified.
@@ -301,7 +301,7 @@ bool LowerGC::runOnFunction(Function &F) {
UnwindInst *UI = new UnwindInst(Cleanup);
PrevPtr = new LoadInst(PrevPtrPtr, "prevptr", UI);
new StoreInst(PrevPtr, RootChain, UI);
-
+
// Loop over all of the function calls, turning them into invokes.
while (!NormalCalls.empty()) {
CallInst *CI = NormalCalls.back();
@@ -314,7 +314,7 @@ bool LowerGC::runOnFunction(Function &F) {
// Remove the unconditional branch inserted at the end of the CBB.
CBB->getInstList().pop_back();
NewBB->getInstList().remove(CI);
-
+
// Create a new invoke instruction.
Value *II = new InvokeInst(CI->getCalledValue(), NewBB, Cleanup,
std::vector<Value*>(CI->op_begin()+1,
diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp
index e2242223a2..725a4ba8eb 100644
--- a/lib/Transforms/Scalar/LowerPacked.cpp
+++ b/lib/Transforms/Scalar/LowerPacked.cpp
@@ -1,10 +1,10 @@
//===- LowerPacked.cpp - Implementation of LowerPacked Transform ---------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by Brad Jones and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements lowering Packed datatypes into more primitive
@@ -38,7 +38,7 @@ namespace {
///
class LowerPacked : public FunctionPass, public InstVisitor<LowerPacked> {
public:
- /// @brief Lowers packed operations to scalar operations.
+ /// @brief Lowers packed operations to scalar operations.
/// @param F The fuction to process
virtual bool runOnFunction(Function &F);
@@ -60,13 +60,13 @@ public:
/// This function asserts if the instruction is a PackedType but
/// is handled by another function.
- ///
+ ///
/// @brief Asserts if PackedType instruction is not handled elsewhere.
/// @param I the unhandled instruction
void visitInstruction(Instruction &I)
{
if(isa<PackedType>(I.getType())) {
- std::cerr << "Unhandled Instruction with Packed ReturnType: " <<
+ std::cerr << "Unhandled Instruction with Packed ReturnType: " <<
I << '\n';
}
}
@@ -82,7 +82,7 @@ private:
void setValues(Value* val,const std::vector<Value*>& values);
// Data Members
- /// @brief whether we changed the function or not
+ /// @brief whether we changed the function or not
bool Changed;
/// @brief a map from old packed values to new smaller packed values
@@ -91,27 +91,27 @@ private:
/// Instructions in the source program to get rid of
/// after we do a pass (the old packed instructions)
std::vector<Instruction*> instrsToRemove;
-};
+};
-RegisterOpt<LowerPacked>
-X("lower-packed",
+RegisterOpt<LowerPacked>
+X("lower-packed",
"lowers packed operations to operations on smaller packed datatypes");
-} // end namespace
+} // end namespace
FunctionPass *llvm::createLowerPackedPass() { return new LowerPacked(); }
// This function sets lowered values for a corresponding
// packed value. Note, in the case of a forward reference
-// getValues(Value*) will have already been called for
-// the packed parameter. This function will then replace
-// all references in the in the function of the "dummy"
-// value the previous getValues(Value*) call
+// getValues(Value*) will have already been called for
+// the packed parameter. This function will then replace
+// all references in the in the function of the "dummy"
+// value the previous getValues(Value*) call
// returned with actual references.
void LowerPacked::setValues(Value* value,const std::vector<Value*>& values)
{
- std::map<Value*,std::vector<Value*> >::iterator it =
+ std::map<Value*,std::vector<Value*> >::iterator it =
packedToScalarMap.lower_bound(value);
if (it == packedToScalarMap.end() || it->first != value) {
// there was not a forward reference to this element
@@ -119,7 +119,7 @@ void LowerPacked::setValues(Value* value,const std::vector<Value*>& values)
}
else {
// replace forward declarations with actual definitions
- assert(it->second.size() == values.size() &&
+ assert(it->second.size() == values.size() &&
"Error forward refences and actual definition differ in size");
for (unsigned i = 0, e = values.size(); i != e; ++i) {
// replace and get rid of old forward references
@@ -133,8 +133,8 @@ void LowerPacked::setValues(Value* value,const std::vector<Value*>& values)
// This function will examine the packed value parameter
// and if it is a packed constant or a forward reference
// properly create the lowered values needed. Otherwise
-// it will simply retreive values from a
-// setValues(Value*,const std::vector<Value*>&)
+// it will simply retreive values from a
+// setValues(Value*,const std::vector<Value*>&)
// call. Failing both of these cases, it will abort
// the program.
std::vector<Value*>& LowerPacked::getValues(Value* value)
@@ -144,7 +144,7 @@ std::vector<Value*>& LowerPacked::getValues(Value* value)
// reject further processing if this one has
// already been handled
- std::map<Value*,std::vector<Value*> >::iterator it =
+ std::map<Value*,std::vector<Value*> >::iterator it =
packedToScalarMap.lower_bound(value);
if (it != packedToScalarMap.end() && it->first == value) {
return it->second;
@@ -162,11 +162,11 @@ std::vector<Value*>& LowerPacked::getValues(Value* value)
}
else if (ConstantAggregateZero* CAZ =
dyn_cast<ConstantAggregateZero>(value)) {
- // zero constant
+ // zero constant
const PackedType* PKT = cast<PackedType>(CAZ->getType());
std::vector<Value*> results;
results.reserve(PKT->getNumElements());
-
+
Constant* C = Constant::getNullValue(PKT->getElementType());
for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
results.push_back(C);
@@ -179,7 +179,7 @@ std::vector<Value*>& LowerPacked::getValues(Value* value)
const PackedType* PKT = cast<PackedType>(value->getType());
std::vector<Value*> results;
results.reserve(PKT->getNumElements());
-
+
for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
results.push_back(new Argument(PKT->getElementType()));
}
@@ -221,19 +221,19 @@ void LowerPacked::visitLoadInst(LoadInst& LI)
Idx[1] = ConstantUInt::get(Type::UIntTy,i);
// Get the pointer
- Value* val = new GetElementPtrInst(array,
+ Value* val = new GetElementPtrInst(array,
Idx,
- LI.getName() +
+ LI.getName() +
".ge." + utostr(i),
&LI);
// generate the new load and save the result in packedToScalar map
- values.push_back(new LoadInst(val,
+ values.push_back(new LoadInst(val,
LI.getName()+"."+utostr(i),
LI.isVolatile(),
&LI));
}
-
+
setValues(&LI,values);
Changed = true;
instrsToRemove.push_back(&LI);
@@ -251,13 +251,13 @@ void LowerPacked::visitBinaryOperator(BinaryOperator& BO)
"The two packed operand to scalar maps must be equal in size.");
result.reserve(op0Vals.size());
-
+
// generate the new binary op and save the result
for (unsigned i = 0; i != op0Vals.size(); ++i) {
- result.push_back(BinaryOperator::create(BO.getOpcode(),
- op0Vals[i],
+ result.push_back(BinaryOperator::create(BO.getOpcode(),
+ op0Vals[i],
op1Vals[i],
- BO.getName() +
+ BO.getName() +
"." + utostr(i),
&BO));
}
@@ -270,12 +270,12 @@ void LowerPacked::visitBinaryOperator(BinaryOperator& BO)
void LowerPacked::visitStoreInst(StoreInst& SI)
{
- if (const PackedType* PKT =
+ if (const PackedType* PKT =
dyn_cast<PackedType>(SI.getOperand(0)->getType())) {
// We will need this for getelementptr
std::vector<Value*> Idx(2);
Idx[0] = ConstantUInt::get(Type::UIntTy,0);
-
+
ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
PKT->getNumElements());
PointerType* APT = PointerType::get(AT);
@@ -286,21 +286,21 @@ void LowerPacked::visitStoreInst(StoreInst& SI)
"store.ge.a.",
&SI);
std::vector<Value*>& values = getValues(SI.getOperand(0));
-
+
assert((values.size() == PKT->getNumElements()) &&
"Scalar must have the same number of elements as Packed Type");
for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
// Generate the indices for getelementptr
Idx[1] = ConstantUInt::get(Type::UIntTy,i);
- Value* val = new GetElementPtrInst(array,
+ Value* val = new GetElementPtrInst(array,
Idx,
"store.ge." +
utostr(i) + ".",
&SI);
new StoreInst(values[i], val, SI.isVolatile(),&SI);
}
-
+
Changed = true;
instrsToRemove.push_back(&SI);
}
@@ -319,12 +319,12 @@ void LowerPacked::visitSelectInst(SelectInst& SELI)
for (unsigned i = 0; i != op0Vals.size(); ++i) {
result.push_back(new SelectInst(SELI.getCondition(),
- op0Vals[i],
+ op0Vals[i],
op1Vals[i],
SELI.getName()+ "." + utostr(i),
&SELI));
}
-
+
setValues(&SELI,result);
Changed = true;
instrsToRemove.push_back(&SELI);
@@ -334,24 +334,24 @@ void LowerPacked::visitSelectInst(SelectInst& SELI)
bool LowerPacked::runOnFunction(Function& F)
{
// initialize
- Changed = false;
-
+ Changed = false;
+
// Does three passes:
- // Pass 1) Converts Packed Operations to
+ // Pass 1) Converts Packed Operations to
// new Packed Operations on smaller
// datatypes
visit(F);
-
+
// Pass 2) Drop all references
std::for_each(instrsToRemove.begin(),
instrsToRemove.end(),
std::mem_fun(&Instruction::dropAllReferences));
// Pass 3) Delete the Instructions to remove aka packed instructions
- for (std::vector<Instruction*>::iterator i = instrsToRemove.begin(),
- e = instrsToRemove.end();
+ for (std::vector<Instruction*>::iterator i = instrsToRemove.begin(),
+ e = instrsToRemove.end();
i != e; ++i) {
- (*i)->getParent()->getInstList().erase(*i);
+ (*i)->getParent()->getInstList().erase(*i);
}
// clean-up
diff --git a/lib/Transforms/Scalar/PRE.cpp b/lib/Transforms/Scalar/PRE.cpp
index b849331ff1..1ee923a442 100644
--- a/lib/Transforms/Scalar/PRE.cpp
+++ b/lib/Transforms/Scalar/PRE.cpp
@@ -1,10 +1,10 @@
//===- PRE.cpp - Partial Redundancy Elimination ---------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements the well-known Partial Redundancy Elimination
@@ -80,7 +80,7 @@ namespace {
AvailableBlocksTy AvailableBlocks;
bool ProcessBlock(BasicBlock *BB);
-
+
// Anticipatibility calculation...
void MarkPostDominatingBlocksAnticipatible(PostDominatorTree::Node *N,
std::vector<char> &AntBlocks,
@@ -262,7 +262,7 @@ void PRE::ReplaceDominatedAvailableOccurrencesWith(Instruction *NewOcc,
// active definition...
if (ExistingAvailableVal == 0) {
ExistingAvailableVal = NewOcc;
-
+
for (DominatorTree::Node::iterator I = N->begin(), E = N->end(); I != E;++I)
ReplaceDominatedAvailableOccurrencesWith(NewOcc, *I);
} else {
@@ -283,7 +283,7 @@ void PRE::ReplaceDominatedAvailableOccurrencesWith(Instruction *NewOcc,
for (df_iterator<DominatorTree::Node*> DI = df_begin(N), E = df_end(N);
DI != E; ++DI)
AvailableBlocks[(*DI)->getBlock()] = NewOcc;
- }
+ }
}
@@ -400,7 +400,7 @@ bool PRE::ProcessExpression(Instruction *Expr) {
if (AnticipatibleBlocks[i])
std::cerr << BlockMapping[i]->getName() <<" ";
std::cerr << "\n";);
-
+
// AvailabilityFrontier - Calculates the availability frontier for the current
@@ -463,7 +463,7 @@ bool PRE::ProcessExpression(Instruction *Expr) {
AnyNotAvailable = true;
break;
}
-
+
// If any predecessor blocks are not available, add the node to
// the current expression dominance frontier.
if (AnyNotAvailable) {
@@ -597,12 +597,12 @@ bool PRE::ProcessExpression(Instruction *Expr) {
++NumRedundant;
DEBUG(std::cerr << " PHI replaces available value: %"
<< OldVal->getName() << "\n");
-
+
// Loop over all of the blocks dominated by this PHI node, and change
// the AvailableBlocks entries to be the PHI node instead of the old
// instruction.
MarkOccurrenceAvailableInAllDominatedBlocks(PN, AFBlock);
-
+
AFBlock->getInstList().erase(OldVal); // Delete old instruction!
// The resultant PHI node is a new definition of the value!
@@ -613,7 +613,7 @@ bool PRE::ProcessExpression(Instruction *Expr) {
// region (occurs when hoisting loop invariants, f.e.). In this case,
// the PHI node should actually just be removed.
assert(PN->use_empty() && "No uses should exist for dead PHI node!");
- PN->getParent()->getInstList().erase(PN);
+ PN->getParent()->getInstList().erase(PN);
}
} else {
// The resultant PHI node is a new definition of the value!
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index 1972b9d5c3..90fcd27550 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -1,10 +1,10 @@
//===- Reassociate.cpp - Reassociate binary expressions -------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass reassociates commutative expressions in an order that is designed
@@ -115,7 +115,7 @@ bool Reassociate::ReassociateExpr(BinaryOperator *I) {
Value *RHS = I->getOperand(1);
unsigned LHSRank = getRank(LHS);
unsigned RHSRank = getRank(RHS);
-
+
bool Changed = false;
// Make sure the LHS of the operand always has the greater rank...
@@ -130,7 +130,7 @@ bool Reassociate::ReassociateExpr(BinaryOperator *I) {
DEBUG(std::cerr << "Transposed: " << *I
/* << " Result BB: " << I->getParent()*/);
}
-
+
// If the LHS is the same operator as the current one is, and if we are the
// only expression using it...
//
@@ -233,7 +233,7 @@ bool Reassociate::ReassociateBB(BasicBlock *BB) {
BI = New;
New->setOperand(1, NegateValue(New->getOperand(1), BI));
-
+
Changed = true;
DEBUG(std::cerr << "Negated: " << *New /*<< " Result BB: " << BB*/);
}
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 08504f42c6..384c00d1ce 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -1,10 +1,10 @@
//===- SCCP.cpp - Sparse Conditional Constant Propagation -----------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements sparse conditional constant propagation and merging:
@@ -45,7 +45,7 @@ using namespace llvm;
namespace {
class LatticeVal {
- enum {
+ enum {
undefined, // This instruction has no known value
constant, // This instruction has a constant value
overdefined // This instruction has an unknown value
@@ -198,7 +198,7 @@ public:
private:
// markConstant - Make a value be marked as "constant". If the value
- // is not already a constant, add it to the instruction work list so that
+ // is not already a constant, add it to the instruction work list so that
// the users of the instruction are updated later.
//
inline void markConstant(LatticeVal &IV, Value *V, Constant *C) {
@@ -212,9 +212,9 @@ private:
}
// markOverdefined - Make a value be marked as "overdefined". If the
- // value is not already overdefined, add it to the overdefined instruction
+ // value is not already overdefined, add it to the overdefined instruction
// work list so that the users of the instruction are updated later.
-
+
inline void markOverdefined(LatticeVal &IV, Value *V) {
if (IV.markOverdefined()) {
DEBUG(std::cerr << "markOverdefined: ";
@@ -262,9 +262,9 @@ private:
return ValueState[V];
}
- // markEdgeExecutable - Mark a basic block as executable, adding it to the BB
+ // markEdgeExecutable - Mark a basic block as executable, adding it to the BB
// work list if it is not already executable...
- //
+ //
void markEdgeExecutable(BasicBlock *Source, BasicBlock *Dest) {
if (!KnownFeasibleEdges.insert(Edge(Source, Dest)).second)
return; // This edge is already known to be executable!
@@ -308,7 +308,7 @@ private:
private:
friend class InstVisitor<SCCPSolver>;
- // visit implementations - Something changed in this instruction... Either an
+ // visit implementations - Something changed in this instruction... Either an
// operand made a transition, or the instruction is newly executable. Change
// the value type of I to reflect these changes if appropriate.
//
@@ -406,7 +406,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
// Make sure the source basic block is executable!!
if (!BBExecutable.count(From)) return false;
-
+
// Check to make sure this edge itself is actually feasible now...
TerminatorInst *TI = From->getTerminator();
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
@@ -422,7 +422,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
if (!isa<ConstantBool>(BCValue.getConstant())) return true;
// Constant condition variables mean the branch can only go a single way
- return BI->getSuccessor(BCValue.getConstant() ==
+ return BI->getSuccessor(BCValue.getConstant() ==
ConstantBool::False) == To;
}
return false;
@@ -511,7 +511,7 @@ void SCCPSolver::visitPHINode(PHINode &PN) {
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
LatticeVal &IV = getValueState(PN.getIncomingValue(i));
if (IV.isUndefined()) continue; // Doesn't influence PHI node.
-
+
if (isEdgeFeasible(PN.getIncomingBlock(i), PN.getParent())) {
if (IV.isOverdefined()) { // PHI node becomes overdefined!
markOverdefined(PNIV, &PN);
@@ -524,7 +524,7 @@ void SCCPSolver::visitPHINode(PHINode &PN) {
// There is already a reachable operand. If we conflict with it,
// then the PHI node becomes overdefined. If we agree with it, we
// can continue on.
-
+
// Check to see if there are two different constants merging...
if (IV.getConstant() != OperandVal) {
// Yes there is. This means the PHI node is not constant.
@@ -753,7 +753,7 @@ void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) {
Constant *Ptr = Operands[0];
Operands.erase(Operands.begin()); // Erase the pointer from idx list...
- markConstant(IV, &I, ConstantExpr::getGetElementPtr(Ptr, Operands));
+ markConstant(IV, &I, ConstantExpr::getGetElementPtr(Ptr, Operands));
}
/// GetGEPGlobalInitializer - Given a constant and a getelementptr constantexpr,
@@ -813,7 +813,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
markConstant(IV, &I, Constant::getNullValue(I.getType()));
return;
}
-
+
// Transform load (constant global) into the value loaded.
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
if (GV->isConstant()) {
@@ -837,7 +837,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
if (CE->getOpcode() == Instruction::GetElementPtr)
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(CE->getOperand(0)))
if (GV->isConstant() && !GV->isExternal())
- if (Constant *V =
+ if (Constant *V =
GetGEPGlobalInitializer(GV->getInitializer(), CE)) {
markConstant(IV, &I, V);
return;
@@ -857,7 +857,7 @@ void SCCPSolver::visitCallSite(CallSite CS) {
hash_map<Function*, LatticeVal>::iterator TFRVI =TrackedFunctionRetVals.end();
if (F && F->hasInternalLinkage())
TFRVI = TrackedFunctionRetVals.find(F);
-
+
if (TFRVI != TrackedFunctionRetVals.end()) {
// If this is the first call to the function hit, mark its entry block
// executable.
@@ -883,7 +883,7 @@ void SCCPSolver::visitCallSite(CallSite CS) {
mergeInValue(IV, I, TFRVI->second);
return;
}
-
+
if (F == 0 || !F->isExternal() || !canConstantFoldCallTo(F)) {
markOverdefined(IV, I);
return;
@@ -914,7 +914,7 @@ void SCCPSolver::visitCallSite(CallSite CS) {
void SCCPSolver::Solve() {
// Process the work lists until they are empty!
- while (!BBWorkList.empty() || !InstWorkList.empty() ||
+ while (!BBWorkList.empty() || !InstWorkList.empty() ||
!OverdefinedInstWorkList.empty()) {
// Process the instruction work list...
while (!OverdefinedInstWorkList.empty()) {
@@ -922,7 +922,7 @@ void SCCPSolver::Solve() {
OverdefinedInstWorkList.pop_back();
DEBUG(std::cerr << "\nPopped off OI-WL: " << *I);
-
+
// "I" got into the work list because it either made the transition from
// bottom to constant
//
@@ -940,7 +940,7 @@ void SCCPSolver::Solve() {
InstWorkList.pop_back();
DEBUG(std::cerr << "\nPopped off I-WL: " << *I);
-
+
// "I" got into the work list because it either made the transition from
// bottom to constant
//
@@ -953,14 +953,14 @@ void SCCPSolver::Solve() {
UI != E; ++UI)
OperandChangedState(*UI);
}
-
+
// Process the basic block work list...
while (!BBWorkList.empty()) {
BasicBlock *BB = BBWorkList.back();
BBWorkList.pop_back();
-
+
DEBUG(std::cerr << "\nPopped off BBWL: " << *BB);
-
+
// Notify all instructions in this basic block that they are newly
// executable.
visit(BB);
@@ -1016,7 +1016,7 @@ namespace {
// algorithm, and return true if the function was modified.
//
bool runOnFunction(Function &F);
-
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
}
@@ -1095,13 +1095,13 @@ bool SCCP::runOnFunction(Function &F) {
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
-
+
// Replaces all of the uses of a variable with uses of the constant.
Inst->replaceAllUsesWith(Const);
-
+
// Delete the instruction.
BB->getInstList().erase(Inst);
-
+
// Hey, we just changed something!
MadeChanges = true;
++NumInstRemoved;
@@ -1217,7 +1217,7 @@ bool IPSCCP::runOnModule(Module &M) {
Constant *CST = IV.isConstant() ?
IV.getConstant() : UndefValue::get(AI->getType());
DEBUG(std::cerr << "*** Arg " << *AI << " = " << *CST <<"\n");
-
+
// Replaces all of the uses of a variable with uses of the
// constant.
AI->replaceAllUsesWith(CST);
@@ -1247,7 +1247,7 @@ bool IPSCCP::runOnModule(Module &M) {
MadeChanges = true;
++IPNumInstRemoved;
}
-
+
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
BasicBlock *Succ = TI->getSuccessor(i);
if (Succ->begin() != Succ->end() && isa<PHINode>(Succ->begin()))
@@ -1272,11 +1272,11 @@ bool IPSCCP::runOnModule(Module &M) {
Constant *Const = IV.isConstant()
? IV.getConstant() : UndefValue::get(Inst->getType());
DEBUG(std::cerr << " Constant: " << *Const << " = " << *Inst);
-
+
// Replaces all of the uses of a variable with uses of the
// constant.
Inst->replaceAllUsesWith(Const);
-
+
// Delete the instruction.
if (!isa<TerminatorInst>(Inst) && !isa<CallInst>(Inst))
BB->getInstList().erase(Inst);
@@ -1300,7 +1300,7 @@ bool IPSCCP::runOnModule(Module &M) {
bool Folded = ConstantFoldTerminator(I->getParent());
assert(Folded && "Didn't fold away reference to block!");
}
-
+
// Finally, delete the basic block.
F->getBasicBlockList().erase(DeadBB);
}
@@ -1338,6 +1338,6 @@ bool IPSCCP::runOnModule(Module &M) {
M.getGlobalList().erase(GV);
++IPNumGlobalConst;
}
-
+
return MadeChanges;
}
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index f934f1f127..4a6aee391c 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -1,10 +1,10 @@
//===- ScalarReplAggregates.cpp - Scalar Replacement of Aggregates --------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This transformation implements the well known scalar replacement of
@@ -91,7 +91,7 @@ bool SROA::performPromotion(Function &F) {
BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
bool Changed = false;
-
+
while (1) {
Allocas.clear();
@@ -154,7 +154,7 @@ bool SROA::performScalarRepl(Function &F) {
DEBUG(std::cerr << "Found inst to xform: " << *AI);
Changed = true;
-
+
std::vector<AllocaInst*> ElementAllocas;
if (const StructType *ST = dyn_cast<StructType>(AI->getAllocatedType())) {
ElementAllocas.reserve(ST->getNumContainedTypes());
@@ -175,7 +175,7 @@ bool SROA::performScalarRepl(Function &F) {
WorkList.push_back(NA); // Add to worklist for recursive processing
}
}
-
+
// Now that we have created the alloca instructions that we want to use,
// expand the getelementptr instructions to use them.
//
@@ -183,12 +183,12 @@ bool SROA::performScalarRepl(Function &F) {
Instruction *User = cast<Instruction>(AI->use_back());
GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User);
// We now know that the GEP is of the form: GEP <ptr>, 0, <cst>
- unsigned Idx =
+ unsigned Idx =
(unsigned)cast<ConstantInt>(GEPI->getOperand(2))->getRawValue();
-
+
assert(Idx < ElementAllocas.size() && "Index out of range?");
AllocaInst *AllocaToUse = ElementAllocas[Idx];
-
+
Value *RepValue;
if (GEPI->getNumOperands() == 3) {
// Do not insert a new getelementptr instruction with zero indices, only
@@ -206,7 +206,7 @@ bool SROA::performScalarRepl(Function &F) {
GEPI->setName("");
RepValue = new GetElementPtrInst(AllocaToUse, NewArgs, OldName, GEPI);
}
-
+
// Move all of the users over to the new GEP.
GEPI->replaceAllUsesWith(RepValue);
// Delete the old GEP
@@ -259,7 +259,7 @@ static bool AllUsersAreLoads(Value *Ptr) {
I != E; ++I)
if (cast<Instruction>(*I)->getOpcode() != Instruction::Load)
return false;
- return true;
+ return true;
}
/// isSafeUseOfAllocation - Check to see if this user is an allowed use for an
@@ -289,7 +289,7 @@ int SROA::isSafeUseOfAllocation(Instruction *User) {
//
if (cast<ConstantInt>(GEPI->getOperand(2))->getRawValue() >= NumElements)
return 0;
-
+
} else {
// If this is an array index and the index is not constant, we cannot
// promote... that is unless the array has exactly one or two elements in
@@ -342,7 +342,7 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) {
if (const ArrayType *AT = dyn_cast<ArrayType>(*I)) {
uint64_t NumElements = AT->getNumElements();
-
+
if (!isa<ConstantInt>(I.getOperand())) {
if (NumElements == 1) {
GEPI->setOperand(2, Constant::getNullValue(Type::IntTy));
diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp
index 88b625becf..8b9c518de9 100644
--- a/lib/Transforms/Scalar/SimplifyCFG.cpp
+++ b/lib/Transforms/Scalar/SimplifyCFG.cpp
@@ -1,10 +1,10 @@
//===- SimplifyCFG.cpp - CFG Simplification Pass --------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements dead code elimination and basic block merging.
@@ -100,7 +100,7 @@ bool CFGSimplifyPass::runOnFunction(Function &F) {
(*SI)->removePredecessor(BB);
BB->dropAllReferences();
}
-
+
for (Function::iterator I = ++F.begin(); I != F.end();)
if (!Reachable.count(I))
I = F.getBasicBlockList().erase(I);
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 0a05d0f9e7..f78ce91d6e 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -1,10 +1,10 @@
//===- TailDuplication.cpp - Simplify CFG through tail duplication --------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This pass performs a limited form of tail duplication, intended to simplify
@@ -127,7 +127,7 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) {
if (TooMany-- == 0) return false;
}
- return true;
+ return true;
}
/// FindObviousSharedDomOf - We know there is a branch from SrcBlock to
@@ -141,7 +141,7 @@ static BasicBlock *FindObviousSharedDomOf(BasicBlock *SrcBlock,
if (PI == PE || ++PI != PE) return 0;
BasicBlock *SrcPred = *pred_begin(SrcBlock);
-
+
// Look at the predecessors of DstBlock. One of them will be SrcBlock. If
// there is only one other pred, get it, otherwise we can't handle it.
PI = pred_begin(DstBlock); PE = pred_end(DstBlock);
@@ -199,7 +199,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
while (isa<PHINode>(BBI)) ++BBI;
while (!isa<TerminatorInst>(BBI)) {
Instruction *I = BBI++;
-
+
bool CanHoist = !I->isTrapping() && !I->mayWriteToMemory();
if (CanHoist) {
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
@@ -303,7 +303,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
// Ok, we have a PHI node. Figure out what the incoming value was for the
// DestBlock.
Value *IV = PN->getIncomingValueForBlock(DestBlock);
-
+
// Remap the value if necessary...
if (Value *MappedIV = ValueMapping[IV])
IV = MappedIV;
diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp
index bf098eb59b..ed8e546e74 100644
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -1,10 +1,10 @@
//===- TailRecursionElimination.cpp - Eliminate Tail Calls ----------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file transforms calls of the current function (self recursion) followed
@@ -89,7 +89,7 @@ bool TailCallElim::runOnFunction(Function &F) {
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
if (ReturnInst *Ret = dyn_cast<ReturnInst>(BB->getTerminator()))
MadeChange |= ProcessReturningBlock(Ret, OldEntry, ArgumentPHIs);
-
+
// If we eliminated any tail recursions, it's possible that we inserted some
// silly PHI nodes which just merge an initial value (the incoming operand)
// with themselves. Check to see if we did and clean up our mess if so. This
@@ -163,7 +163,7 @@ static bool isDynamicConstant(Value *V, CallInst *CI) {
Function *F = CI->getParent()->getParent();
for (Function::arg_iterator AI = F->arg_begin(); &*AI != Arg; ++AI)
++ArgNo;
-
+
// If we are passing this argument into call as the corresponding
// argument operand, then the argument is dynamically constant.
// Otherwise, we cannot transform this function safely.
@@ -292,7 +292,7 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry,
std::string OldName = OldEntry->getName(); OldEntry->setName("tailrecurse");
BasicBlock *NewEntry = new BasicBlock(OldName, F, OldEntry);
new BranchInst(OldEntry, NewEntry);
-
+
// Now that we have created a new block, which jumps to the entry
// block, insert a PHI node for each argument of the function.
// For now, we initialize each PHI to only have the real arguments
@@ -305,13 +305,13 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry,
ArgumentPHIs.push_back(PN);
}
}
-
+
// Ok, now that we know we have a pseudo-entry block WITH all of the
// required PHI nodes, add entries into the PHI node for the actual
// parameters passed into the tail-recursive call.
for (unsigned i = 0, e = CI->getNumOperands()-1; i != e; ++i)
ArgumentPHIs[i]->addIncoming(CI->getOperand(i+1), BB);
-
+
// If we are introducing an accumulator variable to eliminate the recursion,
// do so now. Note that we _know_ that no subsequent tail recursion
// eliminations will happen on this function because of the way the