[PATCH] D67129: [WebAssembly] Compare functions by names in Emscripten Sjlj

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 15:05:32 PDT 2019


aheejin created this revision.
aheejin added reviewers: dschuff, sbc100.
Herald added subscribers: llvm-commits, dexonsmith, sunfish, hiraditya, jgravelle-google, mehdi_amini.
Herald added a project: LLVM.

This removes all string constants for function names and compares
functions by string directly when needed. Many of these constants are
used only once or twice so the benefit of defining them separately is
not very clear, and this actually fixes a bug.

When we already have a `malloc` declaration which is an alias to
something else within the module,

  @malloc = weak hidden alias i8* (i32), i8* (i32)* @dlmalloc

(this happens compiling with emscripten with `-s WASM_OBJECT_FILES=0`
because all bc files are merged before being fed into `wasm-ld` which
runs the backend optimizations as LTO)

`Module::getFunction("malloc")` in `canLongjmp` returns `nullptr`
because `Module::getFunction` dyncasts pointer into `Function`, but the
alias is a `GlobalValue` but not a `Function`. This makes `canLongjmp`
return false for `malloc` in this case, and we end up adding a lot of
longjmp handling code around malloc. This is not only a code size
increase but actually bug because `malloc` is used in the entry block
when preparing for setjmp tables for emscripten sjlj handling, and this
makes initial setjmp preparation, which has to happen in the entry
block, move to another split block, and this interferes with SSA update
later.

Fixes https://github.com/emscripten-core/emscripten/issues/8935.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67129

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/test/CodeGen/WebAssembly/lower-em-sjlj-malloc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67129.218540.patch
Type: text/x-patch
Size: 11092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190903/4eb21f90/attachment.bin>


More information about the llvm-commits mailing list