[LLVMbugs] [Bug 19474] New: GlobalOpt removes SectionAttr unexpecedly

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Apr 17 18:18:10 PDT 2014


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

            Bug ID: 19474
           Summary: GlobalOpt removes SectionAttr unexpecedly
           Product: libraries
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: ahuishiwo at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

when with globalopt, section atttribute of the variable is removed
unexpectedly. The following is the case.

#include <stdio.h>
int main()
{
  static int a_var __attribute__((section("MySection")));
  a_var = 0;
  for (int i = 0; i<10; ++i)
    a_var++;

  return a_var;
}

To reproduce it,
Step1: clang++ -emit-llvm -S main.cpp -o main.ll
Step2: opt -globalopt main.ll -S -o main_opt.ll

Just after step1, the SectionAttr still clings to the variable.
@_ZZ4mainE5a_var = internal global i32 0, section "MySection", align 4

After Step2, SectionAttr is gone as belows,
@%_ZZ4mainE5a_var = alloca i32
store i32 0, i32* %_ZZ4mainE5a_var

The thing is that we need _ZZ4mainE5a_var still convey its SectionAttr
to next phase. However that is not kept for the potential reason that the
shriking process of Globalopt might not copy attribute from original.

-- 
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/20140418/0e6e7bae/attachment.html>


More information about the llvm-bugs mailing list