Discussion:
[developer] SUNWspro compiler bug
Cedric Blancher
2012-09-11 16:00:57 UTC
Permalink
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
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 sent
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
Cindy Swearingen
2012-09-11 16:58:36 UTC
Permalink
Sure, we can pass this feedback along.

Thanks for reporting it.

Cindy
Post by Cedric Blancher
Forwarded conversation
Subject: [developer] SUNWspro compiler bug
------------------------
Date: 11 September 2012 06:35
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.
func: pushq %rbp
func+1: movq %rsp,%rbp
func+4: subq $0x18,%rsp
func+8: movq %rdi,-0x8(%rbp)
func+0xc: movq %rsi,-0x10(%rbp)
func+0x10: movq %rdx,-0x18(%rbp)
func+0x14: pushq %r12
func+0x16: pushq %r13
func+0x18: pushq %r14
func+0x1a: pushq %r15
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
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
----------
Date: 11 September 2012 06:40
Post by Cedric Blancher
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 sent
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
--
Institute Pasteur
_______________________________________________
opensolaris-discuss mailing list
Cedric Blancher
2012-09-11 17:09:27 UTC
Permalink
On 11 September 2012 18:58, Cindy Swearingen
Post by Cindy Swearingen
Sure, we can pass this feedback along.
Thanks for reporting it.
Cindy, please send the CR# number from bugster back to this list as
reference. Thank you.

Ced
--
Cedric Blancher <cedric.blancher-gM/Ye1E23mwN+***@public.gmane.org>
Institute Pasteur
Loading...