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!
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