diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 228e3c1051ab73..9dbd612c7f5f55 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -597,6 +597,10 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI, Flags, MemSize, MFI.getObjectAlign(FI)); NewMI->addMemOperand(MF, MMO); + // The pass "x86 speculative load hardening" always attaches symbols to + // call instructions. We need copy it form old instruction. + NewMI->cloneInstrSymbols(MF, MI); + return NewMI; } diff --git a/llvm/test/CodeGen/X86/speculative-load-hardening-no-spill.ll b/llvm/test/CodeGen/X86/speculative-load-hardening-no-spill.ll index bfc28469281b21..f83254b6d07ba1 100644 --- a/llvm/test/CodeGen/X86/speculative-load-hardening-no-spill.ll +++ b/llvm/test/CodeGen/X86/speculative-load-hardening-no-spill.ll @@ -2,8 +2,8 @@ define i32 @foo(void ()** %0) { ; CHECK-LABEL: foo: -; CHECK-NOT: .Lslh_ret_addr0: ; CHECK: callq *(%{{.*}}) +; CHECK-NEXT: .Lslh_ret_addr0: ; CHECK-NEXT: movq %rsp, %rcx ; CHECK-NEXT: movq -{{[0-9]+}}(%rsp), %rax ; CHECK-NEXT: sarq $63, %rcx