[cfe-dev] CFG blocks and variable scope

Martin Doucha next_ghost at quick.cz
Tue Mar 31 01:09:04 PDT 2009


Ted Kremenek wrote:
> This is an interesting point.  I wonder how much, however, this is a
> real concern in practice.  Consider the LLVM IR for a complex C++
> program.  The LLVM IR is SSA-based CFG that needs to model C++
> destructor calls at a much lower level.  Any "continue", "break", or
> "goto" that crosses scope boundaries requires logic in the IR for the
> necessary destructor calls.  It seems like the same problems you
> describe would be present there.
>
> This aside, we certainly can handle the case you described with the
> right abstractions and still provide the same CFG interface that
> clients expect.  Since we are free to implement basic blocks in any
> matter that we wish (and have different kinds of basic block
> encodings), we can use virtual basic blocks to encode what variables
> are destroyed but employ data sharing between these virtual basic
> blocks to keep the memory costs down.  Through a proper iterator
> interface, clients would iterate over the "virtual" statements in the
> virtual basic blocks, even if we don't explicitly create those
> statements.  This approach can be viewed of the combination of the two
> approaches discussed, except that this has a simpler interface for
> clients.

Excellent. Let's get coding. Where do I start implementing this design?

Regards,
Martin



More information about the cfe-dev mailing list