diff options
author | Mandeep Singh Grang <mgrang@codeaurora.org> | 2018-07-26 18:07:59 +0000 |
---|---|---|
committer | Mandeep Singh Grang <mgrang@codeaurora.org> | 2018-07-26 18:07:59 +0000 |
commit | 2a153101bffaeea3dc39ff2970bb04e5fd1d8e1e (patch) | |
tree | 34bd16b3c32d75b9484da2f9f03bb62ec6712c8f /clang/lib/CodeGen | |
parent | 3bdd60095f637118b7227065868a9206577e4867 (diff) | |
download | bcm5719-llvm-2a153101bffaeea3dc39ff2970bb04e5fd1d8e1e.tar.gz bcm5719-llvm-2a153101bffaeea3dc39ff2970bb04e5fd1d8e1e.zip |
[COFF, ARM64] Decide when to mark struct returns as SRet
Summary:
Refer the MS ARM64 ABI Convention for the behavior for struct returns:
https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions#return-values
Reviewers: mstorsjo, compnerd, rnk, javed.absar, yinma, efriedma
Reviewed By: rnk, efriedma
Subscribers: haripul, TomTan, yinma, efriedma, kristof.beyls, chrib, llvm-commits
Differential Revision: https://reviews.llvm.org/D49464
llvm-svn: 338050
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index f60136c2f17..f066ce16858 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1988,7 +1988,8 @@ void CodeGenModule::ConstructAttributeList( // Attach attributes to sret. if (IRFunctionArgs.hasSRetArg()) { llvm::AttrBuilder SRETAttrs; - SRETAttrs.addAttribute(llvm::Attribute::StructRet); + if (!RetAI.getSuppressSRet()) + SRETAttrs.addAttribute(llvm::Attribute::StructRet); hasUsedSRet = true; if (RetAI.getInReg()) SRETAttrs.addAttribute(llvm::Attribute::InReg); diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index e5e9cf67fdd..a1122dc80af 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1060,10 +1060,22 @@ bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const { // the second parameter. FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false); FI.getReturnInfo().setSRetAfterThis(FI.isInstanceMethod()); + + // aarch64-windows requires that instance methods use X1 for the return + // address. So for aarch64-windows we do not mark the + // return as SRet. + FI.getReturnInfo().setSuppressSRet(CGM.getTarget().getTriple().getArch() == + llvm::Triple::aarch64); return true; } else if (!RD->isPOD()) { // If it's a free function, non-POD types are returned indirectly. FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false); + + // aarch64-windows requires that non-POD, non-instance returns use X0 for + // the return address. So for aarch64-windows we do not mark the return as + // SRet. + FI.getReturnInfo().setSuppressSRet(CGM.getTarget().getTriple().getArch() == + llvm::Triple::aarch64); return true; } |