[llvm] r309694 - [X86] Fix a crash in FEntryInserter Pass.
Manoj Gupta via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 08:39:12 PDT 2017
Author: manojgupta
Date: Tue Aug 1 08:39:12 2017
New Revision: 309694
URL: http://llvm.org/viewvc/llvm-project?rev=309694&view=rev
Log:
[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
Modified:
llvm/trunk/lib/CodeGen/FEntryInserter.cpp
llvm/trunk/test/CodeGen/X86/fentry-insertion.ll
Modified: llvm/trunk/lib/CodeGen/FEntryInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/FEntryInserter.cpp?rev=309694&r1=309693&r2=309694&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/FEntryInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/FEntryInserter.cpp Tue Aug 1 08:39:12 2017
@@ -41,10 +41,8 @@ bool FEntryInserter::runOnMachineFunctio
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;
}
Modified: llvm/trunk/test/CodeGen/X86/fentry-insertion.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fentry-insertion.ll?rev=309694&r1=309693&r2=309694&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fentry-insertion.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fentry-insertion.ll Tue Aug 1 08:39:12 2017
@@ -12,5 +12,19 @@ entry:
; CHECK: retq
}
-attributes #0 = { "fentry-call"="true" }
+define void @test2() #1 {
+entry:
+ br label %bb1
+bb1:
+ call void @address_taken(i64 ptrtoint (i8* blockaddress(@test2, %bb1) to i64), i32 512)
+ ret void
+; CHECK-LABEL: @test2
+; CHECK: callq __fentry__
+; CHECK-NOT: mcount
+; CHECK: retq
+}
+
+declare void @address_taken(i64, i32) local_unnamed_addr
+attributes #0 = { "fentry-call"="true" }
+attributes #1 = { inlinehint minsize noredzone nounwind optsize sspstrong "fentry-call"="true" }
More information about the llvm-commits
mailing list