Skip to content
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

clif: Fix parsing the cold calling convention #8854

Merged
merged 1 commit into from
Jun 20, 2024
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
12 changes: 12 additions & 0 deletions cranelift/filetests/filetests/parser/cold.clif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test cat

function %cold() cold {
sig0 = () cold
sig1 = () -> i8 cold
block1:
return
}

; sameln: function %cold() cold {
; nextln: sig0 = () cold
; nextln: sig1 = () -> i8 cold
10 changes: 8 additions & 2 deletions cranelift/reader/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,14 +1347,20 @@ impl<'a> Parser<'a> {
}

// The calling convention is optional.
if let Some(Token::Identifier(text)) = self.token() {
match text.parse() {
match self.token() {
Some(Token::Identifier(text)) => match text.parse() {
Ok(cc) => {
self.consume();
sig.call_conv = cc;
}
_ => return err!(self.loc, "unknown calling convention: {}", text),
},

Some(Token::Cold) => {
self.consume();
sig.call_conv = CallConv::Cold;
}
_ => {}
}

Ok(sig)
Expand Down