[LLVMbugs] [Bug 19474] GlobalOpt removes SectionAttr unexpecedly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 6 15:20:12 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=19474

Reid Kleckner <rnk at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |david.majnemer at gmail.com
         Resolution|---                         |INVALID

--- Comment #2 from Reid Kleckner <rnk at google.com> ---
I discussed this with David Majnemer, and we think LLVM is working as intended.
You need to mark the data as "used" somehow to prevent its deletion or
localization.

The first test case is making the static global a local variable of main,
because LLVM knows that main is the program entry point, and it cannot be
invoked twice.

The second test case is just LLVM deleting an unreferenced global.

In both cases, adding __attribute__((used)) will resolve the issue.

GCC also has the same behavior. Consider this code:

void f() {
  static int a_var __attribute__((section("MySection"))) = 10;
}

GCC with -O2 will not emit the a_var global.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141106/50e3f64f/attachment.html>


More information about the llvm-bugs mailing list