[llvm] a8ebd85 - [MC] Make MCAsmInfo::isAcceptableChar reflect MCAsmInfo::doesAllowAtInName
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 14:01:45 PDT 2022
Author: Eli Friedman
Date: 2022-03-29T14:01:32-07:00
New Revision: a8ebd85e463b086c0e684c9e7867bbf42555ad27
URL: https://github.com/llvm/llvm-project/commit/a8ebd85e463b086c0e684c9e7867bbf42555ad27
DIFF: https://github.com/llvm/llvm-project/commit/a8ebd85e463b086c0e684c9e7867bbf42555ad27.diff
LOG: [MC] Make MCAsmInfo::isAcceptableChar reflect MCAsmInfo::doesAllowAtInName
On targets which don't allow "@" in unquoted identifiers, make sure we
don't emit them; otherwise, we can't parse our own output.
Differential Revision: https://reviews.llvm.org/D122516
Added:
Modified:
llvm/lib/MC/MCAsmInfo.cpp
llvm/test/CodeGen/AArch64/ehcontguard.ll
llvm/test/CodeGen/AArch64/win_cst_pool.ll
llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index f52503d7b1606..b8d0021ed4322 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -114,7 +114,10 @@ MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
}
bool MCAsmInfo::isAcceptableChar(char C) const {
- return isAlnum(C) || C == '_' || C == '$' || C == '.' || C == '@';
+ if (C == '@')
+ return doesAllowAtInName();
+
+ return isAlnum(C) || C == '_' || C == '$' || C == '.';
}
bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
diff --git a/llvm/test/CodeGen/AArch64/ehcontguard.ll b/llvm/test/CodeGen/AArch64/ehcontguard.ll
index f4fd5a2ce367b..a015851df0935 100644
--- a/llvm/test/CodeGen/AArch64/ehcontguard.ll
+++ b/llvm/test/CodeGen/AArch64/ehcontguard.ll
@@ -1,7 +1,7 @@
; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s
; EHCont Guard is currently only available on Windows
-; CHECK: .set @feat.00, 16384
+; CHECK: .set "@feat.00", 16384
; CHECK: .section .gehcont$y
diff --git a/llvm/test/CodeGen/AArch64/win_cst_pool.ll b/llvm/test/CodeGen/AArch64/win_cst_pool.ll
index 771118c8601dd..5411099440dc9 100644
--- a/llvm/test/CodeGen/AArch64/win_cst_pool.ll
+++ b/llvm/test/CodeGen/AArch64/win_cst_pool.ll
@@ -4,14 +4,14 @@
define double @double() {
ret double 0x2000000000800001
}
-; CHECK: .globl __real at 2000000000800001
-; CHECK-NEXT: .section .rdata,"dr",discard,__real at 2000000000800001
+; CHECK: .globl "__real at 2000000000800001"
+; CHECK-NEXT: .section .rdata,"dr",discard,"__real at 2000000000800001"
; CHECK-NEXT: .p2align 3
-; CHECK-NEXT: __real at 2000000000800001:
+; CHECK-NEXT: "__real at 2000000000800001":
; CHECK-NEXT: .xword 0x2000000000800001
; CHECK: double:
-; CHECK: adrp x8, __real at 2000000000800001
-; CHECK-NEXT: ldr d0, [x8, :lo12:__real at 2000000000800001]
+; CHECK: adrp x8, "__real at 2000000000800001"
+; CHECK-NEXT: ldr d0, [x8, :lo12:"__real at 2000000000800001"]
; CHECK-NEXT: ret
; MINGW: .section .rdata,"dr"
diff --git a/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp b/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
index 9086cec729151..cd0e1b40d5002 100644
--- a/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ b/llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -554,9 +554,11 @@ TEST_F(SystemZAsmLexerZOS, CheckPrintAcceptableSymbol) {
}
TEST_F(SystemZAsmLexerLinux, CheckPrintAcceptableSymbol) {
- std::string AsmStr = "ab13_$.@";
+ std::string AsmStr = "ab13_$.";
EXPECT_EQ(true, MAI->isValidUnquotedName(AsmStr));
- AsmStr += "#";
+ AsmStr = "ab13_$.@";
+ EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
+ AsmStr = "ab13_$.#";
EXPECT_EQ(false, MAI->isValidUnquotedName(AsmStr));
}
More information about the llvm-commits
mailing list