[LLVMbugs] [Bug 10047] New: LLVM doesn't optimize a constructor that memsets-to-0 on a zero-initialized global
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun May 29 10:36:19 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10047
Summary: LLVM doesn't optimize a constructor that memsets-to-0
on a zero-initialized global
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Core LLVM classes
AssignedTo: unassignedbugs at nondot.org
ReportedBy: schaub.johannes at googlemail.com
CC: llvmbugs at cs.uiuc.edu
Following code:
struct A {
A():a() { }
int a[100];
};
A a;
$ clang++ -S -O3 -emit-llvm main1.cpp -o -
This output can be further optimized:
; ModuleID = 'main1.cpp'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"
%0 = type { i32, void ()* }
%struct.A = type { [100 x i32] }
@a = global %struct.A zeroinitializer, align 4
@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()*
@_GLOBAL__I_a }]
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
define internal void @_GLOBAL__I_a() nounwind {
tail call void @llvm.memset.p0i8.i64(i8* bitcast (%struct.A* @a to i8*), i8
0, i64 400, i32 4, i1 false) nounwind
ret void
}
The memset setting "@a" to zero can be optimized away, because it is already
zero. I was told to make a PR for this by nicholas on IRC.
--
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