@@ -304,8 +304,13 @@ template <> struct GraphTraits<BasicBlock*> {
304
304
static NodeRef getEntryNode (BasicBlock *BB) { return BB; }
305
305
static ChildIteratorType child_begin (NodeRef N) { return succ_begin (N); }
306
306
static ChildIteratorType child_end (NodeRef N) { return succ_end (N); }
307
+
308
+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
307
309
};
308
310
311
+ static_assert (GraphHasNodeNumbers<BasicBlock *>,
312
+ " GraphTraits getNumber() not detected" );
313
+
309
314
template <> struct GraphTraits <const BasicBlock*> {
310
315
using NodeRef = const BasicBlock *;
311
316
using ChildIteratorType = const_succ_iterator;
@@ -314,8 +319,13 @@ template <> struct GraphTraits<const BasicBlock*> {
314
319
315
320
static ChildIteratorType child_begin (NodeRef N) { return succ_begin (N); }
316
321
static ChildIteratorType child_end (NodeRef N) { return succ_end (N); }
322
+
323
+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
317
324
};
318
325
326
+ static_assert (GraphHasNodeNumbers<const BasicBlock *>,
327
+ " GraphTraits getNumber() not detected" );
328
+
319
329
// Provide specializations of GraphTraits to be able to treat a function as a
320
330
// graph of basic blocks... and to walk it in inverse order. Inverse order for
321
331
// a function is considered to be when traversing the predecessor edges of a BB
@@ -328,17 +338,27 @@ template <> struct GraphTraits<Inverse<BasicBlock*>> {
328
338
static NodeRef getEntryNode (Inverse<BasicBlock *> G) { return G.Graph ; }
329
339
static ChildIteratorType child_begin (NodeRef N) { return pred_begin (N); }
330
340
static ChildIteratorType child_end (NodeRef N) { return pred_end (N); }
341
+
342
+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
331
343
};
332
344
345
+ static_assert (GraphHasNodeNumbers<Inverse<BasicBlock *>>,
346
+ " GraphTraits getNumber() not detected" );
347
+
333
348
template <> struct GraphTraits <Inverse<const BasicBlock*>> {
334
349
using NodeRef = const BasicBlock *;
335
350
using ChildIteratorType = const_pred_iterator;
336
351
337
352
static NodeRef getEntryNode (Inverse<const BasicBlock *> G) { return G.Graph ; }
338
353
static ChildIteratorType child_begin (NodeRef N) { return pred_begin (N); }
339
354
static ChildIteratorType child_end (NodeRef N) { return pred_end (N); }
355
+
356
+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
340
357
};
341
358
359
+ static_assert (GraphHasNodeNumbers<Inverse<const BasicBlock *>>,
360
+ " GraphTraits getNumber() not detected" );
361
+
342
362
// ===--------------------------------------------------------------------===//
343
363
// GraphTraits specializations for function basic block graphs (CFGs)
344
364
// ===--------------------------------------------------------------------===//
@@ -362,6 +382,13 @@ template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> {
362
382
}
363
383
364
384
static size_t size (Function *F) { return F->size (); }
385
+
386
+ static unsigned getMaxNumber (const Function *F) {
387
+ return F->getMaxBlockNumber ();
388
+ }
389
+ static unsigned getNumberEpoch (const Function *F) {
390
+ return F->getBlockNumberEpoch ();
391
+ }
365
392
};
366
393
template <> struct GraphTraits <const Function*> :
367
394
public GraphTraits<const BasicBlock*> {
@@ -379,6 +406,13 @@ template <> struct GraphTraits<const Function*> :
379
406
}
380
407
381
408
static size_t size (const Function *F) { return F->size (); }
409
+
410
+ static unsigned getMaxNumber (const Function *F) {
411
+ return F->getMaxBlockNumber ();
412
+ }
413
+ static unsigned getNumberEpoch (const Function *F) {
414
+ return F->getBlockNumberEpoch ();
415
+ }
382
416
};
383
417
384
418
// Provide specializations of GraphTraits to be able to treat a function as a
@@ -391,12 +425,26 @@ template <> struct GraphTraits<Inverse<Function*>> :
391
425
static NodeRef getEntryNode (Inverse<Function *> G) {
392
426
return &G.Graph ->getEntryBlock ();
393
427
}
428
+
429
+ static unsigned getMaxNumber (const Function *F) {
430
+ return F->getMaxBlockNumber ();
431
+ }
432
+ static unsigned getNumberEpoch (const Function *F) {
433
+ return F->getBlockNumberEpoch ();
434
+ }
394
435
};
395
436
template <> struct GraphTraits <Inverse<const Function*>> :
396
437
public GraphTraits<Inverse<const BasicBlock*>> {
397
438
static NodeRef getEntryNode (Inverse<const Function *> G) {
398
439
return &G.Graph ->getEntryBlock ();
399
440
}
441
+
442
+ static unsigned getMaxNumber (const Function *F) {
443
+ return F->getMaxBlockNumber ();
444
+ }
445
+ static unsigned getNumberEpoch (const Function *F) {
446
+ return F->getBlockNumberEpoch ();
447
+ }
400
448
};
401
449
402
450
} // end namespace llvm
0 commit comments