diff options
| -rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/MIR/X86/subreg-on-physreg.mir | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 0b5c59dee0c..b3fd16f1588 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -962,6 +962,8 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest, if (Token.is(MIToken::colon)) { if (parseSubRegisterIndex(SubReg)) return true; + if (!TargetRegisterInfo::isVirtualRegister(Reg)) + return error("subregister index expects a virtual register"); } if ((Flags & RegState::Define) == 0) { if (consumeIfPresent(MIToken::lparen)) { diff --git a/llvm/test/CodeGen/MIR/X86/subreg-on-physreg.mir b/llvm/test/CodeGen/MIR/X86/subreg-on-physreg.mir new file mode 100644 index 00000000000..b856df2f85f --- /dev/null +++ b/llvm/test/CodeGen/MIR/X86/subreg-on-physreg.mir @@ -0,0 +1,12 @@ +# RUN: not llc -march=x86-64 -start-after machine-sink -stop-after machine-sink -o /dev/null %s 2>&1 | FileCheck %s +# This test ensures that an error is reported for subreg index on a physreg. +--- | + define void @t() { ret void } +... +--- +name: t +body: | + bb.0: + ; CHECK: [[@LINE+1]]:19: subregister index expects a virtual register + %eax:sub_8bit = COPY %bl +... |

