diff --git a/cranelift/filetests/filetests/parser/cold.clif b/cranelift/filetests/filetests/parser/cold.clif new file mode 100644 index 000000000000..55064fe6ae3d --- /dev/null +++ b/cranelift/filetests/filetests/parser/cold.clif @@ -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 diff --git a/cranelift/reader/src/parser.rs b/cranelift/reader/src/parser.rs index 9cf9116ff4e1..6068af8de3e2 100644 --- a/cranelift/reader/src/parser.rs +++ b/cranelift/reader/src/parser.rs @@ -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)