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

Eric Christopher echristo at gmail.com
Mon Feb 3 10:08:14 PST 2014


On Mon, Feb 3, 2014 at 9:55 AM, Robinson, Paul
<Paul_Robinson at playstation.sony.com> wrote:
>> -----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.

*shrug* The variable the user wants is always the most important, but
I agree 'this' can be pretty useful. I'm wary of introducing any
artificial uses though.

>
> 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.

*nod* That might be more interesting. Not sure about how much this
will add to compile time, but if it greatly increases usefulness (as
something we'd want to measure) then I'm not against it.

-eric


>>
>> -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