Coverage Report

Created: 2018-07-19 03:59

/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
464k
  GISelWorkList() = default;
llvm::GISelWorkList<256u>::GISelWorkList()
Line
Count
Source
31
232k
  GISelWorkList() = default;
llvm::GISelWorkList<128u>::GISelWorkList()
Line
Count
Source
31
232k
  GISelWorkList() = default;
32
33
14.1M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<256u>::empty() const
Line
Count
Source
33
12.1M
  bool empty() const { return WorklistMap.empty(); }
llvm::GISelWorkList<128u>::empty() const
Line
Count
Source
33
1.96M
  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.3M
  void insert(MachineInstr *I) {
40
16.3M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
16.3M
      Worklist.push_back(I);
42
16.3M
    }
43
16.3M
  }
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.1M
  void insert(MachineInstr *I) {
40
14.1M
    if (WorklistMap.try_emplace(I, Worklist.size()).second) {
41
14.1M
      Worklist.push_back(I);
42
14.1M
    }
43
14.1M
  }
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()) 
return786k
; // 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
  }
llvm::GISelWorkList<256u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
560k
  void remove(MachineInstr *I) {
47
560k
    auto It = WorklistMap.find(I);
48
560k
    if (It == WorklistMap.end()) 
return559k
; // Not in worklist.
49
726
50
726
    // Don't bother moving everything down, just null out the slot.
51
726
    Worklist[It->second] = nullptr;
52
726
53
726
    WorklistMap.erase(It);
54
726
  }
llvm::GISelWorkList<128u>::remove(llvm::MachineInstr*)
Line
Count
Source
46
560k
  void remove(MachineInstr *I) {
47
560k
    auto It = WorklistMap.find(I);
48
560k
    if (It == WorklistMap.end()) 
return227k
; // Not in worklist.
49
332k
50
332k
    // Don't bother moving everything down, just null out the slot.
51
332k
    Worklist[It->second] = nullptr;
52
332k
53
332k
    WorklistMap.erase(It);
54
332k
  }
55
56
13.0M
  MachineInstr *pop_back_val() {
57
13.0M
    MachineInstr *I;
58
13.3M
    do {
59
13.3M
      I = Worklist.pop_back_val();
60
13.3M
    } while(!I);
61
13.0M
    assert(I && "Pop back on empty worklist");
62
13.0M
    WorklistMap.erase(I);
63
13.0M
    return I;
64
13.0M
  }
llvm::GISelWorkList<256u>::pop_back_val()
Line
Count
Source
56
11.4M
  MachineInstr *pop_back_val() {
57
11.4M
    MachineInstr *I;
58
11.4M
    do {
59
11.4M
      I = Worklist.pop_back_val();
60
11.4M
    } while(!I);
61
11.4M
    assert(I && "Pop back on empty worklist");
62
11.4M
    WorklistMap.erase(I);
63
11.4M
    return I;
64
11.4M
  }
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