[Chapel Merge] Refactor how the unwind table is built and add rules

Branch: refs/heads/main
Revision: de01286aa2fb70828a54387c2a3eeb3a37b3d24c
Author: dlongnecke-cray
Link: Refactor how the unwind table is built and add rules by dlongnecke-cray · Pull Request #28781 · chapel-lang/chapel · GitHub
Log Message:
Refactor how the unwind table is built and add rules (#28781)

This PR attempts to fix a bug in nightly testing. It refactors some of
the CHPL_UNWIND stack unwind support code we emit in the compiler
during codegen. It adjusts the rules for how names and renames are
placed in the symbol table.

Roughly, the new rules are as follows:

  • A module initializer is always placed in the symbol table
  • The chpl_user_main is always placed in the table
  • All other functions beginning with chpl_ in either the name or
    C-name are ignored
  • If there is a collision on a C-name, then any non-extern function is
    preferred over an extern one (meaning the extern one is dropped on the
    floor)
  • All non-extern functions are renameable
  • An extern function is renameable only if there is no C-name collision.
    If there are multiple extern functions, each with the same C-name but
    different Chapel names (which can trivially happen), then none of them
    can be renamed in the table, because the order is ambiguous. Take any of
    them and use the C-name for both table slots (no renaming).

Additionally, this PR now emits the unwind table in alphabetical order,
but it is up to future code changes in the runtime to take advantage of
that.

Add a test exercising some of the new rules.

TESTING

  • Fixes failing blog test mapDebug
  • standard
  • LLVM=none, COMPILER=gnu
  • COMM=gasnet

Reviewed by @benharsh. Thanks much!

Compare: Comparing 08af864abe0d002f89255f971735888608150733...f4e13fe8c8316c5ca2b10a45742cab44ec17a28a · chapel-lang/chapel · GitHub

Diff:
M compiler/codegen/codegen.cpp
A test/runtime/stacktrace/MultipleExternNoRename.chpl
A test/runtime/stacktrace/MultipleExternNoRename.good
https://github.com/chapel-lang/chapel/pull/28781.diff