[llvm] 6eb9eae - [MS] Copy the symbols assigned to the former instruction when memory folding.
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 00:38:42 PDT 2020
Author: Wang, Pengfei
Date: 2020-06-10T15:38:32+08:00
New Revision: 6eb9eae0100f13ae2574bd74add915bec0078b4d
URL: https://github.com/llvm/llvm-project/commit/6eb9eae0100f13ae2574bd74add915bec0078b4d
DIFF: https://github.com/llvm/llvm-project/commit/6eb9eae0100f13ae2574bd74add915bec0078b4d.diff
LOG: [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
Added:
Modified:
llvm/lib/CodeGen/TargetInstrInfo.cpp
llvm/test/CodeGen/X86/speculative-load-hardening-no-spill.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 228e3c1051ab..9dbd612c7f5f 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 bfc28469281b..f83254b6d07b 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
More information about the llvm-commits
mailing list