Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/OrderedInstructions.cpp
Line
Count
Source
1
//===-- OrderedInstructions.cpp - Instruction dominance function ---------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines utility to check dominance relation of 2 instructions.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/Analysis/OrderedInstructions.h"
14
using namespace llvm;
15
16
bool OrderedInstructions::localDominates(const Instruction *InstA,
17
9.52M
                                         const Instruction *InstB) const {
18
9.52M
  assert(InstA->getParent() == InstB->getParent() &&
19
9.52M
         "Instructions must be in the same basic block");
20
9.52M
21
9.52M
  const BasicBlock *IBB = InstA->getParent();
22
9.52M
  auto OBB = OBBMap.find(IBB);
23
9.52M
  if (OBB == OBBMap.end())
24
519k
    OBB = OBBMap.insert({IBB, make_unique<OrderedBasicBlock>(IBB)}).first;
25
9.52M
  return OBB->second->dominates(InstA, InstB);
26
9.52M
}
27
28
/// Given 2 instructions, use OrderedBasicBlock to check for dominance relation
29
/// if the instructions are in the same basic block, Otherwise, use dominator
30
/// tree.
31
bool OrderedInstructions::dominates(const Instruction *InstA,
32
21.2k
                                    const Instruction *InstB) const {
33
21.2k
  // Use ordered basic block to do dominance check in case the 2 instructions
34
21.2k
  // are in the same basic block.
35
21.2k
  if (InstA->getParent() == InstB->getParent())
36
21.2k
    return localDominates(InstA, InstB);
37
1
  return DT->dominates(InstA->getParent(), InstB->getParent());
38
1
}
39
40
bool OrderedInstructions::dfsBefore(const Instruction *InstA,
41
15.5M
                                    const Instruction *InstB) const {
42
15.5M
  // Use ordered basic block in case the 2 instructions are in the same basic
43
15.5M
  // block.
44
15.5M
  if (InstA->getParent() == InstB->getParent())
45
9.50M
    return localDominates(InstA, InstB);
46
5.99M
47
5.99M
  DomTreeNode *DA = DT->getNode(InstA->getParent());
48
5.99M
  DomTreeNode *DB = DT->getNode(InstB->getParent());
49
5.99M
  return DA->getDFSNumIn() < DB->getDFSNumIn();
50
5.99M
}