Skip to content

Conversation

@zwarich
Copy link
Contributor

@zwarich zwarich commented Jun 12, 2025

This PR fixes an issue where the extendJoinPointContext pass can lift join points containing projections to the top level, as siblings of cases constructs matching on other projections of the same base value. This prevents the structProjCases pass from projecting both at once, extending the lifetime of the parent value and breaking linearity at runtime.

This would theoretically be possible to fix in structProjCases, but it would require some better infrastructure for handling join points. It's also likely that the IR passes dealing with reference counting would have similar bugs that pessimize the code. For this reason, the simplest thing is to just perform the structProjCases pass earlier, which prevents extendJoinPointContext from lifting these join points.

@zwarich zwarich requested a review from leodemoura as a code owner June 12, 2025 21:28
@zwarich zwarich added the changelog-compiler Compiler, runtime, and FFI label Jun 12, 2025
@zwarich zwarich enabled auto-merge June 12, 2025 21:28
@zwarich zwarich added this pull request to the merge queue Jun 12, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jun 12, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 6a698c1c22043cd4c3a1ef0eae4fcd4b334365ee --onto faffe863343211d03d07d4ef19d90a2aa9d6fc8c. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-12 22:00:14)

Merged via the queue into leanprover:master with commit 8aa003b Jun 12, 2025
19 of 21 checks passed
algebraic-dev pushed a commit to algebraic-dev/lean4 that referenced this pull request Jun 18, 2025
…ver#8752)

This PR fixes an issue where the `extendJoinPointContext` pass can lift
join points containing projections to the top level, as siblings of
`cases` constructs matching on other projections of the same base value.
This prevents the `structProjCases` pass from projecting both at once,
extending the lifetime of the parent value and breaking linearity at
runtime.

This would theoretically be possible to fix in `structProjCases`, but it
would require some better infrastructure for handling join points. It's
also likely that the IR passes dealing with reference counting would
have similar bugs that pessimize the code. For this reason, the simplest
thing is to just perform the `structProjCases` pass earlier, which
prevents `extendJoinPointContext` from lifting these join points.
wkrozowski pushed a commit to wkrozowski/lean4 that referenced this pull request Jun 24, 2025
…ver#8752)

This PR fixes an issue where the `extendJoinPointContext` pass can lift
join points containing projections to the top level, as siblings of
`cases` constructs matching on other projections of the same base value.
This prevents the `structProjCases` pass from projecting both at once,
extending the lifetime of the parent value and breaking linearity at
runtime.

This would theoretically be possible to fix in `structProjCases`, but it
would require some better infrastructure for handling join points. It's
also likely that the IR passes dealing with reference counting would
have similar bugs that pessimize the code. For this reason, the simplest
thing is to just perform the `structProjCases` pass earlier, which
prevents `extendJoinPointContext` from lifting these join points.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-compiler Compiler, runtime, and FFI toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants