[PATCH] D35979: [X86] Fix a crash in FEntryInserter Pass.

Manoj Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 11:57:25 PDT 2017


manojgupta updated this revision to Diff 108686.
manojgupta added a comment.

Removed getting DebugLoc from previous instruction based on Dave's comments.


https://reviews.llvm.org/D35979

Files:
  lib/CodeGen/FEntryInserter.cpp
  test/CodeGen/X86/fentry-insertion.ll


Index: test/CodeGen/X86/fentry-insertion.ll
===================================================================
--- test/CodeGen/X86/fentry-insertion.ll
+++ test/CodeGen/X86/fentry-insertion.ll
@@ -12,5 +12,19 @@
 ; 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" }
Index: lib/CodeGen/FEntryInserter.cpp
===================================================================
--- lib/CodeGen/FEntryInserter.cpp
+++ lib/CodeGen/FEntryInserter.cpp
@@ -41,10 +41,8 @@
     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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35979.108686.patch
Type: text/x-patch
Size: 1237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170728/4da17330/attachment.bin>


More information about the llvm-commits mailing list