@@ -304,8 +304,13 @@ template <> struct GraphTraits<BasicBlock*> {
304304 static NodeRef getEntryNode (BasicBlock *BB) { return BB; }
305305 static ChildIteratorType child_begin (NodeRef N) { return succ_begin (N); }
306306 static ChildIteratorType child_end (NodeRef N) { return succ_end (N); }
307+
308+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
307309};
308310
311+ static_assert (GraphHasNodeNumbers<BasicBlock *>,
312+ " GraphTraits getNumber() not detected" );
313+
309314template <> struct GraphTraits <const BasicBlock*> {
310315 using NodeRef = const BasicBlock *;
311316 using ChildIteratorType = const_succ_iterator;
@@ -314,8 +319,13 @@ template <> struct GraphTraits<const BasicBlock*> {
314319
315320 static ChildIteratorType child_begin (NodeRef N) { return succ_begin (N); }
316321 static ChildIteratorType child_end (NodeRef N) { return succ_end (N); }
322+
323+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
317324};
318325
326+ static_assert (GraphHasNodeNumbers<const BasicBlock *>,
327+ " GraphTraits getNumber() not detected" );
328+
319329// Provide specializations of GraphTraits to be able to treat a function as a
320330// graph of basic blocks... and to walk it in inverse order. Inverse order for
321331// a function is considered to be when traversing the predecessor edges of a BB
@@ -328,17 +338,27 @@ template <> struct GraphTraits<Inverse<BasicBlock*>> {
328338 static NodeRef getEntryNode (Inverse<BasicBlock *> G) { return G.Graph ; }
329339 static ChildIteratorType child_begin (NodeRef N) { return pred_begin (N); }
330340 static ChildIteratorType child_end (NodeRef N) { return pred_end (N); }
341+
342+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
331343};
332344
345+ static_assert (GraphHasNodeNumbers<Inverse<BasicBlock *>>,
346+ " GraphTraits getNumber() not detected" );
347+
333348template <> struct GraphTraits <Inverse<const BasicBlock*>> {
334349 using NodeRef = const BasicBlock *;
335350 using ChildIteratorType = const_pred_iterator;
336351
337352 static NodeRef getEntryNode (Inverse<const BasicBlock *> G) { return G.Graph ; }
338353 static ChildIteratorType child_begin (NodeRef N) { return pred_begin (N); }
339354 static ChildIteratorType child_end (NodeRef N) { return pred_end (N); }
355+
356+ static unsigned getNumber (const BasicBlock *BB) { return BB->getNumber (); }
340357};
341358
359+ static_assert (GraphHasNodeNumbers<Inverse<const BasicBlock *>>,
360+ " GraphTraits getNumber() not detected" );
361+
342362// ===--------------------------------------------------------------------===//
343363// GraphTraits specializations for function basic block graphs (CFGs)
344364// ===--------------------------------------------------------------------===//
@@ -362,6 +382,13 @@ template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> {
362382 }
363383
364384 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+ }
365392};
366393template <> struct GraphTraits <const Function*> :
367394 public GraphTraits<const BasicBlock*> {
@@ -379,6 +406,13 @@ template <> struct GraphTraits<const Function*> :
379406 }
380407
381408 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+ }
382416};
383417
384418// Provide specializations of GraphTraits to be able to treat a function as a
@@ -391,12 +425,26 @@ template <> struct GraphTraits<Inverse<Function*>> :
391425 static NodeRef getEntryNode (Inverse<Function *> G) {
392426 return &G.Graph ->getEntryBlock ();
393427 }
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+ }
394435};
395436template <> struct GraphTraits <Inverse<const Function*>> :
396437 public GraphTraits<Inverse<const BasicBlock*>> {
397438 static NodeRef getEntryNode (Inverse<const Function *> G) {
398439 return &G.Graph ->getEntryBlock ();
399440 }
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+ }
400448};
401449
402450} // end namespace llvm
0 commit comments