@@ -1036,6 +1036,16 @@ module SsaCached {
1036
1036
) {
1037
1037
SsaImpl:: lastRefRedefExt ( def , sv , bb , i , next )
1038
1038
}
1039
+
1040
+ cached
1041
+ Definition phiHasInputFromBlock ( PhiNode phi , IRBlock bb ) {
1042
+ SsaImpl:: phiHasInputFromBlock ( phi , result , bb )
1043
+ }
1044
+
1045
+ cached
1046
+ predicate ssaDefReachesRead ( SourceVariable v , Definition def , IRBlock bb , int i ) {
1047
+ SsaImpl:: ssaDefReachesRead ( v , def , bb , i )
1048
+ }
1039
1049
}
1040
1050
1041
1051
cached
@@ -1104,6 +1114,12 @@ abstract class Def extends SsaDef, TDef {
1104
1114
* instead of the other way around.
1105
1115
*/
1106
1116
abstract int getIndirection ( ) ;
1117
+
1118
+ /**
1119
+ * Gets a definition that ultimately defines this SSA definition and is not
1120
+ * itself a phi node.
1121
+ */
1122
+ Def getAnUltimateDefinition ( ) { result .asDef ( ) = def .getAnUltimateDefinition ( ) }
1107
1123
}
1108
1124
1109
1125
private predicate isGlobal ( DefinitionExt def , GlobalDefImpl global ) {
@@ -1182,6 +1198,10 @@ class Phi extends TPhi, SsaDef {
1182
1198
override string toString ( ) { result = "Phi" }
1183
1199
1184
1200
SsaPhiNode getNode ( ) { result .getPhiNode ( ) = phi }
1201
+
1202
+ predicate hasInputFromBlock ( Definition inp , IRBlock bb ) { inp = phiHasInputFromBlock ( phi , bb ) }
1203
+
1204
+ final Definition getAnInput ( ) { this .hasInputFromBlock ( result , _) }
1185
1205
}
1186
1206
1187
1207
private module SsaImpl = SsaImplCommon:: Make< Location , SsaInput > ;
@@ -1204,9 +1224,29 @@ class PhiNode extends SsaImpl::DefinitionExt {
1204
1224
* on reads instead of writes.
1205
1225
*/
1206
1226
predicate isPhiRead ( ) { this instanceof SsaImpl:: PhiReadNode }
1227
+
1228
+ /** Holds if `inp` is an input to this phi node along the edge originating in `bb`. */
1229
+ predicate hasInputFromBlock ( Definition inp , IRBlock bb ) {
1230
+ inp = SsaCached:: phiHasInputFromBlock ( this , bb )
1231
+ }
1232
+
1233
+ /** Gets a definition that is an input to this phi node. */
1234
+ final Definition getAnInput ( ) { this .hasInputFromBlock ( result , _) }
1207
1235
}
1208
1236
1209
- class DefinitionExt = SsaImpl:: DefinitionExt ;
1237
+ /** An static single assignment (SSA) definition. */
1238
+ class DefinitionExt extends SsaImpl:: DefinitionExt {
1239
+ private Definition getAPhiInputOrPriorDefinition ( ) { result = this .( PhiNode ) .getAnInput ( ) }
1240
+
1241
+ /**
1242
+ * Gets a definition that ultimately defines this SSA definition and is
1243
+ * not itself a phi node.
1244
+ */
1245
+ final DefinitionExt getAnUltimateDefinition ( ) {
1246
+ result = this .getAPhiInputOrPriorDefinition * ( ) and
1247
+ not result instanceof PhiNode
1248
+ }
1249
+ }
1210
1250
1211
1251
class Definition = SsaImpl:: Definition ;
1212
1252
0 commit comments