Change uses of Function::front to Function::getEntryBlock for readability.

llvm-svn: 35265
This commit is contained in:
Dan Gohman 2007-03-22 16:38:57 +00:00
parent 085b8d7ae2
commit dcb291faa4
13 changed files with 19 additions and 15 deletions

View File

@ -33,7 +33,7 @@ unsigned ProfileInfo::getExecutionCount(BasicBlock *BB) const {
// Are there zero predecessors of this block? // Are there zero predecessors of this block?
if (PI == PE) { if (PI == PE) {
// If this is the entry block, look for the Null -> Entry edge. // If this is the entry block, look for the Null -> Entry edge.
if (BB == &BB->getParent()->front()) if (BB == &BB->getParent()->getEntryBlock())
return getEdgeWeight(0, BB); return getEdgeWeight(0, BB);
else else
return 0; // Otherwise, this is a dead block. return 0; // Otherwise, this is a dead block.

View File

@ -152,7 +152,8 @@ void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
getBlockCounts(BlockCounts); getBlockCounts(BlockCounts);
for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i) for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i)
if (&BlockCounts[i].first->getParent()->front() == BlockCounts[i].first) if (&BlockCounts[i].first->getParent()->getEntryBlock() ==
BlockCounts[i].first)
Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(), Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(),
BlockCounts[i].second)); BlockCounts[i].second));
} else { } else {

View File

@ -4328,7 +4328,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
std::vector<SDOperand> UnorderedChains; std::vector<SDOperand> UnorderedChains;
// Lower any arguments needed in this block if this is the entry block. // Lower any arguments needed in this block if this is the entry block.
if (LLVMBB == &LLVMBB->getParent()->front()) if (LLVMBB == &LLVMBB->getParent()->getEntryBlock())
LowerArguments(LLVMBB, SDL, UnorderedChains); LowerArguments(LLVMBB, SDL, UnorderedChains);
BB = FuncInfo.MBBMap[LLVMBB]; BB = FuncInfo.MBBMap[LLVMBB];

View File

@ -9946,7 +9946,8 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
if (isa<PHINode>(I) || I->mayWriteToMemory()) return false; if (isa<PHINode>(I) || I->mayWriteToMemory()) return false;
// Do not sink alloca instructions out of the entry block. // Do not sink alloca instructions out of the entry block.
if (isa<AllocaInst>(I) && I->getParent() == &DestBlock->getParent()->front()) if (isa<AllocaInst>(I) && I->getParent() ==
&DestBlock->getParent()->getEntryBlock())
return false; return false;
// We can only sink load instructions if there is nothing between the load and // We can only sink load instructions if there is nothing between the load and

View File

@ -471,7 +471,7 @@ void LICM::sink(Instruction &I) {
if (I.getType() != Type::VoidTy) if (I.getType() != Type::VoidTy)
AI = new AllocaInst(I.getType(), 0, I.getName(), AI = new AllocaInst(I.getType(), 0, I.getName(),
I.getParent()->getParent()->front().begin()); I.getParent()->getParent()->getEntryBlock().begin());
// Secondly, insert load instructions for each use of the instruction // Secondly, insert load instructions for each use of the instruction
// outside of the loop. // outside of the loop.

View File

@ -891,7 +891,7 @@ void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) {
++NumConverted; ++NumConverted;
BasicBlock *EntryBlock = AI->getParent(); BasicBlock *EntryBlock = AI->getParent();
assert(EntryBlock == &EntryBlock->getParent()->front() && assert(EntryBlock == &EntryBlock->getParent()->getEntryBlock() &&
"Not in the entry block!"); "Not in the entry block!");
EntryBlock->getInstList().remove(AI); // Take the alloca out of the program. EntryBlock->getInstList().remove(AI); // Take the alloca out of the program.

View File

@ -108,7 +108,7 @@ static bool CheckForEscapingAllocas(BasicBlock *BB,
// If this alloca is in the body of the function, or if it is a variable // If this alloca is in the body of the function, or if it is a variable
// sized allocation, we cannot tail call eliminate calls marked 'tail' // sized allocation, we cannot tail call eliminate calls marked 'tail'
// with this mechanism. // with this mechanism.
if (BB != &BB->getParent()->front() || if (BB != &BB->getParent()->getEntryBlock() ||
!isa<ConstantInt>(AI->getArraySize())) !isa<ConstantInt>(AI->getArraySize()))
CannotTCETailMarkedCall = true; CannotTCETailMarkedCall = true;
} }

View File

@ -59,7 +59,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
CodeInfo->ContainsUnwinds |= isa<UnwindInst>(BB->getTerminator()); CodeInfo->ContainsUnwinds |= isa<UnwindInst>(BB->getTerminator());
CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas; CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas;
CodeInfo->ContainsDynamicAllocas |= hasStaticAllocas && CodeInfo->ContainsDynamicAllocas |= hasStaticAllocas &&
BB != &BB->getParent()->front(); BB != &BB->getParent()->getEntryBlock();
} }
return NewBB; return NewBB;
} }

