[LLVMdev] Why variables get "optimized away" after the last use in unoptimized code?

Robinson, Paul Paul_Robinson at playstation.sony.com
Mon Feb 3 09:55:21 PST 2014


> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Eric Christopher
> Sent: Sunday, February 02, 2014 10:04 PM
> To: Yuri
> Cc: LLVM Dev
> Subject: Re: [LLVMdev] Why variables get "optimized away" after the last
> use in unoptimized code?
> 
> This means that debug info would change code generation in order to
> artificially lengthen the lifetimes of variables and is something that
> is generally verboten when compiling for debug.

The "this" pointer is the most painful thing to lose, and two different
compilers I've known have introduced an artificial use of "this" in the
method epilog.  Tie it to -O0 instead of -g to avoid the "-g changes
codegen" issue.

There's also the recent talk about extending ranges by not using "last
use" but "next clobber" as the endpoint.  This is opportunistic rather
than intentional and requires dataflow on {reg, var} tuples, but it
also helps some.
--paulr

> 
> -eric
> 
> On Sun, Feb 2, 2014 at 1:57 AM, Yuri <yuri at rawbw.com> wrote:
> > On 02/02/2014 01:48, David Chisnall wrote:
> >>
> >> In most calling conventions, this is a callee-save register.  After
> its
> >> last use, the register allocator may reuse that register. On x86 and
> ARM,
> >> the register that contains this is also (usually) the register used
> for
> >
> >
> > But the rule "after the last use, the register allocator may reuse it"
> is
> > also introduced by llvm, since register allocator is also llvm. So
> this
> > means that the rule "preserve any values while in scope as much as
> possible"
> > is probably a better one for debugging.
> >
> > Yuri
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev






More information about the llvm-dev mailing list