Skip to content

Commit 24dbdb2

Browse files
committed
NFC followups for #48246
1 parent d61cfd2 commit 24dbdb2

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,14 +2188,13 @@ function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, vtypes::
21882188
end
21892189
elseif head === :boundscheck
21902190
if isa(sv, InferenceState)
2191-
flag = sv.src.ssaflags[sv.currpc]
2192-
# If there is no particular @inbounds for this function, then we only taint `noinbounds`,
2193-
# which will subsequently taint consistency if this function is called from another
2194-
# function that uses `@inbounds`. However, if this :boundscheck is itself within an
2191+
# If there is no particular `@inbounds` for this function, then we only taint `:noinbounds`,
2192+
# which will subsequently taint `:consistent`-cy if this function is called from another
2193+
# function that uses `@inbounds`. However, if this `:boundscheck` is itself within an
21952194
# `@inbounds` region, its value depends on `--check-bounds`, so we need to taint
2196-
# consistency here also.
2195+
# `:consistent`-cy here also.
21972196
merge_effects!(interp, sv, Effects(EFFECTS_TOTAL; noinbounds=false,
2198-
consistent = (flag & IR_FLAG_INBOUNDS) != 0 ? ALWAYS_FALSE : ALWAYS_TRUE))
2197+
consistent = (get_curr_flag(sv) & IR_FLAG_INBOUNDS) != 0 ? ALWAYS_FALSE : ALWAYS_TRUE))
21992198
end
22002199
rt = Bool
22012200
elseif head === :inbounds
@@ -2512,8 +2511,8 @@ function abstract_eval_phi(interp::AbstractInterpreter, phi::PhiNode, vtypes::Un
25122511
end
25132512

25142513
function stmt_taints_inbounds_consistency(sv::InferenceState)
2515-
flag = sv.src.ssaflags[sv.currpc]
2516-
return sv.src.propagate_inbounds || (flag & IR_FLAG_INBOUNDS) != 0
2514+
sv.src.propagate_inbounds && return true
2515+
return (get_curr_flag(sv) & IR_FLAG_INBOUNDS) != 0
25172516
end
25182517

25192518
function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e), vtypes::VarTable, sv::InferenceState)
@@ -2525,13 +2524,12 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
25252524
end
25262525
(;rt, effects) = abstract_eval_statement_expr(interp, e, vtypes, sv, nothing)
25272526
if !effects.noinbounds
2528-
flag = sv.src.ssaflags[sv.currpc]
25292527
if !sv.src.propagate_inbounds
25302528
# The callee read our inbounds flag, but unless we propagate inbounds,
25312529
# we ourselves don't read our parent's inbounds.
25322530
effects = Effects(effects; noinbounds=true)
25332531
end
2534-
if (flag & IR_FLAG_INBOUNDS) != 0
2532+
if (get_curr_flag(sv) & IR_FLAG_INBOUNDS) != 0
25352533
effects = Effects(effects; consistent=ALWAYS_FALSE)
25362534
end
25372535
end

base/compiler/effects.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ following meanings:
4040
This state corresponds to LLVM's `inaccessiblemem_or_argmemonly` function attribute.
4141
- `nonoverlayed::Bool`: indicates that any methods that may be called within this method
4242
are not defined in an [overlayed method table](@ref OverlayMethodTable).
43-
- `noinbounds::Bool`: If set, indicates that this method does not read the parent's :inbounds
44-
state. In particular, it does not have any reached :boundscheck exprs, not propagates inbounds
43+
- `noinbounds::Bool`: If set, indicates that this method does not read the parent's `:inbounds`
44+
state. In particular, it does not have any reached `:boundscheck` exprs, not propagates inbounds
4545
to any children that do.
4646
4747
Note that the representations above are just internal implementation details and thus likely

base/compiler/inferencestate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ mutable struct InferenceState
177177

178178
valid_worlds = WorldRange(src.min_world, src.max_world == typemax(UInt) ? get_world_counter() : src.max_world)
179179
bestguess = Bottom
180-
ipo_effects = Effects(EFFECTS_TOTAL)
180+
ipo_effects = EFFECTS_TOTAL
181181

182182
params = InferenceParams(interp)
183183
restrict_abstract_call_sites = isa(linfo.def, Module)

base/expr.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ currently equivalent to the following `setting`s:
608608
must consistently throw given the same argument values.
609609
610610
!!! note
611-
An explict `@inbounds` annotation inside the function will also disable
612-
constant propagation and not be overriden by :foldable.
611+
An explicit `@inbounds` annotation inside the function will also disable
612+
constant folding and not be overriden by `:foldable`.
613613
614614
---
615615
## `:removable`

test/compiler/effects.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@ end |> Core.Compiler.is_foldable
722722
end |> Core.Compiler.is_total
723723

724724
# Test that dead `@inbounds` does not taint consistency
725+
# https://github.com/JuliaLang/julia/issues/48243
725726
@test Base.infer_effects() do
726727
false && @inbounds (1,2,3)[1]
727728
return 1

0 commit comments

Comments
 (0)