Skip to content

Commit a0f25be

Browse files
Kenoaviatesk
andauthored
More 1.12 compat (#112)
* More 1.12 compat Depends on JuliaDebug/JuliaInterpreter.jl#635, so will need appropriate version bumps before release. * Update src/codeedges.jl Co-authored-by: Shuhei Kadowaki <[email protected]> --------- Co-authored-by: Shuhei Kadowaki <[email protected]>
1 parent dc7cc3a commit a0f25be

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/codeedges.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function postprint_linelinks(io::IO, idx::Int, src::CodeInfo, cl::CodeLinks, bbc
156156
printstyled(io, bbchanged ? " " : "", color=:light_black)
157157
printstyled(io, " # ", color=:yellow)
158158
stmt = src.code[idx]
159-
if isexpr(stmt, :(=))
159+
if is_assignment_like(stmt)
160160
lhs = stmt.args[1]
161161
if @issslotnum(lhs)
162162
# id = lhs.id
@@ -184,6 +184,9 @@ function namedkeys(cl::CodeLinks)
184184
return ukeys
185185
end
186186

187+
is_assignment_like(stmt::Expr) = isexpr(stmt, :(=)) || (isexpr(stmt, :const) && length(stmt.args) == 2)
188+
is_assignment_like(@nospecialize stmt) = false
189+
187190
function direct_links!(cl::CodeLinks, src::CodeInfo)
188191
# Utility for when a stmt itself contains a CodeInfo
189192
function add_inner!(cl::CodeLinks, icl::CodeLinks, idx)
@@ -238,7 +241,7 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
238241
end
239242
rhs = stmt
240243
target = P(SSAValue(i), cl.ssapreds[i])
241-
elseif isexpr(stmt, :(=))
244+
elseif is_assignment_like(stmt)
242245
# An assignment
243246
stmt = stmt::Expr
244247
lhs, rhs = stmt.args[1], stmt.args[2]
@@ -415,7 +418,7 @@ function CodeEdges(src::CodeInfo, cl::CodeLinks)
415418
emptylist = Int[]
416419
for (i, stmt) in enumerate(src.code)
417420
# Identify line predecents for slots and named variables
418-
if isexpr(stmt, :(=))
421+
if is_assignment_like(stmt)
419422
stmt = stmt::Expr
420423
lhs = stmt.args[1]
421424
# Mark predecessors and successors of this line by following ssas & named assignments
@@ -899,7 +902,7 @@ function add_inplace!(isrequired, src, edges, norequire)
899902
for k in edges.preds[j]
900903
isrequired[k] || continue
901904
predstmt = src.code[k]
902-
if isexpr(predstmt, :(=))
905+
if is_assignment_like(predstmt)
903906
lhs = predstmt.args[1]
904907
if @issslotnum(lhs) && lhs.id == id
905908
changed |= mark_if_inplace(stmt, j)

src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function callee_matches(f, mod, sym)
5959
end
6060

6161
function rhs(stmt)
62-
isexpr(stmt, :(=)) && return (stmt::Expr).args[2]
62+
is_assignment_like(stmt) && return (stmt::Expr).args[2]
6363
return stmt
6464
end
6565

@@ -120,7 +120,7 @@ function isanonymous_typedef(stmt)
120120
is_global_ref(stmt.args[1], Core, :_typebody!) || return false
121121
@static if VERSION v"1.9.0-DEV.391"
122122
stmt = isa(stmt.args[3], Core.SSAValue) ? src.code[end-3] : src.code[end-2]
123-
isexpr(stmt, :(=)) || return false
123+
is_assignment_like(stmt) || return false
124124
name = stmt.args[1]
125125
if isa(name, GlobalRef)
126126
name = name.name
@@ -185,7 +185,7 @@ function typedef_range(src::CodeInfo, idx)
185185
# Advance to the type-assignment
186186
while iend <= n
187187
stmt = src.code[iend]
188-
isexpr(stmt, :(=)) && break
188+
is_assignment_like(stmt) && break
189189
iend += 1
190190
end
191191
end

0 commit comments

Comments
 (0)