https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114664
Bug ID: 114664 Summary: -fno-omit-frame-pointer causes an ICE during the build of the greenlet package Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: bergner at gcc dot gnu.org Target Milestone: --- Current builds of the greenlet package on one specific distro, are seeing an ICE on multiple architectures (ppc64le & riscv64) when being built with -fno-omit-frame-pointer. The upstream github issue is here: https://github.com/python-greenlet/greenlet/issues/395 A minimized test case on Power is: bergner@ltcden2-lp1:$ cat bug.c void bug (void) { __asm__ volatile ("" : : : "r31"); } bergner@ltcden2-lp1:$ /opt/gcc-nightly/trunk/bin/gcc -S -fno-omit-frame-pointer bug.c bug.c: In function ‘bug’: bug.c:5:1: error: 31 cannot be used in ‘asm’ here 5 | } | ^ bug.c:5:1: error: 31 cannot be used in ‘asm’ here This is not a regression, as all gcc's I have easy access to (back to gcc v8) ICE the same way. The code that is ICEing here is in ira.c:ira_setup_eliminable_regset(): /* Build the regset of all eliminable registers and show we can't use those that we already know won't be eliminated. */ for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++) { bool cannot_elim = (! targetm.can_eliminate (eliminables[i].from, eliminables[i].to) || (eliminables[i].to == STACK_POINTER_REGNUM && frame_pointer_needed)); if (!TEST_HARD_REG_BIT (crtl->asm_clobbers, eliminables[i].from)) { SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from); if (cannot_elim) SET_HARD_REG_BIT (ira_no_alloc_regs, eliminables[i].from); } else if (cannot_elim) error ("%s cannot be used in %<asm%> here", reg_names[eliminables[i].from]); else df_set_regs_ever_live (eliminables[i].from, true); } On Power, targetm.can_eliminate(r31,r1) returns true (ie, the port will allow us to eliminate r31 into r1) even in the face of -fno-omit-frame-pointer, but it's the RA specific test (eliminables[i].to == STACK_POINTER_REGNUM && frame_pointer_needed) that is catching us here. The question I have is, is it legal to mention the hard frame pointer register in an asm clobber list when using -fno-omit-frame-pointer? Ie, is this user error or should the compiler be able to handle this?