[llvm-branch-commits] [llvm] ac40e7a - [X86] Fix to X86LoadValueInjectionRetHardeningPass for possible segfault
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 24 09:36:03 PDT 2020
Author: Scott Constable
Date: 2020-06-24T09:31:04-07:00
New Revision: ac40e7a02efbadd5c91d2fec85aac29ab9a6af18
URL: https://github.com/llvm/llvm-project/commit/ac40e7a02efbadd5c91d2fec85aac29ab9a6af18
DIFF: https://github.com/llvm/llvm-project/commit/ac40e7a02efbadd5c91d2fec85aac29ab9a6af18.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-branch-commits
mailing list