Skip to content

RISCVAsmParser: Reject call foo@invalid #135509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,9 +2079,6 @@ ParseStatus RISCVAsmParser::parseBareSymbol(OperandVector &Operands) {

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

if (Identifier.consume_back("@plt"))
return Error(getLoc(), "'@plt' operand not valid for instruction");

MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);

if (Sym->isVariable()) {
Expand Down Expand Up @@ -2129,8 +2126,9 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) {
Lex();
Lex();
StringRef PLT;
SMLoc Loc = getLoc();
if (getParser().parseIdentifier(PLT) || PLT != "plt")
return ParseStatus::Failure;
return Error(Loc, "@ (except the deprecated/ignored @plt) is disallowed");
} else if (!getLexer().peekTok().is(AsmToken::EndOfStatement)) {
// Avoid parsing the register in `call rd, foo` as a call symbol.
return ParseStatus::NoMatch;
Expand Down
2 changes: 2 additions & 0 deletions llvm/test/MC/RISCV/function-call-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ call %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
call %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
call %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
call foo, bar # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
call foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed
call foo@3 # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed
1 change: 1 addition & 0 deletions llvm/test/MC/RISCV/tail-call-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tail %hi(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
tail %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
tail %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
tail %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
tail foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed
Loading