-
-
Notifications
You must be signed in to change notification settings - Fork 714
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
Code that uses slice.to_type takes 2-3x longer to compile normally, and -o:speed causes compiler to hang. #4924
Comments
Reproducible at godbolt: https://godbolt.org/z/s3c79c98r Seems to be related to the long standing issue around LLVM's treatment of large arrays. |
Very weird, we generate this on -o:none %27 = call i8 @"slice::to_type:proc(buf:[]u8,T:$game::Game)->(:game::Game,:bool)"(<{ i64, i64 }> %26, ptr %8, ptr %__.context_ptr)
%28 = load %"game::Game", ptr %8, align 4
store %"game::Game" %28, ptr %1, align 4 and when optimisations are enabled LLVM turns this into thousands of instructions like: %.fca.0.load = load float, ptr %2, align 4
%.fca.1.0.0.gep = getelementptr inbounds i8, ptr %2, i64 4
%.fca.1.0.0.load = load i32, ptr %.fca.1.0.0.gep, align 4
%.fca.1.0.1.gep = getelementptr inbounds i8, ptr %2, i64 8
%.fca.1.0.1.load = load i32, ptr %.fca.1.0.1.gep, align 4
%.fca.1.0.2.gep = getelementptr inbounds i8, ptr %2, i64 12
%.fca.1.0.2.load = load i8, ptr %.fca.1.0.2.gep, align 4
%.fca.1.0.3.gep = getelementptr inbounds i8, ptr %2, i64 13
%.fca.1.0.3.load = load i8, ptr %.fca.1.0.3.gep, align 1
%.fca.1.0.4.0.gep = getelementptr inbounds i8, ptr %2, i64 14
%.fca.1.0.4.0.load = load i8, ptr %.fca.1.0.4.0.gep, align 2
%.fca.1.0.4.1.gep = getelementptr inbounds i8, ptr %2, i64 15
%.fca.1.0.4.1.load = load i8, ptr %.fca.1.0.4.1.gep, align 1
%.fca.1.0.5.0.gep = getelementptr inbounds i8, ptr %2, i64 16
%.fca.1.0.5.0.load = load float, ptr %.fca.1.0.5.0.gep, align 4
%.fca.1.0.5.1.gep = getelementptr inbounds i8, ptr %2, i64 20
%.fca.1.0.5.1.load = load float, ptr %.fca.1.0.5.1.gep, align 4
%.fca.1.0.6.0.gep = getelementptr inbounds i8, ptr %2, i64 24
%.fca.1.0.6.0.load = load float, ptr %.fca.1.0.6.0.gep, align 4
%.fca.1.0.6.1.gep = getelementptr inbounds i8, ptr %2, i64 28
%.fca.1.0.6.1.load = load float, ptr %.fca.1.0.6.1.gep, align 4
%.fca.1.0.7.0.gep = getelementptr inbounds i8, ptr %2, i64 32
%.fca.1.0.7.0.load = load float, ptr %.fca.1.0.7.0.gep, align 4
%.fca.1.0.7.1.gep = getelementptr inbounds i8, ptr %2, i64 36
%.fca.1.0.7.1.load = load float, ptr %.fca.1.0.7.1.gep, align 4
%.fca.1.0.8.gep = getelementptr inbounds i8, ptr %2, i64 40
%.fca.1.0.8.load = load float, ptr %.fca.1.0.8.gep, align 4
%.fca.1.0.9.0.gep = getelementptr inbounds i8, ptr %2, i64 44
%.fca.1.0.9.0.load = load float, ptr %.fca.1.0.9.0.gep, align 4
%.fca.1.0.9.1.gep = getelementptr inbounds i8, ptr %2, i64 48
%.fca.1.0.9.1.load = load float, ptr %.fca.1.0.9.1.gep, align 4
%.fca.1.0.10.0.gep = getelementptr inbounds i8, ptr %2, i64 52
%.fca.1.0.10.0.load = load float, ptr %.fca.1.0.10.0.gep, align 4
%.fca.1.0.10.1.gep = getelementptr inbounds i8, ptr %2, i64 56
%.fca.1.0.10.1.load = load float, ptr %.fca.1.0.10.1.gep, align 4
%.fca.1.0.10.2.gep = getelementptr inbounds i8, ptr %2, i64 60
%.fca.1.0.10.2.load = load float, ptr %.fca.1.0.10.2.gep, align 4
%.fca.1.0.10.3.gep = getelementptr inbounds i8, ptr %2, i64 64
%.fca.1.0.10.3.load = load float, ptr %.fca.1.0.10.3.gep, align 4
%.fca.1.0.11.0.gep = getelementptr inbounds i8, ptr %2, i64 68
%.fca.1.0.11.0.load = load float, ptr %.fca.1.0.11.0.gep, align 4
%.fca.1.0.11.1.gep = getelementptr inbounds i8, ptr %2, i64 72
%.fca.1.0.11.1.load = load float, ptr %.fca.1.0.11.1.gep, align 4
%.fca.1.0.11.2.gep = getelementptr inbounds i8, ptr %2, i64 76
%.fca.1.0.11.2.load = load float, ptr %.fca.1.0.11.2.gep, align 4
%.fca.1.0.11.3.gep = getelementptr inbounds i8, ptr %2, i64 80
%.fca.1.0.11.3.load = load float, ptr %.fca.1.0.11.3.gep, align 4
%.fca.1.0.12.gep = getelementptr inbounds i8, ptr %2, i64 84
%.fca.1.0.12.load = load i32, ptr %.fca.1.0.12.gep, align 4
%.fca.1.0.13.gep = getelementptr inbounds i8, ptr %2, i64 88
%.fca.1.0.13.load = load i16, ptr %.fca.1.0.13.gep, align 4
%.fca.1.0.14.gep = getelementptr inbounds i8, ptr %2, i64 90
%.fca.1.0.14.load = load i8, ptr %.fca.1.0.14.gep, align 2
%.fca.1.0.15.gep = getelementptr inbounds i8, ptr %2, i64 91
%.fca.1.0.15.load = load i8, ptr %.fca.1.0.15.gep, align 1
%.fca.1.1.0.gep = getelementptr inbounds i8, ptr %2, i64 92
%.fca.1.1.0.load = load i32, ptr %.fca.1.1.0.gep, align 4
%.fca.1.1.1.gep = getelementptr inbounds i8, ptr %2, i64 96
%.fca.1.1.1.load = load i32, ptr %.fca.1.1.1.gep, align 4
%.fca.1.1.2.gep = getelementptr inbounds i8, ptr %2, i64 100
%.fca.1.1.2.load = load i8, ptr %.fca.1.1.2.gep, align 4
%.fca.1.1.3.gep = getelementptr inbounds i8, ptr %2, i64 101
%.fca.1.1.3.load = load i8, ptr %.fca.1.1.3.gep, align 1
%.fca.1.1.4.0.gep = getelementptr inbounds i8, ptr %2, i64 102
%.fca.1.1.4.0.load = load i8, ptr %.fca.1.1.4.0.gep, align 2
%.fca.1.1.4.1.gep = getelementptr inbounds i8, ptr %2, i64 103
%.fca.1.1.4.1.load = load i8, ptr %.fca.1.1.4.1.gep, align 1
%.fca.1.1.5.0.gep = getelementptr inbounds i8, ptr %2, i64 104
%.fca.1.1.5.0.load = load float, ptr %.fca.1.1.5.0.gep, align 4
%.fca.1.1.5.1.gep = getelementptr inbounds i8, ptr %2, i64 108
%.fca.1.1.5.1.load = load float, ptr %.fca.1.1.5.1.gep, align 4
%.fca.1.1.6.0.gep = getelementptr inbounds i8, ptr %2, i64 112
%.fca.1.1.6.0.load = load float, ptr %.fca.1.1.6.0.gep, align 4
%.fca.1.1.6.1.gep = getelementptr inbounds i8, ptr %2, i64 116
%.fca.1.1.6.1.load = load float, ptr %.fca.1.1.6.1.gep, align 4
%.fca.1.1.7.0.gep = getelementptr inbounds i8, ptr %2, i64 120
%.fca.1.1.7.0.load = load float, ptr %.fca.1.1.7.0.gep, align 4
%.fca.1.1.7.1.gep = getelementptr inbounds i8, ptr %2, i64 124
%.fca.1.1.7.1.load = load float, ptr %.fca.1.1.7.1.gep, align 4
%.fca.1.1.8.gep = getelementptr inbounds i8, ptr %2, i64 128
%.fca.1.1.8.load = load float, ptr %.fca.1.1.8.gep, align 4
%.fca.1.1.9.0.gep = getelementptr inbounds i8, ptr %2, i64 132
%.fca.1.1.9.0.load = load float, ptr %.fca.1.1.9.0.gep, align 4
%.fca.1.1.9.1.gep = getelementptr inbounds i8, ptr %2, i64 136
%.fca.1.1.9.1.load = load float, ptr %.fca.1.1.9.1.gep, align 4
%.fca.1.1.10.0.gep = getelementptr inbounds i8, ptr %2, i64 140
%.fca.1.1.10.0.load = load float, ptr %.fca.1.1.10.0.gep, align 4
%.fca.1.1.10.1.gep = getelementptr inbounds i8, ptr %2, i64 144
%.fca.1.1.10.1.load = load float, ptr %.fca.1.1.10.1.gep, align 4
%.fca.1.1.10.2.gep = getelementptr inbounds i8, ptr %2, i64 148
%.fca.1.1.10.2.load = load float, ptr %.fca.1.1.10.2.gep, align 4
%.fca.1.1.10.3.gep = getelementptr inbounds i8, ptr %2, i64 152
%.fca.1.1.10.3.load = load float, ptr %.fca.1.1.10.3.gep, align 4
%.fca.1.1.11.0.gep = getelementptr inbounds i8, ptr %2, i64 156
%.fca.1.1.11.0.load = load float, ptr %.fca.1.1.11.0.gep, align 4
%.fca.1.1.11.1.gep = getelementptr inbounds i8, ptr %2, i64 160
%.fca.1.1.11.1.load = load float, ptr %.fca.1.1.11.1.gep, align 4
%.fca.1.1.11.2.gep = getelementptr inbounds i8, ptr %2, i64 164
%.fca.1.1.11.2.load = load float, ptr %.fca.1.1.11.2.gep, align 4
%.fca.1.1.11.3.gep = getelementptr inbounds i8, ptr %2, i64 168
%.fca.1.1.11.3.load = load float, ptr %.fca.1.1.11.3.gep, align 4 |
Even with -o:none on godbolt the resulting assembly is a long series of various MOVs. |
Hmm maybe |
Ah I now remember reading/hearing people talk about this with llvm, where doing |
Context
Odin: dev-2025-03-nightly
OS: Ubuntu 24.10, Linux 6.11.0-19-generic
CPU: AMD Ryzen 7 6800H with Radeon Graphics
RAM: 14703 MiB
Backend: LLVM 18.1.6
Expected Behavior
Code should compile with reasonable compile times.
Current Behavior
Code takes 2-3x longer to compile normally and doesn't compile with -o:release.
Failure Information (for bugs)
The following code compiles normally when the line with
slice.to_type
is commented out. I am pretty sure this is related to the structure of the data being serialized.Steps to Reproduce
Please provide detailed steps for reproducing the issue.
odin build . -o:speed -show-timings
slice.to_type
or makeEntity
an empty struct.Failure Logs
N/A
The text was updated successfully, but these errors were encountered: