mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
|
@@ -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.
|
||||
//
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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 != e; ++i) {
|
||||
Value *V = PN->removeIncomingValue(Preds[i], false);
|
||||
@@ -266,7 +266,7 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now that the PHI nodes are updated, actually move the edges from
|
||||
// Preds to point to NewBB instead of BB.
|
||||
//
|
||||
@@ -276,14 +276,14 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
|
||||
if (TI->getSuccessor(s) == BB)
|
||||
TI->setSuccessor(s, NewBB);
|
||||
}
|
||||
|
||||
|
||||
} else { // Otherwise the loop is dead...
|
||||
for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I) {
|
||||
PHINode *PN = cast<PHINode>(I);
|
||||
// Insert dummy values as the incoming value...
|
||||
PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NewBB;
|
||||
}
|
||||
|
||||
@@ -300,15 +300,15 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
PI != PE; ++PI)
|
||||
if (!L->contains(*PI)) // Coming in from outside the loop?
|
||||
OutsideBlocks.push_back(*PI); // Keep track of it...
|
||||
|
||||
|
||||
// Split out the loop pre-header
|
||||
BasicBlock *NewBB =
|
||||
SplitBlockPredecessors(Header, ".preheader", OutsideBlocks);
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Update analysis results now that we have performed the transformation
|
||||
//
|
||||
|
||||
|
||||
// We know that we have loop information to update... update it now.
|
||||
if (Loop *Parent = L->getParentLoop())
|
||||
Parent->addBasicBlockToLoop(NewBB, getAnalysis<LoopInfo>());
|
||||
@@ -330,7 +330,7 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
|
||||
DominatorSet &DS = getAnalysis<DominatorSet>(); // Update dominator info
|
||||
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||||
|
||||
|
||||
|
||||
// Update the dominator tree information.
|
||||
// The immediate dominator of the preheader is the immediate dominator of
|
||||
@@ -353,16 +353,16 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
E = df_end(PHDomTreeNode); DFI != E; ++DFI)
|
||||
DS.addDominator((*DFI)->getBlock(), NewBB);
|
||||
}
|
||||
|
||||
|
||||
// Update immediate dominator information if we have it...
|
||||
if (ImmediateDominators *ID = getAnalysisToUpdate<ImmediateDominators>()) {
|
||||
// Whatever i-dominated the header node now immediately dominates NewBB
|
||||
ID->addNewBlock(NewBB, ID->get(Header));
|
||||
|
||||
|
||||
// The preheader now is the immediate dominator for the header node...
|
||||
ID->setImmediateDominator(Header, NewBB);
|
||||
}
|
||||
|
||||
|
||||
// Update dominance frontier information...
|
||||
if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>()) {
|
||||
// The DF(NewBB) is just (DF(Header)-Header), because NewBB dominates
|
||||
@@ -405,7 +405,7 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
/// outside of the loop.
|
||||
BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
|
||||
DominatorSet &DS = getAnalysis<DominatorSet>();
|
||||
|
||||
|
||||
std::vector<BasicBlock*> LoopBlocks;
|
||||
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I)
|
||||
if (L->contains(*I))
|
||||
@@ -579,7 +579,7 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
|
||||
// Move the new backedge block to right after the last backedge block.
|
||||
Function::iterator InsertPos = BackedgeBlocks.back(); ++InsertPos;
|
||||
F->getBasicBlockList().splice(InsertPos, F->getBasicBlockList(), BEBlock);
|
||||
|
||||
|
||||
// Now that the block has been inserted into the function, create PHI nodes in
|
||||
// the backedge block which correspond to any PHI nodes in the header block.
|
||||
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
|
||||
@@ -609,7 +609,7 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Delete all of the incoming values from the old PN except the preheader's
|
||||
assert(PreheaderIdx != ~0U && "PHI has no preheader entry??");
|
||||
if (PreheaderIdx != 0) {
|
||||
@@ -825,7 +825,7 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB,
|
||||
for (DominatorSet::DomSetType::const_iterator PDI = PredDoms.begin(),
|
||||
PDE = PredDoms.end(); PDI != PDE; ++PDI) {
|
||||
BasicBlock *PredDom = *PDI;
|
||||
|
||||
|
||||
// If the NewBBSucc node is in DF(PredDom), then PredDom didn't
|
||||
// dominate NewBBSucc but did dominate a predecessor of it. Now we
|
||||
// change this entry to include NewBB in the DF instead of NewBBSucc.
|
||||
@@ -846,7 +846,7 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ShouldRemove)
|
||||
DF->removeFromFrontier(DFI, NewBBSucc);
|
||||
DF->addToFrontier(DFI, NewBB);
|
||||
|
@@ -1,10 +1,10 @@
|
||||
//===- LowerAllocations.cpp - Reduce malloc & free insts to 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.
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LowerAllocations transformation is a target-dependent tranformation
|
||||
@@ -49,7 +49,7 @@ namespace {
|
||||
virtual bool doInitialization(Function &F) {
|
||||
return BasicBlockPass::doInitialization(F);
|
||||
}
|
||||
|
||||
|
||||
/// runOnBasicBlock - This method does the actual work of converting
|
||||
/// instructions over, assuming that the pass has already been initialized.
|
||||
///
|
||||
@@ -104,7 +104,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) {
|
||||
if (MallocInst *MI = dyn_cast<MallocInst>(I)) {
|
||||
const Type *AllocTy = MI->getType()->getElementType();
|
||||
|
||||
|
||||
// malloc(type) becomes sbyte *malloc(size)
|
||||
Value *MallocArg;
|
||||
if (LowerMallocArgToInteger)
|
||||
@@ -133,7 +133,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
|
||||
const FunctionType *MallocFTy = MallocFunc->getFunctionType();
|
||||
std::vector<Value*> MallocArgs;
|
||||
|
||||
|
||||
if (MallocFTy->getNumParams() > 0 || MallocFTy->isVarArg()) {
|
||||
if (MallocFTy->isVarArg()) {
|
||||
if (MallocArg->getType() != IntPtrTy)
|
||||
@@ -150,14 +150,14 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
|
||||
// Create the call to Malloc...
|
||||
CallInst *MCall = new CallInst(MallocFunc, MallocArgs, "", I);
|
||||
|
||||
|
||||
// Create a cast instruction to convert to the right type...
|
||||
Value *MCast;
|
||||
if (MCall->getType() != Type::VoidTy)
|
||||
MCast = new CastInst(MCall, MI->getType(), "", I);
|
||||
else
|
||||
MCast = Constant::getNullValue(MI->getType());
|
||||
|
||||
|
||||
// Replace all uses of the old malloc inst with the cast inst
|
||||
MI->replaceAllUsesWith(MCast);
|
||||
I = --BBIL.erase(I); // remove and delete the malloc instr...
|
||||
@@ -166,7 +166,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
|
||||
const FunctionType *FreeFTy = FreeFunc->getFunctionType();
|
||||
std::vector<Value*> FreeArgs;
|
||||
|
||||
|
||||
if (FreeFTy->getNumParams() > 0 || FreeFTy->isVarArg()) {
|
||||
Value *MCast = FI->getOperand(0);
|
||||
if (FreeFTy->getNumParams() > 0 &&
|
||||
@@ -178,10 +178,10 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
||||
// If malloc is prototyped to take extra arguments, pass nulls.
|
||||
for (unsigned i = 1; i < FreeFTy->getNumParams(); ++i)
|
||||
FreeArgs.push_back(Constant::getNullValue(FreeFTy->getParamType(i)));
|
||||
|
||||
|
||||
// Insert a call to the free function...
|
||||
new CallInst(FreeFunc, FreeArgs, "", I);
|
||||
|
||||
|
||||
// Delete the old free instruction
|
||||
I = --BBIL.erase(I);
|
||||
Changed = true;
|
||||
|
@@ -1,10 +1,10 @@
|
||||
//===- LowerInvoke.cpp - Eliminate Invoke & Unwind 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.
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This transformation is designed for use by code generators which do not yet
|
||||
@@ -153,7 +153,7 @@ void LowerInvoke::createAbortMessage() {
|
||||
Constant *Msg =
|
||||
ConstantArray::get("ERROR: Exception thrown, but not caught!\n");
|
||||
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
|
||||
|
||||
|
||||
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
|
||||
GlobalValue::InternalLinkage,
|
||||
Msg, "abortmsg", &M);
|
||||
@@ -192,7 +192,7 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) {
|
||||
unsigned NumArgs = FT->getNumParams();
|
||||
for (unsigned i = 0; i != 3; ++i)
|
||||
if (i < NumArgs && FT->getParamType(i) != Args[i]->getType())
|
||||
Args[i] = ConstantExpr::getCast(cast<Constant>(Args[i]),
|
||||
Args[i] = ConstantExpr::getCast(cast<Constant>(Args[i]),
|
||||
FT->getParamType(i));
|
||||
|
||||
new CallInst(WriteFn, Args, "", IB);
|
||||
@@ -209,7 +209,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
|
||||
std::vector<Value*>(II->op_begin()+3,
|
||||
II->op_end()), Name,II);
|
||||
II->replaceAllUsesWith(NewCall);
|
||||
|
||||
|
||||
// Insert an unconditional branch to the normal destination.
|
||||
new BranchInst(II->getNormalDest(), II);
|
||||
|
||||
@@ -269,7 +269,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
Value *NextFieldPtr = new GetElementPtrInst(JmpBuf, Idx, "NextField", II);
|
||||
new StoreInst(OldEntry, NextFieldPtr, II);
|
||||
new StoreInst(JmpBuf, JBListHead, II);
|
||||
|
||||
|
||||
// Call setjmp, passing in the address of the jmpbuffer.
|
||||
Idx[1] = ConstantUInt::get(Type::UIntTy, 1);
|
||||
Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf", II);
|
||||
@@ -283,7 +283,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
// destination.
|
||||
SplitCriticalEdge(II, 0, this);
|
||||
Instruction *InsertLoc = II->getNormalDest()->begin();
|
||||
|
||||
|
||||
// Insert a normal call instruction on the normal execution path.
|
||||
std::string Name = II->getName(); II->setName("");
|
||||
Value *NewCall = new CallInst(II->getCalledValue(),
|
||||
@@ -291,7 +291,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
II->op_end()), Name,
|
||||
InsertLoc);
|
||||
II->replaceAllUsesWith(NewCall);
|
||||
|
||||
|
||||
// If we got this far, then no exception was thrown and we can pop our
|
||||
// jmpbuf entry off.
|
||||
new StoreInst(OldEntry, JBListHead, InsertLoc);
|
||||
@@ -301,8 +301,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
|
||||
// Remove the InvokeInst now.
|
||||
BB->getInstList().erase(II);
|
||||
++NumLowered; Changed = true;
|
||||
|
||||
++NumLowered; Changed = true;
|
||||
|
||||
} else if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
|
||||
if (UnwindBlock == 0) {
|
||||
// Create two new blocks, the unwind block and the terminate block. Add
|
||||
@@ -330,7 +330,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
|
||||
// Remove the UnwindInst now.
|
||||
BB->getInstList().erase(UI);
|
||||
++NumLowered; Changed = true;
|
||||
++NumLowered; Changed = true;
|
||||
}
|
||||
|
||||
// If an unwind instruction was inserted, we need to set up the Unwind and
|
||||
@@ -370,7 +370,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
|
||||
|
||||
// Now we set up the terminate block.
|
||||
RI = TermBlock->getTerminator();
|
||||
|
||||
|
||||
// Insert a new call to write(2, AbortMessage, AbortMessageLength);
|
||||
writeAbortMessage(RI);
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
//===- LowerSelect.cpp - Transform select insts to branches ---------------===//
|
||||
//
|
||||
//
|
||||
// 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 lowers select instructions into conditional branches for targets
|
||||
@@ -86,7 +86,7 @@ bool LowerSelect::runOnFunction(Function &F) {
|
||||
// Use the PHI instead of the select.
|
||||
SI->replaceAllUsesWith(PN);
|
||||
NewCont->getInstList().erase(SI);
|
||||
|
||||
|
||||
Changed = true;
|
||||
break; // This block is done with.
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
//===- LowerSwitch.cpp - Eliminate Switch 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.
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LowerSwitch transformation rewrites switch statements with a sequence of
|
||||
|
@@ -1,10 +1,10 @@
|
||||
//===- Mem2Reg.cpp - The -mem2reg pass, a wrapper around the Utils lib ----===//
|
||||
//
|
||||
//
|
||||
// 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 a simple pass wrapper around the PromoteMemToReg function call
|
||||
@@ -53,7 +53,7 @@ bool PromotePass::runOnFunction(Function &F) {
|
||||
|
||||
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||||
DominanceFrontier &DF = getAnalysis<DominanceFrontier>();
|
||||
|
||||
|
||||
while (1) {
|
||||
Allocas.clear();
|
||||
|
||||
|
@@ -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 @@ bool llvm::isAllocaPromotable(const AllocaInst *AI, const TargetData &TD) {
|
||||
} else {
|
||||
return false; // Not a load or store.
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace {
|
||||
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 @@ void PromoteMem2Reg::run() {
|
||||
|
||||
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 @@ void PromoteMem2Reg::run() {
|
||||
// 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 @@ void PromoteMem2Reg::PromoteLocallyUsedAlloca(BasicBlock *BB, AllocaInst *AI) {
|
||||
} 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 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
|
||||
|
||||
// don't revisit nodes
|
||||
if (Visited.count(BB)) return;
|
||||
|
||||
|
||||
// mark as visited
|
||||
Visited.insert(BB);
|
||||
|
||||
|
@@ -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 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
|
||||
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 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
|
||||
/// 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 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB,
|
||||
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 @@ static bool GatherValueComparisons(Instruction *Cond, Value *&CompVal,
|
||||
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 @@ static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2) {
|
||||
PN->getIncomingValueForBlock(SI2BB))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ static Value *isValueEqualityComparison(TerminatorInst *TI) {
|
||||
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 @@ static Value *isValueEqualityComparison(TerminatorInst *TI) {
|
||||
// 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 @@ GetValueEqualityComparisonCases(TerminatorInst *TI,
|
||||
|
||||
// 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 @@ static bool SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
|
||||
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 @@ static bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI) {
|
||||
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 @@ static bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI) {
|
||||
}
|
||||
NewSI->setSuccessor(i, InfLoopBlock);
|
||||
}
|
||||
|
||||
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
@@ -750,7 +750,7 @@ static bool HoistThenElseCodeToIf(BranchInst *BI) {
|
||||
// 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 @@ static bool HoistThenElseCodeToIf(BranchInst *BI) {
|
||||
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 @@ HoistTerminator:
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
//
|
||||
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
else
|
||||
CondBranchPreds.push_back(BI);
|
||||
}
|
||||
|
||||
|
||||
// If we found some, do the transformation!
|
||||
if (!UncondBranchPreds.empty()) {
|
||||
while (!UncondBranchPreds.empty()) {
|
||||
@@ -1061,7 +1061,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
delete II;
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
|
||||
Preds.pop_back();
|
||||
}
|
||||
|
||||
@@ -1153,7 +1153,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
// 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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
}
|
||||
|
||||
Pred = PN->getIncomingBlock(1);
|
||||
if (CanPromote &&
|
||||
if (CanPromote &&
|
||||
cast<BranchInst>(Pred->getTerminator())->isUnconditional()) {
|
||||
IfBlock2 = Pred;
|
||||
DomBlock = *pred_begin(Pred);
|
||||
@@ -1539,6 +1539,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
@@ -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 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
|
||||
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 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
|
||||
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 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
|
||||
}
|
||||
|
||||
// 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 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) {
|
||||
// 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;
|
||||
|
||||
|
@@ -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 @@ using namespace llvm;
|
||||
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))
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user