@@ -130,7 +130,7 @@ module SemanticExprConfig {
130130
131131 newtype TSsaVariable =
132132 TSsaInstruction ( IR:: Instruction instr ) { instr .hasMemoryResult ( ) } or
133- TSsaOperand ( IR:: Operand op ) { op .isDefinitionInexact ( ) }
133+ TSsaOperand ( IR:: PhiInputOperand op ) { op .isDefinitionInexact ( ) }
134134
135135 class SsaVariable extends TSsaVariable {
136136 string toString ( ) { none ( ) }
@@ -139,7 +139,7 @@ module SemanticExprConfig {
139139
140140 IR:: Instruction asInstruction ( ) { none ( ) }
141141
142- IR:: Operand asOperand ( ) { none ( ) }
142+ IR:: PhiInputOperand asOperand ( ) { none ( ) }
143143 }
144144
145145 class SsaInstructionVariable extends SsaVariable , TSsaInstruction {
@@ -155,15 +155,15 @@ module SemanticExprConfig {
155155 }
156156
157157 class SsaOperand extends SsaVariable , TSsaOperand {
158- IR:: Operand op ;
158+ IR:: PhiInputOperand op ;
159159
160160 SsaOperand ( ) { this = TSsaOperand ( op ) }
161161
162162 final override string toString ( ) { result = op .toString ( ) }
163163
164164 final override Location getLocation ( ) { result = op .getLocation ( ) }
165165
166- final override IR:: Operand asOperand ( ) { result = op }
166+ final override IR:: PhiInputOperand asOperand ( ) { result = op }
167167 }
168168
169169 predicate explicitUpdate ( SsaVariable v , Expr sourceExpr ) {
@@ -190,83 +190,25 @@ module SemanticExprConfig {
190190
191191 SemType getSsaVariableType ( SsaVariable v ) {
192192 result = getSemanticType ( v .asInstruction ( ) .getResultIRType ( ) )
193+ or
194+ result = getSemanticType ( v .asOperand ( ) .getUse ( ) .getResultIRType ( ) )
193195 }
194196
195197 BasicBlock getSsaVariableBasicBlock ( SsaVariable v ) {
196198 result = v .asInstruction ( ) .getBlock ( )
197199 or
198- result = v .asOperand ( ) .getUse ( ) .getBlock ( )
199- }
200-
201- private newtype TReadPosition =
202- TReadPositionBlock ( IR:: IRBlock block ) or
203- TReadPositionPhiInputEdge ( IR:: IRBlock pred , IR:: IRBlock succ ) {
204- exists ( IR:: PhiInputOperand input |
205- pred = input .getPredecessorBlock ( ) and
206- succ = input .getUse ( ) .getBlock ( )
207- )
208- }
209-
210- class SsaReadPosition extends TReadPosition {
211- string toString ( ) { none ( ) }
212-
213- Location getLocation ( ) { none ( ) }
214-
215- predicate hasRead ( SsaVariable v ) { none ( ) }
216- }
217-
218- private class SsaReadPositionBlock extends SsaReadPosition , TReadPositionBlock {
219- IR:: IRBlock block ;
220-
221- SsaReadPositionBlock ( ) { this = TReadPositionBlock ( block ) }
222-
223- final override string toString ( ) { result = block .toString ( ) }
224-
225- final override Location getLocation ( ) { result = block .getLocation ( ) }
226-
227- final override predicate hasRead ( SsaVariable v ) {
228- exists ( IR:: Operand operand | operand .getDef ( ) = v .asInstruction ( ) |
229- not operand instanceof IR:: PhiInputOperand and
230- operand .getUse ( ) .getBlock ( ) = block
231- )
232- }
233- }
234-
235- private class SsaReadPositionPhiInputEdge extends SsaReadPosition , TReadPositionPhiInputEdge {
236- IR:: IRBlock pred ;
237- IR:: IRBlock succ ;
238-
239- SsaReadPositionPhiInputEdge ( ) { this = TReadPositionPhiInputEdge ( pred , succ ) }
240-
241- final override string toString ( ) { result = pred .toString ( ) + "->" + succ .toString ( ) }
242-
243- final override Location getLocation ( ) { result = succ .getLocation ( ) }
244-
245- final override predicate hasRead ( SsaVariable v ) {
246- exists ( IR:: PhiInputOperand operand | operand .getDef ( ) = v .asInstruction ( ) |
247- operand .getPredecessorBlock ( ) = pred and
248- operand .getUse ( ) .getBlock ( ) = succ
249- )
250- }
251- }
252-
253- predicate hasReadOfSsaVariable ( SsaReadPosition pos , SsaVariable v ) { pos .hasRead ( v ) }
254-
255- predicate readBlock ( SsaReadPosition pos , BasicBlock block ) { pos = TReadPositionBlock ( block ) }
256-
257- predicate phiInputEdge ( SsaReadPosition pos , BasicBlock origBlock , BasicBlock phiBlock ) {
258- pos = TReadPositionPhiInputEdge ( origBlock , phiBlock )
200+ result = v .asOperand ( ) .getAnyDef ( ) .getBlock ( )
259201 }
260202
261- predicate phiInput ( SsaReadPosition pos , SsaVariable phi , SsaVariable input ) {
203+ /** Holds if `inp` is an input to the phi node along the edge originating in `bb`. */
204+ predicate phiInputFromBlock ( SsaVariable phi , SsaVariable inp , BasicBlock bb ) {
262205 exists ( IR:: PhiInputOperand operand |
263- pos = TReadPositionPhiInputEdge ( operand .getPredecessorBlock ( ) , operand .getUse ( ) .getBlock ( ) )
264- |
206+ bb = operand .getPredecessorBlock ( ) and
265207 phi .asInstruction ( ) = operand .getUse ( ) and
266208 (
267- input .asInstruction ( ) = operand .getDef ( )
209+ inp .asInstruction ( ) = operand .getDef ( )
268210 or
269- input .asOperand ( ) = operand
211+ inp .asOperand ( ) = operand
270212 )
271213 )
272214 }
0 commit comments