[llvm-commits] CVS: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp BreakCriticalEdges.cpp CloneFunction.cpp CloneModule.cpp CloneTrace.cpp CodeExtractor.cpp DemoteRegToStack.cpp InlineFunction.cpp Local.cpp PromoteMemoryToRegister.cpp SimplifyCFG.cpp UnifyFunctionExitNodes.cpp ValueMapper.cpp ValueMapper.h
Misha Brukman
brukman at cs.uiuc.edu
Thu Apr 21 16:45:45 PDT 2005
Changes in directory llvm/lib/Transforms/Utils:
BasicBlockUtils.cpp updated: 1.13 -> 1.14
BreakCriticalEdges.cpp updated: 1.25 -> 1.26
CloneFunction.cpp updated: 1.24 -> 1.25
CloneModule.cpp updated: 1.11 -> 1.12
CloneTrace.cpp updated: 1.9 -> 1.10
CodeExtractor.cpp updated: 1.37 -> 1.38
DemoteRegToStack.cpp updated: 1.12 -> 1.13
InlineFunction.cpp updated: 1.30 -> 1.31
Local.cpp updated: 1.35 -> 1.36
PromoteMemoryToRegister.cpp updated: 1.75 -> 1.76
SimplifyCFG.cpp updated: 1.68 -> 1.69
UnifyFunctionExitNodes.cpp updated: 1.32 -> 1.33
ValueMapper.cpp updated: 1.19 -> 1.20
ValueMapper.h updated: 1.5 -> 1.6
---
Log message:
Remove trailing whitespace
---
Diffs of the changes: (+151 -151)
BasicBlockUtils.cpp | 10 ++---
BreakCriticalEdges.cpp | 12 +++---
CloneFunction.cpp | 14 +++----
CloneModule.cpp | 4 +-
CloneTrace.cpp | 16 ++++-----
CodeExtractor.cpp | 40 +++++++++++-----------
DemoteRegToStack.cpp | 6 +--
InlineFunction.cpp | 58 ++++++++++++++++----------------
Local.cpp | 22 ++++++------
PromoteMemoryToRegister.cpp | 20 +++++------
SimplifyCFG.cpp | 78 ++++++++++++++++++++++----------------------
UnifyFunctionExitNodes.cpp | 12 +++---
ValueMapper.cpp | 6 +--
ValueMapper.h | 4 +-
14 files changed, 151 insertions(+), 151 deletions(-)
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff -u llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.13 llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.14
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.13 Thu Apr 21 11:04:48 2005
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp Thu Apr 21 18:45:33 2005
@@ -1,10 +1,10 @@
//===-- BasicBlockUtils.cpp - BasicBlock Utilities -------------------------==//
-//
+//
// 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 family of functions perform manipulations on basic blocks, and
@@ -30,7 +30,7 @@
I.replaceAllUsesWith(V);
std::string OldName = I.getName();
-
+
// Delete the unnecessary instruction now...
BI = BIL.erase(BI);
@@ -92,7 +92,7 @@
cast<BranchInst>(TI)->setUnconditionalDest(TI->getSuccessor(1-SuccNum));
} else { // Otherwise convert to a return instruction...
Value *RetVal = 0;
-
+
// Create a value to return... if the function doesn't return null...
if (BB->getParent()->getReturnType() != Type::VoidTy)
RetVal = Constant::getNullValue(BB->getParent()->getReturnType());
@@ -100,7 +100,7 @@
// Create the return...
NewTI = new ReturnInst(RetVal);
}
- break;
+ break;
case Instruction::Invoke: // Should convert to call
case Instruction::Switch: // Should remove entry
Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
diff -u llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.25 llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.26
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp:1.25 Thu Mar 17 09:37:58 2005
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp Thu Apr 21 18:45:33 2005
@@ -1,10 +1,10 @@
//===- BreakCriticalEdges.cpp - Critical Edge Elimination 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.
-//
+//
//===----------------------------------------------------------------------===//
//
// BreakCriticalEdges pass - Break all of the critical edges in the CFG by
@@ -31,7 +31,7 @@
struct BreakCriticalEdges : public FunctionPass {
virtual bool runOnFunction(Function &F);
-
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addPreserved<DominatorSet>();
AU.addPreserved<ImmediateDominators>();
@@ -108,7 +108,7 @@
DestBB->getName() + "_crit_edge");
// Create our unconditional branch...
new BranchInst(DestBB, NewBB);
-
+
// Branch to the new block, breaking the edge...
TI->setSuccessor(SuccNum, NewBB);
@@ -150,11 +150,11 @@
// anything.
ID->addNewBlock(NewBB, TIBB);
}
-
+
// Should we update DominatorTree information?
if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) {
DominatorTree::Node *TINode = DT->getNode(TIBB);
-
+
// The new block is not the immediate dominator for any other nodes, but
// TINode is the immediate dominator for the new node.
//
Index: llvm/lib/Transforms/Utils/CloneFunction.cpp
diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.24 llvm/lib/Transforms/Utils/CloneFunction.cpp:1.25
--- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.24 Mon Mar 14 22:54:21 2005
+++ llvm/lib/Transforms/Utils/CloneFunction.cpp Thu Apr 21 18:45:33 2005
@@ -1,10 +1,10 @@
//===- CloneFunction.cpp - Clone a function into another function ---------===//
-//
+//
// 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 CloneFunctionInto interface, which is used as the
@@ -47,7 +47,7 @@
std::vector<ReturnInst*> &Returns,
const char *NameSuffix) {
assert(NameSuffix && "NameSuffix cannot be null!");
-
+
#ifndef NDEBUG
for (Function::const_arg_iterator I = OldFunc->arg_begin(), E = OldFunc->arg_end();
I != E; ++I)
@@ -61,7 +61,7 @@
for (Function::const_iterator BI = OldFunc->begin(), BE = OldFunc->end();
BI != BE; ++BI) {
const BasicBlock &BB = *BI;
-
+
// Create a new basic block and copy instructions into it!
BasicBlock *CBB = CloneBasicBlock(&BB, ValueMap, NameSuffix, NewFunc);
ValueMap[&BB] = CBB; // Add basic block mapping.
@@ -70,7 +70,7 @@
Returns.push_back(RI);
}
- // Loop over all of the instructions in the function, fixing up operand
+ // Loop over all of the instructions in the function, fixing up operand
// references as we go. This uses ValueMap to do all the hard work.
//
for (Function::iterator BB = cast<BasicBlock>(ValueMap[OldFunc->begin()]),
@@ -105,7 +105,7 @@
// Create the new function...
Function *NewF = new Function(FTy, F->getLinkage(), F->getName());
-
+
// Loop over the arguments, copying the names of the mapped arguments over...
Function::arg_iterator DestI = NewF->arg_begin();
for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
@@ -116,6 +116,6 @@
std::vector<ReturnInst*> Returns; // Ignore returns cloned...
CloneFunctionInto(NewF, F, ValueMap, Returns);
- return NewF;
+ return NewF;
}
Index: llvm/lib/Transforms/Utils/CloneModule.cpp
diff -u llvm/lib/Transforms/Utils/CloneModule.cpp:1.11 llvm/lib/Transforms/Utils/CloneModule.cpp:1.12
--- llvm/lib/Transforms/Utils/CloneModule.cpp:1.11 Mon Mar 14 22:54:21 2005
+++ llvm/lib/Transforms/Utils/CloneModule.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- CloneModule.cpp - Clone an entire module ---------------------------===//
-//
+//
// 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 CloneModule interface which makes a copy of an
Index: llvm/lib/Transforms/Utils/CloneTrace.cpp
diff -u llvm/lib/Transforms/Utils/CloneTrace.cpp:1.9 llvm/lib/Transforms/Utils/CloneTrace.cpp:1.10
--- llvm/lib/Transforms/Utils/CloneTrace.cpp:1.9 Wed Sep 15 12:06:42 2004
+++ llvm/lib/Transforms/Utils/CloneTrace.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- CloneTrace.cpp - Clone a trace -------------------------------------===//
-//
+//
// 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 CloneTrace interface, which is used when writing
@@ -27,7 +27,7 @@
llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) {
std::vector<BasicBlock *> clonedTrace;
std::map<const Value*, Value*> ValueMap;
-
+
//First, loop over all the Basic Blocks in the trace and copy
//them using CloneBasicBlock. Also fix the phi nodes during
//this loop. To fix the phi nodes, we delete incoming branches
@@ -38,7 +38,7 @@
//Clone Basic Block
BasicBlock *clonedBlock =
CloneBasicBlock(*T, ValueMap, ".tr", (*T)->getParent());
-
+
//Add it to our new trace
clonedTrace.push_back(clonedBlock);
@@ -55,10 +55,10 @@
//get incoming value for the previous BB
Value *V = PN->getIncomingValueForBlock(*(T-1));
assert(V && "No incoming value from a BasicBlock in our trace!");
-
+
//remap our phi node to point to incoming value
ValueMap[*&I] = V;
-
+
//remove phi node
clonedBlock->getInstList().erase(PN);
}
@@ -69,7 +69,7 @@
for(std::vector<BasicBlock *>::const_iterator BB = clonedTrace.begin(),
BE = clonedTrace.end(); BB != BE; ++BB) {
for(BasicBlock::iterator I = (*BB)->begin(); I != (*BB)->end(); ++I) {
-
+
//Loop over all the operands of the instruction
for(unsigned op=0, E = I->getNumOperands(); op != E; ++op) {
const Value *Op = I->getOperand(op);
@@ -83,7 +83,7 @@
}
}
}
-
+
//return new vector of basic blocks
return clonedTrace;
}
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.37 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.38
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.37 Mon Mar 14 22:54:21 2005
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- CodeExtractor.cpp - Pull code region into a new function -----------===//
-//
+//
// 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 interface to tear out a code region, such as an
@@ -64,7 +64,7 @@
return true;
return false;
}
-
+
/// definedInCaller - Return true if the specified value is defined in the
/// function being code extracted, but not in the region being extracted.
/// These values must be passed in as live-ins to the function.
@@ -198,7 +198,7 @@
//
void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs) {
std::set<BasicBlock*> ExitBlocks;
- for (std::set<BasicBlock*>::const_iterator ci = BlocksToExtract.begin(),
+ for (std::set<BasicBlock*>::const_iterator ci = BlocksToExtract.begin(),
ce = BlocksToExtract.end(); ci != ce; ++ci) {
BasicBlock *BB = *ci;
@@ -208,7 +208,7 @@
for (User::op_iterator O = I->op_begin(), E = I->op_end(); O != E; ++O)
if (definedInCaller(*O))
inputs.push_back(*O);
-
+
// Consider uses of this instruction (outputs).
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI)
@@ -326,7 +326,7 @@
for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI)
AI->setName(inputs[i]->getName());
for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI)
- AI->setName(outputs[i]->getName()+".out");
+ AI->setName(outputs[i]->getName()+".out");
}
// Rewrite branches to basic blocks outside of the loop to new dummy blocks
@@ -383,8 +383,8 @@
// Allocate a struct at the beginning of this function
Type *StructArgTy = StructType::get(ArgTypes);
- Struct =
- new AllocaInst(StructArgTy, 0, "structArg",
+ Struct =
+ new AllocaInst(StructArgTy, 0, "structArg",
codeReplacer->getParent()->begin()->begin());
params.push_back(Struct);
@@ -399,7 +399,7 @@
StoreInst *SI = new StoreInst(StructValues[i], GEP);
codeReplacer->getInstList().push_back(SI);
}
- }
+ }
// Emit the call to the function
CallInst *call = new CallInst(newFunction, params,
@@ -418,7 +418,7 @@
std::vector<Value*> Indices;
Indices.push_back(Constant::getNullValue(Type::UIntTy));
Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i));
- GetElementPtrInst *GEP
+ GetElementPtrInst *GEP
= new GetElementPtrInst(Struct, Indices,
"gep_reload_" + outputs[i]->getName());
codeReplacer->getInstList().push_back(GEP);
@@ -521,7 +521,7 @@
Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out));
GetElementPtrInst *GEP =
new GetElementPtrInst(OAI, Indices,
- "gep_" + outputs[out]->getName(),
+ "gep_" + outputs[out]->getName(),
NTRet);
new StoreInst(outputs[out], GEP, NTRet);
} else {
@@ -545,7 +545,7 @@
// There are no successors (the block containing the switch itself), which
// means that previously this was the last part of the function, and hence
// this should be rewritten as a `ret'
-
+
// Check if the function should return a value
if (OldFnRetTy == Type::VoidTy) {
new ReturnInst(0, TheSwitch); // Return void
@@ -603,13 +603,13 @@
///
/// find inputs and outputs for the region
///
-/// for inputs: add to function as args, map input instr* to arg#
-/// for outputs: add allocas for scalars,
+/// for inputs: add to function as args, map input instr* to arg#
+/// for outputs: add allocas for scalars,
/// add to func as args, map output instr* to arg#
///
/// rewrite func to use argument #s instead of instr*
///
-/// for each scalar output in the function: at every exit, store intermediate
+/// for each scalar output in the function: at every exit, store intermediate
/// computed result back into memory.
///
Function *CodeExtractor::
@@ -637,7 +637,7 @@
assert(BlocksToExtract.count(*PI) &&
"No blocks in this region may have entries from outside the region"
" except for the first block!");
-
+
// If we have to split PHI nodes or the entry block, do so now.
severSplitPHINodes(header);
@@ -660,7 +660,7 @@
// Construct new function based on inputs/outputs & add allocas for all defs.
Function *newFunction = constructFunction(inputs, outputs, header,
- newFuncRoot,
+ newFuncRoot,
codeReplacer, oldFunction,
oldFunction->getParent());
@@ -676,7 +676,7 @@
if (!BlocksToExtract.count(PN->getIncomingBlock(i)))
PN->setIncomingBlock(i, newFuncRoot);
}
-
+
// Look at all successors of the codeReplacer block. If any of these blocks
// had PHI nodes in them, we need to update the "from" block to be the code
// replacer, not the original block in the extracted region.
@@ -697,7 +697,7 @@
--i; --e;
}
}
-
+
//std::cerr << "NEW FUNCTION: " << *newFunction;
// verifyFunction(*newFunction);
@@ -744,5 +744,5 @@
Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) {
std::vector<BasicBlock*> Blocks;
Blocks.push_back(BB);
- return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks);
+ return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks);
}
Index: llvm/lib/Transforms/Utils/DemoteRegToStack.cpp
diff -u llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.12 llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.13
--- llvm/lib/Transforms/Utils/DemoteRegToStack.cpp:1.12 Thu Mar 17 09:37:58 2005
+++ llvm/lib/Transforms/Utils/DemoteRegToStack.cpp Thu Apr 21 18:45:34 2005
@@ -1,12 +1,12 @@
//===- DemoteRegToStack.cpp - Move a virtual register to the stack --------===//
-//
+//
// 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 provide the function DemoteRegToStack(). This function takes a
// virtual register computed by an Instruction and replaces it with a slot in
// the stack frame, allocated via alloca. It returns the pointer to the
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.30 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.31
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.30 Mon Mar 14 22:54:21 2005
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- InlineFunction.cpp - Code to perform function inlining -------------===//
-//
+//
// 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 inlining of a function into a call site, resolving
@@ -31,8 +31,8 @@
// block of the caller. This returns false if it is not possible to inline this
// call. The program is still in a well defined state if this occurs though.
//
-// Note that this only does one level of inlining. For example, if the
-// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
+// Note that this only does one level of inlining. For example, if the
+// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
// exists in the instruction stream. Similiarly this will inline a recursive
// function by one level.
//
@@ -60,18 +60,18 @@
{ // Scope to destroy ValueMap after cloning.
// Calculate the vector of arguments to pass into the function cloner...
std::map<const Value*, Value*> ValueMap;
- assert(std::distance(CalledFunc->arg_begin(), CalledFunc->arg_end()) ==
+ assert(std::distance(CalledFunc->arg_begin(), CalledFunc->arg_end()) ==
std::distance(CS.arg_begin(), CS.arg_end()) &&
"No varargs calls can be inlined!");
-
+
CallSite::arg_iterator AI = CS.arg_begin();
for (Function::const_arg_iterator I = CalledFunc->arg_begin(),
E = CalledFunc->arg_end(); I != E; ++I, ++AI)
ValueMap[I] = *AI;
-
- // Clone the entire body of the callee into the caller.
+
+ // Clone the entire body of the callee into the caller.
CloneFunctionInto(Caller, CalledFunc, ValueMap, Returns, ".i");
- }
+ }
// Remember the first block that is newly cloned over.
Function::iterator FirstNewBlock = LastBlock; ++FirstNewBlock;
@@ -131,21 +131,21 @@
} else {
// First, split the basic block...
BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
-
+
// Next, create the new invoke instruction, inserting it at the end
// of the old basic block.
InvokeInst *II =
- new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
+ new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
std::vector<Value*>(CI->op_begin()+1, CI->op_end()),
CI->getName(), BB->getTerminator());
// Make sure that anything using the call now uses the invoke!
CI->replaceAllUsesWith(II);
-
+
// Delete the unconditional branch inserted by splitBasicBlock
BB->getInstList().pop_back();
Split->getInstList().pop_front(); // Delete the original call
-
+
// Update any PHI nodes in the exceptional block to indicate that
// there is now a new entry in them.
unsigned i = 0;
@@ -154,7 +154,7 @@
PHINode *PN = cast<PHINode>(I);
PN->addIncoming(InvokeDestPHIValues[i], BB);
}
-
+
// This basic block is now complete, start scanning the next one.
break;
}
@@ -200,7 +200,7 @@
FirstNewBlock->begin(), FirstNewBlock->end());
// Remove the cloned basic block.
Caller->getBasicBlockList().pop_back();
-
+
// If the call site was an invoke instruction, add a branch to the normal
// destination.
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
@@ -229,16 +229,16 @@
// this is an invoke instruction or a call instruction.
BasicBlock *AfterCallBB;
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
-
+
// Add an unconditional branch to make this look like the CallInst case...
BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall);
-
+
// Split the basic block. This guarantees that no PHI nodes will have to be
// updated due to new incoming edges, and make the invoke case more
// symmetric to the call case.
AfterCallBB = OrigBB->splitBasicBlock(NewBr,
CalledFunc->getName()+".exit");
-
+
} else { // It's a call
// If this is a call instruction, we need to split the basic block that
// the call lives in.
@@ -251,7 +251,7 @@
// basic block of the inlined function.
//
TerminatorInst *Br = OrigBB->getTerminator();
- assert(Br && Br->getOpcode() == Instruction::Br &&
+ assert(Br && Br->getOpcode() == Instruction::Br &&
"splitBasicBlock broken!");
Br->setOperand(0, FirstNewBlock);
@@ -273,39 +273,39 @@
if (!TheCall->use_empty()) {
PHI = new PHINode(CalledFunc->getReturnType(),
TheCall->getName(), AfterCallBB->begin());
-
+
// Anything that used the result of the function call should now use the
// PHI node as their operand.
//
TheCall->replaceAllUsesWith(PHI);
}
-
+
// Loop over all of the return instructions, turning them into unconditional
// branches to the merge point now, and adding entries to the PHI node as
// appropriate.
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
ReturnInst *RI = Returns[i];
-
+
if (PHI) {
assert(RI->getReturnValue() && "Ret should have value!");
- assert(RI->getReturnValue()->getType() == PHI->getType() &&
+ assert(RI->getReturnValue()->getType() == PHI->getType() &&
"Ret value not consistent in function!");
PHI->addIncoming(RI->getReturnValue(), RI->getParent());
}
-
+
// Add a branch to the merge point where the PHI node lives if it exists.
new BranchInst(AfterCallBB, RI);
-
+
// Delete the return instruction now
RI->getParent()->getInstList().erase(RI);
}
-
+
} else if (!Returns.empty()) {
// Otherwise, if there is exactly one return value, just replace anything
// using the return value of the call with the computed value.
if (!TheCall->use_empty())
TheCall->replaceAllUsesWith(Returns[0]->getReturnValue());
-
+
// Splice the code from the return block into the block that it will return
// to, which contains the code that was after the call.
BasicBlock *ReturnBB = Returns[0]->getParent();
@@ -314,7 +314,7 @@
// Update PHI nodes that use the ReturnBB to use the AfterCallBB.
ReturnBB->replaceAllUsesWith(AfterCallBB);
-
+
// Delete the return instruction now and empty ReturnBB now.
Returns[0]->eraseFromParent();
ReturnBB->eraseFromParent();
@@ -323,7 +323,7 @@
// nuke the result.
TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
}
-
+
// Since we are now done with the Call/Invoke, we can delete it.
TheCall->eraseFromParent();
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.35 llvm/lib/Transforms/Utils/Local.cpp:1.36
--- llvm/lib/Transforms/Utils/Local.cpp:1.35 Sun Oct 17 16:23:26 2004
+++ llvm/lib/Transforms/Utils/Local.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===-- Local.cpp - Functions to perform local transformations ------------===//
-//
+//
// 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 family of functions perform various local transformations to the
@@ -32,7 +32,7 @@
if (Constant *C = ConstantFoldInstruction(II)) {
// Replaces all of the uses of a variable with uses of the constant.
II->replaceAllUsesWith(C);
-
+
// Remove the instruction from the basic block...
II = II->getParent()->getInstList().erase(II);
return true;
@@ -50,7 +50,7 @@
if (PHINode *PN = dyn_cast<PHINode>(I)) {
if (PN->getNumIncomingValues() == 0)
return Constant::getNullValue(PN->getType());
-
+
Constant *Result = dyn_cast<Constant>(PN->getIncomingValue(0));
if (Result == 0) return 0;
@@ -58,7 +58,7 @@
for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i)
if (PN->getIncomingValue(i) != Result && PN->getIncomingValue(i) != PN)
return 0; // Not all the same incoming constants...
-
+
// If we reach here, all incoming values are the same constant.
return Result;
} else if (CallInst *CI = dyn_cast<CallInst>(I)) {
@@ -89,7 +89,7 @@
}
if (isa<BinaryOperator>(I) || isa<ShiftInst>(I))
- return ConstantExpr::get(I->getOpcode(), Op0, Op1);
+ return ConstantExpr::get(I->getOpcode(), Op0, Op1);
switch (I->getOpcode()) {
default: return 0;
@@ -118,7 +118,7 @@
//
bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
TerminatorInst *T = BB->getTerminator();
-
+
// Branch - See if we are conditional jumping on constant
if (BranchInst *BI = dyn_cast<BranchInst>(T)) {
if (BI->isUnconditional()) return false; // Can't optimize uncond branch
@@ -131,8 +131,8 @@
BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
BasicBlock *OldDest = Cond->getValue() ? Dest2 : Dest1;
- //cerr << "Function: " << T->getParent()->getParent()
- // << "\nRemoving branch from " << T->getParent()
+ //cerr << "Function: " << T->getParent()->getParent()
+ // << "\nRemoving branch from " << T->getParent()
// << "\n\nTo: " << OldDest << endl;
// Let the basic block know that we are letting go of it. Based on this,
@@ -145,7 +145,7 @@
BI->setUnconditionalDest(Destination);
return true;
} else if (Dest2 == Dest1) { // Conditional branch to same location?
- // This branch matches something like this:
+ // This branch matches something like this:
// br bool %cond, label %Dest, label %Dest
// and changes it into: br label %Dest
@@ -294,7 +294,7 @@
if (Name == "llvm.isunordered")
return ConstantBool::get(IsNAN(Op1V) || IsNAN(Op2V));
- else
+ else
if (Name == "pow") {
errno = 0;
double V = pow(Op1V, Op2V);
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.75 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.76
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.75 Tue Nov 30 01:01:15 2004
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- PromoteMemoryToRegister.cpp - Convert allocas to registers ---------===//
-//
+//
// 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 promote memory references to be register references. It promotes
@@ -48,7 +48,7 @@
} else {
return false; // Not a load or store.
}
-
+
return true;
}
@@ -107,7 +107,7 @@
void MarkDominatingPHILive(BasicBlock *BB, unsigned AllocaNum,
std::set<PHINode*> &DeadPHINodes);
void PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI);
- void PromoteLocallyUsedAllocas(BasicBlock *BB,
+ void PromoteLocallyUsedAllocas(BasicBlock *BB,
const std::vector<AllocaInst*> &AIs);
void RenamePass(BasicBlock *BB, BasicBlock *Pred,
@@ -267,13 +267,13 @@
if (AST && isa<PointerType>(PN->getType()))
AST->deleteValue(PN);
- PN->getParent()->getInstList().erase(PN);
+ PN->getParent()->getInstList().erase(PN);
}
- // Keep the reverse mapping of the 'Allocas' array.
+ // Keep the reverse mapping of the 'Allocas' array.
AllocaLookup[Allocas[AllocaNum]] = AllocaNum;
}
-
+
// Process all allocas which are only used in a single basic block.
for (std::map<BasicBlock*, std::vector<AllocaInst*> >::iterator I =
LocallyUsedAllocas.begin(), E = LocallyUsedAllocas.end(); I != E; ++I){
@@ -327,7 +327,7 @@
// have incoming values for all predecessors. Loop over all PHI nodes we have
// created, inserting undef values if they are missing any incoming values.
//
- for (std::map<BasicBlock*, std::vector<PHINode *> >::iterator I =
+ for (std::map<BasicBlock*, std::vector<PHINode *> >::iterator I =
NewPhiNodes.begin(), E = NewPhiNodes.end(); I != E; ++I) {
std::vector<BasicBlock*> Preds(pred_begin(I->first), pred_end(I->first));
@@ -449,7 +449,7 @@
} else {
// Uses of the uninitialized memory location shall get undef.
Value *CurVal = UndefValue::get(AI->getAllocatedType());
-
+
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
Instruction *Inst = I++;
if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
@@ -572,7 +572,7 @@
// don't revisit nodes
if (Visited.count(BB)) return;
-
+
// mark as visited
Visited.insert(BB);
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.68 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.69
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.68 Thu Apr 21 00:31:13 2005
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- SimplifyCFG.cpp - Code to perform CFG simplification ---------------===//
-//
+//
// 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.
-//
+//
//===----------------------------------------------------------------------===//
//
// Peephole optimize the CFG.
@@ -81,7 +81,7 @@
PN->addIncoming(OldValPN->getIncomingValue(i),
OldValPN->getIncomingBlock(i));
} else {
- for (std::vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(),
+ for (std::vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(),
End = BBPreds.end(); PredI != End; ++PredI) {
// Add an incoming value for each of the new incoming values...
PN->addIncoming(OldVal, *PredI);
@@ -97,7 +97,7 @@
/// which entry into BB will be taken. Also, return by references the block
/// that will be entered from if the condition is true, and the block that will
/// be entered if the condition is false.
-///
+///
///
static Value *GetIfCondition(BasicBlock *BB,
BasicBlock *&IfTrue, BasicBlock *&IfFalse) {
@@ -240,7 +240,7 @@
case Instruction::SetGE:
break; // These are all cheap and non-trapping instructions.
}
-
+
// Okay, we can only really hoist these out if their operands are not
// defined in the conditional region.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
@@ -317,7 +317,7 @@
return true;
} else if (Cond->getOpcode() == Instruction::And) {
CompVal = GatherConstantSetNEs(Cond, Values);
-
+
// Return false to indicate that the condition is false if the CompVal is
// equal to one of the constants.
return false;
@@ -360,7 +360,7 @@
PN->getIncomingValueForBlock(SI2BB))
return false;
}
-
+
return true;
}
@@ -397,7 +397,7 @@
if (BI->isConditional() && BI->getCondition()->hasOneUse())
if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))
if ((SCI->getOpcode() == Instruction::SetEQ ||
- SCI->getOpcode() == Instruction::SetNE) &&
+ SCI->getOpcode() == Instruction::SetNE) &&
isa<ConstantInt>(SCI->getOperand(1)))
return SCI->getOperand(0);
return 0;
@@ -406,7 +406,7 @@
// Given a value comparison instruction, decode all of the 'cases' that it
// represents and return the 'default' block.
static BasicBlock *
-GetValueEqualityComparisonCases(TerminatorInst *TI,
+GetValueEqualityComparisonCases(TerminatorInst *TI,
std::vector<std::pair<ConstantInt*,
BasicBlock*> > &Cases) {
if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
@@ -427,7 +427,7 @@
// EliminateBlockCases - Given an vector of bb/value pairs, remove any entries
// in the list that match the specified block.
-static void EliminateBlockCases(BasicBlock *BB,
+static void EliminateBlockCases(BasicBlock *BB,
std::vector<std::pair<ConstantInt*, BasicBlock*> > &Cases) {
for (unsigned i = 0, e = Cases.size(); i != e; ++i)
if (Cases[i].second == BB) {
@@ -491,7 +491,7 @@
BasicBlock *PredDef = GetValueEqualityComparisonCases(Pred->getTerminator(),
PredCases);
EliminateBlockCases(PredDef, PredCases); // Remove default from cases.
-
+
// Find information about how control leaves this block.
std::vector<std::pair<ConstantInt*, BasicBlock*> > ThisCases;
BasicBlock *ThisDef = GetValueEqualityComparisonCases(TI, ThisCases);
@@ -608,7 +608,7 @@
while (!Preds.empty()) {
BasicBlock *Pred = Preds.back();
Preds.pop_back();
-
+
// See if the predecessor is a comparison with the same value.
TerminatorInst *PTI = Pred->getTerminator();
Value *PCV = isValueEqualityComparison(PTI); // PredCondVal
@@ -719,7 +719,7 @@
}
NewSI->setSuccessor(i, InfLoopBlock);
}
-
+
Changed = true;
}
}
@@ -750,7 +750,7 @@
// broken BB), instead clone it, and remove BI.
if (isa<TerminatorInst>(I1))
goto HoistTerminator;
-
+
// For a normal instruction, we just move one to right before the branch,
// then replace all uses of the other with the first. Finally, we remove
// the now redundant second instruction.
@@ -758,7 +758,7 @@
if (!I2->use_empty())
I2->replaceAllUsesWith(I1);
BB2->getInstList().erase(I2);
-
+
I1 = BB1->begin();
I2 = BB2->begin();
} while (I1->getOpcode() == I2->getOpcode() && I1->isIdenticalTo(I2));
@@ -804,7 +804,7 @@
// Update any PHI nodes in our new successors.
for (succ_iterator SI = succ_begin(BB1), E = succ_end(BB1); SI != E; ++SI)
AddPredecessorToBlock(*SI, BIParent, BB1);
-
+
BI->eraseFromParent();
return true;
}
@@ -850,13 +850,13 @@
Instruction &I = BB->back();
// If this instruction is used, replace uses with an arbitrary
// constant value. Because control flow can't get here, we don't care
- // what we replace the value with. Note that since this block is
+ // what we replace the value with. Note that since this block is
// unreachable, and all values contained within it must dominate their
// uses, that all uses will eventually be removed.
- if (!I.use_empty())
+ if (!I.use_empty())
// Make all users of this instruction reference the constant instead
I.replaceAllUsesWith(Constant::getNullValue(I.getType()));
-
+
// Remove the instruction from the basic block
BB->getInstList().pop_back();
}
@@ -886,11 +886,11 @@
//
if (!PropagatePredecessorsForPHIs(BB, Succ)) {
DEBUG(std::cerr << "Killing Trivial BB: \n" << *BB);
-
+
if (isa<PHINode>(&BB->front())) {
std::vector<BasicBlock*>
OldSuccPreds(pred_begin(Succ), pred_end(Succ));
-
+
// Move all PHI nodes in BB to Succ if they are alive, otherwise
// delete them.
while (PHINode *PN = dyn_cast<PHINode>(&BB->front()))
@@ -903,7 +903,7 @@
// strictly dominated Succ.
BB->getInstList().remove(BB->begin());
Succ->getInstList().push_front(PN);
-
+
// We need to add new entries for the PHI node to account for
// predecessors of Succ that the PHI node does not take into
// account. At this point, since we know that BB dominated succ,
@@ -915,7 +915,7 @@
PN->addIncoming(PN, OldSuccPreds[i]);
}
}
-
+
// Everything that jumped to BB now goes to Succ.
std::string OldName = BB->getName();
BB->replaceAllUsesWith(Succ);
@@ -948,7 +948,7 @@
else
CondBranchPreds.push_back(BI);
}
-
+
// If we found some, do the transformation!
if (!UncondBranchPreds.empty()) {
while (!UncondBranchPreds.empty()) {
@@ -1061,7 +1061,7 @@
// is now a fall through...
BranchInst *BI = new BranchInst(II->getNormalDest(), II);
Pred->getInstList().remove(II); // Take out of symbol table
-
+
// Insert the call now...
std::vector<Value*> Args(II->op_begin()+3, II->op_end());
CallInst *CI = new CallInst(II->getCalledValue(), Args,
@@ -1071,7 +1071,7 @@
delete II;
Changed = true;
}
-
+
Preds.pop_back();
}
@@ -1153,7 +1153,7 @@
Instruction::BinaryOps Opcode =
PBI->getSuccessor(0) == TrueDest ?
Instruction::Or : Instruction::And;
- Value *NewCond =
+ Value *NewCond =
BinaryOperator::create(Opcode, PBI->getCondition(),
New, "bothcond", PBI);
PBI->setCondition(NewCond);
@@ -1179,7 +1179,7 @@
OnlyPred = 0; // There are multiple different predecessors...
break;
}
-
+
if (OnlyPred)
if (BranchInst *PBI = dyn_cast<BranchInst>(OnlyPred->getTerminator()))
if (PBI->isConditional() &&
@@ -1275,7 +1275,7 @@
// place to note that the call does not throw though.
BranchInst *BI = new BranchInst(II->getNormalDest(), II);
II->removeFromParent(); // Take out of symbol table
-
+
// Insert the call now...
std::vector<Value*> Args(II->op_begin()+3, II->op_end());
CallInst *CI = new CallInst(II->getCalledValue(), Args,
@@ -1339,23 +1339,23 @@
// Delete the unconditional branch from the predecessor...
OnlyPred->getInstList().pop_back();
-
+
// Move all definitions in the successor to the predecessor...
OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList());
-
+
// Make all PHI nodes that referred to BB now refer to Pred as their
// source...
BB->replaceAllUsesWith(OnlyPred);
std::string OldName = BB->getName();
- // Erase basic block from the function...
+ // Erase basic block from the function...
M->getBasicBlockList().erase(BB);
// Inherit predecessors name if it exists...
if (!OldName.empty() && !OnlyPred->hasName())
OnlyPred->setName(OldName);
-
+
return true;
}
@@ -1393,19 +1393,19 @@
// instruction can't handle, remove them now.
std::sort(Values.begin(), Values.end(), ConstantIntOrdering());
Values.erase(std::unique(Values.begin(), Values.end()), Values.end());
-
+
// Figure out which block is which destination.
BasicBlock *DefaultBB = BI->getSuccessor(1);
BasicBlock *EdgeBB = BI->getSuccessor(0);
if (!TrueWhenEqual) std::swap(DefaultBB, EdgeBB);
-
+
// Create the new switch instruction now.
SwitchInst *New = new SwitchInst(CompVal, DefaultBB,Values.size(),BI);
-
+
// Add all of the 'cases' to the switch instruction.
for (unsigned i = 0, e = Values.size(); i != e; ++i)
New->addCase(Values[i], EdgeBB);
-
+
// We added edges from PI to the EdgeBB. As such, if there were any
// PHI nodes in EdgeBB, they need entries to be added corresponding to
// the number of edges added.
@@ -1489,7 +1489,7 @@
}
Pred = PN->getIncomingBlock(1);
- if (CanPromote &&
+ if (CanPromote &&
cast<BranchInst>(Pred->getTerminator())->isUnconditional()) {
IfBlock2 = Pred;
DomBlock = *pred_begin(Pred);
@@ -1539,6 +1539,6 @@
}
}
}
-
+
return Changed;
}
Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.32 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.33
--- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.32 Sat Oct 16 13:10:19 2004
+++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- UnifyFunctionExitNodes.cpp - Make all functions have a single exit -===//
-//
+//
// 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 used to ensure that functions have at most one return
@@ -64,7 +64,7 @@
UnwindBlock = new BasicBlock("UnifiedUnwindBlock", &F);
new UnwindInst(UnwindBlock);
- for (std::vector<BasicBlock*>::iterator I = UnwindingBlocks.begin(),
+ for (std::vector<BasicBlock*>::iterator I = UnwindingBlocks.begin(),
E = UnwindingBlocks.end(); I != E; ++I) {
BasicBlock *BB = *I;
BB->getInstList().pop_back(); // Remove the unwind insn
@@ -81,7 +81,7 @@
UnreachableBlock = new BasicBlock("UnifiedUnreachableBlock", &F);
new UnreachableInst(UnreachableBlock);
- for (std::vector<BasicBlock*>::iterator I = UnreachableBlocks.begin(),
+ for (std::vector<BasicBlock*>::iterator I = UnreachableBlocks.begin(),
E = UnreachableBlocks.end(); I != E; ++I) {
BasicBlock *BB = *I;
BB->getInstList().pop_back(); // Remove the unreachable inst.
@@ -99,7 +99,7 @@
}
// Otherwise, we need to insert a new basic block into the function, add a PHI
- // node (if the function returns a value), and convert all of the return
+ // node (if the function returns a value), and convert all of the return
// instructions into unconditional branches.
//
BasicBlock *NewRetBlock = new BasicBlock("UnifiedReturnBlock", &F);
@@ -115,7 +115,7 @@
// Loop over all of the blocks, replacing the return instruction with an
// unconditional branch.
//
- for (std::vector<BasicBlock*>::iterator I = ReturningBlocks.begin(),
+ for (std::vector<BasicBlock*>::iterator I = ReturningBlocks.begin(),
E = ReturningBlocks.end(); I != E; ++I) {
BasicBlock *BB = *I;
Index: llvm/lib/Transforms/Utils/ValueMapper.cpp
diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.19 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.20
--- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.19 Sat Oct 16 13:10:31 2004
+++ llvm/lib/Transforms/Utils/ValueMapper.cpp Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- ValueMapper.cpp - Interface shared by lib/Transforms/Utils ---------===//
-//
+//
// 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 defines the MapValue function, which is shared by various parts of
@@ -23,7 +23,7 @@
Value *llvm::MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
Value *&VMSlot = VM[V];
if (VMSlot) return VMSlot; // Does it exist in the map yet?
-
+
// Global values do not need to be seeded into the ValueMap if they are using
// the identity mapping.
if (isa<GlobalValue>(V))
Index: llvm/lib/Transforms/Utils/ValueMapper.h
diff -u llvm/lib/Transforms/Utils/ValueMapper.h:1.5 llvm/lib/Transforms/Utils/ValueMapper.h:1.6
--- llvm/lib/Transforms/Utils/ValueMapper.h:1.5 Wed May 19 04:08:12 2004
+++ llvm/lib/Transforms/Utils/ValueMapper.h Thu Apr 21 18:45:34 2005
@@ -1,10 +1,10 @@
//===- ValueMapper.h - Interface shared by lib/Transforms/Utils -*- C++ -*-===//
-//
+//
// 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 defines the MapValue interface which is used by various parts of
More information about the llvm-commits
mailing list