Skip to content

Commit c0afb77

Browse files
authored
RISCVAsmParser: Reject call foo@invalid
... instead of silently parsing and ignoring it without leaving an error message. While here, remove an unreachable `@plt`. Pull Request: #135509
1 parent 974bda8 commit c0afb77

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2079,9 +2079,6 @@ ParseStatus RISCVAsmParser::parseBareSymbol(OperandVector &Operands) {
20792079

20802080
SMLoc E = SMLoc::getFromPointer(S.getPointer() + Identifier.size());
20812081

2082-
if (Identifier.consume_back("@plt"))
2083-
return Error(getLoc(), "'@plt' operand not valid for instruction");
2084-
20852082
MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
20862083

20872084
if (Sym->isVariable()) {
@@ -2129,8 +2126,9 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) {
21292126
Lex();
21302127
Lex();
21312128
StringRef PLT;
2129+
SMLoc Loc = getLoc();
21322130
if (getParser().parseIdentifier(PLT) || PLT != "plt")
2133-
return ParseStatus::Failure;
2131+
return Error(Loc, "@ (except the deprecated/ignored @plt) is disallowed");
21342132
} else if (!getLexer().peekTok().is(AsmToken::EndOfStatement)) {
21352133
// Avoid parsing the register in `call rd, foo` as a call symbol.
21362134
return ParseStatus::NoMatch;

llvm/test/MC/RISCV/function-call-invalid.s

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ call %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1010
call %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1111
call %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1212
call foo, bar # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
13+
call foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed
14+
call foo@3 # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed

llvm/test/MC/RISCV/tail-call-invalid.s

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ tail %hi(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1010
tail %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1111
tail %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1212
tail %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
13+
tail foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed

0 commit comments

Comments
 (0)