Issue Details (XML | Word | Printable)

Key: PCC-328
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

register used twice during 64-bit multiply & pass to inline function

Created: 19/Apr/11 10:11 PM   Updated: 26/Apr/11 05:23 PM
Component/s: Common code
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File bintime.c (0.5 kB)
2. File bintime.s (1 kB)

Environment: NetBSD/i386

 Description  « Hide
The attached bintime.c program (which is an extract from NetBSD kernel code, to
initialize timecounters) fails with segmentation fault when built with -O2 or more
specifically -Wc,-xtemps,-xinline

The reason is that a register is used twice.. looking at the assembler produced for
the main() function call;

        pushl %ebp
        movl %esp,%ebp
        subl $12,%esp
        movl %ebx,-4(%ebp)
        movl %esi,-8(%ebp)
        movl %edi,-12(%ebp)
        movl 8(%ebp),%eax
        movl 12(%ebp),%eax
        movl $tm0,%eax
        leal 8(%eax),%ecx # load &tm0.th_offset to %ecx
        xorl %esi,%esi
        movl $3,%ecx # but now use %ecx during multiplication
        movl 4(%eax),%ebx
        movl (%eax),%edx
        movl %edx,%eax
        movl %ebx,%edx
        imull %ecx, %edx
        imull %eax, %esi
        addl %edx, %esi
        mull %ecx
        addl %esi, %edx
        movl 12(%ecx),%esi # and tries to reference the now invalid address..
        movl 8(%ecx),%ebx
        addl %eax,8(%ecx)
        adcl %edx,12(%ecx)
        movl 12(%ecx),%edx
        movl 8(%ecx),%eax

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 26/Apr/11 05:23 PM
Should be fixed now.