diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 70b61c3ffae..1960c993793 100644 --- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/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/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index c35b0ef311f..3b7a67d0d1f 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/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/test/MC/AArch64/dot-req.s b/test/MC/AArch64/dot-req.s index 947f945bded..a557f0c6758 100644 --- a/test/MC/AArch64/dot-req.s +++ b/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/test/MC/ARM/dot-req.s b/test/MC/ARM/dot-req.s index 3b4cf5c80c0..848c1241aff 100644 --- a/test/MC/ARM/dot-req.s +++ b/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