[x86/SLH] Fix a bug where we would harden tail calls twice -- once as
a call, and then again as a return.
Also added a comment to try and explain better why we would be doing
what we're doing when hardening the (non-call) returns.
llvm-svn: 337673
diff --git a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
index c068507..3d2bbd3 100644
--- a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
+++ b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
@@ -525,7 +525,11 @@
         continue;
 
       MachineInstr &MI = MBB.back();
-      if (!MI.isReturn())
+
+      // We only care about returns that are not also calls. For calls, that
+      // happen to also be returns (tail calls) we will have already handled
+      // them as calls.
+      if (!MI.isReturn() || MI.isCall())
         continue;
 
       hardenReturnInstr(MI);