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