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
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!
All tests assume
LLVM != none,
Signed-off-by: David Longnecker email@example.com
Modified Files: A test/llvm/abi/sret/SretActualOffsetBug1.chpl