[PATCH] D139901: [BuildLibCalls][RISCV] Sign extend return value of bcmp on riscv64.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 18:08:50 PST 2022


craig.topper added a comment.

In D139901#3990628 <https://reviews.llvm.org/D139901#3990628>, @jrtc27 wrote:

> Hm, maybe not, GCC and Clang both seem to want to normalise the upper bits for dealing with an unsigned 32-bit return value being promoted to 64-bit, whether signed or unsigned... and the psABI document is really unclear on what on earth the convention is for return values in most respects. It's clear on parameters at least...

It looks like TargetInfo.cpp in clang applies the attributes to integer arguments regardless of triple. See `MipsABIInfo::extendType`.

  // MIPS64 ABI requires unsigned 32 bit integers to be sign extended.           
  if (Ty->isUnsignedIntegerOrEnumerationType() && TySize == 32)                  
    return ABIArgInfo::getSignExtend(Ty);                                        
                                                                                 
  return ABIArgInfo::getExtend(Ty);

For returns only applies to if the triple arch is mips64 or mips64el. See the bottom of MipsABIInfo::classifyReturnType.

  if ((RetTy->isUnsignedIntegerOrEnumerationType() ||                            
      RetTy->isSignedIntegerOrEnumerationType()) && Size == 32 && !IsO32)        
    return ABIArgInfo::getSignExtend(RetTy);

Note the `!IsO32` that was not present in `MipsABIInfo::extendType`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139901



More information about the llvm-commits mailing list