[X86] Fix to X86LoadValueInjectionRetHardeningPass for possible segfault

`MBB.back()` could segfault if `MBB.empty()`. Fixed by checking for `MBB.empty()` in the loop.

Differential Revision: https://reviews.llvm.org/D77584
This commit is contained in:
Scott Constable 2020-04-10 17:32:39 -07:00 committed by Craig Topper
parent aa4b37b2ac
commit 0505181006
1 changed files with 3 additions and 0 deletions

View File

@ -99,6 +99,9 @@ bool X86LoadValueInjectionRetHardeningPass::runOnMachineFunction(
bool Modified = false;
for (auto &MBB : MF) {
if (MBB.empty())
continue;
MachineInstr &MI = MBB.back();
if (MI.getOpcode() != X86::RETQ)
continue;