[llvm] r356303 - [ARM] Add MachineVerifier logic for some Thumb1 instructions.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 14:44:49 PDT 2019
Author: efriedma
Date: Fri Mar 15 14:44:49 2019
New Revision: 356303
URL: http://llvm.org/viewvc/llvm-project?rev=356303&view=rev
Log:
[ARM] Add MachineVerifier logic for some Thumb1 instructions.
tMOVr and tPUSH/tPOP/tPOP_RET have register constraints which can't be
expressed in TableGen, so check them explicitly. I've unfortunately run
into issues with both of these recently; hopefully this saves some time
for someone else in the future.
Differential Revision: https://reviews.llvm.org/D59383
Added:
llvm/trunk/test/CodeGen/ARM/machine-verifier.mir
Modified:
llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=356303&r1=356302&r2=356303&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Fri Mar 15 14:44:49 2019
@@ -4570,6 +4570,31 @@ bool ARMBaseInstrInfo::verifyInstruction
ErrInfo = "Pseudo flag setting opcodes only exist in Selection DAG";
return false;
}
+ if (MI.getOpcode() == ARM::tMOVr && !Subtarget.hasV6Ops()) {
+ // Make sure we don't generate a lo-lo mov that isn't supported.
+ if (!ARM::hGPRRegClass.contains(MI.getOperand(0).getReg()) &&
+ !ARM::hGPRRegClass.contains(MI.getOperand(1).getReg())) {
+ ErrInfo = "Non-flag-setting Thumb1 mov is v6-only";
+ return false;
+ }
+ }
+ if (MI.getOpcode() == ARM::tPUSH ||
+ MI.getOpcode() == ARM::tPOP ||
+ MI.getOpcode() == ARM::tPOP_RET) {
+ for (int i = 2, e = MI.getNumOperands(); i < e; ++i) {
+ if (MI.getOperand(i).isImplicit() ||
+ !MI.getOperand(i).isReg())
+ continue;
+ unsigned Reg = MI.getOperand(i).getReg();
+ if (Reg < ARM::R0 || Reg > ARM::R7) {
+ if (!(MI.getOpcode() == ARM::tPUSH && Reg == ARM::LR) &&
+ !(MI.getOpcode() == ARM::tPOP_RET && Reg == ARM::PC)) {
+ ErrInfo = "Unsupported register in Thumb1 push/pop";
+ return false;
+ }
+ }
+ }
+ }
return true;
}
Added: llvm/trunk/test/CodeGen/ARM/machine-verifier.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/machine-verifier.mir?rev=356303&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/machine-verifier.mir (added)
+++ llvm/trunk/test/CodeGen/ARM/machine-verifier.mir Fri Mar 15 14:44:49 2019
@@ -0,0 +1,22 @@
+# RUN: not llc -mtriple=thumb -run-pass none -o /dev/null %s 2>&1 | FileCheck %s
+# This test ensures that the MIR parser runs the machine verifier after parsing.
+
+--- |
+
+ define i32 @inc(i32 %a) {
+ entry:
+ ret i32 %a
+ }
+
+...
+---
+name: inc
+tracksRegLiveness: true
+body: |
+ bb.0.entry:
+ ; CHECK: *** Bad machine code: Unsupported register in Thumb1 push/pop ***
+ frame-setup tPUSH 14, $noreg, undef $r12, killed $lr, implicit-def $sp, implicit $sp
+
+ ; CHECK: *** Bad machine code: Non-flag-setting Thumb1 mov is v6-only ***
+ $r2 = tMOVr killed $r6, 14, $noreg
+...
More information about the llvm-commits
mailing list