Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Oct 25, 2023

Reverts #51764. CI is failing on master after that PR.

@giordano giordano added the revert This reverts a previously merged PR. label Oct 25, 2023
@vtjnash
Copy link
Member

vtjnash commented Oct 25, 2023

It looks like this is an effect_system / caching issue. Somewhere along the way we compile or run a copy of eltype{::Type{Union{}}) without inferring it. I am trying to find where that happens.

methods(eltype, Tuple{Type{Union{}}})[1].specializations.cache
Core.CodeInstance(MethodInstance for eltype(::Type{Union{}}), 0x0000000000000001, 0xffffffffffffffff, Union{}, #undef, nothing, 0x00000000, 0x00000000, nothing, true, false, 0x00, Ptr{Nothing} @0x00007f74d57fc830, Ptr{Nothing} @0x00007f74d56b1cb0)
Core.CodeInstance(MethodInstance for eltype(::Type{Union{}}), 0x000000000000002d, 0xffffffffffffffff, Union{}, #undef, nothing, 0x000010c0, 0x000010c0, nothing, false, true, 0x01, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000)

@vtjnash
Copy link
Member

vtjnash commented Oct 25, 2023

Looks like there are two interconnected issues with how effects are hooked up that lead to this fatal result:

  1. When typeinf_edge needs effects, it checks the first entry of the cache, even though effects are not guaranteed to be populated (only rettype and world are valid entries in the cache--more on this next)
  2. jl_get_method_inferred only ensures that rettype and world are valid to use for IPO, other fields are not permitted to exist or be used by IPO passes, as they are not part of the set of values that get tracked by the compiler when making decisions about how and where to do caching
  3. The code returned from typeinf_ext is from the InferenceFrame, not the InferenceResult. When already_inferred is true, then transform_result_for_cache will never be called on this src, resulting in the contents of this object being invalid, as it will never have been populated with the corrected fields BUT the code will have been modified in-place so it should have had the edges and world-bounds fields populated

vtjnash added a commit that referenced this pull request Oct 25, 2023
When inference decided it was not necessary to cache the object, it also
skipped all of the work required to make the code valid, which
typeinf_ext depends upon. This resulted in caching invalid data, causing
effects tests to break unpredictably. This change ensures that we always
update the InferenceState with the final result, so that typeinf_ext
can get the correct results out of it for internal codegen use.

Fixes one of the issues uncovered in #51860
vtjnash added a commit that referenced this pull request Oct 25, 2023
When inference decided it was not necessary to cache the object, it also
skipped all of the work required to make the code valid, which
typeinf_ext depends upon. This resulted in caching invalid data, causing
effects tests to break unpredictably. This change ensures that we always
update the InferenceState with the final result, so that typeinf_ext
can get the correct results out of it for internal codegen use.

Fixes one of the issues uncovered in #51860
vtjnash added a commit that referenced this pull request Oct 25, 2023
When inference decided it was not necessary to cache the object, it also
skipped all of the work required to make the code valid, which
typeinf_ext depends upon. This resulted in caching invalid data, causing
effects tests to break unpredictably. This change ensures that we always
update the InferenceState with the final result, so that typeinf_ext
can get the correct results out of it for internal codegen use.

Fixes one of the issues uncovered in #51860
vtjnash added a commit that referenced this pull request Oct 25, 2023
When inference decided it was not necessary to cache the object, it also
skipped all of the work required to make the code valid, which
typeinf_ext depends upon. This resulted in caching invalid data, causing
effects tests to break unpredictably. This change ensures that we always
update the InferenceState with the final result (when `must_be_codeinf`
is true), so that typeinf_ext can get the correct results out of it for
internal codegen use. Previously we were disregarding that flag in some
cases.

Fixes one of the issues uncovered in #51860
@Keno Keno closed this Oct 25, 2023
@giordano giordano deleted the revert-51764-jn/cconvert-more branch October 25, 2023 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

revert This reverts a previously merged PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants