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

Reid Kleckner <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #2 from Reid Kleckner <[email protected]> ---
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to