Commit graph

1060 commits

Author SHA1 Message Date
Cameron Zwarich
12cd4ca742
fix: remove incorrect error in LCNF's check (#9720)
This PR removes an error which implicitly assumes that the sort of type
dependency between erased types present in the test being added can not
occur. It would be difficult to refine the error using only the
information present in LCNF types, and it is of very little ongoing
value (I don't recall it ever finding an actual problem), so it makes
more sense to delete it.

Fixes #9692.
2025-08-05 04:36:57 +00:00
Cameron Zwarich
713a46cd75
chore: adopt <||> to reduce code duplication (#9719) 2025-08-05 04:13:02 +00:00
Cameron Zwarich
f236328bc3
chore: don't check type of erased arguments in FixedParams analysis (#9602) 2025-08-05 02:41:36 +00:00
Cameron Zwarich
8edcfbe776
fix: correctly handle non-Nat literal types in LCNF elimDeadBranches (#9703)
This PR changes the LCNF `elimDeadBranches` pass so that it considers
all non-`Nat` literal types to be `⊤`. It turns out that fixing this to
correctly handle all of these types with the current abstract value
representation is surprisingly nontrivial, and it's better to just land
the fix first.
2025-08-05 02:14:07 +00:00
Cameron Zwarich
59579bfc3e
refactor: remove goBig case from UnreachableBranches.ofNat (#9717)
This case can't meaningfully contribute to the result, because there are
no uses of `Nat` constructors in the `mono` phase.
2025-08-04 19:47:40 +00:00
Cameron Zwarich
78b941019b
refactor: use a state monad rather than combinators for computing free indices (#9711) 2025-08-04 13:55:41 +00:00
Cameron Zwarich
c260435913
refactor: use a state monad rather than combinators for computing max indices (#9707) 2025-08-04 05:15:22 +00:00
Cameron Zwarich
1459d17bfd
chore: lift redundant markSimplified (#9691) 2025-08-02 23:21:21 +00:00
Sebastian Ullrich
1e83f62d31
perf: clarify and granularize access to async env ext state (#9587)
* Have asynchronous environment extensions specify whether they are
manipulate data for declarations from the "outside"/main branch (e.g.
attributes) or from the "inside"/async branch (e.g. data collected from
body elaboration) in order to avoid unnecessary waiting.
* Merge `findStateAsync?` into `getState` via a new, optional
`asyncDecl` parameter.
* Make `mayContainAsync` check an automatic part of `modifyState`.
2025-08-02 17:01:08 +00:00
Cameron Zwarich
b60f97cc19
chore: remove unused code in comment (#9687) 2025-08-02 15:18:41 +00:00
Cameron Zwarich
2ea6b5068c
chore: make Compiler.findJoinPoints trace messages more useful (#9668) 2025-08-01 17:42:32 +00:00
Sebastian Ullrich
0aba471758
perf: do not export LCNF/IR function summaries under the module system (#9645)
to avoid unexpected rebuilds
2025-07-31 15:23:04 +00:00
Cameron Zwarich
7931e19572
perf: use xType field rather than conservatively recomputing it (#9345) 2025-07-30 04:34:13 +00:00
Cameron Zwarich
475bd65c90
perf: during specialization, don't abstract all local fun decls under binders (#9596)
The `isUnderBinder` check is intended to avoid inlining repeated
computations into specializations, but this doesn’t apply to local
function decls whose bodies are already delayed.
2025-07-28 17:36:43 +00:00
Cameron Zwarich
0fe7cc8794
perf: increase usage of the tagged IR type for app return values (#9589) 2025-07-28 14:09:38 +00:00
Cameron Zwarich
d7e7bd16a6
chore: increase code sharing in IR LiveVars computation (#9576) 2025-07-27 13:29:58 +00:00
Cameron Zwarich
8ce0e045a8
chore: increase code sharing in IR FreeVars computation (#9569) 2025-07-26 20:37:10 +00:00
Cameron Zwarich
2be6c75c2b
chore: replace partially redundant calls to FnBody.split with .body (#9568) 2025-07-26 20:18:37 +00:00
Cameron Zwarich
dd45a21257
chore: remove unused FnBody.mdata constructor (#9564) 2025-07-26 15:20:13 +00:00
jrr6
fcbd1037fd
refactor: update and consolidate attribute-related error messages (#9495)
This PR consolidates common attribute-related error messages into
reusable functions and updates the wording and formatting of relevant
error messages.
2025-07-26 02:03:18 +00:00
Cameron Zwarich
aa769e7677
chore: make inferVisibility LCNF pass style match others (#9558) 2025-07-26 00:49:52 +00:00
Cameron Zwarich
737105fd78
chore: remove syntax for extern arity specifications (#9556) 2025-07-26 00:44:36 +00:00
Cameron Zwarich
1285a3c9a7
chore: clean up IR.Arg usage (#9557) 2025-07-26 00:22:38 +00:00
Cameron Zwarich
eddc3b421e
chore: remove support for unused arity specification in ExternAttrData (#9552)
This just removes the data for this specification. Removing the parser
support for it seems to require a stage0 update in between.
2025-07-25 21:23:56 +00:00
Cameron Zwarich
7f39e56a79
chore: adopt List.find? in getExternEntryForAux (#9550) 2025-07-25 17:38:22 +00:00
Cameron Zwarich
6300329057
perf: consider functions with ordinary implicit arguments of instance type to be template-like (#9536)
This extends the specialization behavior of functions taking instance
implicits to ordinary implicit arguments that are of instance type. The
choice between the two is often made for subtle inference-related
reasons. It also affects visibility of these functions, because the
module system makes template-like decls visible to the compiler in other
modules.
2025-07-25 16:03:30 +00:00
Cameron Zwarich
15f0cd9527
fix: run inferVisibility after saveMono (#9545)
This PR makes the second instance of the `inferVisibility` pass run
after the `saveMono` pass. As the comment above the first instance of
the pass indicates, this needs to be after `saveMono` in order to see
all decls with their updated bodies.
2025-07-25 15:36:52 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Rob23oba
e148871087
chore: fix spelling errors (#9175)
(Almost) only typos in constant names and doc-strings were considered;
grammar was not considered. Also, along others,
`mkDefinitionValInferrringUnsafe` has been fixed :-)
2025-07-24 23:35:32 +00:00
Sebastian Ullrich
4177f123bc
fix: expose LCNF of private inline decl referenced by implemented_by (#9514) 2025-07-24 13:05:21 +00:00
Cameron Zwarich
8a0d036e82
perf: use an FVarIdHashSet for ReduceArity.State.used (#9497) 2025-07-24 00:25:26 +00:00
Sebastian Ullrich
e46a3108d9
perf: do not export specializations (#9465)
Trading an insignificant amount of IR bloat for better recompilation
avoidance
2025-07-23 13:12:15 +00:00
Sebastian Ullrich
9328271dd0
perf: do not export LCNF decls of closed terms (#9484)
This was only necessary when `isDeclMeta` and `isDeclPublic` were
intertwined
2025-07-23 09:50:29 +00:00
Sebastian Ullrich
0ba5413266
refactor: remove unused Environment.extraConstNames (#9470)
Obsoleted in #9356
2025-07-23 08:58:32 +00:00
Sebastian Ullrich
e28569f2a1
perf: minimize exported codegen data (#9356)
To be documented
2025-07-22 09:05:49 +00:00
Cameron Zwarich
6f5532f069
perf: make function types object rather than tobject (#9461) 2025-07-22 01:16:45 +00:00
Cameron Zwarich
30ca6c82e0
refactor: use named params (#9460) 2025-07-22 00:11:25 +00:00
Cameron Zwarich
968a708a9f
perf: update type information in cases arms for RC optimizations (#9457)
The `isRef` check being removed here used to be an optimization, because
this structure only tracked whether ref counting operations need to be
inserted at all. Now the structure also tracks whether the value needs
to be checked for being a scalar or not, which is something that can be
refined by a `cases` arm, since inductive types can have a mix of scalar
and non-scalar constructors.
2025-07-21 23:10:11 +00:00
Cameron Zwarich
9a34f6bc95
refactor: remove questionable defaults in Context structure (#9458) 2025-07-21 22:16:14 +00:00
Cameron Zwarich
f3e1795175
refactor: clean up monad setup (#9456) 2025-07-21 21:22:20 +00:00
Henrik Böving
09de5cd70e
refactor: remove Lean.RBMap usages (#9260)
This PR removes uses of `Lean.RBMap` in Lean itself.

Furthermore some massaging of the import graph is done in order to avoid
having `Std.Data.TreeMap.AdditionalOperations` (which is quite
expensive) be the critical path for a large chunk of Lean. In particular
we can build `Lean.Meta.Simp` and `Lean.Meta.Grind` without it thanks to
these changes.

We did previously not conduct this change as `Std.TreeMap` was not
outperforming `Lean.RBMap` yet, however this has changed with the new
code generator.
2025-07-21 14:04:45 +00:00
Cameron Zwarich
2f7c0366f5
perf: treat partial application and eta expansion equally for specialization (#9438) 2025-07-20 14:57:21 +00:00
Cameron Zwarich
1a9757d1f6
refactor: make withReader calls more readable (#9442) 2025-07-20 13:39:35 +00:00
Cameron Zwarich
5cd5885da4
fix: make IRType.erased a tobject when boxing it (#9431)
This PR changes `IRType.boxed` to map `erased` to `tobject` rather than
`object`, since `erased` has a representation of a boxed scalar 0 when
we are forced to represent it at runtime. This case does not occur at
all in the Lean codebase.
2025-07-18 20:10:52 +00:00
Cameron Zwarich
1043569648
perf: use more precise IR types for overapplication (#9428) 2025-07-18 16:34:19 +00:00
Cameron Zwarich
cdab726e3d
refactor: clean up creation of IR over-application (#9426) 2025-07-18 06:11:06 +00:00
Cameron Zwarich
d667522524
refactor: remove special cases for subsingleton casesOn (#9412) 2025-07-16 23:41:41 +00:00
Cameron Zwarich
c1b5d54737
feat: compiler support for casesOn of subsingletons (#9411)
This PR adds support for compilation of `casesOn` for subsingletons. We
rely on the elaborator's type checking to restrict this to inductives in
`Prop` that can actually eliminate into `Type n`. This does not yet
cover other recursors of these types (or of inductives not in `Prop` for
that matter).
2025-07-16 23:07:32 +00:00
Cameron Zwarich
e9b75e34b7
perf: decide whether to use _ref variants of inc/dec using IR types (#9399) 2025-07-16 03:52:58 +00:00
Cameron Zwarich
e069c9eb0e
perf: use IR type info to decide whether to insert RC ops (#9396)
This is mostly a refactoring that replaces other analyses with type
information, but due to the introduction of `tagged` it also has the
side effect of eliminating ref counting ops entirely for types that
always have a tagged scalar representation, e.g. `Unit`.
2025-07-16 02:02:32 +00:00