LLVM 22.0.0git
WaitingOnGraph.h
Go to the documentation of this file.
1//===------ WaitingOnGraph.h - ORC symbol dependence graph ------*- 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// Defines WaitingOnGraph and related utilities.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_EXECUTIONENGINE_ORC_WAITINGONGRAPH_H
13#define LLVM_EXECUTIONENGINE_ORC_WAITINGONGRAPH_H
14
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/DenseSet.h"
17#include "llvm/ADT/STLExtras.h"
20
21#include <algorithm>
22#include <vector>
23
24namespace llvm::orc::detail {
25
26class WaitingOnGraphTest;
27
28/// WaitingOnGraph class template.
29///
30/// This type is intended to provide efficient dependence tracking for Symbols
31/// in an ORC program.
32///
33/// WaitingOnGraph models a directed graph with four partitions:
34/// 1. Not-yet-emitted nodes: Nodes identified as waited-on in an emit
35/// operation.
36/// 2. Emitted nodes: Nodes emitted and waiting on some non-empty set of
37/// other nodes.
38/// 3. Ready nodes: Nodes emitted and not waiting on any other nodes
39/// (either because they weren't waiting on any nodes when they were
40/// emitted, or because all transitively waited-on nodes have since
41/// been emitted).
42/// 4. Failed nodes: Nodes that have been marked as failed-to-emit, and
43/// nodes that were found to transitively wait-on some failed node.
44///
45/// Nodes are added to the graph by *emit* and *fail* operations.
46///
47/// The *emit* operation takes a bipartite *local dependence graph* as an
48/// argument and returns...
49/// a. the set of nodes (both existing and newly added from the local
50/// dependence graph) whose waiting-on set is the empty set, and...
51/// b. the set of newly added nodes that are found to depend on failed
52/// nodes.
53///
54/// The *fail* operation takes a set of failed nodes and returns the set of
55/// Emitted nodes that were waiting on the failed nodes.
56///
57/// The concrete representation adopts several approaches for efficiency:
58///
59/// 1. Only *Emitted* and *Not-yet-emitted* nodes are represented explicitly.
60/// *Ready* and *Failed* nodes are represented by the values returned by the
61/// GetExternalStateFn argument to *emit*.
62///
63/// 2. Labels are (*Container*, *Element*) pairs that are intended to represent
64/// ORC symbols (ORC uses types Container = JITDylib,
65/// Element = NonOwningSymbolStringPtr). The internal representation of the
66/// graph is optimized on the assumption that there are many more Elements
67/// (symbol names) than Containers (JITDylibs) used to construct the labels.
68/// (Consider for example the common case where most JIT'd code is placed in
69/// a single "main" JITDylib).
70///
71/// 3. The data structure stores *SuperNodes* which have multiple labels. This
72/// reduces the number of nodes and edges in the graph in the common case
73/// where many JIT symbols have the same set of dependencies. SuperNodes are
74/// coalesced when their dependence sets become equal.
75///
76/// 4. The *simplify* method can be applied to an initial *local dependence
77/// graph* (as a list of SuperNodes) to eliminate any internal dependence
78/// relationships that would have to be propagated internally by *emit*.
79/// Access to the WaitingOnGraph is assumed to be guarded by a mutex (ORC
80/// will access it from multiple threads) so this allows some pre-processing
81/// to be performed outside the mutex.
82template <typename ContainerIdT, typename ElementIdT> class WaitingOnGraph {
83 friend class WaitingOnGraphTest;
84
85public:
86 using ContainerId = ContainerIdT;
87 using ElementId = ElementIdT;
90
91 class SuperNode {
92 friend class WaitingOnGraph;
93 friend class WaitingOnGraphTest;
94
95 public:
97 : Defs(std::move(Defs)), Deps(std::move(Deps)) {}
98 ContainerElementsMap &defs() { return Defs; }
99 const ContainerElementsMap &defs() const { return Defs; }
100 ContainerElementsMap &deps() { return Deps; }
101 const ContainerElementsMap &deps() const { return Deps; }
102
103 private:
106 };
107
108private:
109 using ElemToSuperNodeMap =
111
112 using SuperNodeDepsMap = DenseMap<SuperNode *, DenseSet<SuperNode *>>;
113
114 class Coalescer {
115 public:
116 std::unique_ptr<SuperNode> addOrCreateSuperNode(ContainerElementsMap Defs,
118 auto H = getHash(Deps);
119 if (auto *ExistingSN = findCanonicalSuperNode(H, Deps)) {
120 for (auto &[Container, Elems] : Defs) {
121 auto &DstCElems = ExistingSN->Defs[Container];
122 [[maybe_unused]] size_t ExpectedSize =
123 DstCElems.size() + Elems.size();
124 DstCElems.insert(Elems.begin(), Elems.end());
125 assert(DstCElems.size() == ExpectedSize);
126 }
127 return nullptr;
128 }
129
130 auto NewSN =
131 std::make_unique<SuperNode>(std::move(Defs), std::move(Deps));
132 CanonicalSNs[H].push_back(NewSN.get());
133 return NewSN;
134 }
135
136 void coalesce(std::vector<std::unique_ptr<SuperNode>> &SNs,
137 ElemToSuperNodeMap &ElemToSN) {
138 for (size_t I = 0; I != SNs.size();) {
139 auto &SN = SNs[I];
140 auto H = getHash(SN->Deps);
141 if (auto *CanonicalSN = findCanonicalSuperNode(H, SN->Deps)) {
142 for (auto &[Container, Elems] : SN->Defs) {
143 CanonicalSN->Defs[Container].insert(Elems.begin(), Elems.end());
144 auto &ContainerElemToSN = ElemToSN[Container];
145 for (auto &Elem : Elems)
146 ContainerElemToSN[Elem] = CanonicalSN;
147 }
148 std::swap(SN, SNs.back());
149 SNs.pop_back();
150 } else {
151 CanonicalSNs[H].push_back(SN.get());
152 ++I;
153 }
154 }
155 }
156
157 template <typename Pred> void remove(Pred &&Remove) {
158 std::vector<hash_code> HashesToErase;
159 for (auto &[Hash, SNs] : CanonicalSNs) {
160 for (size_t I = 0; I != SNs.size();) {
161 if (Remove(SNs[I])) {
162 std::swap(SNs[I], SNs.back());
163 SNs.pop_back();
164 } else
165 ++I;
166 }
167 if (SNs.empty())
168 HashesToErase.push_back(Hash);
169 }
170 for (auto Hash : HashesToErase)
171 CanonicalSNs.erase(Hash);
172 }
173
174 private:
175 hash_code getHash(const ContainerElementsMap &M) {
176 SmallVector<ContainerId> SortedContainers;
177 SortedContainers.reserve(M.size());
178 for (auto &[Container, Elems] : M)
179 SortedContainers.push_back(Container);
180 llvm::sort(SortedContainers);
181 hash_code Hash(0);
182 for (auto &Container : SortedContainers) {
183 auto &ContainerElems = M.at(Container);
184 SmallVector<ElementId> SortedElems(ContainerElems.begin(),
185 ContainerElems.end());
186 llvm::sort(SortedElems);
187 Hash = hash_combine(Hash, Container, hash_combine_range(SortedElems));
188 }
189 return Hash;
190 }
191
192 SuperNode *findCanonicalSuperNode(hash_code H,
193 const ContainerElementsMap &M) {
194 for (auto *SN : CanonicalSNs[H])
195 if (SN->Deps == M)
196 return SN;
197 return nullptr;
198 }
199
200 DenseMap<hash_code, SmallVector<SuperNode *>> CanonicalSNs;
201 };
202
203public:
204 /// Build SuperNodes from (definition-set, dependence-set) pairs.
205 ///
206 /// Coalesces definition-sets with identical dependence-sets.
208 public:
210 if (Defs.empty())
211 return;
212 // Remove any self-reference.
214 for (auto &[Container, Elems] : Defs) {
215 assert(!Elems.empty() && "Defs for container must not be empty");
216 auto I = Deps.find(Container);
217 if (I == Deps.end())
218 continue;
219 auto &DepsForContainer = I->second;
220 for (auto &Elem : Elems)
221 DepsForContainer.erase(Elem);
222 if (DepsForContainer.empty())
223 ToRemove.push_back(Container);
224 }
225 for (auto &Container : ToRemove)
226 Deps.erase(Container);
227 if (auto SN = C.addOrCreateSuperNode(std::move(Defs), std::move(Deps)))
228 SNs.push_back(std::move(SN));
229 }
230 std::vector<std::unique_ptr<SuperNode>> takeSuperNodes() {
231 return std::move(SNs);
232 }
233
234 private:
235 Coalescer C;
236 std::vector<std::unique_ptr<SuperNode>> SNs;
237 };
238
239 class SimplifyResult {
240 friend class WaitingOnGraph;
241 friend class WaitingOnGraphTest;
242
243 public:
244 const std::vector<std::unique_ptr<SuperNode>> &superNodes() const {
245 return SNs;
246 }
247
248 private:
249 SimplifyResult(std::vector<std::unique_ptr<SuperNode>> SNs,
250 ElemToSuperNodeMap ElemToSN)
251 : SNs(std::move(SNs)), ElemToSN(std::move(ElemToSN)) {}
252 std::vector<std::unique_ptr<SuperNode>> SNs;
253 ElemToSuperNodeMap ElemToSN;
254 };
255
256 /// Preprocess a list of SuperNodes to remove all intra-SN dependencies.
257 static SimplifyResult simplify(std::vector<std::unique_ptr<SuperNode>> SNs) {
258 // Build ElemToSN map.
259 ElemToSuperNodeMap ElemToSN;
260 for (auto &SN : SNs) {
261 for (auto &[Container, Elements] : SN->Defs) {
262 auto &ContainerElemToSN = ElemToSN[Container];
263 for (auto &E : Elements)
264 ContainerElemToSN[E] = SN.get();
265 }
266 }
267
268 SuperNodeDepsMap SuperNodeDeps;
269 hoistDeps(SuperNodeDeps, SNs, ElemToSN);
270 propagateSuperNodeDeps(SuperNodeDeps);
271 sinkDeps(SNs, SuperNodeDeps);
272
273 // Pre-coalesce nodes.
274 Coalescer().coalesce(SNs, ElemToSN);
275
276 return {std::move(SNs), std::move(ElemToSN)};
277 }
278
279 struct EmitResult {
280 std::vector<std::unique_ptr<SuperNode>> Ready;
281 std::vector<std::unique_ptr<SuperNode>> Failed;
282 };
283
284 enum class ExternalState { None, Ready, Failed };
285
286 /// Add the given SuperNodes to the graph, returning any SuperNodes that
287 /// move to the Ready or Failed states as a result.
288 /// The GetExternalState function is used to represent SuperNodes that have
289 /// already become Ready or Failed (since such nodes are not explicitly
290 /// represented in the graph).
291 template <typename GetExternalStateFn>
292 EmitResult emit(SimplifyResult SR, GetExternalStateFn &&GetExternalState) {
293 auto NewSNs = std::move(SR.SNs);
294 auto ElemToNewSN = std::move(SR.ElemToSN);
295
296 // First process any dependencies on nodes with external state.
297 auto FailedSNs = processExternalDeps(NewSNs, GetExternalState);
298
299 // Collect the PendingSNs whose dep sets are about to be modified.
300 std::vector<std::unique_ptr<SuperNode>> ModifiedPendingSNs;
301 for (size_t I = 0; I != PendingSNs.size();) {
302 auto &SN = PendingSNs[I];
303 bool Remove = false;
304 for (auto &[Container, Elems] : SN->Deps) {
305 auto I = ElemToNewSN.find(Container);
306 if (I == ElemToNewSN.end())
307 continue;
308 for (auto Elem : Elems) {
309 if (I->second.contains(Elem)) {
310 Remove = true;
311 break;
312 }
313 }
314 if (Remove)
315 break;
316 }
317 if (Remove) {
318 ModifiedPendingSNs.push_back(std::move(SN));
319 std::swap(SN, PendingSNs.back());
320 PendingSNs.pop_back();
321 } else
322 ++I;
323 }
324
325 // Remove cycles from the graphs.
326 SuperNodeDepsMap SuperNodeDeps;
327 hoistDeps(SuperNodeDeps, ModifiedPendingSNs, ElemToNewSN);
328
329 CoalesceToPendingSNs.remove(
330 [&](SuperNode *SN) { return SuperNodeDeps.count(SN); });
331
332 hoistDeps(SuperNodeDeps, NewSNs, ElemToPendingSN);
333 propagateSuperNodeDeps(SuperNodeDeps);
334 sinkDeps(NewSNs, SuperNodeDeps);
335 sinkDeps(ModifiedPendingSNs, SuperNodeDeps);
336
337 // Process supernodes. Pending first, since we'll update PendingSNs when we
338 // incorporate NewSNs.
339 std::vector<std::unique_ptr<SuperNode>> ReadyNodes, FailedNodes;
340 processReadyOrFailed(ModifiedPendingSNs, ReadyNodes, FailedNodes,
341 SuperNodeDeps, FailedSNs, &ElemToPendingSN);
342 processReadyOrFailed(NewSNs, ReadyNodes, FailedNodes, SuperNodeDeps,
343 FailedSNs, nullptr);
344
345 CoalesceToPendingSNs.coalesce(ModifiedPendingSNs, ElemToPendingSN);
346 CoalesceToPendingSNs.coalesce(NewSNs, ElemToPendingSN);
347
348 // Integrate remaining ModifiedPendingSNs and NewSNs into PendingSNs.
349 for (auto &SN : ModifiedPendingSNs)
350 PendingSNs.push_back(std::move(SN));
351
352 // Update ElemToPendingSN for the remaining elements.
353 for (auto &SN : NewSNs) {
354 for (auto &[Container, Elems] : SN->Defs) {
355 auto &Row = ElemToPendingSN[Container];
356 for (auto &Elem : Elems)
357 Row[Elem] = SN.get();
358 }
359 PendingSNs.push_back(std::move(SN));
360 }
361
362 return {std::move(ReadyNodes), std::move(FailedNodes)};
363 }
364
365 /// Identify the given symbols as Failed.
366 /// The elements of the Failed map will not be included in the returned
367 /// result, so clients should take whatever actions are needed to mark
368 /// this as failed in their external representation.
369 std::vector<std::unique_ptr<SuperNode>>
371 std::vector<std::unique_ptr<SuperNode>> FailedSNs;
372
373 for (size_t I = 0; I != PendingSNs.size();) {
374 auto &PendingSN = PendingSNs[I];
375 bool FailPendingSN = false;
376 for (auto &[Container, Elems] : PendingSN->Deps) {
377 if (FailPendingSN)
378 break;
379 auto I = Failed.find(Container);
380 if (I == Failed.end())
381 continue;
382 for (auto &Elem : Elems) {
383 if (I->second.count(Elem)) {
384 FailPendingSN = true;
385 break;
386 }
387 }
388 }
389 if (FailPendingSN) {
390 FailedSNs.push_back(std::move(PendingSN));
391 PendingSN = std::move(PendingSNs.back());
392 PendingSNs.pop_back();
393 } else
394 ++I;
395 }
396
397 CoalesceToPendingSNs.remove([&](SuperNode *SN) {
398 for (auto &E : FailedSNs)
399 if (E.get() == SN)
400 return true;
401 return false;
402 });
403
404 for (auto &SN : FailedSNs) {
405 for (auto &[Container, Elems] : SN->Defs) {
406 assert(ElemToPendingSN.count(Container));
407 auto &CElems = ElemToPendingSN[Container];
408 for (auto &Elem : Elems)
409 CElems.erase(Elem);
410 if (CElems.empty())
411 ElemToPendingSN.erase(Container);
412 }
413 }
414
415 return FailedSNs;
416 }
417
419 bool AllGood = true;
420 auto ErrLog = [&]() -> raw_ostream & {
421 AllGood = false;
422 return Log;
423 };
424
425 size_t DefCount = 0;
426 for (auto &PendingSN : PendingSNs) {
427 if (PendingSN->Deps.empty())
428 ErrLog() << "Pending SN " << PendingSN.get() << " has empty dep set.\n";
429 else {
430 bool BadElem = false;
431 for (auto &[Container, Elems] : PendingSN->Deps) {
432 auto I = ElemToPendingSN.find(Container);
433 if (I == ElemToPendingSN.end())
434 continue;
435 if (Elems.empty())
436 ErrLog() << "Pending SN " << PendingSN.get()
437 << " has dependence map entry for " << Container
438 << " with empty element set.\n";
439 for (auto &Elem : Elems) {
440 if (I->second.count(Elem)) {
441 ErrLog() << "Pending SN " << PendingSN.get()
442 << " has dependence on emitted element ( " << Container
443 << ", " << Elem << ")\n";
444 BadElem = true;
445 break;
446 }
447 }
448 if (BadElem)
449 break;
450 }
451 }
452
453 for (auto &[Container, Elems] : PendingSN->Defs) {
454 if (Elems.empty())
455 ErrLog() << "Pending SN " << PendingSN.get()
456 << " has def map entry for " << Container
457 << " with empty element set.\n";
458 DefCount += Elems.size();
459 auto I = ElemToPendingSN.find(Container);
460 if (I == ElemToPendingSN.end())
461 ErrLog() << "Pending SN " << PendingSN.get() << " has "
462 << Elems.size() << " defs in container " << Container
463 << " not covered by ElemsToPendingSN.\n";
464 else {
465 for (auto &Elem : Elems) {
466 auto J = I->second.find(Elem);
467 if (J == I->second.end())
468 ErrLog() << "Pending SN " << PendingSN.get() << " has element ("
469 << Container << ", " << Elem
470 << ") not covered by ElemsToPendingSN.\n";
471 else if (J->second != PendingSN.get())
472 ErrLog() << "ElemToPendingSN value invalid for (" << Container
473 << ", " << Elem << ")\n";
474 }
475 }
476 }
477 }
478
479 size_t DefCount2 = 0;
480 for (auto &[Container, Elems] : ElemToPendingSN)
481 DefCount2 += Elems.size();
482
483 assert(DefCount2 >= DefCount);
484 if (DefCount2 != DefCount)
485 ErrLog() << "ElemToPendingSN contains extra elements.\n";
486
487 return AllGood;
488 }
489
490private:
491 // Replace individual dependencies with supernode dependencies.
492 //
493 // For all dependencies in SNs, if the corresponding node is defined in
494 // ElemToSN then remove the individual dependency and record the dependency
495 // on the corresponding supernode in SuperNodeDeps.
496 static void hoistDeps(SuperNodeDepsMap &SuperNodeDeps,
497 std::vector<std::unique_ptr<SuperNode>> &SNs,
498 ElemToSuperNodeMap &ElemToSN) {
499 for (auto &SN : SNs) {
500 auto &SNDeps = SuperNodeDeps[SN.get()];
501 for (auto &[DefContainer, DefElems] : ElemToSN) {
502 auto I = SN->Deps.find(DefContainer);
503 if (I == SN->Deps.end())
504 continue;
505 for (auto &[DefElem, DefSN] : DefElems)
506 if (I->second.erase(DefElem) && DefSN != SN.get())
507 SNDeps.insert(DefSN);
508 if (I->second.empty())
509 SN->Deps.erase(I);
510 }
511 }
512 }
513
514 // Compute transitive closure of deps for each node.
515 static void propagateSuperNodeDeps(SuperNodeDepsMap &SuperNodeDeps) {
516 for (auto &[SN, Deps] : SuperNodeDeps) {
517 DenseSet<SuperNode *> Reachable;
518 SmallVector<SuperNode *> Worklist(Deps.begin(), Deps.end());
519
520 while (!Worklist.empty()) {
521 auto *DepSN = Worklist.pop_back_val();
522 if (DepSN == SN)
523 continue;
524 if (!Reachable.insert(DepSN).second)
525 continue;
526 auto I = SuperNodeDeps.find(DepSN);
527 if (I == SuperNodeDeps.end())
528 continue;
529 for (auto *DepSNDep : I->second)
530 Worklist.push_back(DepSNDep);
531 }
532
533 Deps = std::move(Reachable);
534 }
535 }
536
537 // Sink SuperNode dependencies back to dependencies on individual nodes.
538 static void sinkDeps(std::vector<std::unique_ptr<SuperNode>> &SNs,
539 SuperNodeDepsMap &SuperNodeDeps) {
540 for (auto &SN : SNs) {
541 auto I = SuperNodeDeps.find(SN.get());
542 if (I == SuperNodeDeps.end())
543 continue;
544
545 for (auto *DepSN : I->second) {
546 assert(DepSN != SN.get() && "Unexpected self-dependence for SN");
547 for (auto &[Container, Elems] : DepSN->Deps)
548 SN->Deps[Container].insert(Elems.begin(), Elems.end());
549 }
550 }
551 }
552
553 template <typename GetExternalStateFn>
554 static std::vector<SuperNode *>
555 processExternalDeps(std::vector<std::unique_ptr<SuperNode>> &SNs,
556 GetExternalStateFn &GetExternalState) {
557 std::vector<SuperNode *> FailedSNs;
558 for (auto &SN : SNs) {
559 bool SNHasError = false;
560 SmallVector<ContainerId> ContainersToRemove;
561 for (auto &[Container, Elems] : SN->Deps) {
562 SmallVector<ElementId> ElemToRemove;
563 for (auto &Elem : Elems) {
564 switch (GetExternalState(Container, Elem)) {
566 break;
568 ElemToRemove.push_back(Elem);
569 break;
571 ElemToRemove.push_back(Elem);
572 SNHasError = true;
573 break;
574 }
575 }
576 for (auto &Elem : ElemToRemove)
577 Elems.erase(Elem);
578 if (Elems.empty())
579 ContainersToRemove.push_back(Container);
580 }
581 for (auto &Container : ContainersToRemove)
582 SN->Deps.erase(Container);
583 if (SNHasError)
584 FailedSNs.push_back(SN.get());
585 }
586
587 return FailedSNs;
588 }
589
590 void processReadyOrFailed(std::vector<std::unique_ptr<SuperNode>> &SNs,
591 std::vector<std::unique_ptr<SuperNode>> &Ready,
592 std::vector<std::unique_ptr<SuperNode>> &Failed,
593 SuperNodeDepsMap &SuperNodeDeps,
594 const std::vector<SuperNode *> &FailedSNs,
595 ElemToSuperNodeMap *ElemToSNs) {
596
597 SmallVector<SuperNode *> ToRemoveFromElemToSNs;
598
599 for (size_t I = 0; I != SNs.size();) {
600 auto &SN = SNs[I];
601
602 bool SNFailed = false;
603 assert(SuperNodeDeps.count(SN.get()));
604 auto &SNSuperNodeDeps = SuperNodeDeps[SN.get()];
605 for (auto *FailedSN : FailedSNs) {
606 if (FailedSN == SN.get() || SNSuperNodeDeps.count(FailedSN)) {
607 SNFailed = true;
608 break;
609 }
610 }
611
612 bool SNReady = SN->Deps.empty();
613
614 if (SNReady || SNFailed) {
615 if (ElemToSNs)
616 ToRemoveFromElemToSNs.push_back(SN.get());
617 auto &NodeList = SNFailed ? Failed : Ready;
618 NodeList.push_back(std::move(SN));
619 std::swap(SN, SNs.back());
620 SNs.pop_back();
621 } else
622 ++I;
623 }
624
625 // Update ElemToSNs (if passed) to remove elements pointing at SN.
626 for (auto *SN : ToRemoveFromElemToSNs) {
627 for (auto &[Container, Elems] : SN->defs()) {
628 auto &Row = (*ElemToSNs)[Container];
629 for (auto &Elem : Elems)
630 Row.erase(Elem);
631 }
632 }
633 }
634
635 std::vector<std::unique_ptr<SuperNode>> PendingSNs;
636 ElemToSuperNodeMap ElemToPendingSN;
637 Coalescer CoalesceToPendingSNs;
638};
639
640} // namespace llvm::orc::detail
641
642#endif // LLVM_EXECUTIONENGINE_ORC_WAITINGONGRAPH_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ReachingDefInfo InstSet & ToRemove
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
#define I(x, y, z)
Definition MD5.cpp:57
#define H(x, y, z)
Definition MD5.cpp:56
register Register Coalescer
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:178
bool erase(const KeyT &Val)
Definition DenseMap.h:330
bool empty() const
Definition DenseMap.h:109
iterator end()
Definition DenseMap.h:81
Implements a dense probed hash-table based set.
Definition DenseSet.h:279
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const std::vector< std::unique_ptr< SuperNode > > & superNodes() const
Build SuperNodes from (definition-set, dependence-set) pairs.
void add(ContainerElementsMap Defs, ContainerElementsMap Deps)
std::vector< std::unique_ptr< SuperNode > > takeSuperNodes()
const ContainerElementsMap & defs() const
const ContainerElementsMap & deps() const
SuperNode(ContainerElementsMap Defs, ContainerElementsMap Deps)
WaitingOnGraph class template.
std::vector< std::unique_ptr< SuperNode > > fail(const ContainerElementsMap &Failed)
Identify the given symbols as Failed.
EmitResult emit(SimplifyResult SR, GetExternalStateFn &&GetExternalState)
Add the given SuperNodes to the graph, returning any SuperNodes that move to the Ready or Failed stat...
static SimplifyResult simplify(std::vector< std::unique_ptr< SuperNode > > SNs)
Preprocess a list of SuperNodes to remove all intra-SN dependencies.
bool validate(raw_ostream &Log)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
SmallVector< Node, 4 > NodeList
Definition RDFGraph.h:550
testing::Matcher< const detail::ErrorHolder & > Failed()
Definition Error.h:198
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1622
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1867
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition Hashing.h:592
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:466
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:869
std::vector< std::unique_ptr< SuperNode > > Failed
std::vector< std::unique_ptr< SuperNode > > Ready