From 7ebbe655edd411bd79a726251ec23d9477ccb64c Mon Sep 17 00:00:00 2001 From: Manoj Gupta Date: Tue, 1 Aug 2017 15:39:12 +0000 Subject: [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 --- llvm/lib/CodeGen/FEntryInserter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/CodeGen/FEntryInserter.cpp b/llvm/lib/CodeGen/FEntryInserter.cpp index 0759bf6713e..9781338f952 100644 --- a/llvm/lib/CodeGen/FEntryInserter.cpp +++ b/llvm/lib/CodeGen/FEntryInserter.cpp @@ -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; } -- cgit v1.2.3