[cfe-dev] CXX ABI, force passing function argument by reference

Diogo Sampaio via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 25 07:58:47 PST 2021


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 at 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.

----- Original Message -----
From: "cfe-dev" <cfe-dev at lists.llvm.org>
To: "cfe-dev" <cfe-dev at lists.llvm.org>
Sent: Wednesday, November 24, 2021 9:37:38 AM
Subject: [cfe-dev] 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 https://godbolt.org/z/1crdTGeKv

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 at 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.




_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


To declare a filtering error, please use the following link : https://www.security-mail.net/reporter.php?mid=46d1.619df9de.3f221.0&r=dsampaio%40kalray.eu&s=cfe-dev-bounces%40lists.llvm.org&o=%5Bcfe-dev%5D+CXX+ABI%2C+force+passing+function+argument+by+reference&verdict=C&c=71b4fd9d238f510d0ac9131fa4f969df02a5cfa2






More information about the cfe-dev mailing list