View File

@ -104,7 +104,7 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
bool HasPredsFromRegion = false; bool HasPredsFromRegion = false;
unsigned NumPredsOutsideRegion = 0; unsigned NumPredsOutsideRegion = 0;
if (Header != &Header->getParent()->front()) { if (Header != &Header->getParent()->getEntryBlock()) {
PHINode *PN = dyn_cast<PHINode>(Header->begin()); PHINode *PN = dyn_cast<PHINode>(Header->begin());
if (!PN) return; // No PHI nodes. if (!PN) return; // No PHI nodes.

View File

@ -265,9 +265,10 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// Transfer all of the allocas over in a block. Using splice means // Transfer all of the allocas over in a block. Using splice means
// that the instructions aren't removed from the symbol table, then // that the instructions aren't removed from the symbol table, then
// reinserted. // reinserted.
Caller->front().getInstList().splice(InsertPoint, Caller->getEntryBlock().getInstList().splice(
FirstNewBlock->getInstList(), InsertPoint,
AI, I); FirstNewBlock->getInstList(),
AI, I);
} }
} }
} }

View File

@ -1185,7 +1185,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
assert(BB && BB->getParent() && "Block not embedded in function!"); assert(BB && BB->getParent() && "Block not embedded in function!");
assert(BB->getTerminator() && "Degenerate basic block encountered!"); assert(BB->getTerminator() && "Degenerate basic block encountered!");
assert(&BB->getParent()->front() != BB && "Can't Simplify entry block!"); assert(&BB->getParent()->getEntryBlock() != BB &&
"Can't Simplify entry block!");
// Remove basic blocks that have no predecessors... which are unreachable. // Remove basic blocks that have no predecessors... which are unreachable.
if (pred_begin(BB) == pred_end(BB) || if (pred_begin(BB) == pred_end(BB) ||

View File

@ -1036,7 +1036,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
if (BB->getParent() == 0) if (BB->getParent() == 0)
Out << "\t\t; Error: Block without parent!"; Out << "\t\t; Error: Block without parent!";
else { else {
if (BB != &BB->getParent()->front()) { // Not the entry block? if (BB != &BB->getParent()->getEntryBlock()) { // Not the entry block?
// Output predecessors for the block... // Output predecessors for the block...
Out << "\t\t;"; Out << "\t\t;";
pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB);

View File

@ -170,7 +170,7 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const {
if (HasUndefInput && !AllowNonDominatingInstruction) if (HasUndefInput && !AllowNonDominatingInstruction)
if (Instruction *IV = dyn_cast<Instruction>(InVal)) if (Instruction *IV = dyn_cast<Instruction>(InVal))
// If it's in the entry block, it dominates everything. // If it's in the entry block, it dominates everything.
if (IV->getParent() != &IV->getParent()->getParent()->front() || if (IV->getParent() != &IV->getParent()->getParent()->getEntryBlock() ||
isa<InvokeInst>(IV)) isa<InvokeInst>(IV))
return 0; // Cannot guarantee that InVal dominates this PHINode. return 0; // Cannot guarantee that InVal dominates this PHINode.