Fix so that reaching definitions are properly computed in loop optimization when there is unreachable code.

Specifically, this ensures that the depth-first numbering of basic blocks starts from 1, which is what ReachingDefinitions expects. Without this fix, reaching definitions wouldn't be correctly computed for functions that contain unreachable basic blocks (including the implicit one to return at the end). This could result in invalid hoisting of operations out of the loop.

This fixes the compca26.c test case.
This commit is contained in:
Stephen Heumann 2016-01-02 20:50:09 -06:00
parent 5ab7c7876b
commit bd19465ab2
1 changed files with 8 additions and 0 deletions

View File

@ -3164,6 +3164,14 @@ var
bb := bb^.next;
end; {while}
Search(DAGBlocks);
if i <> 0 then begin {ensure DFNs start from 1}
bb := DAGblocks;
while bb <> nil do begin
if bb ^.dfn <> 0 then
bb^.dfn := bb^.dfn - i;
bb := bb^.next;
end; {while}
end; {if}
end; {DepthFirstOrder}