[LLVMbugs] [Bug 13677] New: llvm doesn't partially remove static initializers

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 23 07:23:44 PDT 2012


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

             Bug #: 13677
           Summary: llvm doesn't partially remove static initializers
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


A small missed optimization I noticed while debugging another problem is that
given 

int zed();
int x = zed();
struct foo {
  int a;
  int b;
  int c;
  int d;
  int e;
};
foo bar = {x, 1, 2, 3, 4};

Only the first element has to be found at runtime, but llvm still produces code
to initialize the full struct:

define internal void @_GLOBAL__I_a() section ".text.startup" {
entry:
  %call.i = tail call i32 @_Z3zedv() optsize
  store i32 %call.i, i32* @x, align 4, !tbaa !0
  store i32 %call.i, i32* getelementptr inbounds (%struct.foo* @bar, i64 0, i32
0), align 4, !tbaa !0
  store i32 1, i32* getelementptr inbounds (%struct.foo* @bar, i64 0, i32 1),
align 4, !tbaa !0
  store i32 2, i32* getelementptr inbounds (%struct.foo* @bar, i64 0, i32 2),
align 4, !tbaa !0
  store i32 3, i32* getelementptr inbounds (%struct.foo* @bar, i64 0, i32 3),
align 4, !tbaa !0
  store i32 4, i32* getelementptr inbounds (%struct.foo* @bar, i64 0, i32 4),
align 4, !tbaa !0
  ret void
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list