Issue Details (XML | Word | Printable)

Key: PCC-142
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.

code generation bug maybe related to i386 long long assignment

Created: 30/May/10 12:13 PM   Updated: 10/Jun/10 07:27 PM
Component/s: i386 target
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. File init.diff (0.6 kB)
2. File init.i (63 kB)
3. File xx.c (0.1 kB)

Environment: NetBSD/i386

 Description  « Hide
I found that compiling pcc with itself on NetBSD/i386 using the NetBSD build framework caused some kind of loop when then building something else.
I tracked the loop to the setll() function, where we have

        /* Ensure that we have enough entries */
        while (off >= basesz * numents)
                 ll = getll();

and adding printfs shows that 'off' has a massive value. This is the effect and not the cause alas.

I have traced the cause back and found that the return value of the findoff() function which is a long long (for i386) was being corrupted, as illustrated by applying the init.diff patch and running the resulting binary against the xx.c source file attached, like so

% ./ccom -Xii xx.c xx.s
findoff off 0 (0)
scalinit woff 0 (0)
findoff off 32 (20)
scalinit woff 137438953504 (2000000020)

This is clearly wrong, and the init.i file attached is the preprocessed init.c file which caused this. Compiling that with "pcc -O2 -fstack-protector -S init.i" shows that the generated code dealing with the findoff() return value is suspect.

; woff = findoff();
        call findoff
        movl %eax,%ecx
        movl %edx,%ebx
        movl %ecx,%ebx
        movl %ebx,%esi

; if (idebug > 0) fprintf(stderr, "scalinit woff %lld (%llx)\n", woff, woff);
        cmpl $0,idebug
        jle .L720
        pushl %esi
        pushl %ebx
        pushl %esi
        pushl %ebx
        pushl $.L721
        pushl $__sF+176
        call fprintf
        addl $24, %esp it wanted woff to be stored in %esi/%ebx but used %ebx as a scratch register and ends up with MSL/LSL being the same..

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 10/Jun/10 07:27 PM
Should be fixed now. Table assignment between two register pairs were not checked correctly.