Skip to content

Darwin AArch64 calling conventions are wrong in NCG

It appears that all is not well in our treatment of Darwin AArch64 calling conventions. Specifically, consider the program in $3141:

$ _build/ghc-stage1 --info
...
 ,("target platform string","aarch64-apple-darwin")
 ,("target os","OSDarwin")
 ,("target arch","ArchAArch64")
 ,("target word size","8")
...
 ,("Project Git commit id","4ae0cde9cb1d3ca0d34efe049bda37d52c2bac10")
...

$ _build/ghc-stage1 -O0 -g3 -optc-g3 TestHs.hs TestC.c -o Main
$ ./Main
0x1111111111111111
0x2222222222222222
0x3333333333333333
4
5
6
0x7777777777777777
0x8888888888888888
0x9999999999999999
0xaaaaaaaaaaaaaaaa
0xbbbbbbbbbbbbbbbb
cccccccc
0x1dddddddd

$ _build/ghc-stage1 -O0 -g3 -optc-g3 TestHs.hs TestC.c -o Main -fllvm
$ ./Main
0x1111111111111111
0x2222222222222222
0x3333333333333333
4
5
6
0x7777777777777777
0x8888888888888888
0x9999999999999999
0xaaaaaaaaaaaaaaaa
0xbbbbbbbbbbbbbbbb
cccccccc
0xdddddddddddddddd

Look at the output from the last printf, which should print the value of the failed_doing argument (0xdddddddddddddddd) but actually prints 0x1dddddddd. Clearly this is nonsense.

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information