Cedric Blancher
2012-09-11 16:00:57 UTC
Forwarded conversation
Subject: [developer] SUNWspro compiler bug
------------------------
From: Matthew Ahrens <mahrens-IrO+***@public.gmane.org>
Date: 11 September 2012 06:35
To: developer-bGTZWsvkwUGXjz/AKq3pydi2O/***@public.gmane.org
Is there a good place to report a SUNWspro compiler bug?
I've found that functions that use alloca() (or c99 variable-length
arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the
kernel is) restore callee-saved registers incorrectly.
Note that extant code works correctly because the kernel doesn't call
alloca(), and 64-bit userland is not compiled with save_args.
The incorrect assembly looks like:
func: pushq %rbp
func+1: movq %rsp,%rbp
# save arguments:
func+4: subq $0x18,%rsp
func+8: movq %rdi,-0x8(%rbp)
func+0xc: movq %rsi,-0x10(%rbp)
func+0x10: movq %rdx,-0x18(%rbp)
# callee-saved registers which this function needs:
func+0x14: pushq %r12
func+0x16: pushq %r13
func+0x18: pushq %r14
func+0x1a: pushq %r15
# alloca(1):
func+0x1c: subq $0x8,%rsp
func+0x20: decq %rsp
func+0x23: andq $0xfffffffffffffff0,%rsp
... some computation that uses %r12, %r13, %r14, %r15
# incorrectly change %rsp to what it was before the alloca()
# should be -0x38 to include saved arguments
func+0x187: leaq -0x20(%rbp),%rsp
# restore callee-saved registers:
func+0x18b: popq %r15
func+0x18d: popq %r14
func+0x18f: popq %r13
func+0x191: popq %r12
func+0x193: leave
func+0x194: ret
For an example, see the attached test program.
--matt
illumos-developer | Archives | Modify Your Subscription
----------
From: Richard Lowe <richlowe-***@public.gmane.org>
Date: 11 September 2012 06:40
out for review. I think you can file Studio bugs at bugs.sun.com
still, but it won't be any good for illumos, since it'll only be fixed
in a version of the compiler we can't really use.
-- Rich
illumos-developer | Archives | Modify Your Subscription
Ced
--
Cedric Blancher <cedric.blancher-gM/Ye1E23mwN+***@public.gmane.org>
Institute Pasteur
Subject: [developer] SUNWspro compiler bug
------------------------
From: Matthew Ahrens <mahrens-IrO+***@public.gmane.org>
Date: 11 September 2012 06:35
To: developer-bGTZWsvkwUGXjz/AKq3pydi2O/***@public.gmane.org
Is there a good place to report a SUNWspro compiler bug?
I've found that functions that use alloca() (or c99 variable-length
arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the
kernel is) restore callee-saved registers incorrectly.
Note that extant code works correctly because the kernel doesn't call
alloca(), and 64-bit userland is not compiled with save_args.
The incorrect assembly looks like:
func: pushq %rbp
func+1: movq %rsp,%rbp
# save arguments:
func+4: subq $0x18,%rsp
func+8: movq %rdi,-0x8(%rbp)
func+0xc: movq %rsi,-0x10(%rbp)
func+0x10: movq %rdx,-0x18(%rbp)
# callee-saved registers which this function needs:
func+0x14: pushq %r12
func+0x16: pushq %r13
func+0x18: pushq %r14
func+0x1a: pushq %r15
# alloca(1):
func+0x1c: subq $0x8,%rsp
func+0x20: decq %rsp
func+0x23: andq $0xfffffffffffffff0,%rsp
... some computation that uses %r12, %r13, %r14, %r15
# incorrectly change %rsp to what it was before the alloca()
# should be -0x38 to include saved arguments
func+0x187: leaq -0x20(%rbp),%rsp
# restore callee-saved registers:
func+0x18b: popq %r15
func+0x18d: popq %r14
func+0x18f: popq %r13
func+0x191: popq %r12
func+0x193: leave
func+0x194: ret
For an example, see the attached test program.
--matt
illumos-developer | Archives | Modify Your Subscription
----------
From: Richard Lowe <richlowe-***@public.gmane.org>
Date: 11 September 2012 06:40
Is there a good place to report a SUNWspro compiler bug?
I've found that functions that use alloca() (or c99 variable-length arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the kernel is) restore callee-saved registers incorrectly.
I hit this same issue when concocting the libproc changes I just sentI've found that functions that use alloca() (or c99 variable-length arrays) and are compiled with "-m64 -xO1 -Wu,-save_args" (as the kernel is) restore callee-saved registers incorrectly.
out for review. I think you can file Studio bugs at bugs.sun.com
still, but it won't be any good for illumos, since it'll only be fixed
in a version of the compiler we can't really use.
-- Rich
illumos-developer | Archives | Modify Your Subscription
Ced
--
Cedric Blancher <cedric.blancher-gM/Ye1E23mwN+***@public.gmane.org>
Institute Pasteur