From ecb7a77885b174cf4d001a9b48533b3979e7810d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 22 Mar 2007 16:38:57 +0000 Subject: [PATCH] Change uses of Function::front to Function::getEntryBlock for readability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35265 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ProfileInfo.cpp | 2 +- lib/Analysis/ProfileInfoLoader.cpp | 3 ++- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +- lib/Transforms/Scalar/InstructionCombining.cpp | 3 ++- lib/Transforms/Scalar/LICM.cpp | 2 +- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 2 +- lib/Transforms/Scalar/TailRecursionElimination.cpp | 2 +- lib/Transforms/Utils/CloneFunction.cpp | 2 +- lib/Transforms/Utils/CodeExtractor.cpp | 2 +- lib/Transforms/Utils/InlineFunction.cpp | 7 ++++--- lib/Transforms/Utils/SimplifyCFG.cpp | 3 ++- lib/VMCore/AsmWriter.cpp | 2 +- lib/VMCore/Instructions.cpp | 2 +- 13 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index 719eeada15a..6eead0fd6ec 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -33,7 +33,7 @@ unsigned ProfileInfo::getExecutionCount(BasicBlock *BB) const { // Are there zero predecessors of this block? if (PI == PE) { // 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); else return 0; // Otherwise, this is a dead block. diff --git a/lib/Analysis/ProfileInfoLoader.cpp b/lib/Analysis/ProfileInfoLoader.cpp index 23ceb52d8e2..dec29a40b17 100644 --- a/lib/Analysis/ProfileInfoLoader.cpp +++ b/lib/Analysis/ProfileInfoLoader.cpp @@ -152,7 +152,8 @@ void ProfileInfoLoader::getFunctionCounts(std::vectorgetParent()->front() == BlockCounts[i].first) + if (&BlockCounts[i].first->getParent()->getEntryBlock() == + BlockCounts[i].first) Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(), BlockCounts[i].second)); } else { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 70506e32fcd..5a12aeb7069 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -4328,7 +4328,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, std::vector UnorderedChains; // 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); BB = FuncInfo.MBBMap[LLVMBB]; diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 1523f01f377..12f02f758ec 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -9946,7 +9946,8 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { if (isa(I) || I->mayWriteToMemory()) return false; // Do not sink alloca instructions out of the entry block. - if (isa(I) && I->getParent() == &DestBlock->getParent()->front()) + if (isa(I) && I->getParent() == + &DestBlock->getParent()->getEntryBlock()) return false; // We can only sink load instructions if there is nothing between the load and diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 7a578a8fb42..482ac773537 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -471,7 +471,7 @@ void LICM::sink(Instruction &I) { if (I.getType() != Type::VoidTy) 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 // outside of the loop. diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index a26fcbefe81..a29fe4ad3eb 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -891,7 +891,7 @@ void SROA::ConvertToScalar(AllocationInst *AI, const Type *ActualTy) { ++NumConverted; BasicBlock *EntryBlock = AI->getParent(); - assert(EntryBlock == &EntryBlock->getParent()->front() && + assert(EntryBlock == &EntryBlock->getParent()->getEntryBlock() && "Not in the entry block!"); EntryBlock->getInstList().remove(AI); // Take the alloca out of the program. diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index c1ce9d4d3dd..cd3b79aab6c 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -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 // sized allocation, we cannot tail call eliminate calls marked 'tail' // with this mechanism. - if (BB != &BB->getParent()->front() || + if (BB != &BB->getParent()->getEntryBlock() || !isa(AI->getArraySize())) CannotTCETailMarkedCall = true; } diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index d80a83157ab..cff58ab1541 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -59,7 +59,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, CodeInfo->ContainsUnwinds |= isa(BB->getTerminator()); CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas; CodeInfo->ContainsDynamicAllocas |= hasStaticAllocas && - BB != &BB->getParent()->front(); + BB != &BB->getParent()->getEntryBlock(); } return NewBB; } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index f304df2a93d..a4e7ab8972d 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -104,7 +104,7 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) { bool HasPredsFromRegion = false; unsigned NumPredsOutsideRegion = 0; - if (Header != &Header->getParent()->front()) { + if (Header != &Header->getParent()->getEntryBlock()) { PHINode *PN = dyn_cast(Header->begin()); if (!PN) return; // No PHI nodes. diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index d57a8f58aba..a1a638b0c2c 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -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 // that the instructions aren't removed from the symbol table, then // reinserted. - Caller->front().getInstList().splice(InsertPoint, - FirstNewBlock->getInstList(), - AI, I); + Caller->getEntryBlock().getInstList().splice( + InsertPoint, + FirstNewBlock->getInstList(), + AI, I); } } } diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 91664bf2d9d..1bf72a1076e 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1185,7 +1185,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { assert(BB && BB->getParent() && "Block not embedded in function!"); 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. if (pred_begin(BB) == pred_end(BB) || diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 674e077a4fd..0792550e1c5 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1036,7 +1036,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { if (BB->getParent() == 0) Out << "\t\t; Error: Block without parent!"; else { - if (BB != &BB->getParent()->front()) { // Not the entry block? + if (BB != &BB->getParent()->getEntryBlock()) { // Not the entry block? // Output predecessors for the block... Out << "\t\t;"; pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 8c836a2515c..c7da56b96ff 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -170,7 +170,7 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const { if (HasUndefInput && !AllowNonDominatingInstruction) if (Instruction *IV = dyn_cast(InVal)) // 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(IV)) return 0; // Cannot guarantee that InVal dominates this PHINode. -- 2.34.1