File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 27
27
28
28
#include " bolt/Core/BinaryBasicBlock.h"
29
29
#include " bolt/Core/BinaryContext.h"
30
+ #include " bolt/Core/BinaryDomTree.h"
30
31
#include " bolt/Core/BinaryLoop.h"
31
32
#include " bolt/Core/BinarySection.h"
32
33
#include " bolt/Core/DebugData.h"
@@ -266,6 +267,7 @@ class BinaryFunction {
266
267
BinaryContext &BC;
267
268
268
269
std::unique_ptr<BinaryLoopInfo> BLI;
270
+ std::unique_ptr<BinaryDominatorTree> BDT;
269
271
270
272
// / All labels in the function that are referenced via relocations from
271
273
// / data objects. Typically these are jump table destinations and computed
@@ -838,6 +840,14 @@ class BinaryFunction {
838
840
// / stats.
839
841
void calculateMacroOpFusionStats ();
840
842
843
+ // / Returns if BinaryDominatorTree has been constructed for this function.
844
+ bool hasDomTree () const { return BDT != nullptr ; }
845
+
846
+ BinaryDominatorTree &getDomTree () { return *BDT.get (); }
847
+
848
+ // / Constructs DomTree for this function.
849
+ void constructDomTree ();
850
+
841
851
// / Returns if loop detection has been run for this function.
842
852
bool hasLoopInfo () const { return BLI != nullptr ; }
843
853
Original file line number Diff line number Diff line change 12
12
13
13
#include " bolt/Core/BinaryFunction.h"
14
14
#include " bolt/Core/BinaryBasicBlock.h"
15
- #include " bolt/Core/BinaryDomTree.h"
16
15
#include " bolt/Core/DynoStats.h"
17
16
#include " bolt/Core/HashUtilities.h"
18
17
#include " bolt/Core/MCPlusBuilder.h"
@@ -4076,12 +4075,17 @@ BinaryFunction::~BinaryFunction() {
4076
4075
delete BB;
4077
4076
}
4078
4077
4078
+ void BinaryFunction::constructDomTree () {
4079
+ BDT.reset (new BinaryDominatorTree);
4080
+ BDT->recalculate (*this );
4081
+ }
4082
+
4079
4083
void BinaryFunction::calculateLoopInfo () {
4084
+ if (!hasDomTree ())
4085
+ constructDomTree ();
4080
4086
// Discover loops.
4081
- BinaryDominatorTree DomTree;
4082
- DomTree.recalculate (*this );
4083
4087
BLI.reset (new BinaryLoopInfo ());
4084
- BLI->analyze (DomTree );
4088
+ BLI->analyze (getDomTree () );
4085
4089
4086
4090
// Traverse discovered loops and add depth and profile information.
4087
4091
std::stack<BinaryLoop *> St;
You can’t perform that action at this time.
0 commit comments