[LLVMbugs] [Bug 12880] New: static constructor not simplified
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 18 09:39:32 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12880
Bug #: 12880
Summary: static constructor not simplified
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
We compile
void foo();
struct bar {
bar() : zed(0) {
}
unsigned zed;
};
bar bah;
struct baz {
baz() {
foo();
}
};
static baz bax;
to
%struct.bar = type { i32 }
@bah = global %struct.bar zeroinitializer, align 4
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()*
} { i32 65535, void ()* @_GLOBAL__I_a }]
declare void @_Z3foov() optsize
define internal void @_GLOBAL__I_a() nounwind section ".text.startup" {
entry:
store i32 0, i32* getelementptr inbounds (%struct.bar* @bah, i64 0, i32 0),
align 4
tail call void @_Z3foov() nounwind optsize
ret void
}
Note that the store of 0 is unnecessary. In fact, if the call to foo is
commented out we produce
%struct.bar = type { i32 }
@bah = global %struct.bar zeroinitializer, align 4
@llvm.global_ctors = appending global [0 x { i32, void ()* }] zeroinitializer
--
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