@@ -2606,23 +2606,6 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
2606
2606
) ;
2607
2607
}
2608
2608
2609
- /**
2610
- * A node where some checking is required, and hence the big-step relation
2611
- * is not allowed to step over.
2612
- */
2613
- additional class FlowCheckNode extends NodeEx {
2614
- FlowCheckNode ( ) {
2615
- revFlow ( this , _, _) and
2616
- (
2617
- castNode ( this .asNode ( ) ) or
2618
- clearsContentCached ( this .asNode ( ) , _) or
2619
- expectsContentCached ( this .asNode ( ) , _) or
2620
- neverSkipInPathGraph ( this .asNode ( ) ) or
2621
- Config:: neverSkip ( this .asNode ( ) )
2622
- )
2623
- }
2624
- }
2625
-
2626
2609
/**
2627
2610
* Provides a big-step relation for local flow steps.
2628
2611
*
@@ -2631,6 +2614,23 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
2631
2614
* reachable in this stage.
2632
2615
*/
2633
2616
additional module LocalFlowBigStep< LocalFlowBigStepInputSig Input> {
2617
+ /**
2618
+ * A node where some checking is required, and hence the big-step relation
2619
+ * is not allowed to step over.
2620
+ */
2621
+ private class FlowCheckNode extends NodeEx {
2622
+ FlowCheckNode ( ) {
2623
+ revFlow ( this , _, _) and
2624
+ (
2625
+ castNode ( this .asNode ( ) ) or
2626
+ clearsContentCached ( this .asNode ( ) , _) or
2627
+ expectsContentCached ( this .asNode ( ) , _) or
2628
+ neverSkipInPathGraph ( this .asNode ( ) ) or
2629
+ Config:: neverSkip ( this .asNode ( ) )
2630
+ )
2631
+ }
2632
+ }
2633
+
2634
2634
private predicate additionalLocalStateStep (
2635
2635
NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 , DataFlowType t ,
2636
2636
LocalCallContext lcc , string label
@@ -2647,7 +2647,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
2647
2647
* Holds if `node` can be the first node in a maximal subsequence of local
2648
2648
* flow steps in a dataflow path.
2649
2649
*/
2650
- private predicate localFlowEntry ( NodeEx node , FlowState state , Ap ap ) {
2650
+ predicate localFlowEntry ( NodeEx node , FlowState state , Ap ap ) {
2651
2651
revFlow ( node , state , ap ) and
2652
2652
(
2653
2653
sourceNode ( node , state )
@@ -2679,7 +2679,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
2679
2679
* Holds if `node` can be the last node in a maximal subsequence of local
2680
2680
* flow steps in a dataflow path.
2681
2681
*/
2682
- private predicate localFlowExit ( NodeEx node , FlowState state , Ap ap ) {
2682
+ predicate localFlowExit ( NodeEx node , FlowState state , Ap ap ) {
2683
2683
revFlow ( node , pragma [ only_bind_into ] ( state ) , pragma [ only_bind_into ] ( ap ) ) and
2684
2684
(
2685
2685
exists ( NodeEx next , Ap apNext | revFlow ( next , pragma [ only_bind_into ] ( state ) , apNext ) |
@@ -3788,7 +3788,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
3788
3788
import CallContextSensitivity< CallContextSensitivityInput >
3789
3789
import NoLocalCallContext
3790
3790
3791
- additional module BigStepInput implements PrevStage:: LocalFlowBigStepInputSig {
3791
+ private module BigStepInput implements PrevStage:: LocalFlowBigStepInputSig {
3792
3792
bindingset [ node1, state1]
3793
3793
bindingset [ node2, state2]
3794
3794
predicate localStep (
@@ -4409,46 +4409,28 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
4409
4409
import LocalCallContext
4410
4410
4411
4411
private module BigStepInput implements PrevStage:: LocalFlowBigStepInputSig {
4412
- private predicate smallStep = Stage3Param:: BigStepInput:: localStep / 8 ;
4413
-
4414
- private predicate localStepCand (
4415
- NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 , boolean preservesValue
4416
- ) {
4417
- Stage5Param:: localStep ( node1 , state1 , _, _, _, _, _, _) and
4418
- smallStep ( node1 , state1 , node2 , state2 , preservesValue , _, _, _)
4419
- or
4420
- exists ( FlowState midState , NodeEx midNode |
4421
- localStepCand ( node1 , state1 , midNode , midState , preservesValue ) and
4422
- smallStep ( midNode , midState , node2 , state2 , _, _, _, _) and
4423
- not (
4424
- Stage5Param:: localStep ( midNode , midState , _, _, _, _, _, _) and
4425
- Stage5Param:: localStep ( _, _, midNode , midState , _, _, _, _)
4426
- ) and
4427
- not midNode instanceof Stage5:: FlowCheckNode
4428
- )
4429
- }
4430
-
4431
- /**
4432
- * When calculating `localFlowBigStep` based on `Stage5Param::localStep`, which
4433
- * is already a big-step relation, we must be careful to avoid quadratic blowup.
4434
- *
4435
- * This is achieved by restricting `Stage5Param::localStep` to those node pairs
4436
- * reacheable via 1 or more `smallStep`s, where any intermediate node is not
4437
- * already part of `Stage5Param::localStep`.
4438
- */
4439
- pragma [ nomagic]
4440
- predicate localStep (
4441
- NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 , boolean preservesValue ,
4442
- DataFlowType t , LocalCallContext lcc , string label
4443
- ) {
4444
- localStepCand ( node1 , state1 , node2 , state2 , preservesValue ) and
4445
- Stage5Param:: localStep ( node1 , state1 , node2 , state2 , preservesValue , t , lcc , label ) and
4446
- PrevStage:: revFlow ( node1 , pragma [ only_bind_into ] ( state1 ) , _) and
4447
- PrevStage:: revFlow ( node2 , pragma [ only_bind_into ] ( state2 ) , _)
4448
- }
4412
+ predicate localStep = Stage5Param:: localStep / 8 ;
4449
4413
}
4450
4414
4451
- predicate localStep = PrevStage:: LocalFlowBigStep< BigStepInput > :: localFlowBigStep / 8 ;
4415
+ pragma [ nomagic]
4416
+ predicate localStep (
4417
+ NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 , boolean preservesValue ,
4418
+ DataFlowType t , LocalCallContext lcc , string label
4419
+ ) {
4420
+ // The following should be equivalent to
4421
+ //
4422
+ // ```
4423
+ // PrevStage::LocalFlowBigStep<BigStepInput>::localFlowBigStep
4424
+ // ```
4425
+ //
4426
+ // but avoids computing the big-step relation based on an existing big-step
4427
+ // releation, which may have worst-case quadratic complexity.
4428
+ exists ( AccessPathApprox ap |
4429
+ BigStepInput:: localStep ( node1 , state1 , node2 , state2 , preservesValue , t , lcc , label ) and
4430
+ PrevStage:: LocalFlowBigStep< BigStepInput > :: localFlowEntry ( node1 , state1 , ap ) and
4431
+ PrevStage:: LocalFlowBigStep< BigStepInput > :: localFlowExit ( node2 , state2 , ap )
4432
+ )
4433
+ }
4452
4434
4453
4435
bindingset [ node, state, t0, ap]
4454
4436
predicate filter ( NodeEx node , FlowState state , Typ t0 , Ap ap , Typ t ) {
0 commit comments