@@ -8,6 +8,22 @@ private import internal.IRBlockImports as Imports
88import Imports:: EdgeKind
99private import Cached
1010
11+ /**
12+ * Holds if `block` is a block in `func` and `sortOverride`, `sortKey1`, and `sortKey2` are the
13+ * sort keys of the block (derived from its first instruction)
14+ */
15+ pragma [ nomagic]
16+ private predicate blockSortKeys (
17+ IRFunction func , IRBlockBase block , int sortOverride , int sortKey1 , int sortKey2
18+ ) {
19+ block .getEnclosingIRFunction ( ) = func and
20+ block .getFirstInstruction ( ) .hasSortKeys ( sortKey1 , sortKey2 ) and
21+ // Ensure that the block containing `EnterFunction` always comes first.
22+ if block .getFirstInstruction ( ) instanceof EnterFunctionInstruction
23+ then sortOverride = 0
24+ else sortOverride = 1
25+ }
26+
1127/**
1228 * A basic block in the IR. A basic block consists of a sequence of `Instructions` with the only
1329 * incoming edges at the beginning of the sequence and the only outgoing edges at the end of the
@@ -37,17 +53,14 @@ class IRBlockBase extends TIRBlock {
3753 exists ( IRConfiguration:: IRConfiguration config |
3854 config .shouldEvaluateDebugStringsForFunction ( this .getEnclosingFunction ( ) )
3955 ) and
40- this =
41- rank [ result + 1 ] ( IRBlock funcBlock , int sortOverride , int sortKey1 , int sortKey2 |
42- funcBlock .getEnclosingFunction ( ) = this .getEnclosingFunction ( ) and
43- funcBlock .getFirstInstruction ( ) .hasSortKeys ( sortKey1 , sortKey2 ) and
44- // Ensure that the block containing `EnterFunction` always comes first.
45- if funcBlock .getFirstInstruction ( ) instanceof EnterFunctionInstruction
46- then sortOverride = 0
47- else sortOverride = 1
48- |
49- funcBlock order by sortOverride , sortKey1 , sortKey2
50- )
56+ exists ( IRFunction func |
57+ this =
58+ rank [ result + 1 ] ( IRBlock funcBlock , int sortOverride , int sortKey1 , int sortKey2 |
59+ blockSortKeys ( func , funcBlock , sortOverride , sortKey1 , sortKey2 )
60+ |
61+ funcBlock order by sortOverride , sortKey1 , sortKey2
62+ )
63+ )
5164 }
5265
5366 /**
0 commit comments