[gortran, PATCH] Fix PR 18937

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Sun Mar 25 22:10:00 GMT 2007


Hi,

this patch fixes the quadratic bottleneck in the resolution of branches 
by essentially doing what Steven Bosscher suggested in PR18540: for 
every block keep track of the branch targets allowed within, merging 
them as one descends through to the innermost blocks.  The data 
structure employed for this purpose is chosen to be a bitmap, which is 
allocated of an obstack which is thrown away once the code unit is resolved.

Of course, life is not as simple as one would hope: in order to 
determine if a branch is valid we have to know if the branch target is 
an END {DO,SELECT,IF} statement (can someone point me to the relevant 
quote in the standard, I couldn't seem to find it.  I just recreated 
what the code -- I believe unsuccessfully -- attempted to do before). 
Since we don't store explicit pointer to these, and they're outside the 
block for IF and SELECT blocks, but inside for DO, I had to go through a 
few contortions, but the final result is somewhat satisfying: since one 
has to iterate through each block to find all labels, it comes at no 
additional cost to also record the last statement in the block.  When 
resolving a branch we now go up the code_stack and look at the last 
statement of each block, checking if it's the branch target and the 
EXEC_NOP corresponding to an END* statement with a label.  The code then 
  calls gfc_notify_std as appropriate.

Built and tested on i386-darwin.  Ok for the mainline?

- Tobi

:ADDPATCH fortran:

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr18937.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070325/49eab699/attachment.txt>


More information about the Gcc-patches mailing list