LLVM  6.0.0svn
OrderedInstructions.cpp
Go to the documentation of this file.
1 //===-- OrderedInstructions.cpp - Instruction dominance function ---------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines utility to check dominance relation of 2 instructions.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 using namespace llvm;
16 
17 /// Given 2 instructions, use OrderedBasicBlock to check for dominance relation
18 /// if the instructions are in the same basic block, Otherwise, use dominator
19 /// tree.
21  const Instruction *InstB) const {
22  const BasicBlock *IBB = InstA->getParent();
23  // Use ordered basic block to do dominance check in case the 2 instructions
24  // are in the same basic block.
25  if (IBB == InstB->getParent()) {
26  auto OBB = OBBMap.find(IBB);
27  if (OBB == OBBMap.end())
28  OBB = OBBMap.insert({IBB, make_unique<OrderedBasicBlock>(IBB)}).first;
29  return OBB->second->dominates(InstA, InstB);
30  }
31  return DT->dominates(InstA->getParent(), InstB->getParent());
32 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool dominates(const Instruction *, const Instruction *) const
Return true if first instruction dominates the second.
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
Definition: Dominators.cpp:239
const BasicBlock * getParent() const
Definition: Instruction.h:66