Coverage Report

Created: 2018-09-23 16:00

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h
Line
Count
Source
1
//===- GISelWorkList.h - Worklist for GISel passes ----*- C++ -*-===//
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
#ifndef LLVM_GISEL_WORKLIST_H
11
#define LLVM_GISEL_WORKLIST_H
12
13
#include "llvm/ADT/DenseMap.h"
14
#include "llvm/ADT/SmallVector.h"
15
#include "llvm/Support/Debug.h"
16
17
namespace llvm {
18
19
class MachineInstr;
20
21
// Worklist which mostly works similar to InstCombineWorkList, but on MachineInstrs.
22
// The main difference with something like a SetVector is that erasing an element doesn't
23
// move all elements over one place - instead just nulls out the element of the vector.
24
// FIXME: Does it make sense to factor out common code with the instcombinerWorkList?
25
template<unsigned N>
26
class GISelWorkList {
27
  SmallVector<MachineInstr*, N> Worklist;
28
  DenseMap<MachineInstr*, unsigned> WorklistMap;
29
30
public:
31
468k
  GISelWorkList() = default;
llvm::GISelWorkList<256u>::GISelWorkList()
Line
Count
Source
31
234k
  GISelWorkList() = default;
llvm::GISelWorkList<128u>::GISelWorkList()
Line
Count
Source
31
234k
  GISelWorkList() = default;
32
33
14.4M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<256u>::empty() const
Line
Count
Source
33
12.4M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<128u>::empty() const
Line
Count
Source
33
1.98M
  bool empty() const { return WorklistMap.empty(); }
34
35
  unsigned size() const { return WorklistMap.size(); }
36
37
  /// Add - Add the specified instruction to the worklist if it isn't already
38
  /// in it.
39
16.7M
  void insert(MachineInstr *I) {
40
16.7M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
16.7M
      Worklist.push_back(I);
42
16.7M
    }
43
16.7M
  }
llvm::GISelWorkList<128u>::insert(llvm::MachineInstr*)
Line
Count
Source
39
2.23M
  void insert(MachineInstr *I) {
40
2.23M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
2.23M
      Worklist.push_back(I);
42
2.23M
    }
43
2.23M
  }
llvm::GISelWorkList<256u>::insert(llvm::MachineInstr*)
Line
Count
Source
39
14.5M
  void insert(MachineInstr *I) {
40
14.5M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
14.5M
      Worklist.push_back(I);
42
14.5M
    }
43
14.5M
  }
44
45
  /// Remove - remove I from the worklist if it exists.
46
1.12M
  void remove(MachineInstr *I) {
47
1.12M
    auto It = WorklistMap.find(I);
48
1.12M
    if (It == WorklistMap.end()) 
return790k
; // Not in worklist.
49
335k
50
335k
    // Don't bother moving everything down, just null out the slot.
51
335k
    Worklist[It->second] = nullptr;
52
335k
53
335k
    WorklistMap.erase(It);
54
335k
  }
llvm::GISelWorkList<256u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
562k
  void remove(MachineInstr *I) {
47
562k
    auto It = WorklistMap.find(I);
48
562k
    if (It == WorklistMap.end()) 
return561k
; // Not in worklist.
49
1.90k
50
1.90k
    // Don't bother moving everything down, just null out the slot.
51
1.90k
    Worklist[It->second] = nullptr;
52
1.90k
53
1.90k
    WorklistMap.erase(It);
54
1.90k
  }
llvm::GISelWorkList<128u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
562k
  void remove(MachineInstr *I) {
47
562k
    auto It = WorklistMap.find(I);
48
562k
    if (It == WorklistMap.end()) 
return229k
; // Not in worklist.
49
333k
50
333k
    // Don't bother moving everything down, just null out the slot.
51
333k
    Worklist[It->second] = nullptr;
52
333k
53
333k
    WorklistMap.erase(It);
54
333k
  }
55
56
13.3M
  MachineInstr *pop_back_val() {
57
13.3M
    MachineInstr *I;
58
13.6M
    do {
59
13.6M
      I = Worklist.pop_back_val();
60
13.6M
    } while(!I);
61
13.3M
    assert(I && "Pop back on empty worklist");
62
13.3M
    WorklistMap.erase(I);
63
13.3M
    return I;
64
13.3M
  }
llvm::GISelWorkList<256u>::pop_back_val()
Line
Count
Source
56
11.6M
  MachineInstr *pop_back_val() {
57
11.6M
    MachineInstr *I;
58
11.6M
    do {
59
11.6M
      I = Worklist.pop_back_val();
60
11.6M
    } while(!I);
61
11.6M
    assert(I && "Pop back on empty worklist");
62
11.6M
    WorklistMap.erase(I);
63
11.6M
    return I;
64
11.6M
  }
llvm::GISelWorkList<128u>::pop_back_val()
Line
Count
Source
56
1.60M
  MachineInstr *pop_back_val() {
57
1.60M
    MachineInstr *I;
58
1.91M
    do {
59
1.91M
      I = Worklist.pop_back_val();
60
1.91M
    } while(!I);
61
1.60M
    assert(I && "Pop back on empty worklist");
62
1.60M
    WorklistMap.erase(I);
63
1.60M
    return I;
64
1.60M
  }
65
};
66
67
} // end namespace llvm.
68
69
#endif