File tree Expand file tree Collapse file tree 4 files changed +26
-10
lines changed
src/semmle/code/cpp/ir/implementation Expand file tree Collapse file tree 4 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -280,9 +280,18 @@ cached private module Cached {
280280
281281 cached Instruction getInstructionBackEdgeSuccessor ( Instruction instruction , EdgeKind kind ) {
282282 exists ( OldInstruction oldInstruction |
283- oldInstruction = getOldInstruction ( instruction ) and
284- result = getNewInstruction ( oldInstruction .getBackEdgeSuccessor ( kind ) ) and
285- not Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , kind )
283+ not Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , kind ) and
284+ // There is only one case for the translation into `result` because the
285+ // SSA construction never inserts extra instructions _before_ an existing
286+ // instruction.
287+ getOldInstruction ( result ) = oldInstruction .getBackEdgeSuccessor ( kind ) and
288+ // There are two cases for the translation into `instruction` because the
289+ // SSA construction might have inserted a chi node _after_
290+ // `oldInstruction`, in which case the back edge should come out of the
291+ // chi node instead.
292+ if hasChiNode ( _, oldInstruction )
293+ then instruction = getChiInstruction ( oldInstruction )
294+ else instruction = getNewInstruction ( oldInstruction )
286295 )
287296 }
288297
Original file line number Diff line number Diff line change @@ -280,9 +280,18 @@ cached private module Cached {
280280
281281 cached Instruction getInstructionBackEdgeSuccessor ( Instruction instruction , EdgeKind kind ) {
282282 exists ( OldInstruction oldInstruction |
283- oldInstruction = getOldInstruction ( instruction ) and
284- result = getNewInstruction ( oldInstruction .getBackEdgeSuccessor ( kind ) ) and
285- not Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , kind )
283+ not Reachability:: isInfeasibleInstructionSuccessor ( oldInstruction , kind ) and
284+ // There is only one case for the translation into `result` because the
285+ // SSA construction never inserts extra instructions _before_ an existing
286+ // instruction.
287+ getOldInstruction ( result ) = oldInstruction .getBackEdgeSuccessor ( kind ) and
288+ // There are two cases for the translation into `instruction` because the
289+ // SSA construction might have inserted a chi node _after_
290+ // `oldInstruction`, in which case the back edge should come out of the
291+ // chi node instead.
292+ if hasChiNode ( _, oldInstruction )
293+ then instruction = getChiInstruction ( oldInstruction )
294+ else instruction = getNewInstruction ( oldInstruction )
286295 )
287296 }
288297
Original file line number Diff line number Diff line change @@ -4687,5 +4687,5 @@ ir.cpp:
46874687# 1059| r3_8(int) = Constant[0] :
46884688# 1059| r3_9(bool) = CompareGT : r3_4, r3_8
46894689# 1059| v3_10(void) = ConditionalBranch : r3_9
4690- #-----| False (back edge) -> Block 2
4691- #-----| True (back edge) -> Block 1
4690+ #-----| False -> Block 2
4691+ #-----| True -> Block 1
Original file line number Diff line number Diff line change @@ -8,6 +8,4 @@ operandAcrossFunctions
88instructionWithoutUniqueBlock
99containsLoopOfForwardEdges
1010lostReachability
11- | ir.cpp:1060:12:1060:12 | Constant: (char)... |
12- | ir.cpp:1061:1:1061:1 | NoOp: return ... |
1311backEdgeCountMismatch
You can’t perform that action at this time.
0 commit comments