[LLVMdev] recognizing DTORs and vptr updates in LLVM.

Eli Friedman eli.friedman at gmail.com
Mon Mar 19 17:24:27 PDT 2012


On Mon, Mar 19, 2012 at 4:52 PM, Chandler Carruth <chandlerc at google.com> wrote:
> On Mon, Mar 19, 2012 at 4:46 PM, Eli Friedman <eli.friedman at gmail.com>
> wrote:
>>
>> Given that, I'm not sure I really see the issue with just
>> special-casing any store where the value stored is a pointer to a
>> global... but it could be argued either way, I guess.
>
>
> I users expect this to "just work", why not extend the language and make it
> just work?

I'm not sure anyone really expects this to "just work", just that they
did it by accident.  Making cross-thread unsynchronized virtual calls
on an object which is being destroyed strikes me as a construct nobody
would intentionally write.

> We could, as an implementation, decide to emit these as relaxed atomic
> stores, making the code well defined without changing the semantics (or
> optimization) in any meaningful way, right?

Making all vptr loads and stores atomic would block some optimizations
(specifically, we can't perform certain optimizations involving
memcpy, and IIRC some optimizers have incomplete atomics handling).
Not sure if it would have much practical impact, though.

Specifically just making vptr stores in destructors "unordered", and
making unordered stores which don't change the stored value
effectively no-ops in the memory model, could work too; the potential
impact on optimization is much less, and I don't think the model
changes would lead to any optimizer changes.

-Eli



More information about the llvm-dev mailing list