mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 21:40:58 +00:00
Optimize literal list construction in LLVM backend
Currently, list literals are always heap-allocated and their elements are stored by emitting a GEP and store for each item in the literal. This produces huge quantities of IR, causing compile times for e.g. programs with large literals or ingested files to blow up. Instead, if a list literal consists entirely of literal values, create a global section for the literal and return a pointer to it.
This commit is contained in:
parent
08019951be
commit
9abbcfaafc
2 changed files with 51 additions and 109 deletions
|
|
@ -49,6 +49,17 @@ impl<'a> ListLiteralElement<'a> {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_literal(&self) -> Option<Literal<'a>> {
|
||||
match self {
|
||||
Self::Literal(l) => Some(*l),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_literal(&self) -> bool {
|
||||
matches!(self, Self::Literal(_))
|
||||
}
|
||||
}
|
||||
|
||||
pub enum NumLiteral {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue