[llvm] r340763 - MachineVerifier: Fix assert on implicit virtreg use
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 27 10:40:09 PDT 2018
Author: arsenm
Date: Mon Aug 27 10:40:09 2018
New Revision: 340763
URL: http://llvm.org/viewvc/llvm-project?rev=340763&view=rev
Log:
MachineVerifier: Fix assert on implicit virtreg use
If the liveness of a physical register was invalid, this
was attempting to iterate the subregisters of all register
uses of the instruction, which would assert when it
encountered an implicit virtual register operand.
Added:
llvm/trunk/test/CodeGen/AMDGPU/verifier-implicit-virtreg-invalid-physreg-liveness.mir
Modified:
llvm/trunk/lib/CodeGen/MachineVerifier.cpp
Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=340763&r1=340762&r2=340763&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Mon Aug 27 10:40:09 2018
@@ -1533,10 +1533,12 @@ void MachineVerifier::checkLiveness(cons
// get a report for its operand.
if (Bad) {
for (const MachineOperand &MOP : MI->uses()) {
- if (!MOP.isReg())
+ if (!MOP.isReg() || !MOP.isImplicit())
continue;
- if (!MOP.isImplicit())
+
+ if (!TargetRegisterInfo::isPhysicalRegister(MOP.getReg()))
continue;
+
for (MCSubRegIterator SubRegs(MOP.getReg(), TRI); SubRegs.isValid();
++SubRegs) {
if (*SubRegs == Reg) {
Added: llvm/trunk/test/CodeGen/AMDGPU/verifier-implicit-virtreg-invalid-physreg-liveness.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/verifier-implicit-virtreg-invalid-physreg-liveness.mir?rev=340763&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/verifier-implicit-virtreg-invalid-physreg-liveness.mir (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/verifier-implicit-virtreg-invalid-physreg-liveness.mir Mon Aug 27 10:40:09 2018
@@ -0,0 +1,21 @@
+# RUN: not llc -mtriple=amdgcn-amd-amdhsa -verify-machineinstrs -o /dev/null %s 2>&1 | FileCheck -check-prefix=ERROR %s
+
+# When the verifier was detecting the invalid liveness for vcc, it would assert when trying to iterate the subregisters of the implicit virtual register use.
+
+
+# ERROR: *** Bad machine code: Using an undefined physical register ***
+# ERROR: instruction: S_ENDPGM implicit %0:vgpr_32, implicit $vcc
+# ERROR: operand 1: implicit $vcc
+
+...
+
+name: invalid_implicit_physreg_use_with_implicit_virtreg
+tracksRegLiveness: true
+
+body: |
+ bb.0:
+ %0:vgpr_32 = IMPLICIT_DEF
+ S_ENDPGM implicit %0, implicit $vcc
+
+...
+
More information about the llvm-commits
mailing list