Bug 1958295

Summary: gcc ice when compiling compiler-rt on aarch64
Product: Red Hat Enterprise Linux 8 Reporter: serge_sans_paille <sguelton>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: Alexandra Petlanová Hájková <ahajkova>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: ahajkova, fweimer, jakub, ohudlick
Version: 8.5Keywords: Bugfix, Triaged
Target Milestone: beta   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-8.5.0-1.el8 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:35:43 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
t.cc none

Description serge_sans_paille 2021-05-07 15:01:14 UTC
Created attachment 1780768 [details]
t.cc

Description of problem:
# uname -a
Linux hpe-apollo-cn99xx-14-vm-10.khw4.lab.eng.bos.redhat.com 4.18.0-305.1.el8.aarch64 #1 SMP Fri Apr 30 16:27:55 EDT 2021 aarch64 aarch64 aarch64 GNU/Linux

# g++ --version
g++ (GCC) 8.4.1 20210423 (Red Hat 8.4.1-2)

# g++ -c -std=c++14 -fPIC -O2 t.cc -w
t.cc: In function ‘void Quarantine<Callback>::DoRecycle() [with Callback = QuarantineCallback]’:
t.cc:30:2: error: could not split insn
  }
  ^
(insn:TI 53 50 163 (parallel [
            (set (reg:CC 66 cc)
                (unspec_volatile:CC [
                        (const_int 0 [0])
                    ] UNSPECV_ATOMIC_CMPSW))
            (set (reg:DI 1 x1 [114])
                (mem/v:DI (reg/f:DI 23 x23 [128]) [-1  S8 A128]))
            (set (mem/v:DI (reg/f:DI 23 x23 [128]) [-1  S8 A128])
                (unspec_volatile:DI [
                        (const_int 42084505273 [0x9cc6e96b9])
                        (reg/v:DI 0 x0 [orig:97 xchg ] [97])
                        (const_int 0 [0])
                        (const_int 32773 [0x8005])
                        (const_int 32773 [0x8005])
                    ] UNSPECV_ATOMIC_CMPSW))
            (clobber (reg:SI 2 x2 [134]))
        ]) "t.cc":6 3372 {aarch64_compare_and_swapdi}
     (expr_list:REG_DEAD (reg/v:DI 0 x0 [orig:97 xchg ] [97])
        (expr_list:REG_UNUSED (reg:CC 66 cc)
            (expr_list:REG_UNUSED (reg:SI 2 x2 [134])
                (expr_list:REG_UNUSED (reg:DI 1 x1 [114])
                    (nil))))))
during RTL pass: final
t.cc:30:2: internal compiler error: in final_scan_insn_1, at final.c:3145

The attached test case got reduce from compiler-rt source by cvise.

Comment 1 Jakub Jelinek 2021-05-07 15:58:43 UTC
Slightly more reduced testcase:
// PR target/87839
// { dg-do compile { target c++11 } }
// { dg-options "-O2" }
// { dg-additional-options "-fpic" { target fpic } }

long long a;
static inline bool c(unsigned long long *j) {
  long long d = a, c = *j;
  __sync_val_compare_and_swap(&a, c, d);
  return true;
}
struct m { m(int *); };
struct p { void g() { m h(&aa); } int aa; };
struct q { using k = p; void g() { l.g(); } k l; };
template <typename> using n = q;
using o = n<int>;
struct t { long ab; void *ac[64]; };
struct F {
  t *r();
};
long x;
template <typename s> struct G {
  F af;
  s u;
  void __attribute__((noinline)) ae() {
    while (t *b = af.r())
      for (long j = 0; j < 6; j++)
        for (long i = x, e = b->ab; i < e; i++)
          if (i + e)
            u.v((int *)b->ac[i]);
  }
};
struct H {
  o w;
  void v(int *j) { w.g(); if (j) { unsigned long long f = 12084505273LL; c(&f); } }
};
struct x { G<H> ah; x(int); void y() { ah.ae(); } } g(0);
void aj() { g.y(); }

Comment 2 Marek Polacek 2021-05-07 16:20:44 UTC
This will be fixed next week by a new GCC 8.4.1 tarball.

Comment 3 Jakub Jelinek 2021-05-07 17:43:07 UTC
8.5.0 tarball ;)

Fixed upstream now: https://gcc.gnu.org/r8-10959-g3488242b9a949ebc55b4a857380f94506f90ff76

Comment 7 errata-xmlrpc 2021-11-09 19:35:43 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 (Low: gcc security and bug fix 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/RHSA-2021:4386