[llvm] d946fb8 - [X86] Make sure load size is not larger than stack slot
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 21:17:53 PDT 2022
Author: Haohai Wen
Date: 2022-07-20T12:17:44+08:00
New Revision: d946fb8d9511698384706a67545ec1ae6d7f447e
URL: https://github.com/llvm/llvm-project/commit/d946fb8d9511698384706a67545ec1ae6d7f447e
DIFF: https://github.com/llvm/llvm-project/commit/d946fb8d9511698384706a67545ec1ae6d7f447e.diff
LOG: [X86] Make sure load size is not larger than stack slot
Reviewed By: LuoYuanke
Differential Revision: https://reviews.llvm.org/D130084
Added:
Modified:
llvm/lib/Target/X86/X86InstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index 1a04448a4fad1..74ef831e1658a 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -3892,6 +3892,10 @@ void X86InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
Register DestReg, int FrameIdx,
const TargetRegisterClass *RC,
const TargetRegisterInfo *TRI) const {
+ const MachineFunction &MF = *MBB.getParent();
+ const MachineFrameInfo &MFI = MF.getFrameInfo();
+ assert(MFI.getObjectSize(FrameIdx) >= TRI->getSpillSize(*RC) &&
+ "Load size exceeds stack slot");
if (RC->getID() == X86::TILERegClassID) {
unsigned Opc = X86::TILELOADD;
// tileloadd (%sp, %idx), %tmm
@@ -3913,8 +3917,6 @@ void X86InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
addFrameReference(BuildMI(MBB, MI, DebugLoc(), get(Opc), DestReg),
FrameIdx);
} else {
- const MachineFunction &MF = *MBB.getParent();
- const MachineFrameInfo &MFI = MF.getFrameInfo();
unsigned Alignment = std::max<uint32_t>(TRI->getSpillSize(*RC), 16);
bool isAligned =
(Subtarget.getFrameLowering()->getStackAlign() >= Alignment) ||
More information about the llvm-commits
mailing list