@@ -352,7 +352,7 @@ cached private module Cached {
352352 }
353353
354354 private predicate ssa_variableUpdate ( Alias:: VirtualVariable vvar ,
355- OldInstruction instr , OldBlock block , int index ) {
355+ OldBlock block , int index , OldInstruction instr ) {
356356 block .getInstruction ( index ) = instr and
357357 Alias:: getResultMemoryAccess ( instr ) .getVirtualVariable ( ) = vvar
358358 }
@@ -370,11 +370,11 @@ cached private module Cached {
370370 }
371371
372372 private predicate defUseRank ( Alias:: VirtualVariable vvar , OldBlock block , int rankIndex , int index ) {
373- index = rank [ rankIndex ] ( int j | hasDefinition ( vvar , block , j ) or hasUse ( vvar , _ , block , j ) )
373+ index = rank [ rankIndex ] ( int j | hasDefinition ( vvar , block , j ) or hasUse ( vvar , block , j , _ ) )
374374 }
375375
376- private predicate hasUse ( Alias:: VirtualVariable vvar , OldInstruction use , OldBlock block ,
377- int index ) {
376+ private predicate hasUse ( Alias:: VirtualVariable vvar , OldBlock block , int index ,
377+ OldInstruction use ) {
378378 exists ( Alias:: MemoryAccess access |
379379 (
380380 access = Alias:: getOperandMemoryAccess ( use .getAnOperand ( ) )
@@ -392,10 +392,16 @@ cached private module Cached {
392392 }
393393
394394 private predicate variableLiveOnEntryToBlock ( Alias:: VirtualVariable vvar , OldBlock block ) {
395- exists ( int index | hasUse ( vvar , _, block , index ) |
396- not exists ( int j | ssa_variableUpdate ( vvar , _, block , j ) | j < index )
397- ) or
398- ( variableLiveOnExitFromBlock ( vvar , block ) and not ssa_variableUpdate ( vvar , _, block , _) )
395+ exists ( int firstAccess |
396+ hasUse ( vvar , block , firstAccess , _) and
397+ firstAccess = min ( int index |
398+ hasUse ( vvar , block , index , _)
399+ or
400+ ssa_variableUpdate ( vvar , block , index , _)
401+ )
402+ )
403+ or
404+ ( variableLiveOnExitFromBlock ( vvar , block ) and not ssa_variableUpdate ( vvar , block , _, _) )
399405 }
400406
401407 pragma [ noinline]
@@ -422,7 +428,7 @@ cached private module Cached {
422428 private predicate hasUseAtRank ( Alias:: VirtualVariable vvar , OldBlock block , int rankIndex ,
423429 OldInstruction use ) {
424430 exists ( int index |
425- hasUse ( vvar , use , block , index ) and
431+ hasUse ( vvar , block , index , use ) and
426432 defUseRank ( vvar , block , rankIndex , index )
427433 )
428434 }
0 commit comments