Changes between Version 15 and Version 16 of Commentary/Compiler/Backends/LLVM/DevelopmentNotes
- Jul 18, 2010 4:12:00 PM (4 years ago)
v15 v16 12 12 == GHC LLVM Back-end Bugs == 13 13 14 === Foreign Calls on MacOSX === 14 === OSX === 15 15 16 Foreign calls on Mac OS X don't work. Seems to be because LLVM isn't generating correct code. All system calls must be 16 byte aligned in OS X and llvm isn't respecting this. Not sure if its a bug in LLVM or due to my changes to LLVM. 16 . 17 17 18 Update (20/02/10): I fixed this issue using the inline assembler approach (see below). This reduces the test failures on Mac OSX from 22 to 9. So doesn't fix everything. Still other issues. Also, I tried using the new stalk alignment feature but that interacts badly with the GHC calling convention, clobbering the Base register. 18 . 19 19 20 Update (07/07/10): Issue still exists. 20 E.g Asm generated by LLVM: 21 21 22 '''Solutions''': 23 * A new function attribute has just landed in SVN which allows stack alignment to be specified when a call is made. 24 * Can use inline assembler to fix stack alignment. 25 * Fix stack calculation in LLVM (my changes must have broken it). 22 _func: 23 subl $12, %esp 24 ... 25 call _sin 26 ... 27 addl $12, %esp 26 28 27 === Repa examples - FFT segfaults === 29 The mangler will change this to: 28 30 29 If you run the FFT program form [http://hackage.haskell.org/package/repa-examples repa-examples], it segfaults under the LLVM backend. 31 _func: 32 subl $12, %esp 33 ... 34 call _sin 35 ... 36 addl $12, %esp 37 38 The better solution would be to change GHC to keep the stack at 16n - 4 alignment on function. This will require changing the RTS (StgCRun.hs) to set the stack properly before calling into Stg land and also fixing up the NCG to align code properly. There may also be a problem with the C backend as currently all function prolouge and epilouge code is stripped out, which means all the stack manipulation code generated by GCC is removed. This works fine now since the stack is already 16 byte aligned on entry, but if it is now 16n - 4 byte aligned then some stack manipulation will be required. 39 40 === QuickHull (DPH Example, OSX) === 41 42 The Quickhull example segfaults under OS X.