[all-commits] [llvm/llvm-project] bc48b3: [lld][WebAssembly] Fix spurious signature mismatch...

Daniel Bertalan via All-commits all-commits at lists.llvm.org
Fri Apr 18 09:37:15 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bc48b3f8b812c755c5e9c42d6b970a9c1b496578
      https://github.com/llvm/llvm-project/commit/bc48b3f8b812c755c5e9c42d6b970a9c1b496578
  Author: Daniel Bertalan <dani at danielbertalan.dev>
  Date:   2025-04-18 (Fri, 18 Apr 2025)

  Changed paths:
    A lld/test/wasm/lto/thinlto-signature-mismatch-unknown.ll
    M lld/wasm/LTO.cpp

  Log Message:
  -----------
  [lld][WebAssembly] Fix spurious signature mismatch under LTO (#136197)

When generating C++ vtables, Clang declares virtual functions as
`void(void)` when their signature is not known (e.g.parameter types are
forward-declared). As WASM type checks imports, this would conflict with
the real definition during linking. Commit 59f959ff introduced a
workaround for this by deferring signature assignment until a definition
or direct call is seen.

When performing LTO, LLD first scans the bitcode files and creates
`DefinedFunction` symbol table entries for their contents. After LTO
codegen, they are replaced with `UndefinedFunction`s (so that the
definitions will be pulled in from the native LTO-d files when they are
added). At this point, if a function is only referenced in bitcode, its
signature remains `nullptr`.

>From here, it should have behaved like in the non-LTO case: the first
direct call sets the signature. However, as the `isCalledDirectly` flag
was set to true, the missing signature was filled in by the type of the
first reference to the function, which could be a `void(void)` vtable
entry, which would then conflict with the real definition.

This commit sets `isCalledDirectly` to false so that the signature will
only be populated when a direct call is found.

See godotengine/godot#104497 and
emscripten-core/emscripten#10831



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list