[llvm] 1c80a6c - [Statepoints] FixupStatepoint: properly set isKill on spilled register.

Denis Antrushin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 08:20:03 PDT 2020


Author: Denis Antrushin
Date: 2020-08-14T22:19:20+07:00
New Revision: 1c80a6ce5f2217c01fb40bd43bc5bf094c32278a

URL: https://github.com/llvm/llvm-project/commit/1c80a6ce5f2217c01fb40bd43bc5bf094c32278a
DIFF: https://github.com/llvm/llvm-project/commit/1c80a6ce5f2217c01fb40bd43bc5bf094c32278a.diff

LOG: [Statepoints] FixupStatepoint: properly set isKill on spilled register.

When spilling statepoint meta arg register it is incorrect to blindly
mark it as killed - it may be used in non-meta args (e.g., as call
parameter).

Added: 
    

Modified: 
    llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
    llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
index 7491a92645f5..a92968fa1cd8 100644
--- a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
+++ b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
@@ -157,12 +157,14 @@ static Register performCopyPropagation(Register Reg,
                                        MachineBasicBlock::iterator &RI,
                                        bool &IsKill, const TargetInstrInfo &TII,
                                        const TargetRegisterInfo &TRI) {
-  if (!EnableCopyProp)
-    return Reg;
-
   // First check if statepoint itself uses Reg in non-meta operands.
   int Idx = RI->findRegisterUseOperandIdx(Reg, false, &TRI);
-  if (Idx >= 0 && (unsigned)Idx < StatepointOpers(&*RI).getNumDeoptArgsIdx())
+  if (Idx >= 0 && (unsigned)Idx < StatepointOpers(&*RI).getNumDeoptArgsIdx()) {
+    IsKill = false;
+    return Reg;
+  }
+
+  if (!EnableCopyProp)
     return Reg;
 
   MachineBasicBlock *MBB = RI->getParent();

diff  --git a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir
index 7742d0c45fd1..94d09efcede3 100644
--- a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir
+++ b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir
@@ -1,5 +1,5 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
-# RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved | FileCheck %s
+# RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved -verify-machineinstrs | FileCheck %s
 
 # Check that COPY is not eliminated if dest register is used in
 # non-meta arguments of statepoint.
@@ -76,7 +76,7 @@ body:             |
     ; CHECK: liveins: $rcx, $rsi
     ; CHECK: renamable $rdi = COPY $rsi
     ; CHECK: MOV64mr %stack.0, 1, $noreg, 0, $noreg, killed renamable $rcx :: (store 8 into %stack.0)
-    ; CHECK: MOV64mr %stack.1, 1, $noreg, 0, $noreg, killed $rdi :: (store 8 into %stack.1)
+    ; CHECK: MOV64mr %stack.1, 1, $noreg, 0, $noreg, $rdi :: (store 8 into %stack.1)
     ; CHECK: STATEPOINT 0, 0, 1, @foo, $rdi, 2, 0, 2, 0, 2, 1, 1, 8, %stack.1, 0, 1, 8, %stack.0, 0, 1, 8, %stack.0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (volatile load store 8 on %stack.0), (load 8 from %stack.1)
     ; CHECK: renamable $rax = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load 8 from %stack.0)
     ; CHECK: RET 0, $rax


        


More information about the llvm-commits mailing list