Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/PseudoSourceValue.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
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 implements the PseudoSourceValue class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/CodeGen/PseudoSourceValue.h"
14
#include "llvm/ADT/STLExtras.h"
15
#include "llvm/CodeGen/MachineFrameInfo.h"
16
#include "llvm/CodeGen/TargetInstrInfo.h"
17
#include "llvm/IR/DerivedTypes.h"
18
#include "llvm/IR/LLVMContext.h"
19
#include "llvm/Support/ErrorHandling.h"
20
#include "llvm/Support/raw_ostream.h"
21
using namespace llvm;
22
23
static const char *const PSVNames[] = {
24
    "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
25
    "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
26
27
PseudoSourceValue::PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
28
3.58M
    : Kind(Kind) {
29
3.58M
  AddressSpace = TII.getAddressSpaceForPseudoSourceKind(Kind);
30
3.58M
}
31
32
33
3.58M
PseudoSourceValue::~PseudoSourceValue() {}
34
35
4
void PseudoSourceValue::printCustom(raw_ostream &O) const {
36
4
  if (Kind < TargetCustom)
37
0
    O << PSVNames[Kind];
38
4
  else
39
4
    O << "TargetCustom" << Kind;
40
4
}
41
42
697k
bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
43
697k
  if (isStack())
44
0
    return false;
45
697k
  if (isGOT() || 
isConstantPool()429k
||
isJumpTable()2.87k
)
46
697k
    return true;
47
0
  llvm_unreachable("Unknown PseudoSourceValue!");
48
0
}
49
50
87.6k
bool PseudoSourceValue::isAliased(const MachineFrameInfo *) const {
51
87.6k
  if (isStack() || 
isGOT()353
||
isConstantPool()95
||
isJumpTable()21
)
52
87.6k
    return false;
53
0
  llvm_unreachable("Unknown PseudoSourceValue!");
54
0
}
55
56
90.0k
bool PseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
57
90.0k
  return !(isGOT() || 
isConstantPool()90.0k
||
isJumpTable()90.0k
);
58
90.0k
}
59
60
bool FixedStackPseudoSourceValue::isConstant(
61
791k
    const MachineFrameInfo *MFI) const {
62
791k
  return MFI && MFI->isImmutableObjectIndex(FI);
63
791k
}
64
65
63.8k
bool FixedStackPseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const {
66
63.8k
  if (!MFI)
67
0
    return true;
68
63.8k
  return MFI->isAliasedObjectIndex(FI);
69
63.8k
}
70
71
139k
bool FixedStackPseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const {
72
139k
  if (!MFI)
73
0
    return true;
74
139k
  // Spill slots will not alias any LLVM IR value.
75
139k
  return !MFI->isSpillSlotObjectIndex(FI);
76
139k
}
77
78
0
void FixedStackPseudoSourceValue::printCustom(raw_ostream &OS) const {
79
0
  OS << "FixedStack" << FI;
80
0
}
81
82
CallEntryPseudoSourceValue::CallEntryPseudoSourceValue(
83
    unsigned Kind, const TargetInstrInfo &TII)
84
1.34k
    : PseudoSourceValue(Kind, TII) {}
85
86
7.40k
bool CallEntryPseudoSourceValue::isConstant(const MachineFrameInfo *) const {
87
7.40k
  return false;
88
7.40k
}
89
90
700
bool CallEntryPseudoSourceValue::isAliased(const MachineFrameInfo *) const {
91
700
  return false;
92
700
}
93
94
251
bool CallEntryPseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
95
251
  return false;
96
251
}
97
98
GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue(
99
    const GlobalValue *GV,
100
    const TargetInstrInfo &TII)
101
734
    : CallEntryPseudoSourceValue(GlobalValueCallEntry, TII), GV(GV) {}
102
ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue(
103
    const char *ES, const TargetInstrInfo &TII)
104
614
    : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TII), ES(ES) {}
105
106
PseudoSourceValueManager::PseudoSourceValueManager(
107
    const TargetInstrInfo &TIInfo)
108
    : TII(TIInfo),
109
      StackPSV(PseudoSourceValue::Stack, TII),
110
      GOTPSV(PseudoSourceValue::GOT, TII),
111
      JumpTablePSV(PseudoSourceValue::JumpTable, TII),
112
527k
      ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
113
114
164k
const PseudoSourceValue *PseudoSourceValueManager::getStack() {
115
164k
  return &StackPSV;
116
164k
}
117
118
43.1k
const PseudoSourceValue *PseudoSourceValueManager::getGOT() { return &GOTPSV; }
119
120
73.7k
const PseudoSourceValue *PseudoSourceValueManager::getConstantPool() {
121
73.7k
  return &ConstantPoolPSV;
122
73.7k
}
123
124
426
const PseudoSourceValue *PseudoSourceValueManager::getJumpTable() {
125
426
  return &JumpTablePSV;
126
426
}
127
128
const PseudoSourceValue *
129
3.50M
PseudoSourceValueManager::getFixedStack(int FI) {
130
3.50M
  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
131
3.50M
  if (!V)
132
1.47M
    V = llvm::make_unique<FixedStackPseudoSourceValue>(FI, TII);
133
3.50M
  return V.get();
134
3.50M
}
135
136
const PseudoSourceValue *
137
1.14k
PseudoSourceValueManager::getGlobalValueCallEntry(const GlobalValue *GV) {
138
1.14k
  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
139
1.14k
      GlobalCallEntries[GV];
140
1.14k
  if (!E)
141
734
    E = llvm::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
142
1.14k
  return E.get();
143
1.14k
}
144
145
const PseudoSourceValue *
146
650
PseudoSourceValueManager::getExternalSymbolCallEntry(const char *ES) {
147
650
  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
148
650
      ExternalCallEntries[ES];
149
650
  if (!E)
150
614
    E = llvm::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
151
650
  return E.get();
152
650
}