[llvm-dev] GlobalOPT and sections

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 20 15:28:26 PDT 2015


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