Skip to content

Revert 86b1b0671cafd "MachineVerifier: Check stack protector is top-most in frame" #122444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 1 addition & 51 deletions llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ struct MachineVerifier {
LaneBitmask LaneMask = LaneBitmask::getNone());

void verifyStackFrame();
// Check that the stack protector is the top-most object in the stack.
void verifyStackProtector();

void verifySlotIndexes() const;
void verifyProperties(const MachineFunction &MF);
Expand Down Expand Up @@ -711,10 +709,8 @@ void MachineVerifier::visitMachineFunctionBefore() {
// Check that the register use lists are sane.
MRI->verifyUseLists();

if (!MF->empty()) {
if (!MF->empty())
verifyStackFrame();
verifyStackProtector();
}
}

void
Expand Down Expand Up @@ -4042,49 +4038,3 @@ void MachineVerifier::verifyStackFrame() {
}
}
}

void MachineVerifier::verifyStackProtector() {
const MachineFrameInfo &MFI = MF->getFrameInfo();
if (!MFI.hasStackProtectorIndex())
return;
// Only applicable when the offsets of frame objects have been determined,
// which is indicated by a non-zero stack size.
if (!MFI.getStackSize())
return;
const TargetFrameLowering &TFI = *MF->getSubtarget().getFrameLowering();
bool StackGrowsDown =
TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsDown;
// Collect the frame indices of the callee-saved registers which are spilled
// to the stack. These are the registers that are stored above the stack
// protector.
SmallSet<unsigned, 4> CalleeSavedFrameIndices;
if (MFI.isCalleeSavedInfoValid()) {
for (const CalleeSavedInfo &Info : MFI.getCalleeSavedInfo()) {
if (!Info.isSpilledToReg())
CalleeSavedFrameIndices.insert(Info.getFrameIdx());
}
}
unsigned FI = MFI.getStackProtectorIndex();
int64_t SPStart = MFI.getObjectOffset(FI);
int64_t SPEnd = SPStart + MFI.getObjectSize(FI);
for (unsigned I = 0, E = MFI.getObjectIndexEnd(); I != E; ++I) {
if (I == FI)
continue;
// Variable-sized objects do not have a fixed offset.
if (MFI.isVariableSizedObjectIndex(I))
continue;
if (CalleeSavedFrameIndices.contains(I))
continue;
int64_t ObjStart = MFI.getObjectOffset(I);
int64_t ObjEnd = ObjStart + MFI.getObjectSize(I);
if (SPStart < ObjEnd && ObjStart < SPEnd) {
report("Stack protector overlaps with another stack object", MF);
break;
}
if ((StackGrowsDown && SPStart <= ObjStart) ||
(!StackGrowsDown && SPStart >= ObjStart)) {
report("Stack protector is not the top-most object on the stack", MF);
break;
}
}
}
63 changes: 0 additions & 63 deletions llvm/test/MachineVerifier/stack-protector-offset.mir

This file was deleted.

Loading