summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-05-02 21:57:00 +0000
committerDevang Patel <dpatel@apple.com>2011-05-02 21:57:00 +0000
commit67352b3ce7110541475ed7fb335ee95954f0523a (patch)
tree19ed871eb13831e368ee195ec4c27ffcd1c25672 /lib/Transforms/Utils/BasicBlockUtils.cpp
parentd61c40360c3acc847263c5e5184b715c17528b09 (diff)
downloadllvm-67352b3ce7110541475ed7fb335ee95954f0523a.tar.gz
llvm-67352b3ce7110541475ed7fb335ee95954f0523a.tar.bz2
llvm-67352b3ce7110541475ed7fb335ee95954f0523a.tar.xz
Scanning entire basic block may be too expensive in terms of compile time. Instead, just use whatever location info first non-phi instruction has.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130729 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index c705cc5109..92464e8cf1 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -542,11 +542,9 @@ ReturnInst *llvm::FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB,
/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a
/// given basic block.
DebugLoc llvm::GetFirstDebugLocInBasicBlock(const BasicBlock *BB) {
- for (BasicBlock::const_iterator BI = BB->begin(), BE = BB->end();
- BI != BE; ++BI) {
- DebugLoc DL = BI->getDebugLoc();
- if (!DL.isUnknown())
- return DL;
- }
+ if (const Instruction *I = BB->getFirstNonPHI())
+ return I->getDebugLoc();
+ // Scanning entire block may be too expensive, if the first instruction
+ // does not have valid location info.
return DebugLoc();
}