[LLVMdev] Warning about variable optimized away?

Reid Kleckner rnk at google.com
Tue Aug 5 11:14:10 PDT 2014


This isn't really feasible.

First, you are asking for a warning from LLVM's optimizers, which we strive
to avoid, as they are unstable and affected by optimization levels.

Second, there are many, many optimizations that transform code in ways that
could remove gc roots, and it is not practical to annotate them all.

If you have a relocating GC, you need to implement something more
sophisticated like Phillip's late safepoint insertion approach.

On Tue, Aug 5, 2014 at 4:55 AM, Dmitry Antipov <antipov at dev.rtsoft.ru>
wrote:

> Hello,
>
> it it possible to get a kind of diagnostics if the variable
> is totally optimized away?  For example, in:
>
> void foo (struct some_type *obj) {
>   ... some code where 'obj' is not used ...
>   bar (obj->some_member);
>   ... some code where 'obj' is not used again ...
>   baz (obj->some_member);
> }
>
> 'obj' is likely to be optimized away so only 'obj->some_member' really
> exists (in a register or stack location).  Getting diagnostics
> or preserving 'obj' may be important if there is a GC which scans
> C stack and registers conservatively - if there is no direct reference
> to 'obj', it's likely to be reclaimed and so 'obj->some_member'
> becomes garbage.
>
> Dmitry
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140805/a0879eda/attachment.html>


More information about the llvm-dev mailing list