summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Gupta <manojgupta@google.com>2017-08-01 15:39:12 +0000
committerManoj Gupta <manojgupta@google.com>2017-08-01 15:39:12 +0000
commit7ebbe655edd411bd79a726251ec23d9477ccb64c (patch)
tree97d098d134b8cafce43927d1eaa98c3a34b8481c
parent2462a713ae4e06f11bc558787153412531fe1a52 (diff)
downloadbcm5719-llvm-7ebbe655edd411bd79a726251ec23d9477ccb64c.tar.gz
bcm5719-llvm-7ebbe655edd411bd79a726251ec23d9477ccb64c.zip
[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
-rw-r--r--llvm/lib/CodeGen/FEntryInserter.cpp4
-rw-r--r--llvm/test/CodeGen/X86/fentry-insertion.ll16
2 files changed, 16 insertions, 4 deletions
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;
}
diff --git a/llvm/test/CodeGen/X86/fentry-insertion.ll b/llvm/test/CodeGen/X86/fentry-insertion.ll
index a585d96b209..c5fb3b254b2 100644
--- a/llvm/test/CodeGen/X86/fentry-insertion.ll
+++ b/llvm/test/CodeGen/X86/fentry-insertion.ll
@@ -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" }
OpenPOWER on IntegriCloud