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: [email protected]
ReportedBy: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs