@@ -1055,18 +1055,40 @@ module Make<InputSig Input> {
10551055 ) ;
10561056 }
10571057
1058+ /** A definition that is relevant for the consistency queries. */
1059+ abstract class RelevantDefinitionExt extends DefinitionExt {
1060+ /** Override this predicate to ensure locations in consistency results. */
1061+ abstract predicate hasLocationInfo (
1062+ string filepath , int startline , int startcolumn , int endline , int endcolumn
1063+ ) ;
1064+ }
1065+
10581066 /** Holds if a read can be reached from multiple definitions. */
10591067 query predicate nonUniqueDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
10601068 ssaDefReachesRead ( v , def , bb , i ) and
10611069 not exists ( unique( Definition def0 | ssaDefReachesRead ( v , def0 , bb , i ) ) )
10621070 }
10631071
1072+ /** Holds if a read can be reached from multiple definitions. */
1073+ query predicate nonUniqueDefExt (
1074+ RelevantDefinitionExt def , SourceVariable v , BasicBlock bb , int i
1075+ ) {
1076+ ssaDefReachesReadExt ( v , def , bb , i ) and
1077+ not exists ( unique( DefinitionExt def0 | ssaDefReachesReadExt ( v , def0 , bb , i ) ) )
1078+ }
1079+
10641080 /** Holds if a read cannot be reached from a definition. */
10651081 query predicate readWithoutDef ( SourceVariable v , BasicBlock bb , int i ) {
10661082 variableRead ( bb , i , v , _) and
10671083 not ssaDefReachesRead ( v , _, bb , i )
10681084 }
10691085
1086+ /** Holds if a read cannot be reached from a definition. */
1087+ query predicate readWithoutDefExt ( SourceVariable v , BasicBlock bb , int i ) {
1088+ variableRead ( bb , i , v , _) and
1089+ not ssaDefReachesReadExt ( v , _, bb , i )
1090+ }
1091+
10701092 /** Holds if a definition cannot reach a read. */
10711093 query predicate deadDef ( RelevantDefinition def , SourceVariable v ) {
10721094 v = def .getSourceVariable ( ) and
@@ -1075,6 +1097,15 @@ module Make<InputSig Input> {
10751097 not uncertainWriteDefinitionInput ( _, def )
10761098 }
10771099
1100+ /** Holds if a definition cannot reach a read. */
1101+ query predicate deadDefExt ( RelevantDefinitionExt def , SourceVariable v ) {
1102+ v = def .getSourceVariable ( ) and
1103+ not ssaDefReachesReadExt ( _, def , _, _) and
1104+ not phiHasInputFromBlock ( _, def , _) and
1105+ not phiReadHasInputFromBlock ( _, def , _) and
1106+ not uncertainWriteDefinitionInput ( _, def )
1107+ }
1108+
10781109 /** Holds if a read is not dominated by a definition. */
10791110 query predicate notDominatedByDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
10801111 exists ( BasicBlock bbDef , int iDef | def .definesAt ( v , bbDef , iDef ) |
@@ -1086,5 +1117,19 @@ module Make<InputSig Input> {
10861117 not def .definesAt ( v , getImmediateBasicBlockDominator * ( bb ) , _)
10871118 )
10881119 }
1120+
1121+ /** Holds if a read is not dominated by a definition. */
1122+ query predicate notDominatedByDefExt (
1123+ RelevantDefinitionExt def , SourceVariable v , BasicBlock bb , int i
1124+ ) {
1125+ exists ( BasicBlock bbDef , int iDef | def .definesAt ( v , bbDef , iDef , _) |
1126+ ssaDefReachesReadWithinBlock ( v , def , bb , i ) and
1127+ ( bb != bbDef or i < iDef )
1128+ or
1129+ ssaDefReachesReadExt ( v , def , bb , i ) and
1130+ not ssaDefReachesReadWithinBlock ( v , def , bb , i ) and
1131+ not def .definesAt ( v , getImmediateBasicBlockDominator * ( bb ) , _, _)
1132+ )
1133+ }
10891134 }
10901135}
0 commit comments