Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimisation fails in PIC modes #244

Open
elliotnunn opened this issue May 7, 2024 · 1 comment
Open

Optimisation fails in PIC modes #244

elliotnunn opened this issue May 7, 2024 · 1 comment

Comments

@elliotnunn
Copy link

Wolfgang, thank you for fixing my previous issue with -msep-data. My ROM driver is working well. Working with the A5 data model I also noticed that compilation fails on any non-0 optimisation level.

Currently I work around this by giving a long list of individual "-fsomething" arguments that does NOT include "-fcombine-stack-adjustments".

I poked around expr.cc, where I got the vague idea that "note" structures track how much scratch data needs to be popped from the stack, but my understanding is limited. From the history of expr.cc it seems that this is bug came from upstream GCC.

COMPILING THIS TEST CODE:
        void func1(char *string);
        void func2(void) {
            func1("string");
        }

COMPILED WITH "m68k-apple-macos-gcc -c -O1 "
           0:	4879 0000 0000 	pea 0 <func2>
           6:	4eb9 0000 0000 	jsr 0 <func2>
           c:	588f           	addql #4,%sp
           e:	4e75           	rts
          10:	8566           	orw %d2,%fp@-
          12:	756e           	.short 0x756e
          14:	6332           	blss 48 <func2+0x48>

COMPILED WITH "m68k-apple-macos-gcc -c -O1 -mpcrel"
           0:	487a 0000      	pea %pc@(2 <func2+0x2>)
           4:	6100 0000      	bsrw 6 <func2+0x6>
           8:	588f           	addql #4,%sp
           a:	4e75           	rts
           c:	8566           	orw %d2,%fp@-
           e:	756e           	.short 0x756e
          10:	6332           	blss 44 <func2+0x44>

COMPILED WITH "m68k-apple-macos-gcc -c -O1 -fpic"
        during RTL pass: combine
        /tmp/ctest.c: In function ‘func2’:
        /tmp/ctest.c:4:1: internal compiler error: in fixup_args_size_notes, at expr.cc:4469
            4 | }
              | ^
        Please submit a full bug report, with preprocessed source (by using -freport-bug).
        See <https://gcc.gnu.org/bugs/> for instructions.

COMPILED WITH "m68k-apple-macos-gcc -c -O1 -fPIC"
        during RTL pass: combine
        /tmp/ctest.c: In function ‘func2’:
        /tmp/ctest.c:4:1: internal compiler error: in fixup_args_size_notes, at expr.cc:4469
            4 | }
              | ^
        Please submit a full bug report, with preprocessed source (by using -freport-bug).
        See <https://gcc.gnu.org/bugs/> for instructions.

COMPILED WITH "m68k-apple-macos-gcc -c -O1 -msep-data"
        during RTL pass: combine
        /tmp/ctest.c: In function ‘func2’:
        /tmp/ctest.c:4:1: internal compiler error: in fixup_args_size_notes, at expr.cc:4469
            4 | }
              | ^
        Please submit a full bug report, with preprocessed source (by using -freport-bug).
        See <https://gcc.gnu.org/bugs/> for instructions.

COMPILED WITH "m68k-apple-macos-gcc -c -O1 -mid-shared-library"
        during RTL pass: combine
        /tmp/ctest.c: In function ‘func2’:
        /tmp/ctest.c:4:1: internal compiler error: in fixup_args_size_notes, at expr.cc:4469
            4 | }
              | ^
        Please submit a full bug report, with preprocessed source (by using -freport-bug).
        See <https://gcc.gnu.org/bugs/> for instructions.
@autc04
Copy link
Owner

autc04 commented May 7, 2024

I'm rapidly growing to dislike fixup_args_size_notes. Never figured out what's going on there.

I also assume that it's related to #232...

The assertion failure is close to a 'HALF-UNDERSTOOD HACK' that I added to prevent a different internal compiler error. So the first thing to try will be to disable that hack...

autc04 added a commit that referenced this issue May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants