[llvm] 0505181 - [X86] Fix to X86LoadValueInjectionRetHardeningPass for possible segfault
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 18:28:16 PDT 2020
Author: Scott Constable
Date: 2020-04-10T18:28:08-07:00
New Revision: 0505181006f1088b2cb28a7240d5f27613783307
URL: https://github.com/llvm/llvm-project/commit/0505181006f1088b2cb28a7240d5f27613783307
DIFF: https://github.com/llvm/llvm-project/commit/0505181006f1088b2cb28a7240d5f27613783307.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp b/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
index 9c36e86099f9..6e1134a25950 100644
--- a/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
+++ b/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
@@ -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;
More information about the llvm-commits
mailing list