Bug 2028798

Summary: gcc: reload failures on x86-64 after Systemtap 4.6 upgrade
Product: Red Hat Enterprise Linux 8 Reporter: Florian Weimer <fweimer>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: Václav Kadlčík <vkadlcik>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, dgilbert, fche, fweimer, jakub, mcermak, ohudlick, scox, vmakarov
Version: 8.6Keywords: Bugfix, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-8.5.0-6.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:27:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
good-dl-load.i
none
bad-dl-load.i none

Description Florian Weimer 2021-12-03 11:40:36 UTC
Created attachment 1844580 [details]
good-dl-load.i

The attached reproducer needs to be compiled -O2 -fstack-clash-protection. Then the error for bad-dl-load.i is:

during RTL pass: reload
dl-load.c: In function ‘_dl_map_object_from_fd’:
dl-load.c:1452:1: internal compiler error: Max. number of generated reload insns per insn is achieved (90)

I do not think it's the number of newlines (unlike on Arm) that is the problem here. The issue appears to trigger once the constraint changes to "norf".

We didn't see this on later GCC versions.

I could reproduce the issue with systemtap-sdt-devel-4.6-2.el8.x86_64. This build isn't in the buildroot yet, so we have some time to resolve this.

Comment 1 Florian Weimer 2021-12-03 11:41:22 UTC
Created attachment 1844581 [details]
bad-dl-load.i

Comment 2 Jakub Jelinek 2021-12-03 11:50:40 UTC
Bisection points to https://gcc.gnu.org/r10-2587-gcc19f80ceb27cc3d31d259ebecaad12005acfd7e which wasn't a RA fix though.

Comment 3 Jakub Jelinek 2021-12-03 12:25:06 UTC
Reduced testcase, just -O2 is enough:
struct B { int a; };
int c, d;
int bar (void);
void baz (void);

void
foo (struct B *f)
{
  int *g = (int *) (__INTPTR_TYPE__) bar ();
lab:
  __asm__("" ::"norfxy"(g));
  baz ();
  int k[d];
  for (; f < (struct B *) &f; ++f)
    switch (f->a)
    case 1:
      if (__builtin_expect (c, 0))
        goto lab;
}

This one got fixed with https://gcc.gnu.org/r11-3041-g6001db79c477b03eacc7e7049560921fb54b7845
which from quick look might be a real fix, but dunno how risky it is to backport it.

I think the "f" in the constraint is a terribly bad idea, reg-stack.c makes quite a few assumptions on what inline asm
can do with the f/t/u constraints.

Comment 9 Frank Ch. Eigler 2021-12-07 20:15:27 UTC
See also: bug #2029924

Comment 10 Frank Ch. Eigler 2021-12-07 20:16:48 UTC
and: bug #2029926

Comment 17 errata-xmlrpc 2022-05-10 15:27:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gcc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2072