diff options
Diffstat (limited to 'lib/Transforms/Utils')
20 files changed, 203 insertions, 203 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index efaf22d459..f344580634 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -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 @@ void llvm::ReplaceInstWithValue(BasicBlock::InstListType &BIL, I.replaceAllUsesWith(V); std::string OldName = I.getName(); - + // Delete the unnecessary instruction now... BI = BIL.erase(BI); @@ -92,7 +92,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { 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 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { // Create the return... NewTI = new ReturnInst(RetVal); } - break; + break; case Instruction::Invoke: // Should convert to call case Instruction::Switch: // Should remove entry diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 87b019f77a..acc1e2cd3f 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -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 @@ namespace { 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 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { 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 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { // 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. // diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 6440851b9d..7eaf147dc6 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -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 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, 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 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, 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 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, 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 @@ Function *llvm::CloneFunction(const Function *F, // 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 @@ Function *llvm::CloneFunction(const Function *F, std::vector<ReturnInst*> Returns; // Ignore returns cloned... CloneFunctionInto(NewF, F, ValueMap, Returns); - return NewF; + return NewF; } diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index 66e005e82c..fd242870b2 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/lib/Transforms/Utils/CloneModule.cpp @@ -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 diff --git a/lib/Transforms/Utils/CloneTrace.cpp b/lib/Transforms/Utils/CloneTrace.cpp index 52bdd15dc3..5eca653fa4 100644 --- a/lib/Transforms/Utils/CloneTrace.cpp +++ b/lib/Transforms/Utils/CloneTrace.cpp @@ -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 @@ std::vector<BasicBlock *> 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 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) { //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 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) { //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 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) { 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 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) { } } } - + //return new vector of basic blocks return clonedTrace; } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index cf9cafb04a..85b9dcb131 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -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 @@ namespace { 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::splitReturnBlocks() { // 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 @@ void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs) { 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 @@ Function *CodeExtractor::constructFunction(const Values &inputs, 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, 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 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // 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 @@ void CodeExtractor::moveCodeToFunction(Function *newFunction) { /// /// 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 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { 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 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { // 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 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { 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 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { --i; --e; } } - + //std::cerr << "NEW FUNCTION: " << *newFunction; // verifyFunction(*newFunction); @@ -744,5 +744,5 @@ Function* llvm::ExtractLoop(DominatorSet &DS, Loop *L, bool AggregateArgs) { 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); } diff --git a/lib/Transforms/Utils/DemoteRegToStack.cpp b/lib/Transforms/Utils/DemoteRegToStack.cpp index 74d618c93c..ecd92f7fdb 100644 --- a/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/lib/Transforms/Utils/DemoteRegToStack.cpp @@ -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 diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 6bfdda230e..97ee58f71a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -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 @@ bool llvm::InlineFunction(InvokeInst *II) {return InlineFunction(CallSite(II));} // 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 @@ bool llvm::InlineFunction(CallSite CS) { { // 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 @@ bool llvm::InlineFunction(CallSite CS) { } 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 @@ bool llvm::InlineFunction(CallSite CS) { 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 @@ bool llvm::InlineFunction(CallSite CS) { 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 @@ bool llvm::InlineFunction(CallSite CS) { // 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 @@ bool llvm::InlineFunction(CallSite CS) { // 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 @@ bool llvm::InlineFunction(CallSite CS) { 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 @@ bool llvm::InlineFunction(CallSite CS) { // 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 @@ bool llvm::InlineFunction(CallSite CS) { // nuke the result. TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType())); } - + // Since we are now done with the Call/Invoke, we can delete it. TheCall->eraseFromParent(); diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index b188884a40..915c6676ab 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -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 @@ bool llvm::doConstantPropagation(BasicBlock::iterator &II) { 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 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I) { 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 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I) { 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 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I) { } 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 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I) { // 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 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) { 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 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) { 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 @@ Constant *llvm::ConstantFoldCall(Function *F, if (Name == "llvm.isunordered") return ConstantBool::get(IsNAN(Op1V) || IsNAN(Op2V)); - else + else if (Name == "pow") { errno = 0; double V = pow(Op1V, Op2V); diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index ba63f9b371..3e4312681d 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -1,10 +1,10 @@ //===- LoopSimplify.cpp - Loop Canonicalization 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 several transformations to transform natural loops into a @@ -60,7 +60,7 @@ namespace { AliasAnalysis *AA; virtual bool runOnFunction(Function &F); - + virtual void getAnalysisUsage(AnalysisUsage &AU) const { // We need loop information to identify the loops... AU.addRequired<LoopInfo>(); @@ -204,13 +204,13 @@ bool LoopSimplify::ProcessLoop(Loop *L) { BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB, const char *Suffix, const std::vector<BasicBlock*> &Preds) { - + // Create new basic block, insert right before the original block... BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB->getParent(), BB); // The preheader first gets an unconditional branch to the loop header... BranchInst *BI = new BranchInst(BB, NewBB); - + // For every PHI node in the block, insert a PHI node into NewBB where the // incoming values from the out of loop edges are moved to NewBB. We have two // possible cases here. If the loop is dead, we just insert dummy entries @@ -232,13 +232,13 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB, InVal = 0; break; } - + // If the values coming into the block are not the same, we need a PHI. if (InVal == 0) { // Create the new PHI node, insert it into NewBB at the end of the block PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI); if (AA) AA->copyValue(PN, NewPHI); - + // Move all of the edges from blocks outside the loop to the new PHI for (unsigned i = 0, e = Preds.size(); i != |