@@ -19,12 +19,6 @@ private module SourceVariables {
1919 )
2020 }
2121
22- class BaseSourceVariable = SsaInternals0:: BaseSourceVariable ;
23-
24- class BaseIRVariable = SsaInternals0:: BaseIRVariable ;
25-
26- class BaseCallVariable = SsaInternals0:: BaseCallVariable ;
27-
2822 cached
2923 private newtype TSourceVariable =
3024 TSourceIRVariable ( BaseIRVariable baseVar , int ind ) {
@@ -159,15 +153,10 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
159153 * Gets the instruction that computes the base of this definition or use.
160154 * This is always a `VariableAddressInstruction` or an `AllocationInstruction`.
161155 */
162- abstract Instruction getBase ( ) ;
156+ abstract BaseSourceVariableInstruction getBase ( ) ;
163157
164158 final BaseSourceVariable getBaseSourceVariable ( ) {
165- exists ( IRVariable var |
166- result .( BaseIRVariable ) .getIRVariable ( ) = var and
167- instructionHasIRVariable ( this .getBase ( ) , var )
168- )
169- or
170- result .( BaseCallVariable ) .getCallInstruction ( ) = this .getBase ( )
159+ this .getBase ( ) .getBaseSourceVariable ( ) = result
171160 }
172161
173162 /** Gets the variable that is defined or used. */
@@ -179,11 +168,6 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
179168 }
180169}
181170
182- pragma [ noinline]
183- private predicate instructionHasIRVariable ( VariableAddressInstruction vai , IRVariable var ) {
184- vai .getIRVariable ( ) = var
185- }
186-
187171private predicate defOrUseHasSourceVariable ( DefOrUseImpl defOrUse , BaseSourceVariable bv , int ind ) {
188172 defHasSourceVariable ( defOrUse , bv , ind )
189173 or
@@ -214,7 +198,7 @@ class DefImpl extends DefOrUseImpl, TDefImpl {
214198
215199 DefImpl ( ) { this = TDefImpl ( address , ind ) }
216200
217- override Instruction getBase ( ) { isDef ( _, _, address , result , _, _) }
201+ override BaseSourceVariableInstruction getBase ( ) { isDef ( _, _, address , result , _, _) }
218202
219203 Operand getAddressOperand ( ) { result = address }
220204
@@ -259,7 +243,7 @@ class UseImpl extends DefOrUseImpl, TUseImpl {
259243
260244 override int getIndirectionIndex ( ) { result = ind }
261245
262- override Instruction getBase ( ) { isUse ( _, operand , result , _, ind ) }
246+ override BaseSourceVariableInstruction getBase ( ) { isUse ( _, operand , result , _, ind ) }
263247
264248 predicate isCertain ( ) { isUse ( true , operand , _, _, ind ) }
265249}
@@ -308,9 +292,8 @@ predicate outNodeHasAddressAndIndex(
308292}
309293
310294private predicate defToNode ( Node nodeFrom , Def def ) {
311- // TODO: This is not yet needed (and in fact, the compiler rejects it because `exists(def.getValue().asOperand())` never holds).
312- // nodeHasOperand(nodeFrom, def.getValue().asOperand(), def.getIndirectionIndex())
313- // or
295+ nodeHasOperand ( nodeFrom , def .getValue ( ) .asOperand ( ) , def .getIndirectionIndex ( ) )
296+ or
314297 nodeHasInstruction ( nodeFrom , def .getValue ( ) .asInstruction ( ) , def .getIndirectionIndex ( ) )
315298}
316299
@@ -415,22 +398,14 @@ predicate fromPhiNode(SsaPhiNode nodeFrom, Node nodeTo) {
415398 )
416399}
417400
418- private SsaInternals0:: SourceVariable getOldSourceVariable ( SourceVariable v ) {
419- v .getBaseVariable ( ) .( BaseIRVariable ) .getIRVariable ( ) =
420- result .getBaseVariable ( ) .( SsaInternals0:: BaseIRVariable ) .getIRVariable ( )
421- or
422- v .getBaseVariable ( ) .( BaseCallVariable ) .getCallInstruction ( ) =
423- result .getBaseVariable ( ) .( SsaInternals0:: BaseCallVariable ) .getCallInstruction ( )
424- }
425-
426401/**
427402 * Holds if there is a write at index `i` in basic block `bb` to variable `v` that's
428403 * subsequently read (as determined by the SSA pruning stage).
429404 */
430405private predicate variableWriteCand ( IRBlock bb , int i , SourceVariable v ) {
431406 exists ( SsaInternals0:: Def def , SsaInternals0:: SourceVariable v0 |
432407 def .asDefOrUse ( ) .hasIndexInBlock ( bb , i , v0 ) and
433- v0 = getOldSourceVariable ( v )
408+ v0 = v . getBaseVariable ( )
434409 )
435410}
436411
0 commit comments