CXX ABI, force passing function argument by reference

Hi all,

A clang noob question...

In our target C++ ABI aggregates that are not trivially copyable should be passed by reference.
For example, in Compiler Explorer

We have the string iii passed by a pointer (from the caller stack main) to function test_it

        addd $r0 = $r12, 64
        call test_it(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)

However our current llvm implementation breaks this abi, passing it by copy in registers:
        ld $r0 = 0[$r12]
        ;;
        ld $r1 = 8[$r12]
        ;;
        ld $r2 = 16[$r12]
        ;;
        ld $r3 = 24[$r12]
        call test_it(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)

Could anyone point me in how to change clang's choice of passing it by copy in register?

I've implemented a target specific CXXABI based in ItaniumCXXABI and overrided getRecordArgABI to return RAA_Indirect or RAA_DirectInMemory if the CXXRecordDecl is not marked as isTriviallyCopyable, and made our target use this CXXABI. However that does not do the trick. Even if I make it always return RAA_DirectInMemory, it does not change a thing in this code.

Thanks in advance,

Diogo Sampaio
Senior Compiler Engineer • Kalray
dsampaio@kalrayinc.com • [ https://www.kalrayinc.com/ | www.kalrayinc.com ]

[ https://www.kalrayinc.com/ | ]

Please consider the environment before printing this e-mail.
This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

For future readers, it can be handled in the target specific <TARGET>ABIInfo::classifyType method. Don't know if this is the best place for it though.

Diogo Sampaio
Senior Compiler Engineer • Kalray
dsampaio@kalrayinc.com • [ https://www.kalrayinc.com/ | www.kalrayinc.com ]

[ https://www.kalrayinc.com/ | ]

Please consider the environment before printing this e-mail.
This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.