diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index e9c0280638580..a207f3886bd0e 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -2292,7 +2292,7 @@ class TargetLoweringBase { virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilderBase &Builder) const {} /// Returns true if arguments should be sign-extended in lib calls. - virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const { + virtual bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const { return IsSigned; } diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 2b595b26c9c1c..ca87168929f96 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -2104,7 +2104,7 @@ std::pair SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L InChain = TCChain; TargetLowering::CallLoweringInfo CLI(DAG); - bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, isSigned); + bool signExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, isSigned); CLI.setDebugLoc(SDLoc(Node)) .setChain(InChain) .setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee, @@ -2135,7 +2135,7 @@ std::pair SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall L Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext()); Entry.Node = Op; Entry.Ty = ArgTy; - Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, isSigned); + Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, isSigned); Entry.IsZExt = !Entry.IsSExt; Args.push_back(Entry); } diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 5d9e8b35e24ef..68fbd36cf6e62 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -159,8 +159,8 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, SDValue NewOp = Ops[i]; Entry.Node = NewOp; Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext()); - Entry.IsSExt = shouldSignExtendTypeInLibCall(NewOp.getValueType(), - CallOptions.IsSigned); + Entry.IsSExt = + shouldSignExtendTypeInLibCall(Entry.Ty, CallOptions.IsSigned); Entry.IsZExt = !Entry.IsSExt; if (CallOptions.IsSoften && @@ -177,7 +177,7 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext()); TargetLowering::CallLoweringInfo CLI(DAG); - bool signExtend = shouldSignExtendTypeInLibCall(RetVT, CallOptions.IsSigned); + bool signExtend = shouldSignExtendTypeInLibCall(RetTy, CallOptions.IsSigned); bool zeroExtend = !signExtend; if (CallOptions.IsSoften && diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp index 16bceacfaa222..5a21ac7ebba0d 100644 --- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp @@ -6404,8 +6404,8 @@ ISD::NodeType LoongArchTargetLowering::getExtendForAtomicCmpSwapArg() const { } bool LoongArchTargetLowering::shouldSignExtendTypeInLibCall( - EVT Type, bool IsSigned) const { - if (Subtarget.is64Bit() && Type == MVT::i32) + Type *Ty, bool IsSigned) const { + if (Subtarget.is64Bit() && Ty->isIntegerTy(32)) return true; return IsSigned; diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h index 605093b01476d..e6de0dc4e361a 100644 --- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.h +++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.h @@ -273,7 +273,7 @@ class LoongArchTargetLowering : public TargetLowering { return false; } bool shouldConsiderGEPOffsetSplit() const override { return true; } - bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override; + bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override; bool shouldExtendTypeInLibCall(EVT Type) const override; bool shouldAlignPointerArgs(CallInst *CI, unsigned &MinSize, diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index d90348153fd3e..036b59c57d5b0 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -3871,10 +3871,10 @@ MipsTargetLowering::CanLowerReturn(CallingConv::ID CallConv, return CCInfo.CheckReturn(Outs, RetCC_Mips); } -bool MipsTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, +bool MipsTargetLowering::shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const { - if ((ABI.IsN32() || ABI.IsN64()) && Type == MVT::i32) - return true; + if ((ABI.IsN32() || ABI.IsN64()) && Ty->isIntegerTy(32)) + return true; return IsSigned; } diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h index 8033898091c75..e245c056de649 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.h +++ b/llvm/lib/Target/Mips/MipsISelLowering.h @@ -623,7 +623,7 @@ class TargetRegisterClass; SDValue LowerInterruptReturn(SmallVectorImpl &RetOps, const SDLoc &DL, SelectionDAG &DAG) const; - bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override; + bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override; // Inline asm support ConstraintType getConstraintType(StringRef Constraint) const override; diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index e917ef3f5e8c9..564fa29bce7d2 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -18828,7 +18828,7 @@ SDValue PPCTargetLowering::lowerToLibCall(const char *LibCallName, SDValue Op, Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext()); SDValue Callee = DAG.getExternalSymbol(LibCallName, TLI.getPointerTy(DAG.getDataLayout())); - bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetVT, false); + bool SignExtend = TLI.shouldSignExtendTypeInLibCall(RetTy, false); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; for (const SDValue &N : Op->op_values()) { @@ -18836,7 +18836,7 @@ SDValue PPCTargetLowering::lowerToLibCall(const char *LibCallName, SDValue Op, Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext()); Entry.Node = N; Entry.Ty = ArgTy; - Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgVT, SignExtend); + Entry.IsSExt = TLI.shouldSignExtendTypeInLibCall(ArgTy, SignExtend); Entry.IsZExt = !Entry.IsSExt; Args.push_back(Entry); } diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 4544a922def1a..641433688bbab 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -21285,8 +21285,9 @@ bool RISCVTargetLowering::shouldExtendTypeInLibCall(EVT Type) const { return true; } -bool RISCVTargetLowering::shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const { - if (Subtarget.is64Bit() && Type == MVT::i32) +bool RISCVTargetLowering::shouldSignExtendTypeInLibCall(Type *Ty, + bool IsSigned) const { + if (Subtarget.is64Bit() && Ty->isIntegerTy(32)) return true; return IsSigned; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h index c753469562eba..bb0d9a71abf7e 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.h +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h @@ -746,7 +746,7 @@ class RISCVTargetLowering : public TargetLowering { getExceptionSelectorRegister(const Constant *PersonalityFn) const override; bool shouldExtendTypeInLibCall(EVT Type) const override; - bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override; + bool shouldSignExtendTypeInLibCall(Type *Ty, bool IsSigned) const override; /// Returns the register with the specified architectural or ABI name. This /// method is necessary to lower the llvm.read_register.* and diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index 8f505b7e198cf..975a0f5050d16 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -2147,8 +2147,8 @@ std::pair SystemZTargetLowering::makeExternalCall( for (SDValue Op : Ops) { Entry.Node = Op; Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext()); - Entry.IsSExt = shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned); - Entry.IsZExt = !shouldSignExtendTypeInLibCall(Op.getValueType(), IsSigned); + Entry.IsSExt = shouldSignExtendTypeInLibCall(Entry.Ty, IsSigned); + Entry.IsZExt = !Entry.IsSExt; Args.push_back(Entry); } @@ -2157,7 +2157,7 @@ std::pair SystemZTargetLowering::makeExternalCall( Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext()); TargetLowering::CallLoweringInfo CLI(DAG); - bool SignExtend = shouldSignExtendTypeInLibCall(RetVT, IsSigned); + bool SignExtend = shouldSignExtendTypeInLibCall(RetTy, IsSigned); CLI.setDebugLoc(DL) .setChain(Chain) .setCallee(CallConv, RetTy, Callee, std::move(Args))