[Chapel Merge] dlopen: Adjust some codegen-time arrays to be `GEN_VAL` instead of `GEN_PTR`

Branch: refs/heads/main
Revision: 3b48dbfa0b6368a0d80158a3047c9af44f441589
Author: dlongnecke-cray
Link: dlopen: Adjust some codegen-time arrays to be `GEN_VAL` instead of `GEN_PTR` by dlongnecke-cray · Pull Request #28677 · chapel-lang/chapel · GitHub
Log Message:
dlopen: Adjust some codegen-time arrays to be GEN_VAL instead of GEN_PTR (#28677)

This PR adjusts several constant arrays prepared at codegen-time under
LLVM to be marked as GEN_VAL instead of GEN_PTR as preparation for
further dynamic loading work. It also adds a test to lock in the correct
behavior for the LLVM backend.

This change has no effect on the C backend. The generated code remains
the exact same.

For the LLVM backend, before this change the Chapel compiler would emit
a load instruction and deref the symbol's address. Then, it would pass
the deref'd pointer around, which effectively contained garbage. This
caused bizarre behavior within C code that inspected the pointer.

After this change, the LLVM code emitted by the Chapel compiler just
uses the symbol directly. Intuitively, this more closely matches C
semantics (e.g., if we have a char** foo, we want to just pass that
foo around as a value as opposed to doing *foo every time we try to
read it).

While here, also forward declare a function
CreateConfigVarTable(void); under the C backend. This will be needed
later when it is no longer forward declared by the runtime.

TESTING

  • standard
  • COMM=none, COMPILER=clang
  • COMM=gasnet
  • COMM=gasnet, COMPILER=clang
  • COMM=none, LLVM=none

Reviewed @benharsh. Thanks!

Compare: Comparing 6b190ea05b1b33f9c10cc6ae1f60db20c0d024b8...5759896cf5f912a393713bc9ee69deaf0ad6c270 · chapel-lang/chapel · GitHub

Diff:
M compiler/codegen/codegen.cpp
A test/dynamic-loading/CodegenTimeArrays.chpl
A test/dynamic-loading/CodegenTimeArrays.good
A test/dynamic-loading/CodegenTimeArrays.skipif
https://github.com/chapel-lang/chapel/pull/28677.diff