[PATCH] D40738: Don't use Wasm function sections for more than one function
Nicholas Wilson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 1 10:39:02 PST 2017
ncw created this revision.
Herald added subscribers: cfe-commits, aheejin, sbc100, dschuff, jfb.
Fixes Bugzilla https://bugs.llvm.org/show_bug.cgi?id=35467
If a Wasm function section is created with more than one symbol, WasmObjectWriter fails with the following message: "function sections must contain one function each".
Currently, if a C++ file contains multiple static initialisers, they'll all be put in the same function section, triggering the error.
I think this change here is safe - it seems to be a spurious optimisation. In fact, I'm not even sure how it's intended to optimise the output...?
Repository:
rC Clang
https://reviews.llvm.org/D40738
Files:
lib/Basic/Targets/OSTargets.h
test/CodeGenCXX/static-init-wasm.cpp
Index: test/CodeGenCXX/static-init-wasm.cpp
===================================================================
--- test/CodeGenCXX/static-init-wasm.cpp
+++ test/CodeGenCXX/static-init-wasm.cpp
@@ -43,12 +43,12 @@
A theA;
-// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 section ".text.__startup" {
+// WEBASSEMBLY32: define internal void @__cxx_global_var_init() #3 {
// WEBASSEMBLY32: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 section ".text.__startup" {
+// WEBASSEMBLY32: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 {
// WEBASSEMBLY32: call void @__cxx_global_var_init()
//
-// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 section ".text.__startup" {
+// WEBASSEMBLY64: define internal void @__cxx_global_var_init() #3 {
// WEBASSEMBLY64: call %struct.A* @_ZN1AC1Ev(%struct.A* @theA)
-// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 section ".text.__startup" {
+// WEBASSEMBLY64: define internal void @_GLOBAL__sub_I_static_init_wasm.cpp() #3 {
// WEBASSEMBLY64: call void @__cxx_global_var_init()
Index: lib/Basic/Targets/OSTargets.h
===================================================================
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -711,11 +711,6 @@
Builder.defineMacro("_GNU_SOURCE");
}
- // As an optimization, group static init code together in a section.
- const char *getStaticInitSectionSpecifier() const final {
- return ".text.__startup";
- }
-
public:
explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40738.125174.patch
Type: text/x-patch
Size: 1738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171201/cabb82d9/attachment.bin>
More information about the cfe-commits
mailing list