[LLVMdev] LLVMdev Digest, Vol 77, Issue 37

Peter Lawrence peterl95124 at sbcglobal.net
Thu Dec 2 13:18:09 PST 2010


Bill,
        I am still trying to figure out what you mean by "region", is  
it merely a conceptual hold-over
from the high level language definition(s) of exceptions, or are you  
attempting to introduce
some new construct into the LLVM IR control-flow graph.....

I see (at least) two alternatives for lowering exception regions

1) identify a "region" as you say as being an area of code from which  
any thrown exception
gets handled by some common handler code.  This seems to require  
adding a new capability
to the control-flow graph.  Along with that the proposal would have  
to include precise semantics
of what the limits to optimization are within and across the boundary  
of that region,  this would
then probably necessitate adding (lots of?) logic to all existing  
analyzers and optimizers.


2) identify with each instruction that can generate an exception  --   
(be that a numerical instruction
that could fault, an allocate instruction that could exhaust memory,  
a memory reference that could
be invalid, or an invoke from which an exception could be propagated  
out of, etc, etc, etc)  --  the
alternate location to go to for a fault/throw rather than sequential  
fall thru execution for that particular
instruction.   This seems to require adding a new capability to each  
instruction that can fault or
propagate.  Hopefully the optimization semantics of such enhanced  
instructions would be identical
to those existing control-flow controlling instructions (conditional  
jumps, switch cases, computed
gotos, etc), and

both of these options seem to require changes/enhancements, but which  
of them allows for the
rest of the analysis and optimization phases of LLVM to continue with  
the least amount of
change ?, or with the least objectionable change ?, or with the least  
complicating and  least
counter-intuitive change ?


option (2) is what analysis and optimization algorithms require,  
namely complete and exact
control flow and data flow information.

option (1) is what your mental run-time model wants,  namely a fairly  
simple match-up with the
original source code, which also happens to match-up with an existing  
ABI that is also a fairly
simple match-up with the original source code.




sincerely,
Peter Lawrence.




















>
> Definitions
> ===========
>
> A "region" is defined as a section of code where, if an exception  
> is thrown
> anywhere within that section, control is passed to code that will  
> handle the
> exception (called a "landing pad"). The code which handles the  
> specific
> exception is unique to that region. For example, "invoke A" and  
> "invoke B" are
> within the same region (X):
>
>
> Region X
> ..........................................
> :                                        :
> :    .----------.          .----------.  :
> :    | invoke A |          | invoke B |  :
> :    `----------'          `----------'  :
> :      /      |              /      |    :
> : normal      |         normal      |    :
> ..........................................
>               |                     |
>               |                     v
>               |            .------------------.
>               |            | B's cleanup code |
>               |            `------------------'
>               |                     |
>               `---------------------'
>                          |
>                          v
>              .-----------------------.
>              |   A's cleanup code    |
>              | dispatch for region X |
>              `-----------------------'
>                          |
>            .-----------------------------.
>            |        |          |         |
>            v        v          v         v
>          .----.   .----.     .----.  .--------.
>          | C1 |   | C2 | ... | Cn |  | resume |
>
>
> C1, C2, ..., Cn are the catches for the exception thrown. If none  
> of the
> catches' types match the type of the exception thrown, control  
> passes to the
> "resume".
>
> Notice that even though invokes A and B are in the same region,  
> they do not
> necessarily jump to the same basic block when an exception occurs.
>
>




More information about the llvm-dev mailing list