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

backport fix for Const propagation of uninitialized structs to v1.1. #31418

Closed
ghost opened this issue Mar 21, 2019 · 8 comments
Closed

backport fix for Const propagation of uninitialized structs to v1.1. #31418

ghost opened this issue Mar 21, 2019 · 8 comments
Assignees

Comments

@ghost
Copy link

ghost commented Mar 21, 2019

Opening an issue about this so we don't forget.

Today we noticed our code incorrectly const-propagating an unitialized tuple on julia 1.1, which it wasn't doing on julia 1.0.

This is fixed on master by the following lines, introduced in 52bafeb:

if t !== Bottom && fieldcount(t) == length(ats)
if allconst
t = Const(ccall(:jl_new_structv, Any, (Any, Ptr{Cvoid}, UInt32), t, args, length(args)))
elseif anyconst
t = PartialStruct(t, ats)
end
end

We discussed backporting this fix to a patch release for v1.1. Does that still seem doable? 😊Would we backport just those lines, or the whole commit 52bafeb?

Thanks! :)

@ghost
Copy link
Author

ghost commented Apr 2, 2019

As-is, we are still unable to use julia v1.1 because LLVM takes 3 hours trying to compile a single function when trying to const-propagate an uninitialized struct (a Nullables.Nullable{LargeStruct} that starts as nothing). This bug was introduced in v1.1, and doesn't happen on v1.0.3.

Would it be possible to back-port all of the commit 52bafeb? If not, is there an easy way to fix this problem for backport?
Thanks

@ghost
Copy link
Author

ghost commented Apr 8, 2019

😁@Keno, I see that @vchuravy assigned you to this. Haha sorry and thanks. :)

Let me know if I can help you with this at all. This is currently making v1.1 unusable for us without running on -O1, but that of course makes our benchmarking less reliable.

Thanks!

@Keno
Copy link
Member

Keno commented Apr 8, 2019

I don't think it's very hard. It should literally just be about adding that if statement (the fieldcount(t) == length(ats), but of course on 1.1, I don't think you need to actually construct the ats, you can just count it)

@ghost
Copy link
Author

ghost commented Apr 8, 2019

Cool, good to hear.

So for v1.1, you think the diff would basically just be something like this?:

diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl
index b01ad3a271..e493b4a1b9 100644
--- a/base/compiler/abstractinterpretation.jl
+++ b/base/compiler/abstractinterpretation.jl
@@ -910,7 +910,7 @@ function abstract_eval(@nospecialize(e), vtypes::VarTable, sv::InferenceState)
                     isconst = false
                 end
             end
-            if isconst
+            if isconst && fieldcount(t) == length(e.args) - 1
                 t = Const(ccall(:jl_new_structv, Any, (Any, Ptr{Cvoid}, UInt32), t, args, length(args)))
             end
         end

@Keno
Copy link
Member

Keno commented Apr 8, 2019

yes, something like that. If that works and solves your issue, submit it as a PR :)

@ghost
Copy link
Author

ghost commented Apr 8, 2019

K, i'll look into it. Thanks for the support, Keno. :)

NHDaly added a commit to NHDaly/julia that referenced this issue Apr 12, 2019
Fixes bug introduced in `v1.1.0` causing some LLVM optimizations to run
for hours.

Fixes JuliaLang#31418
@ghost
Copy link
Author

ghost commented Apr 12, 2019

Thanks Keno, that did indeed fix our issue. I've opened a PR directly against the backport-1.1.1 branch here:
#31699

KristofferC pushed a commit that referenced this issue Apr 15, 2019
Fixes bug introduced in `v1.1.0` causing some LLVM optimizations to run
for hours.

Fixes #31418
@ghost
Copy link
Author

ghost commented Apr 15, 2019

This has been addressed in #31699. Closing.

@ghost ghost mentioned this issue Apr 24, 2019
39 tasks
@NHDaly NHDaly assigned NHDaly and unassigned NHDaly Dec 20, 2021
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

No branches or pull requests

3 participants