Skip to content

Commit 0b52709

Browse files
committed
SSA: Remove the need for ExitBasicBlock in SSA.
1 parent 34edda6 commit 0b52709

File tree

11 files changed

+6
-36
lines changed

11 files changed

+6
-36
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/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: 0 additions & 2 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
/**

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/internal/SsaImpl.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ module SsaInput implements SsaImplCommon::InputSig<Location> {
1818

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

21-
class ExitBasicBlock extends BasicBlock, BasicBlocks::ExitBasicBlock { }
22-
2321
class SourceVariable = LocalVariable;
2422

2523
/**

rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ module SsaInput implements SsaImplCommon::InputSig<Location> {
4747

4848
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
4949

50-
class ExitBasicBlock = BasicBlocks::ExitBasicBlock;
51-
5250
/**
5351
* A variable amenable to SSA construction.
5452
*

shared/dataflow/codeql/dataflow/VariableCapture.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ signature module InputSig<LocationSig Location> {
6767
/** Holds if `bb` is a control-flow entry point. */
6868
default predicate entryBlock(BasicBlock bb) { not exists(getImmediateBasicBlockDominator(bb)) }
6969

70-
/** Holds if `bb` is a control-flow exit point. */
71-
default predicate exitBlock(BasicBlock bb) { not exists(getABasicBlockSuccessor(bb)) }
72-
7370
/** A variable that is captured in a closure. */
7471
class CapturedVariable {
7572
/** Gets a textual representation of this variable. */
@@ -699,10 +696,6 @@ module Flow<LocationSig Location, InputSig<Location> Input> implements OutputSig
699696
result = Input::getABasicBlockSuccessor(bb)
700697
}
701698

702-
class ExitBasicBlock extends BasicBlock {
703-
ExitBasicBlock() { exitBlock(this) }
704-
}
705-
706699
class SourceVariable = CaptureContainer;
707700

708701
predicate variableWrite(BasicBlock bb, int i, SourceVariable cc, boolean certain) {

shared/ssa/codeql/ssa/Ssa.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ signature module InputSig<LocationSig Location> {
6060
/** Gets an immediate successor of basic block `bb`, if any. */
6161
BasicBlock getABasicBlockSuccessor(BasicBlock bb);
6262

63-
/**
64-
* An exit basic block, that is, a basic block whose last node is
65-
* an exit node.
66-
*/
67-
class ExitBasicBlock extends BasicBlock;
68-
6963
/** A variable that can be SSA converted. */
7064
class SourceVariable {
7165
/** Gets a textual representation of this variable. */
@@ -855,6 +849,9 @@ module Make<LocationSig Location, InputSig<Location> Input> {
855849
lastRefRedef(inp, _, _, def)
856850
}
857851

852+
/** Holds if `bb` is a control-flow exit point. */
853+
private predicate exitBlock(BasicBlock bb) { not exists(getABasicBlockSuccessor(bb)) }
854+
858855
/**
859856
* NB: If this predicate is exposed, it should be cached.
860857
*
@@ -873,7 +870,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
873870
lastSsaRefExt(def, _, bb, i) and
874871
(
875872
// Can reach exit directly
876-
bb instanceof ExitBasicBlock
873+
exitBlock(bb)
877874
or
878875
// Can reach a block using one or more steps, where `def` is no longer live
879876
varBlockReachesExitExt(def, bb)
@@ -893,7 +890,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
893890
lastSsaRef(def, _, bb, i) and
894891
(
895892
// Can reach exit directly
896-
bb instanceof ExitBasicBlock
893+
exitBlock(bb)
897894
or
898895
// Can reach a block using one or more steps, where `def` is no longer live
899896
varBlockReachesExit(def, bb)

0 commit comments

Comments
 (0)