Coverage Report

Created: 2018-11-12 17:33

/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
729k
  GISelWorkList() = default;
llvm::GISelWorkList<512u>::GISelWorkList()
Line
Count
Source
31
260k
  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
45.6M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<512u>::empty() const
Line
Count
Source
33
31.1M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<256u>::empty() const
Line
Count
Source
33
12.5M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<128u>::empty() const
Line
Count
Source
33
1.97M
  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
47.8M
  void insert(MachineInstr *I) {
40
47.8M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
47.8M
      Worklist.push_back(I);
42
47.8M
    }
43
47.8M
  }
llvm::GISelWorkList<512u>::insert(llvm::MachineInstr*)
Line
Count
Source
39
31.0M
  void insert(MachineInstr *I) {
40
31.0M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
31.0M
      Worklist.push_back(I);
42
31.0M
    }
43
31.0M
  }
llvm::GISelWorkList<128u>::insert(llvm::MachineInstr*)
Line
Count
Source
39
2.19M
  void insert(MachineInstr *I) {
40
2.19M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
2.19M
      Worklist.push_back(I);
42
2.19M
    }
43
2.19M
  }
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.27M
  void remove(MachineInstr *I) {
47
1.27M
    auto It = WorklistMap.find(I);
48
1.27M
    if (It == WorklistMap.end()) 
return807k
; // Not in worklist.
49
468k
50
468k
    // Don't bother moving everything down, just null out the slot.
51
468k
    Worklist[It->second] = nullptr;
52
468k
53
468k
    WorklistMap.erase(It);
54
468k
  }
llvm::GISelWorkList<512u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
129k
  void remove(MachineInstr *I) {
47
129k
    auto It = WorklistMap.find(I);
48
129k
    if (It == WorklistMap.end()) 
return0
; // Not in worklist.
49
129k
50
129k
    // Don't bother moving everything down, just null out the slot.
51
129k
    Worklist[It->second] = nullptr;
52
129k
53
129k
    WorklistMap.erase(It);
54
129k
  }
llvm::GISelWorkList<256u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
573k
  void remove(MachineInstr *I) {
47
573k
    auto It = WorklistMap.find(I);
48
573k
    if (It == WorklistMap.end()) 
return571k
; // Not in worklist.
49
1.40k
50
1.40k
    // Don't bother moving everything down, just null out the slot.
51
1.40k
    Worklist[It->second] = nullptr;
52
1.40k
53
1.40k
    WorklistMap.erase(It);
54
1.40k
  }
llvm::GISelWorkList<128u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
573k
  void remove(MachineInstr *I) {
47
573k
    auto It = WorklistMap.find(I);
48
573k
    if (It == WorklistMap.end()) 
return235k
; // Not in worklist.
49
337k
50
337k
    // Don't bother moving everything down, just null out the slot.
51
337k
    Worklist[It->second] = nullptr;
52
337k
53
337k
    WorklistMap.erase(It);
54
337k
  }
55
56
44.2M
  MachineInstr *pop_back_val() {
57
44.2M
    MachineInstr *I;
58
44.7M
    do {
59
44.7M
      I = Worklist.pop_back_val();
60
44.7M
    } while(!I);
61
44.2M
    assert(I && "Pop back on empty worklist");
62
44.2M
    WorklistMap.erase(I);
63
44.2M
    return I;
64
44.2M
  }
llvm::GISelWorkList<512u>::pop_back_val()
Line
Count
Source
56
30.9M
  MachineInstr *pop_back_val() {
57
30.9M
    MachineInstr *I;
58
31.0M
    do {
59
31.0M
      I = Worklist.pop_back_val();
60
31.0M
    } while(!I);
61
30.9M
    assert(I && "Pop back on empty worklist");
62
30.9M
    WorklistMap.erase(I);
63
30.9M
    return I;
64
30.9M
  }
llvm::GISelWorkList<256u>::pop_back_val()
Line
Count
Source
56
11.7M
  MachineInstr *pop_back_val() {
57
11.7M
    MachineInstr *I;
58
11.7M
    do {
59
11.7M
      I = Worklist.pop_back_val();
60
11.7M
    } while(!I);
61
11.7M
    assert(I && "Pop back on empty worklist");
62
11.7M
    WorklistMap.erase(I);
63
11.7M
    return I;
64
11.7M
  }
llvm::GISelWorkList<128u>::pop_back_val()
Line
Count
Source
56
1.59M
  MachineInstr *pop_back_val() {
57
1.59M
    MachineInstr *I;
58
1.90M
    do {
59
1.90M
      I = Worklist.pop_back_val();
60
1.90M
    } while(!I);
61
1.59M
    assert(I && "Pop back on empty worklist");
62
1.59M
    WorklistMap.erase(I);
63
1.59M
    return I;
64
1.59M
  }
65
};
66
67
} // end namespace llvm.
68
69
#endif