close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 12 years ago

Closed 12 years ago

#61 closed defect (fixed)

Darwin+clang doesn't produce a working lisp

Reported by: Raymond Toy Owned by: somebody
Priority: major Milestone:
Component: Core Version: 2012-07
Keywords: Cc:

Description

Compiling the C runtime on Darwin with clang does not produce a working lisp. The cause is that clang uses xmm registers in gencgc.c, but the allocator calls alloc() directly without saving any live xmm registers which eventually get trashed. For example the vop

(define-vop (move-from-single)
  (:args (x :scs (single-reg) :to :save))
  (:results (y :scs (descriptor-reg)))
  (:node-var node)
  (:note _N"float to pointer coercion")
  (:save-p t)
  (:generator 13
     (with-fixed-allocation (y vm:single-float-type vm:single-float-size node)
       (inst movss (ea-for-sf-desc y) x))))

will save any live float registers, but not the arg x. If the allocator calls alloc(), x could be destroyed.

Possible solutions:

  1. Save and restore float args to the stack in every float vop that does allocation.
  2. Make alloc() save all the float registers.

The first solution is nice because only the registers that need to be saved are saved. But it's not nice because every vop will save/restore when most of the time alloc() will not be called.

The second solution is nice because it's always safe, even if some vop forgot to save a register. But it's not nice because all float registers are saved when only one (or a very small number) needs to be saved. But it looks like alloc() is relatively expensive so perhaps the cost of saving all registers is in the noise. (Should measure this.)

Change History (1)

comment:1 Changed 12 years ago by toy.raymond@…

Resolution: fixed
Status: newclosed

commit 40b532c59cd9ff6d48588ed8c36880a625009142 Author: Raymond Toy <toy.raymond@…> Date: Tue Jul 17 20:11:13 2012 -0700

Fix ticket:61, using option 2.

src/lisp/gencgc.c: o Save and restore the FPU state in alloc().

src/compiler/x86/alloc.lisp src/compiler/x86/array.lisp src/compiler/x86/call.lisp src/compiler/x86/float-sse2.lisp src/compiler/x86/float.lisp src/compiler/x86/move.lisp src/compiler/x86/sap.lisp: o Don't need to use :save-p anymore because the allocation routine

saves an live registers anyway. This improves code generation as well.

src/general-info/release-20d.txt: o Update.

Note: See TracTickets for help on using tickets.