@@ -340,13 +340,29 @@ function unwraptv_lb(@nospecialize t)
340
340
end
341
341
const unwraptv = unwraptv_ub
342
342
343
- # this query is specially written for `adjust_effects` and returns true if a value of this type
344
- # never involves inconsistency of mutable objects that are allocated somewhere within a call graph
345
- is_consistent_argtype (@nospecialize ty) =
346
- is_consistent_type (widenconst (ignorelimited (ty)))
347
- is_consistent_type (@nospecialize ty) = isidentityfree (ty)
343
+ """
344
+ is_identity_free_argtype(argtype) -> Bool
345
+
346
+ Return `true` if the `argtype` object is identity free in the sense that this type or any
347
+ reachable through its fields has non-content-based identity (see `Base.isidentityfree`).
348
+ This query is specifically designed for `adjust_effects`, enabling it to refine the
349
+ `:consistent` effect property tainted by mutable allocation(s) within the analyzed call
350
+ graph when the return value type is `is_identity_free_argtype`, ensuring that the allocated
351
+ mutable objects are never returned.
352
+ """
353
+ is_identity_free_argtype (@nospecialize ty) = is_identity_free_type (widenconst (ignorelimited (ty)))
354
+ is_identity_free_type (@nospecialize ty) = isidentityfree (ty)
355
+
356
+ """
357
+ is_immutable_argtype(argtype) -> Bool
348
358
349
- is_immutable_argtype (@nospecialize ty) = is_immutable_type (widenconst (ignorelimited (ty)))
359
+ Return `true` if the `argtype` object is known to be immutable.
360
+ This query is specifically designed for `getfield_effects` and `isdefined_effects`, allowing
361
+ them to prove `:consistent`-cy of `getfield` / `isdefined` calls when applied to immutable
362
+ objects. Otherwise, we need to additionally prove that the non-immutable object is not a
363
+ global object to prove the `:consistent`-cy.
364
+ """
365
+ is_immutable_argtype (@nospecialize argtype) = is_immutable_type (widenconst (ignorelimited (argtype)))
350
366
is_immutable_type (@nospecialize ty) = _is_immutable_type (unwrap_unionall (ty))
351
367
function _is_immutable_type (@nospecialize ty)
352
368
if isa (ty, Union)
@@ -355,6 +371,16 @@ function _is_immutable_type(@nospecialize ty)
355
371
return ! isabstracttype (ty) && ! ismutabletype (ty)
356
372
end
357
373
358
- is_mutation_free_argtype (@nospecialize argtype) =
374
+ """
375
+ is_mutation_free_argtype(argtype) -> Bool
376
+
377
+ Return `true` if `argtype` object is mutation free in the sense that no mutable memory
378
+ is reachable from this type (either in the type itself) or through any fields
379
+ (see `Base.ismutationfree`).
380
+ This query is specifically written for analyzing the `:inaccessiblememonly` effect property
381
+ and is supposed to improve the analysis accuracy by not tainting the `:inaccessiblememonly`
382
+ property when there is access to mutation-free global object.
383
+ """
384
+ is_mutation_free_argtype (@nospecialize (argtype)) =
359
385
is_mutation_free_type (widenconst (ignorelimited (argtype)))
360
386
is_mutation_free_type (@nospecialize ty) = ismutationfree (ty)
0 commit comments