Skip to content

Commit e1c810a

Browse files
authored
Merge pull request github#18729 from aschackmull/ssa/deprecate-deadcode
Ssa: Deprecate the unused getALastRead predicate.
2 parents 9971398 + c5d0e2f commit e1c810a

File tree

20 files changed

+40
-673
lines changed

20 files changed

+40
-673
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,4 @@ module InputSigCommon {
769769
BasicBlock getImmediateBasicBlockDominator(BasicBlock bb) { result.immediatelyDominates(bb) }
770770

771771
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
772-
773-
class ExitBasicBlock extends BasicBlock {
774-
ExitBasicBlock() { this.getLastInstruction() instanceof ExitFunctionInstruction }
775-
}
776772
}

csharp/ql/lib/semmle/code/csharp/controlflow/internal/PreSsa.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module PreSsa {
9090

9191
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
9292

93-
class ExitBasicBlock extends BasicBlock {
93+
private class ExitBasicBlock extends BasicBlock {
9494
ExitBasicBlock() { scopeLast(_, this.getLastElement(), _) }
9595
}
9696

csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ module Ssa {
345345
* - The read of `this.Field` on line 11 is a last read of the phi node
346346
* between lines 9 and 10.
347347
*/
348-
final AssignableRead getALastRead() { result = this.getALastReadAtNode(_) }
348+
deprecated final AssignableRead getALastRead() { result = this.getALastReadAtNode(_) }
349349

350350
/**
351351
* Gets a last read of the source variable underlying this SSA definition at
@@ -375,7 +375,7 @@ module Ssa {
375375
* - The read of `this.Field` on line 11 is a last read of the phi node
376376
* between lines 9 and 10.
377377
*/
378-
final AssignableRead getALastReadAtNode(ControlFlow::Node cfn) {
378+
deprecated final AssignableRead getALastReadAtNode(ControlFlow::Node cfn) {
379379
SsaImpl::lastReadSameVar(this, cfn) and
380380
result.getAControlFlowNode() = cfn
381381
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/BaseSSA.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ module BaseSsa {
5555

5656
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
5757

58-
class ExitBasicBlock extends BasicBlock, ControlFlow::BasicBlocks::ExitBlock { }
59-
6058
class SourceVariable = PreSsa::SimpleLocalScopeVariable;
6159

6260
predicate variableWrite(BasicBlock bb, int i, SourceVariable v, boolean certain) {

csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ private module SsaInput implements SsaImplCommon::InputSig<Location> {
1717

1818
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
1919

20-
class ExitBasicBlock extends BasicBlock, ControlFlow::BasicBlocks::ExitBlock { }
21-
2220
class SourceVariable = Ssa::SourceVariable;
2321

2422
/**
@@ -784,7 +782,9 @@ private predicate adjacentDefReachesUncertainRead(
784782

785783
/** Same as `lastRefRedef`, but skips uncertain reads. */
786784
pragma[nomagic]
787-
private predicate lastRefSkipUncertainReads(Definition def, SsaInput::BasicBlock bb, int i) {
785+
deprecated private predicate lastRefSkipUncertainReads(
786+
Definition def, SsaInput::BasicBlock bb, int i
787+
) {
788788
Impl::lastRef(def, bb, i) and
789789
not SsaInput::variableRead(bb, i, def.getSourceVariable(), false)
790790
or
@@ -794,6 +794,15 @@ private predicate lastRefSkipUncertainReads(Definition def, SsaInput::BasicBlock
794794
)
795795
}
796796

797+
pragma[nomagic]
798+
deprecated predicate lastReadSameVar(Definition def, ControlFlow::Node cfn) {
799+
exists(ControlFlow::BasicBlock bb, int i |
800+
lastRefSkipUncertainReads(def, bb, i) and
801+
variableReadActual(bb, i, _) and
802+
cfn = bb.getNode(i)
803+
)
804+
}
805+
797806
cached
798807
private module Cached {
799808
cached
@@ -957,15 +966,6 @@ private module Cached {
957966
)
958967
}
959968

960-
cached
961-
predicate lastReadSameVar(Definition def, ControlFlow::Node cfn) {
962-
exists(ControlFlow::BasicBlock bb, int i |
963-
lastRefSkipUncertainReads(def, bb, i) and
964-
variableReadActual(bb, i, _) and
965-
cfn = bb.getNode(i)
966-
)
967-
}
968-
969969
cached
970970
Definition uncertainWriteDefinitionInput(UncertainWriteDefinition def) {
971971
Impl::uncertainWriteDefinitionInput(def, result)

csharp/ql/test/library-tests/dataflow/ssa/SsaDefLastRead.expected

Lines changed: 0 additions & 259 deletions
This file was deleted.

csharp/ql/test/library-tests/dataflow/ssa/SsaDefLastRead.ql

Lines changed: 0 additions & 5 deletions
This file was deleted.

javascript/ql/lib/semmle/javascript/dataflow/internal/VariableCapture.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
240240
BasicBlock getImmediateBasicBlockDominator(BasicBlock bb) { result = bb.getImmediateDominator() }
241241

242242
predicate entryBlock(BasicBlock bb) { bb instanceof js::EntryBasicBlock }
243-
244-
predicate exitBlock(BasicBlock bb) { bb.getLastNode() instanceof js::ControlFlowExitNode }
245243
}
246244

247245
module VariableCaptureOutput = Flow<js::DbLocation, VariableCaptureConfig>;

javascript/ql/lib/semmle/javascript/dataflow/internal/sharedlib/Ssa.qll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ module SsaConfig implements InputSig<js::DbLocation> {
1414

1515
class BasicBlock = js::BasicBlock;
1616

17-
class ExitBasicBlock extends BasicBlock {
18-
ExitBasicBlock() { this.isExitBlock() }
19-
}
20-
2117
class SourceVariable extends LocalVariableOrThis {
2218
SourceVariable() { not this.isCaptured() }
2319
}

ruby/ql/lib/codeql/ruby/dataflow/SSA.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module Ssa {
102102
* end
103103
* ```
104104
*/
105-
final VariableReadAccessCfgNode getALastRead() { SsaImpl::lastRead(this, result) }
105+
deprecated final VariableReadAccessCfgNode getALastRead() { SsaImpl::lastRead(this, result) }
106106

107107
/**
108108
* Holds if `read1` and `read2` are adjacent reads of this SSA definition.

0 commit comments

Comments
 (0)