annotate llvm/lib/IR/LLVMContextImpl.cpp @ 240:ca573705d418

merge
author matac
date Fri, 28 Jul 2023 20:50:09 +0900
parents 173fe712db74
children 731cecd08f47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===- LLVMContextImpl.cpp - Implement LLVMContextImpl --------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This file implements the opaque LLVMContextImpl.
anatofuz
parents:
diff changeset
10 //
anatofuz
parents:
diff changeset
11 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 #include "LLVMContextImpl.h"
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
14 #include "AttributeImpl.h"
150
anatofuz
parents:
diff changeset
15 #include "llvm/ADT/SetVector.h"
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
16 #include "llvm/ADT/StringMapEntry.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
17 #include "llvm/ADT/iterator.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
18 #include "llvm/ADT/iterator_range.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
19 #include "llvm/IR/DiagnosticHandler.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
20 #include "llvm/IR/LLVMRemarkStreamer.h"
150
anatofuz
parents:
diff changeset
21 #include "llvm/IR/Module.h"
anatofuz
parents:
diff changeset
22 #include "llvm/IR/OptBisect.h"
anatofuz
parents:
diff changeset
23 #include "llvm/IR/Type.h"
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
24 #include "llvm/IR/Use.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
25 #include "llvm/IR/User.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
26 #include "llvm/Remarks/RemarkStreamer.h"
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
27 #include "llvm/Support/CommandLine.h"
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
28 #include "llvm/Support/Compiler.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
29 #include "llvm/Support/ErrorHandling.h"
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
30 #include "llvm/Support/TypeSize.h"
150
anatofuz
parents:
diff changeset
31 #include <cassert>
anatofuz
parents:
diff changeset
32 #include <utility>
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 using namespace llvm;
anatofuz
parents:
diff changeset
35
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
36 static cl::opt<bool>
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
37 OpaquePointersCL("opaque-pointers", cl::desc("Use opaque pointers"),
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
38 cl::init(true));
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
39
150
anatofuz
parents:
diff changeset
40 LLVMContextImpl::LLVMContextImpl(LLVMContext &C)
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
41 : DiagHandler(std::make_unique<DiagnosticHandler>()),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
42 VoidTy(C, Type::VoidTyID), LabelTy(C, Type::LabelTyID),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
43 HalfTy(C, Type::HalfTyID), BFloatTy(C, Type::BFloatTyID),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
44 FloatTy(C, Type::FloatTyID), DoubleTy(C, Type::DoubleTyID),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
45 MetadataTy(C, Type::MetadataTyID), TokenTy(C, Type::TokenTyID),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
46 X86_FP80Ty(C, Type::X86_FP80TyID), FP128Ty(C, Type::FP128TyID),
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
47 PPC_FP128Ty(C, Type::PPC_FP128TyID), X86_MMXTy(C, Type::X86_MMXTyID),
240
matac
parents: 239
diff changeset
48 #ifndef noCbC
matac
parents: 239
diff changeset
49 X86_AMXTy(C, Type::X86_AMXTyID), __CodeTy(C, Type::__CodeTyID), Int1Ty(C, 1), Int8Ty(C, 8),
matac
parents: 239
diff changeset
50 #else
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 207
diff changeset
51 X86_AMXTy(C, Type::X86_AMXTyID), Int1Ty(C, 1), Int8Ty(C, 8),
240
matac
parents: 239
diff changeset
52 #endif
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
53 Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128) {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
54 if (OpaquePointersCL.getNumOccurrences()) {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
55 OpaquePointers = OpaquePointersCL;
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
56 }
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
57 }
150
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 LLVMContextImpl::~LLVMContextImpl() {
anatofuz
parents:
diff changeset
60 // NOTE: We need to delete the contents of OwnedModules, but Module's dtor
anatofuz
parents:
diff changeset
61 // will call LLVMContextImpl::removeModule, thus invalidating iterators into
anatofuz
parents:
diff changeset
62 // the container. Avoid iterators during this operation:
anatofuz
parents:
diff changeset
63 while (!OwnedModules.empty())
anatofuz
parents:
diff changeset
64 delete *OwnedModules.begin();
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 #ifndef NDEBUG
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
67 // Check for metadata references from leaked Values.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
68 for (auto &Pair : ValueMetadata)
150
anatofuz
parents:
diff changeset
69 Pair.first->dump();
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
70 assert(ValueMetadata.empty() && "Values with metadata have been leaked");
150
anatofuz
parents:
diff changeset
71 #endif
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 // Drop references for MDNodes. Do this before Values get deleted to avoid
anatofuz
parents:
diff changeset
74 // unnecessary RAUW when nodes are still unresolved.
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
75 for (auto *I : DistinctMDNodes) {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
76 // We may have DIArgList that were uniqued, and as it has a custom
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
77 // implementation of dropAllReferences, it needs to be explicitly invoked.
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
78 if (auto *AL = dyn_cast<DIArgList>(I)) {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
79 AL->dropAllReferences();
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
80 continue;
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
81 }
150
anatofuz
parents:
diff changeset
82 I->dropAllReferences();
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
83 }
150
anatofuz
parents:
diff changeset
84 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
anatofuz
parents:
diff changeset
85 for (auto *I : CLASS##s) \
anatofuz
parents:
diff changeset
86 I->dropAllReferences();
anatofuz
parents:
diff changeset
87 #include "llvm/IR/Metadata.def"
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 // Also drop references that come from the Value bridges.
anatofuz
parents:
diff changeset
90 for (auto &Pair : ValuesAsMetadata)
anatofuz
parents:
diff changeset
91 Pair.second->dropUsers();
anatofuz
parents:
diff changeset
92 for (auto &Pair : MetadataAsValues)
anatofuz
parents:
diff changeset
93 Pair.second->dropUse();
anatofuz
parents:
diff changeset
94
anatofuz
parents:
diff changeset
95 // Destroy MDNodes.
anatofuz
parents:
diff changeset
96 for (MDNode *I : DistinctMDNodes)
anatofuz
parents:
diff changeset
97 I->deleteAsSubclass();
anatofuz
parents:
diff changeset
98 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
anatofuz
parents:
diff changeset
99 for (CLASS * I : CLASS##s) \
anatofuz
parents:
diff changeset
100 delete I;
anatofuz
parents:
diff changeset
101 #include "llvm/IR/Metadata.def"
anatofuz
parents:
diff changeset
102
anatofuz
parents:
diff changeset
103 // Free the constants.
anatofuz
parents:
diff changeset
104 for (auto *I : ExprConstants)
anatofuz
parents:
diff changeset
105 I->dropAllReferences();
anatofuz
parents:
diff changeset
106 for (auto *I : ArrayConstants)
anatofuz
parents:
diff changeset
107 I->dropAllReferences();
anatofuz
parents:
diff changeset
108 for (auto *I : StructConstants)
anatofuz
parents:
diff changeset
109 I->dropAllReferences();
anatofuz
parents:
diff changeset
110 for (auto *I : VectorConstants)
anatofuz
parents:
diff changeset
111 I->dropAllReferences();
anatofuz
parents:
diff changeset
112 ExprConstants.freeConstants();
anatofuz
parents:
diff changeset
113 ArrayConstants.freeConstants();
anatofuz
parents:
diff changeset
114 StructConstants.freeConstants();
anatofuz
parents:
diff changeset
115 VectorConstants.freeConstants();
anatofuz
parents:
diff changeset
116 InlineAsms.freeConstants();
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118 CAZConstants.clear();
anatofuz
parents:
diff changeset
119 CPNConstants.clear();
anatofuz
parents:
diff changeset
120 UVConstants.clear();
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
121 PVConstants.clear();
150
anatofuz
parents:
diff changeset
122 IntConstants.clear();
anatofuz
parents:
diff changeset
123 FPConstants.clear();
anatofuz
parents:
diff changeset
124 CDSConstants.clear();
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 // Destroy attribute node lists.
anatofuz
parents:
diff changeset
127 for (FoldingSetIterator<AttributeSetNode> I = AttrsSetNodes.begin(),
anatofuz
parents:
diff changeset
128 E = AttrsSetNodes.end(); I != E; ) {
anatofuz
parents:
diff changeset
129 FoldingSetIterator<AttributeSetNode> Elem = I++;
anatofuz
parents:
diff changeset
130 delete &*Elem;
anatofuz
parents:
diff changeset
131 }
anatofuz
parents:
diff changeset
132
anatofuz
parents:
diff changeset
133 // Destroy MetadataAsValues.
anatofuz
parents:
diff changeset
134 {
anatofuz
parents:
diff changeset
135 SmallVector<MetadataAsValue *, 8> MDVs;
anatofuz
parents:
diff changeset
136 MDVs.reserve(MetadataAsValues.size());
anatofuz
parents:
diff changeset
137 for (auto &Pair : MetadataAsValues)
anatofuz
parents:
diff changeset
138 MDVs.push_back(Pair.second);
anatofuz
parents:
diff changeset
139 MetadataAsValues.clear();
anatofuz
parents:
diff changeset
140 for (auto *V : MDVs)
anatofuz
parents:
diff changeset
141 delete V;
anatofuz
parents:
diff changeset
142 }
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 // Destroy ValuesAsMetadata.
anatofuz
parents:
diff changeset
145 for (auto &Pair : ValuesAsMetadata)
anatofuz
parents:
diff changeset
146 delete Pair.second;
anatofuz
parents:
diff changeset
147 }
anatofuz
parents:
diff changeset
148
anatofuz
parents:
diff changeset
149 void LLVMContextImpl::dropTriviallyDeadConstantArrays() {
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
150 SmallSetVector<ConstantArray *, 4> WorkList;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
151
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
152 // When ArrayConstants are of substantial size and only a few in them are
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
153 // dead, starting WorkList with all elements of ArrayConstants can be
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
154 // wasteful. Instead, starting WorkList with only elements that have empty
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
155 // uses.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
156 for (ConstantArray *C : ArrayConstants)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
157 if (C->use_empty())
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
158 WorkList.insert(C);
150
anatofuz
parents:
diff changeset
159
anatofuz
parents:
diff changeset
160 while (!WorkList.empty()) {
anatofuz
parents:
diff changeset
161 ConstantArray *C = WorkList.pop_back_val();
anatofuz
parents:
diff changeset
162 if (C->use_empty()) {
anatofuz
parents:
diff changeset
163 for (const Use &Op : C->operands()) {
anatofuz
parents:
diff changeset
164 if (auto *COp = dyn_cast<ConstantArray>(Op))
anatofuz
parents:
diff changeset
165 WorkList.insert(COp);
anatofuz
parents:
diff changeset
166 }
anatofuz
parents:
diff changeset
167 C->destroyConstant();
anatofuz
parents:
diff changeset
168 }
anatofuz
parents:
diff changeset
169 }
anatofuz
parents:
diff changeset
170 }
anatofuz
parents:
diff changeset
171
anatofuz
parents:
diff changeset
172 void Module::dropTriviallyDeadConstantArrays() {
anatofuz
parents:
diff changeset
173 Context.pImpl->dropTriviallyDeadConstantArrays();
anatofuz
parents:
diff changeset
174 }
anatofuz
parents:
diff changeset
175
anatofuz
parents:
diff changeset
176 namespace llvm {
anatofuz
parents:
diff changeset
177
anatofuz
parents:
diff changeset
178 /// Make MDOperand transparent for hashing.
anatofuz
parents:
diff changeset
179 ///
anatofuz
parents:
diff changeset
180 /// This overload of an implementation detail of the hashing library makes
anatofuz
parents:
diff changeset
181 /// MDOperand hash to the same value as a \a Metadata pointer.
anatofuz
parents:
diff changeset
182 ///
anatofuz
parents:
diff changeset
183 /// Note that overloading \a hash_value() as follows:
anatofuz
parents:
diff changeset
184 ///
anatofuz
parents:
diff changeset
185 /// \code
anatofuz
parents:
diff changeset
186 /// size_t hash_value(const MDOperand &X) { return hash_value(X.get()); }
anatofuz
parents:
diff changeset
187 /// \endcode
anatofuz
parents:
diff changeset
188 ///
anatofuz
parents:
diff changeset
189 /// does not cause MDOperand to be transparent. In particular, a bare pointer
anatofuz
parents:
diff changeset
190 /// doesn't get hashed before it's combined, whereas \a MDOperand would.
anatofuz
parents:
diff changeset
191 static const Metadata *get_hashable_data(const MDOperand &X) { return X.get(); }
anatofuz
parents:
diff changeset
192
anatofuz
parents:
diff changeset
193 } // end namespace llvm
anatofuz
parents:
diff changeset
194
anatofuz
parents:
diff changeset
195 unsigned MDNodeOpsKey::calculateHash(MDNode *N, unsigned Offset) {
anatofuz
parents:
diff changeset
196 unsigned Hash = hash_combine_range(N->op_begin() + Offset, N->op_end());
anatofuz
parents:
diff changeset
197 #ifndef NDEBUG
anatofuz
parents:
diff changeset
198 {
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
199 SmallVector<Metadata *, 8> MDs(drop_begin(N->operands(), Offset));
150
anatofuz
parents:
diff changeset
200 unsigned RawHash = calculateHash(MDs);
anatofuz
parents:
diff changeset
201 assert(Hash == RawHash &&
anatofuz
parents:
diff changeset
202 "Expected hash of MDOperand to equal hash of Metadata*");
anatofuz
parents:
diff changeset
203 }
anatofuz
parents:
diff changeset
204 #endif
anatofuz
parents:
diff changeset
205 return Hash;
anatofuz
parents:
diff changeset
206 }
anatofuz
parents:
diff changeset
207
anatofuz
parents:
diff changeset
208 unsigned MDNodeOpsKey::calculateHash(ArrayRef<Metadata *> Ops) {
anatofuz
parents:
diff changeset
209 return hash_combine_range(Ops.begin(), Ops.end());
anatofuz
parents:
diff changeset
210 }
anatofuz
parents:
diff changeset
211
anatofuz
parents:
diff changeset
212 StringMapEntry<uint32_t> *LLVMContextImpl::getOrInsertBundleTag(StringRef Tag) {
anatofuz
parents:
diff changeset
213 uint32_t NewIdx = BundleTagCache.size();
anatofuz
parents:
diff changeset
214 return &*(BundleTagCache.insert(std::make_pair(Tag, NewIdx)).first);
anatofuz
parents:
diff changeset
215 }
anatofuz
parents:
diff changeset
216
anatofuz
parents:
diff changeset
217 void LLVMContextImpl::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const {
anatofuz
parents:
diff changeset
218 Tags.resize(BundleTagCache.size());
anatofuz
parents:
diff changeset
219 for (const auto &T : BundleTagCache)
anatofuz
parents:
diff changeset
220 Tags[T.second] = T.first();
anatofuz
parents:
diff changeset
221 }
anatofuz
parents:
diff changeset
222
anatofuz
parents:
diff changeset
223 uint32_t LLVMContextImpl::getOperandBundleTagID(StringRef Tag) const {
anatofuz
parents:
diff changeset
224 auto I = BundleTagCache.find(Tag);
anatofuz
parents:
diff changeset
225 assert(I != BundleTagCache.end() && "Unknown tag!");
anatofuz
parents:
diff changeset
226 return I->second;
anatofuz
parents:
diff changeset
227 }
anatofuz
parents:
diff changeset
228
anatofuz
parents:
diff changeset
229 SyncScope::ID LLVMContextImpl::getOrInsertSyncScopeID(StringRef SSN) {
anatofuz
parents:
diff changeset
230 auto NewSSID = SSC.size();
anatofuz
parents:
diff changeset
231 assert(NewSSID < std::numeric_limits<SyncScope::ID>::max() &&
anatofuz
parents:
diff changeset
232 "Hit the maximum number of synchronization scopes allowed!");
anatofuz
parents:
diff changeset
233 return SSC.insert(std::make_pair(SSN, SyncScope::ID(NewSSID))).first->second;
anatofuz
parents:
diff changeset
234 }
anatofuz
parents:
diff changeset
235
anatofuz
parents:
diff changeset
236 void LLVMContextImpl::getSyncScopeNames(
anatofuz
parents:
diff changeset
237 SmallVectorImpl<StringRef> &SSNs) const {
anatofuz
parents:
diff changeset
238 SSNs.resize(SSC.size());
anatofuz
parents:
diff changeset
239 for (const auto &SSE : SSC)
anatofuz
parents:
diff changeset
240 SSNs[SSE.second] = SSE.first();
anatofuz
parents:
diff changeset
241 }
anatofuz
parents:
diff changeset
242
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
243 /// Gets the OptPassGate for this LLVMContextImpl, which defaults to the
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
244 /// singleton OptBisect if not explicitly set.
150
anatofuz
parents:
diff changeset
245 OptPassGate &LLVMContextImpl::getOptPassGate() const {
anatofuz
parents:
diff changeset
246 if (!OPG)
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
247 OPG = &getOptBisector();
150
anatofuz
parents:
diff changeset
248 return *OPG;
anatofuz
parents:
diff changeset
249 }
anatofuz
parents:
diff changeset
250
anatofuz
parents:
diff changeset
251 void LLVMContextImpl::setOptPassGate(OptPassGate& OPG) {
anatofuz
parents:
diff changeset
252 this->OPG = &OPG;
anatofuz
parents:
diff changeset
253 }
236
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
254
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
255 bool LLVMContextImpl::hasOpaquePointersValue() {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
256 return OpaquePointers.has_value();
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
257 }
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
258
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
259 bool LLVMContextImpl::getOpaquePointers() {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
260 if (LLVM_UNLIKELY(!OpaquePointers))
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
261 OpaquePointers = OpaquePointersCL;
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
262 return *OpaquePointers;
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
263 }
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
264
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
265 void LLVMContextImpl::setOpaquePointers(bool OP) {
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
266 assert((!OpaquePointers || OpaquePointers.value() == OP) &&
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
267 "Cannot change opaque pointers mode once set");
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
268 OpaquePointers = OP;
c4bab56944e8 LLVM 16
kono
parents: 223
diff changeset
269 }