<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 28, 2017 at 10:32 AM Manoj Gupta via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">manojgupta updated this revision to Diff 108677.<br>
manojgupta removed a reviewer: dblaikie.<br>
manojgupta added a comment.<br>
<br>
Linux kernel is still WIP.<br>
<br>
Added back the DebugLoc from first instruction. I am not sure though if reusing<br>
debug location from an unrelated instruction is ok.<br></blockquote><div><br>Depends what you mean by "unrelated" - if the new instruction is created because of/only in the presence of the old instruction, yaeh, using its debugloc may be appropriate. (Though if the new instruction may be created in a different basic block - that gets trickier)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<a href="https://reviews.llvm.org/D35979" rel="noreferrer" target="_blank">https://reviews.llvm.org/D35979</a><br>
<br>
Files:<br>
  lib/CodeGen/FEntryInserter.cpp<br>
  test/CodeGen/X86/fentry-insertion.ll<br>
<br>
<br>
Index: test/CodeGen/X86/fentry-insertion.ll<br>
===================================================================<br>
--- test/CodeGen/X86/fentry-insertion.ll<br>
+++ test/CodeGen/X86/fentry-insertion.ll<br>
@@ -12,5 +12,19 @@<br>
 ; CHECK: retq<br>
 }<br>
<br>
-attributes #0 = { "fentry-call"="true" }<br>
+define void @test2() #1 {<br>
+entry:<br>
+  br label %bb1<br>
+bb1:<br>
+  call void @address_taken(i64 ptrtoint (i8* blockaddress(@test2, %bb1) to i64), i32 512)<br>
+  ret void<br>
<br>
+; CHECK-LABEL: @test2<br>
+; CHECK: callq __fentry__<br>
+; CHECK-NOT: mcount<br>
+; CHECK: retq<br>
+}<br>
+<br>
+declare void @address_taken(i64, i32) local_unnamed_addr<br>
+attributes #0 = { "fentry-call"="true" }<br>
+attributes #1 = { inlinehint minsize noredzone nounwind optsize sspstrong "fentry-call"="true" }<br>
Index: lib/CodeGen/FEntryInserter.cpp<br>
===================================================================<br>
--- lib/CodeGen/FEntryInserter.cpp<br>
+++ lib/CodeGen/FEntryInserter.cpp<br>
@@ -41,11 +41,15 @@<br>
     return false;<br>
<br>
   auto &FirstMBB = *MF.begin();<br>
-  auto &FirstMI = *FirstMBB.begin();<br>
-<br>
   auto *TII = MF.getSubtarget().getInstrInfo();<br>
-  BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),<br>
-          TII->get(TargetOpcode::FENTRY_CALL));<br>
+  if (FirstMBB.empty()) {<br>
+    BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),<br>
+            TII->get(TargetOpcode::FENTRY_CALL));<br>
+  } else {<br>
+    auto &FirstMI = *FirstMBB.begin();<br>
+    BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),<br>
+            TII->get(TargetOpcode::FENTRY_CALL));<br>
+  }<br>
   return true;<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>