[llvm] r344008 - ExpandPostRAPseudos: Fix alldefsAreDead() not removing operands

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 17:07:34 PDT 2018


Author: matze
Date: Mon Oct  8 17:07:34 2018
New Revision: 344008

URL: http://llvm.org/viewvc/llvm-project?rev=344008&view=rev
Log:
ExpandPostRAPseudos: Fix alldefsAreDead() not removing operands

One case left around nonsensical operands for the KILL instruction
which the machine verifier checks for nowadays. While this should not
hurt in release builds we should fix the machine verifier errors anyway.

Added:
    llvm/trunk/test/CodeGen/X86/expand-post-ra-pseudo.mir
Modified:
    llvm/trunk/lib/CodeGen/ExpandPostRAPseudos.cpp

Modified: llvm/trunk/lib/CodeGen/ExpandPostRAPseudos.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExpandPostRAPseudos.cpp?rev=344008&r1=344007&r2=344008&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ExpandPostRAPseudos.cpp (original)
+++ llvm/trunk/lib/CodeGen/ExpandPostRAPseudos.cpp Mon Oct  8 17:07:34 2018
@@ -97,6 +97,8 @@ bool ExpandPostRA::LowerSubregToReg(Mach
 
   if (MI->allDefsAreDead()) {
     MI->setDesc(TII->get(TargetOpcode::KILL));
+    MI->RemoveOperand(3); // SubIdx
+    MI->RemoveOperand(1); // Imm
     LLVM_DEBUG(dbgs() << "subreg: replaced by: " << *MI);
     return true;
   }

Added: llvm/trunk/test/CodeGen/X86/expand-post-ra-pseudo.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/expand-post-ra-pseudo.mir?rev=344008&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/expand-post-ra-pseudo.mir (added)
+++ llvm/trunk/test/CodeGen/X86/expand-post-ra-pseudo.mir Mon Oct  8 17:07:34 2018
@@ -0,0 +1,11 @@
+# RUN: llc -o - %s -mtriple=x86_64-- -run-pass=postrapseudos | FileCheck %s
+---
+# CHECK-LABEL: name: func
+name: func
+body: |
+  bb.0:
+    liveins: $eax
+    ; CHECK-NOT: dead $rax = KILL {{[0-9]+}}
+    ; CHECK: dead $rax = KILL killed $eax
+    dead $rax = SUBREG_TO_REG 0, killed $eax, %subreg.sub_32bit
+...




More information about the llvm-commits mailing list