From b61f01f1c2faed05d8d78a5dc920e1a857a80721 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Wed, 4 Feb 2015 03:10:03 +0000 Subject: [PATCH] Fix some unnoticed/unwanted behavior change from r222319. The ARM assembler allows register alias redefinitions as long as it targets the same register. r222319 broke that. In the AArch64 case it would just produce a new warning, but in the ARM case it would error out on previously accepted assembler. llvm-svn: 228109 --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 2 +- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 2 +- llvm/test/MC/AArch64/dot-req.s | 4 +++- llvm/test/MC/ARM/dot-req.s | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 70b61c3ffaee..1960c9937933 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -4132,7 +4132,7 @@ bool AArch64AsmParser::parseDirectiveReq(StringRef Name, SMLoc L) { Parser.Lex(); // Consume the EndOfStatement auto pair = std::make_pair(IsVector, RegNum); - if (!RegisterReqs.insert(std::make_pair(Name, pair)).second) + if (RegisterReqs.insert(std::make_pair(Name, pair)).first->second != pair) Warning(L, "ignoring redefinition of register alias '" + Name + "'"); return true; diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index c35b0ef311f2..3b7a67d0d1f0 100644 --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -9010,7 +9010,7 @@ bool ARMAsmParser::parseDirectiveReq(StringRef Name, SMLoc L) { Parser.Lex(); // Consume the EndOfStatement - if (!RegisterReqs.insert(std::make_pair(Name, Reg)).second) { + if (RegisterReqs.insert(std::make_pair(Name, Reg)).first->second != Reg) { Error(SRegLoc, "redefinition of '" + Name + "' does not match original."); return false; } diff --git a/llvm/test/MC/AArch64/dot-req.s b/llvm/test/MC/AArch64/dot-req.s index 947f945bded8..a557f0c67589 100644 --- a/llvm/test/MC/AArch64/dot-req.s +++ b/llvm/test/MC/AArch64/dot-req.s @@ -1,7 +1,9 @@ -// RUN: llvm-mc -triple=aarch64-none-linux-gnu -show-encoding < %s | FileCheck %s +// RUN: llvm-mc -triple=aarch64-none-linux-gnu -show-encoding < %s 2>&1 | FileCheck %s bar: fred .req x5 +// CHECK-NOT: ignoring redefinition of register alias 'fred' + fred .req x5 mov fred, x11 .unreq fred fred .req w6 diff --git a/llvm/test/MC/ARM/dot-req.s b/llvm/test/MC/ARM/dot-req.s index 3b4cf5c80c00..848c1241affd 100644 --- a/llvm/test/MC/ARM/dot-req.s +++ b/llvm/test/MC/ARM/dot-req.s @@ -1,6 +1,9 @@ @ RUN: llvm-mc -triple=armv7-apple-darwin -show-encoding < %s | FileCheck %s .syntax unified bar: +@ The line is duplicated on purpose, it is legal to redefine a req with +@ the same value. +fred .req r5 fred .req r5 mov r11, fred .unreq fred