Branch: refs/heads/master
Revision: ddf0314
Author: dlongnecke-cray
Log Message:
Merge pull request #17872 from dlongnecke-cray/fix-struct-actual-abi-bug
Fix a bug in ABI support when first LLVM formal is for struct return
This PR fixes a bug which has been blocking #17015.
When an exported function returns a structure, the Chapel compiler's
ABI support code will opt to add a new formal that is a pointer used
to write out the return value. This LLVM formal is marked "sret"
(short for struct return). Clang considers this sort of return to be
an "indirect return".
The ABI support code which activates for exported Chapel functions
during FnSymbol::codegenDef
runs a loop over Chapel formals and
LLVM formals. For each LLVM formal in the loop, it fetches ABI
information about the formal from Clang, and uses this info to change
the LLVM formal accordingly.
Neither Chapel or Clang is aware of the "sret" formal in the LLVM
function. When the LLVM function has a "sret" formal, increment the
iterator over LLVM formals to skip past the "sret" formal before
inspecting the remaining formals.
Reviewed by @mppf. Thanks!
TESTING:
All tests assume LLVM != none
, CHPL_LIB_PIC=pic
.
- [x]
ALL
onlinux64
whenCOMM=none
- [x]
ALL
onlinux64
whenCOMM=gasnet
Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com
Modified Files:
A test/llvm/abi/sret/SretActualOffsetBug1.chpl
A test/llvm/abi/sret/SretActualOffsetBug1.good
A test/llvm/abi/sret/SretActualOffsetBug2.chpl
A test/llvm/abi/sret/SretActualOffsetBug2.good
M compiler/codegen/symbol.cpp
M test/interop/C/llvm/makefiles/dynamicLinking/PRECOMP
M test/llvm/abi/x86-64/SKIPIF
Compare: https://github.com/chapel-lang/chapel/compare/8fe1586c3bb6...ddf03142a67a