@@ -25,15 +25,7 @@ cached private module Cached {
2525 not oldInstruction instanceof OldIR:: PhiInstruction and
2626 hasChiNode ( _, oldInstruction )
2727 } or
28- UnreachedTag ( OldInstruction oldInstruction , EdgeKind kind ) {
29- // We need an `Unreached` instruction for the destination of any edge whose predecessor
30- // instruction is reachable, but whose successor block is not. This should occur only for
31- // infeasible edges.
32- exists ( OldIR:: Instruction succInstruction |
33- succInstruction = oldInstruction .getSuccessor ( kind ) and
34- not succInstruction instanceof OldInstruction
35- )
36- }
28+ UnreachedTag ( )
3729
3830 cached class InstructionTagType extends TInstructionTag {
3931 cached final string toString ( ) {
@@ -133,11 +125,12 @@ cached private module Cached {
133125 resultType = vvar .getType ( ) and
134126 isGLValue = false
135127 ) or
136- exists ( OldInstruction oldInstruction , EdgeKind kind |
137- oldInstruction .getFunction ( ) = func and
138- tag = UnreachedTag ( oldInstruction , kind ) and
128+ exists ( OldInstruction oldInstruction |
129+ func = oldInstruction .getFunction ( ) and
130+ Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , _) and
131+ tag = UnreachedTag ( ) and
139132 opcode instanceof Opcode:: Unreached and
140- ast = oldInstruction . getSuccessor ( kind ) . getAST ( ) and
133+ ast = func and
141134 resultType instanceof VoidType and
142135 isGLValue = false
143136 )
@@ -213,7 +206,7 @@ cached private module Cached {
213206 exists ( Alias:: VirtualVariable vvar , OldBlock phiBlock ,
214207 OldBlock defBlock , int defRank , int defIndex , OldBlock predBlock |
215208 hasPhiNode ( vvar , phiBlock ) and
216- predBlock = phiBlock .getAPredecessor ( ) and
209+ predBlock = phiBlock .getAFeasiblePredecessor ( ) and
217210 instr .getTag ( ) = PhiTag ( vvar , phiBlock ) and
218211 newPredecessorBlock = getNewBlock ( predBlock ) and
219212 hasDefinitionAtRank ( vvar , defBlock , defRank , defIndex ) and
@@ -266,13 +259,22 @@ cached private module Cached {
266259 result = getChiInstruction ( getOldInstruction ( instruction ) ) and
267260 kind instanceof GotoEdge
268261 else (
269- result = getNewInstruction ( getOldInstruction ( instruction ) .getSuccessor ( kind ) )
270- or
262+ exists ( OldInstruction oldInstruction |
263+ oldInstruction = getOldInstruction ( instruction ) and
264+ (
265+ if Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , kind ) then (
266+ result .getTag ( ) = UnreachedTag ( ) and
267+ result .getFunction ( ) = instruction .getFunction ( )
268+ )
269+ else (
270+ result = getNewInstruction ( oldInstruction .getSuccessor ( kind ) )
271+ )
272+ )
273+ ) or
271274 exists ( OldInstruction oldInstruction |
272275 instruction = getChiInstruction ( oldInstruction ) and
273276 result = getNewInstruction ( oldInstruction .getSuccessor ( kind ) )
274- ) or
275- result .getTag ( ) = UnreachedTag ( getOldInstruction ( instruction ) , kind )
277+ )
276278 )
277279 }
278280
@@ -380,7 +382,7 @@ cached private module Cached {
380382
381383 pragma [ noinline]
382384 private predicate variableLiveOnExitFromBlock ( Alias:: VirtualVariable vvar , OldBlock block ) {
383- variableLiveOnEntryToBlock ( vvar , block .getASuccessor ( ) )
385+ variableLiveOnEntryToBlock ( vvar , block .getAFeasibleSuccessor ( ) )
384386 }
385387
386388 /**
@@ -474,7 +476,7 @@ cached private module Cached {
474476 useRank ) or
475477 (
476478 definitionReachesEndOfBlock ( vvar , defBlock , defRank ,
477- useBlock .getAPredecessor ( ) ) and
479+ useBlock .getAFeasiblePredecessor ( ) ) and
478480 not definitionReachesUseWithinBlock ( vvar , useBlock , _, useBlock , useRank )
479481 )
480482 )
@@ -518,9 +520,9 @@ cached private module CachedForDebugging {
518520 instr .getTag ( ) = PhiTag ( vvar , phiBlock ) and
519521 result = "Phi Block(" + phiBlock .getUniqueId ( ) + "): " + vvar .getUniqueId ( )
520522 ) or
521- exists ( OldInstruction oldInstr , EdgeKind kind |
522- instr .getTag ( ) = UnreachedTag ( oldInstr , kind ) and
523- result = "Unreached(" + oldInstr . getUniqueId ( ) + ":" + kind . toString ( ) + ") "
523+ (
524+ instr .getTag ( ) = UnreachedTag ( ) and
525+ result = "Unreached"
524526 )
525527 }
526528
0 commit comments