diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h index 4016247376c4f..37653631cc238 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -180,7 +180,7 @@ std::optional getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI); /// \p VReg is defined by a G_CONSTANT, return the corresponding value. -APInt getIConstantFromReg(Register VReg, const MachineRegisterInfo &MRI); +const APInt &getIConstantFromReg(Register VReg, const MachineRegisterInfo &MRI); /// Simple struct used to hold a constant integer value and a virtual /// register. diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp index dcbbb0871a844..5cee07461d7e2 100644 --- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp @@ -287,7 +287,8 @@ std::optional llvm::getIConstantVRegVal(Register VReg, return ValAndVReg->Value; } -APInt llvm::getIConstantFromReg(Register Reg, const MachineRegisterInfo &MRI) { +const APInt &llvm::getIConstantFromReg(Register Reg, + const MachineRegisterInfo &MRI) { MachineInstr *Const = MRI.getVRegDef(Reg); assert((Const && Const->getOpcode() == TargetOpcode::G_CONSTANT) && "expected a G_CONSTANT on Reg");