summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp6
-rw-r--r--llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll6
2 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
index c068507095a..3d2bbd3e55c 100644
--- a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
+++ b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
@@ -525,7 +525,11 @@ bool X86SpeculativeLoadHardeningPass::runOnMachineFunction(
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);
diff --git a/llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll b/llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
index b067c10a254..33741ff7b75 100644
--- a/llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
+++ b/llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
@@ -37,9 +37,6 @@ define i32 @test_indirect_tail_call(i32 ()** %ptr) nounwind {
; X64-NEXT: movq %rsp, %rax
; X64-NEXT: movq $-1, %rcx
; X64-NEXT: sarq $63, %rax
-; X64-NEXT: movq %rax, %rcx
-; X64-NEXT: shlq $47, %rcx
-; X64-NEXT: orq %rcx, %rsp
; X64-NEXT: shlq $47, %rax
; X64-NEXT: orq %rax, %rsp
; X64-NEXT: jmpq *(%rdi) # TAILCALL
@@ -77,9 +74,6 @@ define i32 @test_indirect_tail_call_global() nounwind {
; X64-NEXT: movq %rsp, %rax
; X64-NEXT: movq $-1, %rcx
; X64-NEXT: sarq $63, %rax
-; X64-NEXT: movq %rax, %rcx
-; X64-NEXT: shlq $47, %rcx
-; X64-NEXT: orq %rcx, %rsp
; X64-NEXT: shlq $47, %rax
; X64-NEXT: orq %rax, %rsp
; X64-NEXT: jmpq *{{.*}}(%rip) # TAILCALL
OpenPOWER on IntegriCloud