Page MenuHomePhabricator

Fix bug in Hexagon's AnalyzeBranch function

Authored by djasper on Mar 18 2015, 4:18 AM.



This was surfaced by r231064 which introduces more critical edge splitting.

This fixes

Diff Detail

Event Timeline

djasper updated this revision to Diff 22172.Mar 18 2015, 4:18 AM
djasper retitled this revision from to Fix bug in Hexagon's AnalyzeBranch function.
djasper updated this object.
djasper edited the test plan for this revision. (Show Details)
djasper added a reviewer: qcolombet.
djasper added a subscriber: Unknown Object (MLST).

This fix is incorrect. Please do not commit.

Could you elaborate a bit?

I'm actually preparing a better one right now.

The problem was caused by incompleteness of Hexagon's InsertBranch and RemoveBranch. AnalyzeBranch handled the combination of ENDLOOP0+J2_jump, which is a loop-end branch (conditional) followed by an unconditional branch, but none of the other two functions did.

The instruction ENDLOOP0 has only one explicit operand (the loop header), the other operands are implicit uses/defs of various reserved registers. Your patch picked up PC (program counter), and the branch insertion code interpreted a "Cond" vector with a register in it as a conditional branch, where the register is a predicate register. As a result, the instruction was "J2_jumpt %PC", which is not valid.

I see. Thank you!

djasper abandoned this revision.Mar 18 2015, 8:44 AM

I couldn't upload a new diff into your revision, so I created a new one:

Fix was committed in r232643.