diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h --- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/Register.h" +#include "llvm/Support/Alignment.h" #include "llvm/Support/LowLevelTypeImpl.h" #include "llvm/Support/MachineValueType.h" @@ -181,8 +182,13 @@ return isKnownNeverNaN(Val, MRI, true); } -unsigned inferAlignmentFromPtrInfo(MachineFunction &MF, - const MachinePointerInfo &MPO); +Align inferAlignFromPtrInfo(MachineFunction &MF, const MachinePointerInfo &MPO); + +/// FIXME: Remove once the transition to Align is over. +inline unsigned inferAlignmentFromPtrInfo(MachineFunction &MF, + const MachinePointerInfo &MPO) { + return inferAlignFromPtrInfo(MF, MPO).value(); +} /// Return the least common multiple type of \p Ty0 and \p Ty1, by changing /// the number of vector elements or scalar bitwidth. The intent is a diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp --- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp @@ -457,15 +457,16 @@ return false; } -unsigned llvm::inferAlignmentFromPtrInfo(MachineFunction &MF, - const MachinePointerInfo &MPO) { +Align llvm::inferAlignFromPtrInfo(MachineFunction &MF, + const MachinePointerInfo &MPO) { auto PSV = MPO.V.dyn_cast(); if (auto FSPV = dyn_cast_or_null(PSV)) { MachineFrameInfo &MFI = MF.getFrameInfo(); - return MinAlign(MFI.getObjectAlignment(FSPV->getFrameIndex()), MPO.Offset); + return commonAlignment(MFI.getObjectAlign(FSPV->getFrameIndex()), + MPO.Offset); } - return 1; + return Align(1); } Optional llvm::ConstantFoldExtOp(unsigned Opcode, const unsigned Op1,