https://bugs.llvm.org/show_bug.cgi?id=48156
Bug ID: 48156
Summary: GC Optimization incorrectly determines when to keep
init-sections
Product: lld
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: wasm
Assignee: unassignedb...@nondot.org
Reporter: try...@google.com
CC: llvm-bugs@lists.llvm.org, s...@chromium.org
I believe the optimization added here (https://reviews.llvm.org/D85062) has an
error which was revealed after https://reviews.llvm.org/D89290.
Fairly small example here:
https://github.com/trybka/scraps/tree/master/lld-test
Depending on the link order, the `bug::Foo` object is never initialized in
`foo.cc`.
I believe this is due to an error in the logic in MarkLive.cpp and Symbols.cpp.
In MarkLive.cpp enqueue:
https://github.com/llvm/llvm-project/blob/dd8723d348c9e6182155233a62769024dd345c6b/lld/wasm/MarkLive.cpp#L62
The check `bool needInitFunctions = file && !file->isLive() &&
sym->isDefined();`
will be False for an undefined symbol.
However, when the symbol is marked live, it sets its file to live as well. In
the case of an undefined symbol, that is the wrong file.
Subsequent queued symbols actually in that file will then fail the
needInitFunctions check (as they are already apparently live) and so the init
is never added.
In the example above, __cxa_atexit would be undefined in foo.o. When marking
__cxa_atexit as "referenced", foo.o would be marked live, but the init is never
added.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs