@@ -1071,157 +1071,12 @@ module SsaCached {
10711071 predicate variableWrite = SsaInput:: variableWrite / 4 ;
10721072}
10731073
1074- cached
1075- private newtype TSsaDef =
1076- TDef ( DefinitionExt def ) or
1077- TPhi ( PhiNode phi )
1078-
1079- abstract private class SsaDef extends TSsaDef {
1080- /** Gets a textual representation of this element. */
1081- string toString ( ) { none ( ) }
1082-
1083- /** Gets the underlying non-phi definition or use. */
1084- DefinitionExt asDef ( ) { none ( ) }
1085-
1086- /** Gets the underlying phi node. */
1087- PhiNode asPhi ( ) { none ( ) }
1088-
1089- /** Gets the location of this element. */
1090- abstract Location getLocation ( ) ;
1091- }
1092-
1093- abstract class Def extends SsaDef , TDef {
1094- DefinitionExt def ;
1095-
1096- Def ( ) { this = TDef ( def ) }
1097-
1098- final override DefinitionExt asDef ( ) { result = def }
1099-
1100- /** Gets the source variable underlying this SSA definition. */
1101- final SourceVariable getSourceVariable ( ) { result = def .getSourceVariable ( ) }
1102-
1103- override string toString ( ) { result = def .toString ( ) }
1104-
1105- /**
1106- * Holds if this definition (or use) has index `index` in block `block`,
1107- * and is a definition (or use) of the variable `sv`.
1108- */
1109- predicate hasIndexInBlock ( IRBlock block , int index , SourceVariable sv ) {
1110- def .definesAt ( sv , block , index , _)
1111- }
1112-
1113- /** Gets the value written by this definition, if any. */
1114- Node0Impl getValue ( ) { none ( ) }
1115-
1116- /**
1117- * Holds if this definition is guaranteed to overwrite the entire
1118- * destination's allocation.
1119- */
1120- abstract predicate isCertain ( ) ;
1121-
1122- /** Gets the address operand written to by this definition. */
1123- Operand getAddressOperand ( ) { none ( ) }
1124-
1125- /** Gets the address written to by this definition. */
1126- final Instruction getAddress ( ) { result = this .getAddressOperand ( ) .getDef ( ) }
1127-
1128- /** Gets the indirection index of this definition. */
1129- abstract int getIndirectionIndex ( ) ;
1130-
1131- /**
1132- * Gets the indirection level that this definition is writing to.
1133- * For instance, `x = y` is a definition of `x` at indirection level 1 and
1134- * `*x = y` is a definition of `x` at indirection level 2.
1135- */
1136- abstract int getIndirection ( ) ;
1137-
1138- /**
1139- * Gets a definition that ultimately defines this SSA definition and is not
1140- * itself a phi node.
1141- */
1142- Def getAnUltimateDefinition ( ) { result .asDef ( ) = def .getAnUltimateDefinition ( ) }
1143- }
1144-
1145- private predicate isGlobal ( DefinitionExt def , GlobalDefImpl global ) {
1146- exists ( SourceVariable sv , IRBlock bb , int i |
1147- def .definesAt ( sv , bb , i , _) and
1148- global .hasIndexInBlock ( bb , i , sv )
1149- )
1150- }
1151-
1152- private class NonGlobalDef extends Def {
1153- NonGlobalDef ( ) { not isGlobal ( def , _) }
1154-
1155- final override Location getLocation ( ) { result = this .getImpl ( ) .getLocation ( ) }
1156-
1157- private DefImpl getImpl ( ) {
1158- exists ( SourceVariable sv , IRBlock bb , int i |
1159- this .hasIndexInBlock ( bb , i , sv ) and
1160- result .hasIndexInBlock ( bb , i , sv )
1161- )
1162- }
1163-
1164- override Node0Impl getValue ( ) { result = this .getImpl ( ) .getValue ( ) }
1165-
1166- override predicate isCertain ( ) { this .getImpl ( ) .isCertain ( ) }
1167-
1168- override Operand getAddressOperand ( ) { result = this .getImpl ( ) .getAddressOperand ( ) }
1169-
1170- override int getIndirectionIndex ( ) { result = this .getImpl ( ) .getIndirectionIndex ( ) }
1171-
1172- override int getIndirection ( ) { result = this .getImpl ( ) .getIndirection ( ) }
1173- }
1174-
1175- class GlobalDef extends Def {
1176- GlobalDefImpl global ;
1177-
1178- GlobalDef ( ) { isGlobal ( def , global ) }
1179-
1180- /** Gets a textual representation of this definition. */
1181- override string toString ( ) { result = global .toString ( ) }
1182-
1183- final override Location getLocation ( ) { result = global .getLocation ( ) }
1184-
1185- /**
1186- * Gets the type of this definition after specifiers have been deeply stripped
1187- * and typedefs have been resolved.
1188- */
1189- DataFlowType getUnspecifiedType ( ) { result = global .getUnspecifiedType ( ) }
1190-
1191- /**
1192- * Gets the type of this definition, after typedefs have been resolved.
1193- */
1194- DataFlowType getUnderlyingType ( ) { result = global .getUnderlyingType ( ) }
1195-
1196- /** Gets the `IRFunction` whose body is evaluated after this definition. */
1197- IRFunction getIRFunction ( ) { result = global .getIRFunction ( ) }
1198-
1199- /** Gets the global variable associated with this definition. */
1200- GlobalLikeVariable getVariable ( ) { result = global .getVariable ( ) }
1201-
1202- override predicate isCertain ( ) { any ( ) }
1203-
1204- final override int getIndirectionIndex ( ) { result = global .getIndirectionIndex ( ) }
1205-
1206- final override int getIndirection ( ) { result = global .getIndirection ( ) }
1207- }
1208-
1209- class Phi extends TPhi , SsaDef {
1210- PhiNode phi ;
1211-
1212- Phi ( ) { this = TPhi ( phi ) }
1213-
1214- final override PhiNode asPhi ( ) { result = phi }
1215-
1216- final override Location getLocation ( ) { result = phi .getBasicBlock ( ) .getLocation ( ) }
1217-
1218- override string toString ( ) { result = phi .toString ( ) }
1219-
1220- SsaPhiInputNode getNode ( IRBlock block ) { result .getPhiNode ( ) = phi and result .getBlock ( ) = block }
1074+ class GlobalDef extends DefinitionExt {
1075+ GlobalDefImpl impl ;
12211076
1222- predicate hasInputFromBlock ( Definition inp , IRBlock bb ) { inp = phiHasInputFromBlockExt ( phi , bb ) }
1077+ GlobalDef ( ) { impl = this . getImpl ( ) }
12231078
1224- final Definition getAnInput ( ) { this . hasInputFromBlock ( result , _ ) }
1079+ GlobalLikeVariable getVariable ( ) { result = impl . getVariable ( ) }
12251080}
12261081
12271082private module SsaImpl = SsaImplCommon:: Make< Location , SsaInput > ;
0 commit comments