@@ -154,6 +154,8 @@ private string location_string(EssaVariable v) {
154154 |
155155 def = TEssaNodeDefinition ( _, b , index )
156156 or
157+ def = TEssaNodeRefinement ( _, b , index )
158+ or
157159 def = TEssaEdgeDefinition ( _, _, b ) and index = piIndex ( )
158160 or
159161 def = TPhiFunction ( _, b ) and index = phiIndex ( )
@@ -177,7 +179,11 @@ private int var_rank(EssaVariable v) {
177179/** Underlying IPA type for EssaDefinition and EssaVariable. */
178180private cached newtype TEssaDefinition =
179181 TEssaNodeDefinition ( SsaSourceVariable v , BasicBlock b , int i ) {
180- EssaDefinitions:: variableUpdate ( v , _, b , _, i )
182+ EssaDefinitions:: variableDefinition ( v , _, b , _, i )
183+ }
184+ or
185+ TEssaNodeRefinement ( SsaSourceVariable v , BasicBlock b , int i ) {
186+ EssaDefinitions:: variableRefinement ( v , _, b , _, i )
181187 }
182188 or
183189 TEssaEdgeDefinition ( SsaSourceVariable v , BasicBlock pred , BasicBlock succ ) {
@@ -446,21 +452,15 @@ class PhiFunction extends EssaDefinition, TPhiFunction {
446452 }
447453}
448454
449- library class EssaNode extends EssaDefinition , TEssaNodeDefinition {
455+ /** A definition of an ESSA variable that is not directly linked to
456+ * another ESSA variable.
457+ */
458+ class EssaNodeDefinition extends EssaDefinition , TEssaNodeDefinition {
450459
451460 override string toString ( ) {
452461 result = "Essa node definition"
453462 }
454463
455- /** Gets the ControlFlowNode corresponding to this definition */
456- ControlFlowNode getDefiningNode ( ) {
457- this .definedBy ( _, result )
458- }
459-
460- override Location getLocation ( ) {
461- result = this .getDefiningNode ( ) .getLocation ( )
462- }
463-
464464 override ControlFlowNode getAUse ( ) {
465465 exists ( SsaSourceVariable v , BasicBlock b , int i |
466466 this = TEssaNodeDefinition ( v , b , i ) and
@@ -479,6 +479,15 @@ library class EssaNode extends EssaDefinition, TEssaNodeDefinition {
479479 this = TEssaNodeDefinition ( result , _, _)
480480 }
481481
482+ /** Gets the ControlFlowNode corresponding to this definition */
483+ ControlFlowNode getDefiningNode ( ) {
484+ this .definedBy ( _, result )
485+ }
486+
487+ override Location getLocation ( ) {
488+ result = this .getDefiningNode ( ) .getLocation ( )
489+ }
490+
482491 override string getRepresentation ( ) {
483492 result = this .getDefiningNode ( ) .toString ( )
484493 }
@@ -501,27 +510,9 @@ library class EssaNode extends EssaDefinition, TEssaNodeDefinition {
501510
502511}
503512
504- /** A definition of an ESSA variable that is not directly linked to
505- * another ESSA variable.
506- */
507- class EssaNodeDefinition extends EssaNode {
508-
509- EssaNodeDefinition ( ) {
510- this .getSourceVariable ( ) .hasDefiningNode ( this .getDefiningNode ( ) )
511- }
512-
513- }
514-
515513/** A definition of an ESSA variable that takes another ESSA variable as an input.
516514 */
517- class EssaNodeRefinement extends EssaNode {
518-
519- EssaNodeRefinement ( ) {
520- exists ( SsaSourceVariable v , ControlFlowNode def |
521- this .definedBy ( v , def ) and
522- v .hasRefinement ( _, def )
523- )
524- }
515+ class EssaNodeRefinement extends EssaDefinition , TEssaNodeRefinement {
525516
526517 override string toString ( ) {
527518 result = "SSA filter definition"
@@ -533,22 +524,62 @@ class EssaNodeRefinement extends EssaNode {
533524 not result = potential_input ( potential_input ( this ) .getDefinition ( ) )
534525 }
535526
527+ override ControlFlowNode getAUse ( ) {
528+ exists ( SsaSourceVariable v , BasicBlock b , int i |
529+ this = TEssaNodeRefinement ( v , b , i ) and
530+ SsaDefinitions:: reachesUse ( v , b , i , result )
531+ )
532+ }
533+
534+ override predicate reachesEndOfBlock ( BasicBlock b ) {
535+ exists ( BasicBlock defb , int i |
536+ this = TEssaNodeRefinement ( _, defb , i ) and
537+ SsaDefinitions:: reachesEndOfBlock ( this .getSourceVariable ( ) , defb , i , b )
538+ )
539+ }
540+
541+ override SsaSourceVariable getSourceVariable ( ) {
542+ this = TEssaNodeRefinement ( result , _, _)
543+ }
544+
545+ /** Gets the ControlFlowNode corresponding to this definition */
546+ ControlFlowNode getDefiningNode ( ) {
547+ this .definedBy ( _, result )
548+ }
549+
550+ override Location getLocation ( ) {
551+ result = this .getDefiningNode ( ) .getLocation ( )
552+ }
553+
536554 override string getRepresentation ( ) {
537555 result = this .getAQlClass ( ) + "(" + this .getInput ( ) .getRepresentation ( ) + ")"
538556 }
539557
558+ override Scope getScope ( ) {
559+ exists ( BasicBlock defb |
560+ this = TEssaNodeRefinement ( _, defb , _) and
561+ result = defb .getScope ( )
562+ )
563+ }
564+
565+ predicate definedBy ( SsaSourceVariable v , ControlFlowNode def ) {
566+ exists ( BasicBlock b , int i |
567+ def = b .getNode ( i ) |
568+ this = TEssaNodeRefinement ( v , b , i + i )
569+ or
570+ this = TEssaNodeRefinement ( v , b , i + i + 1 )
571+ )
572+ }
573+
540574}
541575
542576pragma [ noopt]
543577private EssaVariable potential_input ( EssaNodeRefinement ref ) {
544- exists ( EssaNode node , ControlFlowNode use , SsaSourceVariable var , ControlFlowNode def |
578+ exists ( ControlFlowNode use , SsaSourceVariable var , ControlFlowNode def |
545579 var .hasRefinement ( use , def ) and
546580 use = result .getAUse ( ) and
547581 var = result .getSourceVariable ( ) and
548- def = node .getDefiningNode ( ) and
549- var = node .getSourceVariable ( ) and
550- ref = ( EssaNodeRefinement ) node
582+ def = ref .getDefiningNode ( ) and
583+ var = ref .getSourceVariable ( )
551584 )
552585}
553-
554-
0 commit comments