@@ -36,28 +36,6 @@ private module Cached {
36
36
not Ssa:: ignoreOperand ( op ) and exists ( Ssa:: getIRRepresentationOfOperand ( op ) )
37
37
}
38
38
}
39
-
40
- /**
41
- * Gets an additional term that is added to the `join` and `branch` computations to reflect
42
- * an additional forward or backwards branching factor that is not taken into account
43
- * when calculating the (virtual) dispatch cost.
44
- *
45
- * Argument `arg` is part of a path from a source to a sink, and `p` is the target parameter.
46
- */
47
- pragma [ nomagic]
48
- cached
49
- int getAdditionalFlowIntoCallNodeTerm ( ArgumentNode arg , ParameterNode p ) {
50
- DataFlowImplCommon:: forceCachingInSameStage ( ) and
51
- exists (
52
- ParameterNode switchee , SwitchInstruction switch , ConditionOperand op , DataFlowCall call
53
- |
54
- DataFlowImplCommon:: viableParamArg ( call , p , arg ) and
55
- DataFlowImplCommon:: viableParamArg ( call , switchee , _) and
56
- switch .getExpressionOperand ( ) = op and
57
- getAdditionalFlowIntoCallNodeTermStep + ( switchee , operandNode ( op ) ) and
58
- result = countNumberOfBranchesUsingParameter ( switch , p )
59
- )
60
- }
61
39
}
62
40
63
41
import Cached
@@ -1433,78 +1411,6 @@ private predicate localStepsToSwitch(Node node) {
1433
1411
)
1434
1412
}
1435
1413
1436
- /**
1437
- * Holds if `node` is part of a path from a `ParameterNode` to an operand
1438
- * of a `SwitchInstruction`.
1439
- */
1440
- private predicate localStepsFromParameterToSwitch ( Node node ) {
1441
- localStepsToSwitch ( node ) and
1442
- (
1443
- node instanceof ParameterNode
1444
- or
1445
- exists ( Node prev |
1446
- localStepsFromParameterToSwitch ( prev ) and
1447
- localFlowStepWithSummaries ( prev , node )
1448
- )
1449
- )
1450
- }
1451
-
1452
- /**
1453
- * The local flow relation `localFlowStepWithSummaries` pruned to only
1454
- * include steps that are part of a path from a `ParameterNode` to an
1455
- * operand of a `SwitchInstruction`.
1456
- */
1457
- private predicate getAdditionalFlowIntoCallNodeTermStep ( Node node1 , Node node2 ) {
1458
- localStepsFromParameterToSwitch ( node1 ) and
1459
- localStepsFromParameterToSwitch ( node2 ) and
1460
- localFlowStepWithSummaries ( node1 , node2 )
1461
- }
1462
-
1463
- /** Gets the `IRVariable` associated with the parameter node `p`. */
1464
- pragma [ nomagic]
1465
- private IRVariable getIRVariableForParameterNode ( ParameterNode p ) {
1466
- result = p .( InstructionDirectParameterNode ) .getIRVariable ( )
1467
- or
1468
- result .getAst ( ) = p .( IndirectParameterNode ) .getParameter ( )
1469
- }
1470
-
1471
- /** Holds if `v` is the source variable corresponding to the parameter represented by `p`. */
1472
- pragma [ nomagic]
1473
- private predicate parameterNodeHasSourceVariable ( ParameterNode p , Ssa:: SourceVariable v ) {
1474
- v .getIRVariable ( ) = getIRVariableForParameterNode ( p ) and
1475
- exists ( Position pos | p .isParameterOf ( _, pos ) |
1476
- pos instanceof DirectPosition and
1477
- v .getIndirection ( ) = 1
1478
- or
1479
- pos .( IndirectionPosition ) .getIndirectionIndex ( ) + 1 = v .getIndirection ( )
1480
- )
1481
- }
1482
-
1483
- private EdgeKind caseOrDefaultEdge ( ) {
1484
- result instanceof CaseEdge or
1485
- result instanceof DefaultEdge
1486
- }
1487
-
1488
- /**
1489
- * Gets the number of switch branches that that read from (or write to) the parameter `p`.
1490
- */
1491
- private int countNumberOfBranchesUsingParameter ( SwitchInstruction switch , ParameterNode p ) {
1492
- exists ( Ssa:: SourceVariable sv |
1493
- parameterNodeHasSourceVariable ( p , sv ) and
1494
- // Count the number of cases that use the parameter. We do this by finding the phi node
1495
- // that merges the uses/defs of the parameter. There might be multiple such phi nodes, so
1496
- // we pick the one with the highest edge count.
1497
- result =
1498
- max ( SsaPhiNode phi |
1499
- switch .getSuccessor ( caseOrDefaultEdge ( ) ) .getBlock ( ) .dominanceFrontier ( ) =
1500
- phi .getBasicBlock ( ) and
1501
- phi .getSourceVariable ( ) = sv
1502
- |
1503
- strictcount ( phi .getAnInput ( ) )
1504
- )
1505
- )
1506
- }
1507
-
1508
1414
pragma [ nomagic]
1509
1415
private predicate isInputOutput (
1510
1416
DF:: DataFlowFunction target , Node node1 , Node node2 , IO:: FunctionInput input ,
0 commit comments