[X86] Fix a crash in FEntryInserter Pass.
Summary: FEntryInserter pass unconditionally derefs the first Instruction in the first Basic Block. The pass crashes when the first BasicBlock is empty. Fix the crash by not dereferencing the basic Block iterator. This fixes an issue observed when building Linux kernel 4.4 with clang. Fixes PR33971. Reviewers: hfinkel, niravd, dblaikie Reviewed By: niravd Subscribers: davide, llvm-commits Differential Revision: https://reviews.llvm.org/D35979 llvm-svn: 309694
This commit is contained in:
@@ -41,10 +41,8 @@ bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
|
||||
return false;
|
||||
|
||||
auto &FirstMBB = *MF.begin();
|
||||
auto &FirstMI = *FirstMBB.begin();
|
||||
|
||||
auto *TII = MF.getSubtarget().getInstrInfo();
|
||||
BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),
|
||||
BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
|
||||
TII->get(TargetOpcode::FENTRY_CALL));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user