@@ -10,13 +10,12 @@ private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs as FIO
10
10
private import semmle.code.cpp.ir.internal.IRCppLanguage
11
11
private import semmle.code.cpp.ir.dataflow.internal.ModelUtil
12
12
private import DataFlowPrivate
13
- private import ssa0.SsaInternals as SsaInternals0
14
13
import SsaInternalsCommon
15
14
16
15
private module SourceVariables {
17
16
cached
18
17
private newtype TSourceVariable =
19
- TMkSourceVariable ( SsaInternals0 :: SourceVariable base , int ind ) {
18
+ TMkSourceVariable ( BaseSourceVariable base , int ind ) {
20
19
ind = [ 0 .. countIndirectionsForCppType ( base .getLanguageType ( ) ) + 1 ]
21
20
}
22
21
@@ -30,7 +29,7 @@ private module SourceVariables {
30
29
}
31
30
32
31
class SourceVariable extends TSourceVariable {
33
- SsaInternals0 :: SourceVariable base ;
32
+ BaseSourceVariable base ;
34
33
int ind ;
35
34
36
35
SourceVariable ( ) { this = TMkSourceVariable ( base , ind ) }
@@ -42,7 +41,7 @@ private module SourceVariables {
42
41
* Gets the base source variable (i.e., the variable without any
43
42
* indirections) of this source variable.
44
43
*/
45
- SsaInternals0 :: SourceVariable getBaseVariable ( ) { result = base }
44
+ BaseSourceVariable getBaseVariable ( ) { result = base }
46
45
47
46
/** Gets a textual representation of this element. */
48
47
string toString ( ) { result = repeatStars ( this .getIndirection ( ) ) + base .toString ( ) }
@@ -105,16 +104,7 @@ predicate hasRawIndirectInstruction(Instruction instr, int indirectionIndex) {
105
104
cached
106
105
private newtype TDefOrUseImpl =
107
106
TDefImpl ( BaseSourceVariableInstruction base , Operand address , int indirectionIndex ) {
108
- isDef ( _, _, address , base , _, indirectionIndex ) and
109
- (
110
- // We only include the definition if the SSA pruning stage
111
- // concluded that the definition is live after the write.
112
- any ( SsaInternals0:: Def def ) .getAddressOperand ( ) = address
113
- or
114
- // Since the pruning stage doesn't know about global variables we can't use the above check to
115
- // rule out dead assignments to globals.
116
- base .( VariableAddressInstruction ) .getAstVariable ( ) instanceof GlobalLikeVariable
117
- )
107
+ isDef ( _, _, address , base , _, indirectionIndex )
118
108
} or
119
109
TUseImpl ( BaseSourceVariableInstruction base , Operand operand , int indirectionIndex ) {
120
110
isUse ( _, operand , base , _, indirectionIndex ) and
@@ -133,8 +123,7 @@ private newtype TDefOrUseImpl =
133
123
TIteratorDef (
134
124
Operand iteratorDerefAddress , BaseSourceVariableInstruction container , int indirectionIndex
135
125
) {
136
- isIteratorDef ( container , iteratorDerefAddress , _, _, indirectionIndex ) and
137
- any ( SsaInternals0:: Def def | def .isIteratorDef ( ) ) .getAddressOperand ( ) = iteratorDerefAddress
126
+ isIteratorDef ( container , iteratorDerefAddress , _, _, indirectionIndex )
138
127
} or
139
128
TIteratorUse (
140
129
Operand iteratorAddress , BaseSourceVariableInstruction container , int indirectionIndex
@@ -984,17 +973,6 @@ predicate fromPhiNode(SsaPhiNode nodeFrom, Node nodeTo) {
984
973
)
985
974
}
986
975
987
- /**
988
- * Holds if there is a write at index `i` in basic block `bb` to variable `v` that's
989
- * subsequently read (as determined by the SSA pruning stage).
990
- */
991
- private predicate variableWriteCand ( IRBlock bb , int i , SourceVariable v ) {
992
- exists ( SsaInternals0:: Def def , SsaInternals0:: SourceVariable v0 |
993
- def .asDefOrUse ( ) .hasIndexInBlock ( bb , i , v0 ) and
994
- v0 = v .getBaseVariable ( )
995
- )
996
- }
997
-
998
976
private predicate sourceVariableIsGlobal (
999
977
SourceVariable sv , GlobalLikeVariable global , IRFunction func , int indirectionIndex
1000
978
) {
@@ -1018,16 +996,14 @@ private module SsaInput implements SsaImplCommon::InputSig<Location> {
1018
996
predicate variableWrite ( IRBlock bb , int i , SourceVariable v , boolean certain ) {
1019
997
DataFlowImplCommon:: forceCachingInSameStage ( ) and
1020
998
(
1021
- variableWriteCand ( bb , i , v ) or
1022
- sourceVariableIsGlobal ( v , _, _, _)
1023
- ) and
1024
- exists ( DefImpl def | def .hasIndexInBlock ( bb , i , v ) |
1025
- if def .isCertain ( ) then certain = true else certain = false
1026
- )
1027
- or
1028
- exists ( GlobalDefImpl global |
1029
- global .hasIndexInBlock ( bb , i , v ) and
1030
- certain = true
999
+ exists ( DefImpl def | def .hasIndexInBlock ( bb , i , v ) |
1000
+ if def .isCertain ( ) then certain = true else certain = false
1001
+ )
1002
+ or
1003
+ exists ( GlobalDefImpl global |
1004
+ global .hasIndexInBlock ( bb , i , v ) and
1005
+ certain = true
1006
+ )
1031
1007
)
1032
1008
}
1033
1009
0 commit comments