@@ -51,6 +51,7 @@ module InstructionSanity {
5151 * Holds if instruction `instr` is missing an expected operand with tag `tag`.
5252 */
5353 query predicate missingOperand ( Instruction instr , string message , IRFunction func , string funcText ) {
54+ instr .getAST ( ) .fromSource ( ) and
5455 exists ( OperandTag tag |
5556 expectsOperand ( instr , tag ) and
5657 not exists ( NonPhiOperand operand |
@@ -68,6 +69,7 @@ module InstructionSanity {
6869 * Holds if instruction `instr` has an unexpected operand with tag `tag`.
6970 */
7071 query predicate unexpectedOperand ( Instruction instr , OperandTag tag ) {
72+ instr .getAST ( ) .fromSource ( ) and
7173 exists ( NonPhiOperand operand |
7274 operand = instr .getAnOperand ( ) and
7375 operand .getOperandTag ( ) = tag ) and
@@ -80,6 +82,7 @@ module InstructionSanity {
8082 * Holds if instruction `instr` has multiple operands with tag `tag`.
8183 */
8284 query predicate duplicateOperand ( Instruction instr , OperandTag tag ) {
85+ instr .getAST ( ) .fromSource ( ) and
8386 strictcount ( NonPhiOperand operand |
8487 operand = instr .getAnOperand ( ) and
8588 operand .getOperandTag ( ) = tag
@@ -92,6 +95,7 @@ module InstructionSanity {
9295 * the predecessor block `pred`.
9396 */
9497 query predicate missingPhiOperand ( PhiInstruction instr , IRBlock pred ) {
98+ instr .getAST ( ) .fromSource ( ) and pred .getEnclosingFunction ( ) .fromSource ( ) and
9599 pred = instr .getBlock ( ) .getAPredecessor ( ) and
96100 not exists ( PhiInputOperand operand |
97101 operand = instr .getAnOperand ( ) and
@@ -111,6 +115,7 @@ module InstructionSanity {
111115 * Holds if an instruction, other than `ExitFunction`, has no successors.
112116 */
113117 query predicate instructionWithoutSuccessor ( Instruction instr ) {
118+ instr .getAST ( ) .fromSource ( ) and
114119 not exists ( instr .getASuccessor ( ) ) and
115120 not instr instanceof ExitFunctionInstruction and
116121 // Phi instructions aren't linked into the instruction-level flow graph.
@@ -125,6 +130,7 @@ module InstructionSanity {
125130 query predicate ambiguousSuccessors (
126131 Instruction source , EdgeKind kind , int n , Instruction target
127132 ) {
133+ source .getAST ( ) .fromSource ( ) and target .getAST ( ) .fromSource ( ) and
128134 n = strictcount ( Instruction t | source .getSuccessor ( kind ) = t ) and
129135 n > 1 and
130136 source .getSuccessor ( kind ) = target
@@ -135,6 +141,7 @@ module InstructionSanity {
135141 * contains no element that can cause loops.
136142 */
137143 query predicate unexplainedLoop ( Callable f , Instruction instr ) {
144+ instr .getAST ( ) .fromSource ( ) and f .fromSource ( ) and
138145 exists ( IRBlock block |
139146 instr .getBlock ( ) = block and
140147 block .getEnclosingFunction ( ) = f and
@@ -149,6 +156,7 @@ module InstructionSanity {
149156 * predecessors.
150157 */
151158 query predicate unnecessaryPhiInstruction ( PhiInstruction instr ) {
159+ instr .getAST ( ) .fromSource ( ) and
152160 count ( instr .getBlock ( ) .getAPredecessor ( ) ) < 2
153161 }
154162
@@ -157,6 +165,7 @@ module InstructionSanity {
157165 * a different function.
158166 */
159167 query predicate operandAcrossFunctions ( Operand operand , Instruction instr , Instruction defInstr ) {
168+ instr .getAST ( ) .fromSource ( ) and defInstr .getAST ( ) .fromSource ( ) and
160169 operand .getUseInstruction ( ) = instr and
161170 operand .getDefinitionInstruction ( ) = defInstr and
162171 instr .getEnclosingIRFunction ( ) != defInstr .getEnclosingIRFunction ( )
@@ -166,11 +175,13 @@ module InstructionSanity {
166175 * Holds if instruction `instr` is not in exactly one block.
167176 */
168177 query predicate instructionWithoutUniqueBlock ( Instruction instr , int blockCount ) {
178+ instr .getAST ( ) .fromSource ( ) and
169179 blockCount = count ( instr .getBlock ( ) ) and
170180 blockCount != 1
171181 }
172182
173183 private predicate forwardEdge ( IRBlock b1 , IRBlock b2 ) {
184+ b1 .getEnclosingFunction ( ) .fromSource ( ) and b2 .getEnclosingFunction ( ) .fromSource ( ) and
174185 b1 .getASuccessor ( ) = b2 and
175186 not b1 .getBackEdgeSuccessor ( _) = b2
176187 }
@@ -181,6 +192,7 @@ module InstructionSanity {
181192 * This check ensures we don't have too _few_ back edges.
182193 */
183194 query predicate containsLoopOfForwardEdges ( IRFunction f ) {
195+ f .getFunction ( ) .fromSource ( ) and
184196 exists ( IRBlock block |
185197 forwardEdge + ( block , block ) and
186198 block .getEnclosingIRFunction ( ) = f
@@ -196,6 +208,7 @@ module InstructionSanity {
196208 * This check ensures we don't have too _many_ back edges.
197209 */
198210 query predicate lostReachability ( IRBlock block ) {
211+ block .getEnclosingFunction ( ) .fromSource ( ) and
199212 exists ( IRFunction f , IRBlock entry |
200213 entry = f .getEntryBlock ( ) and
201214 entry .getASuccessor + ( ) = block and
@@ -209,6 +222,7 @@ module InstructionSanity {
209222 * and the `IRBlock` graph.
210223 */
211224 query predicate backEdgeCountMismatch ( Callable f , int fromInstr , int fromBlock ) {
225+ f .fromSource ( ) and
212226 fromInstr = count ( Instruction i1 , Instruction i2 |
213227 i1 .getEnclosingCallable ( ) = f and i1 .getBackEdgeSuccessor ( _) = i2
214228 ) and
@@ -625,7 +639,7 @@ class FunctionInstruction extends Instruction {
625639 Callable callableSymbol ;
626640
627641 FunctionInstruction ( ) {
628- callableSymbol = Construction:: getInstructionFunction ( this )
642+ callableSymbol = Construction:: getInstructionCallable ( this )
629643 }
630644
631645 override final string getImmediateString ( ) {
0 commit comments