diff --git a/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp b/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp --- a/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp +++ b/llvm/lib/Target/X86/X86LoadValueInjectionRetHardening.cpp @@ -99,6 +99,9 @@ bool Modified = false; for (auto &MBB : MF) { + if (MBB.empty()) + continue; + MachineInstr &MI = MBB.back(); if (MI.getOpcode() != X86::RETQ) continue;