Mercurial > hg > CbC > CbC_llvm
comparison llvm/lib/IR/LLVMContextImpl.cpp @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | dd44ba33042e 5f17cb93ff66 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
33 TokenTy(C, Type::TokenTyID), | 33 TokenTy(C, Type::TokenTyID), |
34 X86_FP80Ty(C, Type::X86_FP80TyID), | 34 X86_FP80Ty(C, Type::X86_FP80TyID), |
35 FP128Ty(C, Type::FP128TyID), | 35 FP128Ty(C, Type::FP128TyID), |
36 PPC_FP128Ty(C, Type::PPC_FP128TyID), | 36 PPC_FP128Ty(C, Type::PPC_FP128TyID), |
37 X86_MMXTy(C, Type::X86_MMXTyID), | 37 X86_MMXTy(C, Type::X86_MMXTyID), |
38 X86_AMXTy(C, Type::X86_AMXTyID), | |
38 Int1Ty(C, 1), | 39 Int1Ty(C, 1), |
39 Int8Ty(C, 8), | 40 Int8Ty(C, 8), |
40 Int16Ty(C, 16), | 41 Int16Ty(C, 16), |
41 Int32Ty(C, 32), | 42 Int32Ty(C, 32), |
42 Int64Ty(C, 64), | 43 Int64Ty(C, 64), |
48 // the container. Avoid iterators during this operation: | 49 // the container. Avoid iterators during this operation: |
49 while (!OwnedModules.empty()) | 50 while (!OwnedModules.empty()) |
50 delete *OwnedModules.begin(); | 51 delete *OwnedModules.begin(); |
51 | 52 |
52 #ifndef NDEBUG | 53 #ifndef NDEBUG |
53 // Check for metadata references from leaked Instructions. | 54 // Check for metadata references from leaked Values. |
54 for (auto &Pair : InstructionMetadata) | 55 for (auto &Pair : ValueMetadata) |
55 Pair.first->dump(); | 56 Pair.first->dump(); |
56 assert(InstructionMetadata.empty() && | 57 assert(ValueMetadata.empty() && "Values with metadata have been leaked"); |
57 "Instructions with metadata have been leaked"); | |
58 #endif | 58 #endif |
59 | 59 |
60 // Drop references for MDNodes. Do this before Values get deleted to avoid | 60 // Drop references for MDNodes. Do this before Values get deleted to avoid |
61 // unnecessary RAUW when nodes are still unresolved. | 61 // unnecessary RAUW when nodes are still unresolved. |
62 for (auto *I : DistinctMDNodes) | 62 for (auto *I : DistinctMDNodes) |
96 InlineAsms.freeConstants(); | 96 InlineAsms.freeConstants(); |
97 | 97 |
98 CAZConstants.clear(); | 98 CAZConstants.clear(); |
99 CPNConstants.clear(); | 99 CPNConstants.clear(); |
100 UVConstants.clear(); | 100 UVConstants.clear(); |
101 PVConstants.clear(); | |
101 IntConstants.clear(); | 102 IntConstants.clear(); |
102 FPConstants.clear(); | 103 FPConstants.clear(); |
103 | |
104 for (auto &CDSConstant : CDSConstants) | |
105 delete CDSConstant.second; | |
106 CDSConstants.clear(); | 104 CDSConstants.clear(); |
107 | 105 |
108 // Destroy attribute node lists. | 106 // Destroy attribute node lists. |
109 for (FoldingSetIterator<AttributeSetNode> I = AttrsSetNodes.begin(), | 107 for (FoldingSetIterator<AttributeSetNode> I = AttrsSetNodes.begin(), |
110 E = AttrsSetNodes.end(); I != E; ) { | 108 E = AttrsSetNodes.end(); I != E; ) { |
127 for (auto &Pair : ValuesAsMetadata) | 125 for (auto &Pair : ValuesAsMetadata) |
128 delete Pair.second; | 126 delete Pair.second; |
129 } | 127 } |
130 | 128 |
131 void LLVMContextImpl::dropTriviallyDeadConstantArrays() { | 129 void LLVMContextImpl::dropTriviallyDeadConstantArrays() { |
132 SmallSetVector<ConstantArray *, 4> WorkList(ArrayConstants.begin(), | 130 SmallSetVector<ConstantArray *, 4> WorkList; |
133 ArrayConstants.end()); | 131 |
132 // When ArrayConstants are of substantial size and only a few in them are | |
133 // dead, starting WorkList with all elements of ArrayConstants can be | |
134 // wasteful. Instead, starting WorkList with only elements that have empty | |
135 // uses. | |
136 for (ConstantArray *C : ArrayConstants) | |
137 if (C->use_empty()) | |
138 WorkList.insert(C); | |
134 | 139 |
135 while (!WorkList.empty()) { | 140 while (!WorkList.empty()) { |
136 ConstantArray *C = WorkList.pop_back_val(); | 141 ConstantArray *C = WorkList.pop_back_val(); |
137 if (C->use_empty()) { | 142 if (C->use_empty()) { |
138 for (const Use &Op : C->operands()) { | 143 for (const Use &Op : C->operands()) { |
169 | 174 |
170 unsigned MDNodeOpsKey::calculateHash(MDNode *N, unsigned Offset) { | 175 unsigned MDNodeOpsKey::calculateHash(MDNode *N, unsigned Offset) { |
171 unsigned Hash = hash_combine_range(N->op_begin() + Offset, N->op_end()); | 176 unsigned Hash = hash_combine_range(N->op_begin() + Offset, N->op_end()); |
172 #ifndef NDEBUG | 177 #ifndef NDEBUG |
173 { | 178 { |
174 SmallVector<Metadata *, 8> MDs(N->op_begin() + Offset, N->op_end()); | 179 SmallVector<Metadata *, 8> MDs(drop_begin(N->operands(), Offset)); |
175 unsigned RawHash = calculateHash(MDs); | 180 unsigned RawHash = calculateHash(MDs); |
176 assert(Hash == RawHash && | 181 assert(Hash == RawHash && |
177 "Expected hash of MDOperand to equal hash of Metadata*"); | 182 "Expected hash of MDOperand to equal hash of Metadata*"); |
178 } | 183 } |
179 #endif | 184 #endif |
213 SSNs.resize(SSC.size()); | 218 SSNs.resize(SSC.size()); |
214 for (const auto &SSE : SSC) | 219 for (const auto &SSE : SSC) |
215 SSNs[SSE.second] = SSE.first(); | 220 SSNs[SSE.second] = SSE.first(); |
216 } | 221 } |
217 | 222 |
218 /// Singleton instance of the OptBisect class. | 223 /// Gets the OptPassGate for this LLVMContextImpl, which defaults to the |
219 /// | 224 /// singleton OptBisect if not explicitly set. |
220 /// This singleton is accessed via the LLVMContext::getOptPassGate() function. | |
221 /// It provides a mechanism to disable passes and individual optimizations at | |
222 /// compile time based on a command line option (-opt-bisect-limit) in order to | |
223 /// perform a bisecting search for optimization-related problems. | |
224 /// | |
225 /// Even if multiple LLVMContext objects are created, they will all return the | |
226 /// same instance of OptBisect in order to provide a single bisect count. Any | |
227 /// code that uses the OptBisect object should be serialized when bisection is | |
228 /// enabled in order to enable a consistent bisect count. | |
229 static ManagedStatic<OptBisect> OptBisector; | |
230 | |
231 OptPassGate &LLVMContextImpl::getOptPassGate() const { | 225 OptPassGate &LLVMContextImpl::getOptPassGate() const { |
232 if (!OPG) | 226 if (!OPG) |
233 OPG = &(*OptBisector); | 227 OPG = &(*OptBisector); |
234 return *OPG; | 228 return *OPG; |
235 } | 229 } |