summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorScott Constable <scott.d.constable@intel.com>2020-04-10 17:32:39 -0700
committerTom Stellard <tstellar@redhat.com>2020-06-24 09:31:04 -0700
commitac40e7a02efbadd5c91d2fec85aac29ab9a6af18 (patch)
treedc02a455d8e36fb826680e399a2068558a385f37 /llvm/lib
parentd758416a9152a9c7e41671493ae4f77a0dfc1993 (diff)
downloadbcm5719-llvm-ac40e7a02efbadd5c91d2fec85aac29ab9a6af18.tar.gz
bcm5719-llvm-ac40e7a02efbadd5c91d2fec85aac29ab9a6af18.zip
[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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp b/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp
index 9c36e86099f..6e1134a2595 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;
OpenPOWER on IntegriCloud