-
Notifications
You must be signed in to change notification settings - Fork 24
Add Julia v1.12 compatibility #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5dfd3a6
ade6e08
ed221c7
1507b4d
b4fb31c
1eb8a0e
6534540
ab4d1d5
4671737
8e8484d
37abc8b
5204f39
e18ed11
5a8046f
61769b4
16005e2
2e1f87b
188b70f
497898c
aa8c925
54922f2
0b3548e
b59b842
8ef0897
d386f1a
e9ac11d
b049c94
6b7210b
d4372a6
e6e3dc1
bcd9215
1b052df
726a7c2
d76e8e5
90e7450
b673282
06861b1
29d2dca
29fe51b
a154279
bd7e51d
030d2bb
d262fee
065b2ea
bddaf1c
2db7324
63b6b1d
6d2cad2
75d0c95
ea7c4da
c3704d6
e8d103d
bfee9d1
22992fe
6a5c78c
864e80c
230de34
21c1e70
b7d34d3
58a23ee
18e036a
fcd7823
9556ef3
0f6b775
0007df7
71b99c8
6273382
8357414
0974045
47e383a
42bc8aa
dea66e6
8596b90
827f413
3701766
066f105
d54706a
2154677
0b97be5
23caf6d
4147d69
75299ef
bdeb525
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,9 @@ steps: | |
| matrix: | ||
| setup: | ||
| version: | ||
| - "1.11" | ||
| - "1.10" | ||
| - "1.11" | ||
| - "1.12" | ||
| label: | ||
| - "cuda" | ||
| - "nnlib" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,45 +272,57 @@ These should be assumed to be ordered. | |
| """ | ||
| collect_stmts(bb::BBlock)::Vector{IDInstPair} = collect(zip(bb.inst_ids, bb.insts)) | ||
|
|
||
| """ | ||
| BBCode( | ||
| @eval begin | ||
| """ | ||
| BBCode( | ||
| blocks::Vector{BBlock} | ||
| argtypes::Vector{Any} | ||
| sptypes::Vector{CC.VarState} | ||
| linetable::Vector{Core.LineInfoNode} (v1.11 and lower) | ||
| debuginfo::CC.DebugInfoStream (v1.12+) | ||
| meta::Vector{Expr} | ||
| valid_worlds::CC.WorldRange (v1.12+) | ||
| ) | ||
|
|
||
| A `BBCode` is a data structure which is similar to `IRCode`, but adds additional structure. | ||
|
|
||
| In particular, a `BBCode` comprises a sequence of basic blocks (`BBlock`s), each of which | ||
| comprise a sequence of statements. Moreover, each `BBlock` has its own unique `ID`, as does | ||
| each statment. | ||
|
|
||
| The consequence of this is that new basic blocks can be inserted into a `BBCode`. This is | ||
| distinct from `IRCode`, in which to create a new basic block, one must insert additional | ||
| statments which you know will create a new basic block -- this is generally quite an | ||
| unreliable process, while inserting a new `BBlock` into `BBCode` is entirely predictable. | ||
| Furthermore, inserting a new `BBlock` does not change the `ID` associated to the other | ||
| blocks, meaning that you can safely assume that references from existing basic block | ||
| terminators / phi nodes to other blocks will not be modified by inserting a new basic block. | ||
|
|
||
| Additionally, since each statment in each basic block has its own unique `ID`, new | ||
| statments can be inserted without changing references between other blocks. `IRCode` also | ||
| has some support for this via its `new_nodes` field, but eventually all statements will be | ||
| renamed upon `compact!`ing the `IRCode`, meaning that the name of any given statement will | ||
| eventually change. | ||
|
|
||
| Finally, note that the basic blocks in a `BBCode` support the custom `Switch` statement. | ||
| This statement is not valid in `IRCode`, and is therefore lowered into a collection of | ||
| `GotoIfNot`s and `GotoNode`s when a `BBCode` is converted back into an `IRCode`. | ||
| """ | ||
| struct BBCode | ||
| blocks::Vector{BBlock} | ||
| argtypes::Vector{Any} | ||
| sptypes::Vector{CC.VarState} | ||
| linetable::Vector{Core.LineInfoNode} | ||
| $( | ||
| if VERSION > v"1.12-" | ||
| :(debuginfo::CC.DebugInfoStream) | ||
| else | ||
| :(linetable::Vector{Core.LineInfoNode}) | ||
| end | ||
| ) | ||
| meta::Vector{Expr} | ||
| ) | ||
|
|
||
| A `BBCode` is a data structure which is similar to `IRCode`, but adds additional structure. | ||
|
|
||
| In particular, a `BBCode` comprises a sequence of basic blocks (`BBlock`s), each of which | ||
| comprise a sequence of statements. Moreover, each `BBlock` has its own unique `ID`, as does | ||
| each statment. | ||
|
|
||
| The consequence of this is that new basic blocks can be inserted into a `BBCode`. This is | ||
| distinct from `IRCode`, in which to create a new basic block, one must insert additional | ||
| statments which you know will create a new basic block -- this is generally quite an | ||
| unreliable process, while inserting a new `BBlock` into `BBCode` is entirely predictable. | ||
| Furthermore, inserting a new `BBlock` does not change the `ID` associated to the other | ||
| blocks, meaning that you can safely assume that references from existing basic block | ||
| terminators / phi nodes to other blocks will not be modified by inserting a new basic block. | ||
|
|
||
| Additionally, since each statment in each basic block has its own unique `ID`, new | ||
| statments can be inserted without changing references between other blocks. `IRCode` also | ||
| has some support for this via its `new_nodes` field, but eventually all statements will be | ||
| renamed upon `compact!`ing the `IRCode`, meaning that the name of any given statement will | ||
| eventually change. | ||
|
|
||
| Finally, note that the basic blocks in a `BBCode` support the custom `Switch` statement. | ||
| This statement is not valid in `IRCode`, and is therefore lowered into a collection of | ||
| `GotoIfNot`s and `GotoNode`s when a `BBCode` is converted back into an `IRCode`. | ||
| """ | ||
| struct BBCode | ||
| blocks::Vector{BBlock} | ||
| argtypes::Vector{Any} | ||
| sptypes::Vector{CC.VarState} | ||
| linetable::Vector{Core.LineInfoNode} | ||
| meta::Vector{Expr} | ||
| $(VERSION > v"1.12-" ? :(valid_worlds::CC.WorldRange) : nothing) | ||
| end | ||
| export BBCode | ||
| end | ||
|
|
||
| """ | ||
|
|
@@ -319,14 +331,27 @@ end | |
| Make a new `BBCode` whose `blocks` is given by `new_blocks`, and fresh copies are made of | ||
| all other fields from `ir`. | ||
| """ | ||
| function BBCode(ir::Union{IRCode,BBCode}, new_blocks::Vector{BBlock}) | ||
| return BBCode( | ||
| new_blocks, | ||
| CC.copy(ir.argtypes), | ||
| CC.copy(ir.sptypes), | ||
| CC.copy(ir.linetable), | ||
| CC.copy(ir.meta), | ||
| ) | ||
| @static if VERSION > v"1.12-" | ||
| function BBCode(ir::Union{IRCode,BBCode}, new_blocks::Vector{BBlock}) | ||
| return BBCode( | ||
| new_blocks, | ||
| CC.copy(ir.argtypes), | ||
| CC.copy(ir.sptypes), | ||
| CC.copy(ir.debuginfo), | ||
| CC.copy(ir.meta), | ||
| ir.valid_worlds, | ||
| ) | ||
| end | ||
| else | ||
| function BBCode(ir::Union{IRCode,BBCode}, new_blocks::Vector{BBlock}) | ||
| return BBCode( | ||
| new_blocks, | ||
| CC.copy(ir.argtypes), | ||
| CC.copy(ir.sptypes), | ||
| CC.copy(ir.linetable), | ||
| CC.copy(ir.meta), | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| # Makes use of the above outer constructor for `BBCode`. | ||
|
|
@@ -640,20 +665,47 @@ function CC.IRCode(bb_code::BBCode) | |
| insts = _ids_to_line_numbers(bb_code) | ||
| cfg = control_flow_graph(bb_code) | ||
| insts = _lines_to_blocks(insts, cfg) | ||
| return IRCode( | ||
| CC.InstructionStream( | ||
| map(x -> x.stmt, insts), | ||
| map(x -> x.type, insts), | ||
| map(x -> x.info, insts), | ||
| map(x -> x.line, insts), | ||
| map(x -> x.flag, insts), | ||
| ), | ||
| cfg, | ||
| CC.copy(bb_code.linetable), | ||
| CC.copy(bb_code.argtypes), | ||
| CC.copy(bb_code.meta), | ||
| CC.copy(bb_code.sptypes), | ||
| ) | ||
| @static if VERSION > v"1.12-" | ||
| lines = CC.copy(bb_code.debuginfo.codelocs) | ||
| n = length(insts) | ||
| if length(lines) > 3n | ||
| resize!(lines, 3n) | ||
| elseif length(lines) < 3n | ||
| for _ in (length(lines) + 1):3n | ||
| push!(lines, 0) | ||
| end | ||
| end | ||
|
Comment on lines
+669
to
+677
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the situations where the length of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect that
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For 1.11 and below, we expect as many integers as there are instructions, say
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there cases where the vector is not properly
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The resize logic is defensive programming to ensure robustness. In Julia 1.12+, |
||
| return IRCode( | ||
| CC.InstructionStream( | ||
| Any[x.stmt for x in insts], | ||
| Any[x.type for x in insts], | ||
| CC.CallInfo[x.info for x in insts], | ||
| lines, | ||
| UInt32[x.flag for x in insts], | ||
| ), | ||
| cfg, | ||
| CC.copy(bb_code.debuginfo), | ||
| CC.copy(bb_code.argtypes), | ||
| CC.copy(bb_code.meta), | ||
| CC.copy(bb_code.sptypes), | ||
| bb_code.valid_worlds, | ||
| ) | ||
| else | ||
| return IRCode( | ||
| CC.InstructionStream( | ||
| Any[x.stmt for x in insts], | ||
| Any[x.type for x in insts], | ||
| CC.CallInfo[x.info for x in insts], | ||
| Int32[x.line for x in insts], | ||
| UInt32[x.flag for x in insts], | ||
| ), | ||
| cfg, | ||
| CC.copy(bb_code.linetable), | ||
| CC.copy(bb_code.argtypes), | ||
| CC.copy(bb_code.meta), | ||
| CC.copy(bb_code.sptypes), | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.