[PATCH] D83397: [flang] Replace uses of _Complex with std::complex

David Truby via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 08:17:06 PDT 2020


DavidTruby added a comment.

Thanks for the additional context; I checked returning std::complex on x86_64 and Aarch64 before my comment and it worked fine; I guess the calling convention for x86_32 differs here in a way I didn't appreciate.
At least on those two architectures, at each optimisation level the way the value is returned matches: at `O0` and `O1` both return in memory and at `O2` and `O3` both return in registers.

In this specific code, I don't see how the differing calling convention can be an issue though. These functions are not callable from C as they are template functions, so surely there's no need to match the C calling convention here?

In terms of a more general solution, I'm uncomfortable with the idea of simply aborting compilation in perfectly compliant C++ compilers due to the use of non-standard features. Would it be possible to write a function on the C side that wraps these functions and returns a struct with two floats/doubles (that will also be layout compatible with both types) to force the calling convention to match the C++ one? Those functions could then be called safely from C++ with `std::complex` prototypes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83397/new/

https://reviews.llvm.org/D83397





More information about the llvm-commits mailing list