Skip to content

Commit f0bae56

Browse files
authored
[GISel] Return const APInt & from getIConstantFromReg. NFC (#114320)
This matches what the call to ConstantInt::getValue() returns. Let the caller make a copy if needed.
1 parent 8127162 commit f0bae56

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/include/llvm/CodeGen/GlobalISel/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ std::optional<int64_t> getIConstantVRegSExtVal(Register VReg,
180180
const MachineRegisterInfo &MRI);
181181

182182
/// \p VReg is defined by a G_CONSTANT, return the corresponding value.
183-
APInt getIConstantFromReg(Register VReg, const MachineRegisterInfo &MRI);
183+
const APInt &getIConstantFromReg(Register VReg, const MachineRegisterInfo &MRI);
184184

185185
/// Simple struct used to hold a constant integer value and a virtual
186186
/// register.

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ std::optional<APInt> llvm::getIConstantVRegVal(Register VReg,
287287
return ValAndVReg->Value;
288288
}
289289

290-
APInt llvm::getIConstantFromReg(Register Reg, const MachineRegisterInfo &MRI) {
290+
const APInt &llvm::getIConstantFromReg(Register Reg,
291+
const MachineRegisterInfo &MRI) {
291292
MachineInstr *Const = MRI.getVRegDef(Reg);
292293
assert((Const && Const->getOpcode() == TargetOpcode::G_CONSTANT) &&
293294
"expected a G_CONSTANT on Reg");

0 commit comments

Comments
 (0)