[llvm] r244081 - MIR Parser: Report an error when parsing duplicate register flags.
Alex Lorenz
arphaman at gmail.com
Wed Aug 5 11:09:03 PDT 2015
Author: arphaman
Date: Wed Aug 5 13:09:03 2015
New Revision: 244081
URL: http://llvm.org/viewvc/llvm-project?rev=244081&view=rev
Log:
MIR Parser: Report an error when parsing duplicate register flags.
Added:
llvm/trunk/test/CodeGen/MIR/X86/duplicate-register-flag-error.mir
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=244081&r1=244080&r2=244081&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Aug 5 13:09:03 2015
@@ -474,6 +474,7 @@ bool MIParser::parseRegister(unsigned &R
}
bool MIParser::parseRegisterFlag(unsigned &Flags) {
+ const unsigned OldFlags = Flags;
switch (Token.kind()) {
case MIToken::kw_implicit:
Flags |= RegState::Implicit;
@@ -496,11 +497,14 @@ bool MIParser::parseRegisterFlag(unsigne
case MIToken::kw_debug_use:
Flags |= RegState::Debug;
break;
- // TODO: report an error when we specify the same flag more than once.
// TODO: parse the other register flags.
default:
llvm_unreachable("The current token should be a register flag");
}
+ if (OldFlags == Flags)
+ // We know that the same flag is specified more than once when the flags
+ // weren't modified.
+ return error("duplicate '" + Token.stringValue() + "' register flag");
lex();
return false;
}
Added: llvm/trunk/test/CodeGen/MIR/X86/duplicate-register-flag-error.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/X86/duplicate-register-flag-error.mir?rev=244081&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/X86/duplicate-register-flag-error.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/X86/duplicate-register-flag-error.mir Wed Aug 5 13:09:03 2015
@@ -0,0 +1,38 @@
+# RUN: not llc -march=x86-64 -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+
+--- |
+
+ define i32 @foo(i32 %a) {
+ entry:
+ %0 = icmp sle i32 %a, 10
+ br i1 %0, label %less, label %exit
+
+ less:
+ ret i32 0
+
+ exit:
+ ret i32 %a
+ }
+
+...
+---
+name: foo
+body:
+ - id: 0
+ name: entry
+ successors: [ '%bb.1.less', '%bb.2.exit' ]
+ instructions:
+ - 'CMP32ri8 %edi, 10, implicit-def %eflags'
+# CHECK: [[@LINE+1]]:36: duplicate 'implicit' register flag
+ - 'JG_1 %bb.2.exit, implicit implicit %eflags'
+ - id: 1
+ name: less
+ instructions:
+ - '%eax = MOV32r0 implicit-def %eflags'
+ - 'RETQ %eax'
+ - id: 2
+ name: exit
+ instructions:
+ - '%eax = COPY %edi'
+ - 'RETQ %eax'
+...
More information about the llvm-commits
mailing list