mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-16 17:00:53 +00:00
Generate asserts to help LLVM
This commit is contained in:
parent
9320f34bd4
commit
af88b698c2
@ -930,6 +930,16 @@ impl<'ascent, 'grammar, W: Write> CodeGenerator<'ascent, 'grammar, W, TableDrive
|
||||
rust!(self.out, "// {:?}", production);
|
||||
|
||||
// Pop each of the symbols and their associated states.
|
||||
if production.symbols.len() > 1 {
|
||||
// By asserting that there are enough elements to pop before popping multiple elements
|
||||
// we may help LLVM to optimize better since it does not need to generate panic
|
||||
// branches for each unwrap
|
||||
rust!(
|
||||
self.out,
|
||||
"assert!(symbols.len() >= {});",
|
||||
production.symbols.len()
|
||||
);
|
||||
}
|
||||
for (index, symbol) in production.symbols.iter().enumerate().rev() {
|
||||
let name = self.variant_name_for_symbol(symbol);
|
||||
rust!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user