Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct codegen bugs introduced by allocation-hoisting-PR #45476

Merged
merged 17 commits into from
Jul 21, 2022

Conversation

gbaraldi
Copy link
Member

Adresses some of the reviews for #45153

@gbaraldi
Copy link
Member Author

@vtjnash How does this look to you? The mangling from emit_a_ccall gave errors so I got it from some passes downstream.

@@ -901,7 +901,7 @@ static LoadInst *emit_nthptr_recast(jl_codectx_t &ctx, Value *v, ssize_t n, MDNo
emit_bitcast(ctx, vptr, PointerType::get(type, 0)))));
}

static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &v);
static Value *boxed(jl_codectx_t &ctx, const jl_cgval_t &v, bool is_promotable=false);
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So promotion is now always forbidden implicitly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the regression we were seeing was from something getting promoted when we called boxed on a separate part fo the of the compilation and then hoist something that shouldn't be hoisted.
In the case of the regression we were hosting a string allocation from inside an error to the main path of the function which then impeded an optimization.
From what I understand we should only hoist the allocation when we have nested structs and it's fields are promotable which we only check inside emit_new_struct

src/cgutils.cpp Outdated Show resolved Hide resolved
src/cgutils.cpp Outdated Show resolved Hide resolved
@vtjnash vtjnash changed the title Address reviews for 45153 correct codegen bugs introduced by allocation-hoisting-PR Jun 10, 2022
@vtjnash vtjnash added the needs nanosoldier run This PR should have benchmarks run on it label Jun 10, 2022
@fredrikekre
Copy link
Member

@nanosoldier runbenchmarks(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Something went wrong when running your job:

NanosoldierError: error when preparing/pushing to report repo: failed process: Process(setenv(`git push`; dir="/nanosoldier/workdir/NanosoldierReports"), ProcessExited(1)) [1]

Unfortunately, the logs could not be uploaded.

@gbaraldi
Copy link
Member Author

@vtjnash I'm not super accustomed to nanosoldier results, was this a particularly noisy benchmark or should I take a look at some more regressions.
The original regression found i.e more memory usage in skipmissing seems to have been fixed.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 14, 2022

It looks like noise, though it wouldn't be too surprising if some of the differences were real. The memory changes are always real.

@inkydragon
Copy link
Sponsor Member

Maybe related to #45485.

julia> versioninfo()
Julia Version 1.9.0-DEV.883
Commit e4257cbc89 (2022-06-30 17:58 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 6 × Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.5 (ORCJIT, skylake)
  Threads: 1 on 6 virtual cores

julia> VERSION
v"1.9.0-DEV.883"

julia> struct MaybeTuple
           val::Union{Nothing, Tuple{Float32}}
       end

julia> MaybeTuple((0,))
Assertion failed: New->getType() == getType() && "replaceAllUses of value with new value of different type!", file /workspace/srcdir/llvm-project/llvm/lib/IR/Value.cpp, line 503

signal (22): SIGABRT
in expression starting at REPL[4]:1

@gbaraldi
Copy link
Member Author

gbaraldi commented Jul 2, 2022

Yeah, this branch currently breaks unions.

edit: this commit should fix them

@vchuravy vchuravy added this to the 1.9 milestone Jul 3, 2022
@vchuravy
Copy link
Sponsor Member

vchuravy commented Jul 3, 2022

How close is this? Should we revert #45153 and then re-land it with these fixes?

@gbaraldi
Copy link
Member Author

gbaraldi commented Jul 3, 2022

We might want to run pkgeval, but the issues related to the original pr are fixed by this

@vchuravy
Copy link
Sponsor Member

vchuravy commented Jul 3, 2022

@nanosoldier runtests(ALL, vs = ":master", buildflags=["LLVM_ASSERTIONS=1", "FORCE_ASSERTIONS=1"], vs_buildflags=["LLVM_ASSERTIONS=1", "FORCE_ASSERTIONS=1"])

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@gbaraldi
Copy link
Member Author

gbaraldi commented Jul 4, 2022

After a rebase I tested it locally and the failures seen weren't there

@@ -3681,7 +3681,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
if (fval_info.typ == jl_bottom_type)
return jl_cgval_t();
// TODO: Use (post-)domination instead.
bool field_promotable = !init_as_value && fval_info.promotion_ssa != -1 &&
bool field_promotable = !jl_is_uniontype(jtype) && !init_as_value && fval_info.promotion_ssa != -1 &&
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be valid though if jl_field_isptr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that unions currently don't get their promotion point correctly, I'm not exactly what's needed to fix that, so for now, not allowing unions at all seems fine.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 7, 2022

@nanosoldier runtests(["Ai4EComponentLib", "BioMASS", "BitInformation", "BloqadeODE", "Convex1d", "CryptoDashApp", "DifferentiableBackwardEuler", "EnsembleKalmanProcesses", "Evolutionary", "FiniteStateProjection", "Fronts", "GeoDatasets", "ImmersedLayers", "MRIgeneralizedBloch", "NumericalAlgorithms", "OpenStreetMapXPlot", "OptimKit", "PCRE2", "PlanningDomains", "PyRhodium", "Quiqbox", "RankRevealing", "RemoveLFS", "RipQP", "ShipMMG", "SimpleFWA", "TransferEntropy", "Transparency", "VoronoiGraph", "Zarr"], vs = ":master", buildflags=["LLVM_ASSERTIONS=1", "FORCE_ASSERTIONS=1"], vs_buildflags=["LLVM_ASSERTIONS=1", "FORCE_ASSERTIONS=1"])

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 7, 2022

@nanosoldier runbenchmarks(!"scalar", vs=":master")

@vtjnash vtjnash removed the needs nanosoldier run This PR should have benchmarks run on it label Jul 7, 2022
@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 8, 2022

@nanosoldier runbenchmarks(["array", "comprehension", ("collect", "Vector{Float64}")], vs=":master")

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 8, 2022

@nanosoldier runbenchmarks("array" && "comprehension" && ("collect", "Vector{Float64}"), vs=":master")

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 8, 2022

@nanosoldier runbenchmarks("array" && "comprehension", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here.

@maleadt maleadt merged commit d75843d into JuliaLang:master Jul 21, 2022
ffucci pushed a commit to ffucci/julia that referenced this pull request Aug 11, 2022
pcjentsch pushed a commit to pcjentsch/julia that referenced this pull request Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants