- Show closed items
Related merge requests 4
When these merge requests are accepted, this issue will be closed automatically.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Maintainer
If that's not a silly C&P bug I don't know what is. I will write a patch for this unless someone beats me to it.
Do you have a test case we could add to the test suite?
- Andreas Klebinger mentioned in merge request !675 (closed)
mentioned in merge request !675 (closed)
- Ben Gamari changed milestone to %8.6.5
changed milestone to %8.6.5
- Ben Gamari changed weight to 8
changed weight to 8
- Ben Gamari added 1 deleted label
added 1 deleted label
- Author Reporter
Here's a small test program. I hope you can add it to the test suite.
Note that this issue is very sensitive to the code generated by the compiler, and some of the lines in
xmm.cpp
are required to trigger the issue, even if they seem completely unnecessary.main.hs
module Main where import Control.Monad (when) import System.Exit (exitWith, ExitCode(..)) foreign export ccall fn_hs :: IO () fn_hs :: IO () fn_hs = return () foreign import ccall test :: IO Int main :: IO () main = do res <- test when (res /= 0) (exitWith $ ExitFailure res)
xmm.cpp
#include <iostream> #include <stdexcept> extern "C" { void fn_hs(); void fn() { fn_hs(); } void check(double sqrt2, double sqrt3, double sqrt5, double sqrt8, double sqrt13, double sqrt21) { std::cout << std::fixed << sqrt2 << " " << sqrt3 << " " << sqrt5 << " " << sqrt8 << " " << sqrt13 << " " << sqrt21 << std::endl; if (sqrt2 != 1.41421 || sqrt3 != 1.73205 || sqrt5 != 2.23607 || sqrt8 != 2.82843 || sqrt13 != 3.60555 || sqrt21 != 4.58258) { throw std::runtime_error("xmm registers have been scratched"); } } int test() { try { double sqrt2 = 1.41421; double sqrt3 = 1.73205; double sqrt5 = 2.23607; double sqrt8 = 2.82843; double sqrt13 = 3.60555; double sqrt21 = 4.58258; check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); fn(); check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); try { fn(); } catch (const std::exception &) { } check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); } catch (const std::exception &e) { std::cerr << e.what() << std::endl; return 1; } return 0; } } // extern "C"
With ghc 8.6.3:
$ ghc -O3 -o xmm.exe xmm.cpp main.hs -lstdc++ && ./xmm.exe && echo OK [1 of 1] Compiling Main ( main.hs, main.o ) Linking xmm.exe ... 1.414210 1.732050 2.236070 2.828430 3.605550 4.582580 0.000000 1.732050 2.236070 2.828430 3.605550 0.000000 xmm registers have been scratched
After applying the fix:
$ ghc -O3 -o xmm.exe xmm.cpp main.hs -lstdc++ && ./xmm.exe && echo OK Linking xmm.exe ... 1.414210 1.732050 2.236070 2.828430 3.605550 4.582580 1.414210 1.732050 2.236070 2.828430 3.605550 4.582580 1.414210 1.732050 2.236070 2.828430 3.605550 4.582580 OK
- Maintainer
Thanks @ryrag!
- Ben Gamari mentioned in commit 32e0232f
mentioned in commit 32e0232f
- Ben Gamari mentioned in merge request !687 (closed)
mentioned in merge request !687 (closed)
- Ben Gamari added Windows code generation incorrect runtime result labels
added Windows code generation incorrect runtime result labels
- Ben Gamari added Tbug label
added Tbug label
- Ben Gamari mentioned in commit d2fd0db3
mentioned in commit d2fd0db3
- Maintainer
The reproducer does not work for me. I tried with GHC HEAD, 8.6.3, and 8.6.4. I'm on x86_64 Linux.
Collapse replies - Author Reporter
That's expected. This issue is only present on Windows x86_64.
- Maintainer
Ah, right. Thanks.
- Andreas Klebinger mentioned in commit cbb88865
mentioned in commit cbb88865
- Andreas Klebinger mentioned in commit 5654a1d2
mentioned in commit 5654a1d2
- Andreas Klebinger mentioned in commit 9cf1f91b
mentioned in commit 9cf1f91b
- Ben Gamari mentioned in commit 4bbf665d
mentioned in commit 4bbf665d
- Maintainer
Backported to %8.6.5 in 4bbf665d.
Being backported to %8.8.1 in !707 (merged).
- Andreas Klebinger mentioned in commit c64c528f
mentioned in commit c64c528f
- Ben Gamari closed via merge request !705 (merged)
closed via merge request !705 (merged)
- Ben Gamari mentioned in commit b9001408
mentioned in commit b9001408
- Andreas Klebinger mentioned in commit 996a8732
mentioned in commit 996a8732
- Andreas Klebinger mentioned in commit cb9c0f21
mentioned in commit cb9c0f21
- Moe Bot mentioned in issue #14619 (closed)
mentioned in issue #14619 (closed)
- Ben Gamari mentioned in commit 80b73038
mentioned in commit 80b73038
- Ben Gamari mentioned in commit 8d33ffe7
mentioned in commit 8d33ffe7
- Ben Gamari mentioned in commit 5372ed22
mentioned in commit 5372ed22
- Ben Gamari mentioned in commit 065defc3
mentioned in commit 065defc3
- Ben Gamari mentioned in commit 41bf4045
mentioned in commit 41bf4045
- Ben Gamari mentioned in commit 8f2ab95d
mentioned in commit 8f2ab95d
- Ben Gamari mentioned in commit bd128434
mentioned in commit bd128434
- Ben Gamari mentioned in commit c1c0ce7a
mentioned in commit c1c0ce7a
- Ben Gamari added Phigh label
added Phigh label
- Ben Gamari removed 1 deleted label
removed 1 deleted label