[llvm-dev] GlobalOPT and sections

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 21 20:36:41 PDT 2015


On Sep 21, 2015, at 11:59 AM, Sergei Larin <slarin at codeaurora.org> wrote:
> Chris,
> 
>  Thanks for the clarification... at least no bug report is due... and I am glad that I've asked. 
> 
> In my case these transformations are rather useful and forcing them to copy original global variable section is making them compatible with our (rather important) use case, so I guess I will have to fix it locally.
> Nevertheless if someone else would have a similar issue - I would be happy to patch it.

Ah, so you’re saying that you *want* the transformation, but the global has an explicit section?

Two questions:
1) Why does the global have a section?  Is this something that should be better modeled in IR somehow?
2) Perhaps this transformation can be better modeled as something that uses IPA to inject “range” metadata on loads from globals?

Doing #2 would allow inferring that a global only has something in the range of 0..5, at least when the only stores are simple enough to analyze trivially.

-Chris


> 
> Sergei
> 
> ---
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
> 
> 
>> -----Original Message-----
>> From: Chris Lattner [mailto:clattner at apple.com]
>> Sent: Sunday, September 20, 2015 5:28 PM
>> To: Sergei Larin
>> Cc: llvm-dev at lists.llvm.org; Lang Hames
>> Subject: Re: GlobalOPT and sections
>> 
>> On Sep 18, 2015, at 10:45 AM, Sergei Larin <slarin at codeaurora.org> wrote:
>>> What I do not see - the section information from the original GV is never
>> copied to the NewGV, so this test would be failing for me:
>>> Now the proverbial question - is this a bug or a feature?  ...and if it was
>> meant to be done that way then why…
>> 
>> Historically speaking, this optimization probably predated the ability to put a
>> section on a global.
>> 
>> That said, I think that this is a feature: The sorts of optimizations that
>> globalopt does are extremely transformative to the underlying global
>> variable, and whatever reason the global was assigned to a section in the first
>> place is probably not going to work with the transformed value.
>> 
>> If you’re having a problem with this, it is probably best to just make globalopt
>> more conservative: have it refuse to transform a global that has any explicitly
>> assigned section.
>> 
>> -Chris
> 



More information about the llvm-dev mailing list