summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/SlotIndexes.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-11 20:01:44 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-04-11 20:01:44 +0000
commit3d32202748f3ce3de31e48a183130d94e767e97c (patch)
treebbf5bcc1b348b080b55b5df89bf82d175d903370 /include/llvm/CodeGen/SlotIndexes.h
parent6d73c7dad165bde864769ae1a351bce27b261565 (diff)
downloadllvm-3d32202748f3ce3de31e48a183130d94e767e97c.tar.gz
llvm-3d32202748f3ce3de31e48a183130d94e767e97c.tar.bz2
llvm-3d32202748f3ce3de31e48a183130d94e767e97c.tar.xz
Skip a binary search when possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/SlotIndexes.h')
-rw-r--r--include/llvm/CodeGen/SlotIndexes.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h
index dc247132c8..7bbb7521e5 100644
--- a/include/llvm/CodeGen/SlotIndexes.h
+++ b/include/llvm/CodeGen/SlotIndexes.h
@@ -545,6 +545,8 @@ namespace llvm {
/// Returns the basic block which the given index falls in.
MachineBasicBlock* getMBBFromIndex(SlotIndex index) const {
+ if (MachineInstr *MI = getInstructionFromIndex(index))
+ return MI->getParent();
SmallVectorImpl<IdxMBBPair>::const_iterator I =
std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), index);
// Take the pair containing the index