@@ -156,7 +156,7 @@ function postprint_linelinks(io::IO, idx::Int, src::CodeInfo, cl::CodeLinks, bbc
156
156
printstyled (io, bbchanged ? " " : " │" , color= :light_black )
157
157
printstyled (io, " # " , color= :yellow )
158
158
stmt = src. code[idx]
159
- if isexpr (stmt, :( = ) )
159
+ if is_assignment_like (stmt)
160
160
lhs = stmt. args[1 ]
161
161
if @issslotnum (lhs)
162
162
# id = lhs.id
@@ -184,6 +184,9 @@ function namedkeys(cl::CodeLinks)
184
184
return ukeys
185
185
end
186
186
187
+ is_assignment_like (stmt:: Expr ) = isexpr (stmt, :(= )) || (isexpr (stmt, :const ) && length (stmt. args) == 2 )
188
+ is_assignment_like (@nospecialize stmt) = false
189
+
187
190
function direct_links! (cl:: CodeLinks , src:: CodeInfo )
188
191
# Utility for when a stmt itself contains a CodeInfo
189
192
function add_inner! (cl:: CodeLinks , icl:: CodeLinks , idx)
@@ -238,7 +241,7 @@ function direct_links!(cl::CodeLinks, src::CodeInfo)
238
241
end
239
242
rhs = stmt
240
243
target = P (SSAValue (i), cl. ssapreds[i])
241
- elseif isexpr (stmt, :( = ) )
244
+ elseif is_assignment_like (stmt)
242
245
# An assignment
243
246
stmt = stmt:: Expr
244
247
lhs, rhs = stmt. args[1 ], stmt. args[2 ]
@@ -415,7 +418,7 @@ function CodeEdges(src::CodeInfo, cl::CodeLinks)
415
418
emptylist = Int[]
416
419
for (i, stmt) in enumerate (src. code)
417
420
# Identify line predecents for slots and named variables
418
- if isexpr (stmt, :( = ) )
421
+ if is_assignment_like (stmt)
419
422
stmt = stmt:: Expr
420
423
lhs = stmt. args[1 ]
421
424
# Mark predecessors and successors of this line by following ssas & named assignments
@@ -899,7 +902,7 @@ function add_inplace!(isrequired, src, edges, norequire)
899
902
for k in edges. preds[j]
900
903
isrequired[k] || continue
901
904
predstmt = src. code[k]
902
- if isexpr (predstmt, :( = ) )
905
+ if is_assignment_like (predstmt)
903
906
lhs = predstmt. args[1 ]
904
907
if @issslotnum (lhs) && lhs. id == id
905
908
changed |= mark_if_inplace (stmt, j)
0 commit comments