[cfe-dev] LValue to RValue conversion and AST size

John McCall rjmccall at apple.com
Wed Dec 8 04:07:00 PST 2010


On Dec 8, 2010, at 2:52 AM, Abramo Bagnara wrote:
> Adding an implicit cast node for each lvalue to rvalue conversion has a
> severe impact on the number of nodes in the AST.

I don't doubt it.

> Have you considered to add a bit to the nodes that might be casted (or
> at least the more frequent ones) or other alternatives?

Well, the prior status quo was to figure out the context's desired value kind,
and that was pretty awful, because it turns out that "should we load from this
l-value" is a very touchy, language-specific question with a lot of corner
cases that we weren't getting right, and it's only going to get worse.

It's worth noting that we've always had lvalue-to-rvalue conversion nodes
when the lvalue was qualified.  That, of course, means that we also had
bugs when an lvalue was qualified.

The most plausible alternative I can see is to change Expr* to a tagged
pointer, and that's really unappealing — for one, it'd probably be a
noticeable slowdown.

But honestly, I think that the missing lvalue-to-rvalue conversions have been
an extremely annoying hole in our representation of language semantics for
years, and filling that gap is worth some memory overhead, particularly
when it simplifies and optimizes analyses made elsewhere.  I would much
rather find ways to decrease our memory use that don't have unfortunate
trade-offs for other parts of the compiler.  For example, killing the largely
unnecessary vtables in the Stmt/Expr hierarchy.

John.



More information about the cfe-dev mailing list