[PATCH] D89151: [X86] Don't copy kill flag when expanding LCMPXCHG16B_SAVE_RBX

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 10:45:54 PDT 2020


craig.topper created this revision.
craig.topper added reviewers: qcolombet, rnk, RKSimon, pengfei.
Herald added subscribers: jfb, hiraditya.
Herald added a project: LLVM.
craig.topper requested review of this revision.

The expansion code creates a copy to RBX before the real LCMPXCHG16B.
It's possible this copy uses a register that is also used by the
real LCMPXCHG16B. If we set the kill flag on the use in the copy,
then we'll fail the machine verifier on the use on the LCMPXCHG16B.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89151

Files:
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/test/CodeGen/X86/pr42064.ll


Index: llvm/test/CodeGen/X86/pr42064.ll
===================================================================
--- llvm/test/CodeGen/X86/pr42064.ll
+++ llvm/test/CodeGen/X86/pr42064.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc19.11.0 -mattr=+avx,+cx16 | FileCheck %s
+; RUN: llc < %s -verify-machineinstrs -mtriple=x86_64-pc-windows-msvc19.11.0 -mattr=+avx,+cx16 | FileCheck %s
 
 %struct.TestStruct = type { %union.Int128 }
 %union.Int128 = type { i128 }
Index: llvm/lib/Target/X86/X86ExpandPseudo.cpp
===================================================================
--- llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -346,7 +346,9 @@
 
     // Copy the input argument of the pseudo into the argument of the
     // actual instruction.
-    TII->copyPhysReg(MBB, MBBI, DL, X86::RBX, InArg.getReg(), InArg.isKill());
+    // NOTE: We don't copy the kill flag since the input might be the same reg
+    // as one of the other operands of LCMPXCHG16B.
+    TII->copyPhysReg(MBB, MBBI, DL, X86::RBX, InArg.getReg(), false);
     // Create the actual instruction.
     MachineInstr *NewInstr = BuildMI(MBB, MBBI, DL, TII->get(X86::LCMPXCHG16B));
     // Copy the operands related to the address.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89151.297281.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201009/7ae607e4/attachment.bin>


More information about the llvm-commits mailing list