Skip to content

lowering: Fix accidental clearing of never-undef flag in closure convert#51991

Merged
Keno merged 2 commits intomasterfrom
kfjb/loweringbitflip
Nov 3, 2023
Merged

lowering: Fix accidental clearing of never-undef flag in closure convert#51991
Keno merged 2 commits intomasterfrom
kfjb/loweringbitflip

Conversation

@Keno
Copy link
Copy Markdown
Member

@Keno Keno commented Nov 2, 2023

This code dates back all the way to the original closure conversion code [1]. At the time, the 0x4 bit of the vinfo was used for tracking whether a variable is assigned in an inner function [2], which apparently needed to be cleared during closure conversion. However, shortly afterwards, the bit was removed [3] and subsequently re-used for never-undef [4]. However, the magic number in the closure conversion pass was never updated, causing the new never-undef flag to be accidentally cleared unconditionally.

[1] a1ee867
[2]

julia/src/ast.scm

Lines 217 to 218 in a1ee867

;; whether var is assigned by an inner function
(define (vinfo:set-iasg! v a) (set-car! (cddr v) (set-bit (caddr v) 4 a)))

[3] 7e7d743
[4] 3d8f8d1

…ersion pass

This code dates back all the way to the original closure conversion code.
At the time, the 0x4 bit of the vinfo was used for tracking whether a
variable is assigned in an inner function, which apparently needed to
be cleared during closure conversion. However, shortly afterwards,
the bit was removed [3] and subsequently re-used for never-undef [4].
However, the magic number in the closure conversion pass was never
updated, causing the new never-undef flag to be accidentally cleared
unconditionally.

[1] a1ee867
[2] https://github.com/JuliaLang/julia/blob/a1ee8676f00fc14bd67aaf7eb20ce46ff99f322e/src/ast.scm#L217-L218
[3] 7e7d743
[4] 3d8f8d1

Co-authored-by: Jeff Bezanson <jeff@juliahub.com>
@Keno Keno added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label Nov 2, 2023
@Keno Keno merged commit 4462257 into master Nov 3, 2023
@Keno Keno deleted the kfjb/loweringbitflip branch November 3, 2023 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants