[MS] Copy the symbols assigned to the former instruction when memory folding.

The memory folding raplaced the old instruction without copying the symbols assigned. Which will resulted in built fail due to the lost symbols.

Reviewed by craig.topper

Differential Revision: https://reviews.llvm.org/D78471
This commit is contained in:
Wang, Pengfei 2020-06-10 14:52:54 +08:00
parent a8fbbf8fe2
commit 6eb9eae010
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -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