From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83AC1386102E; Wed, 1 Jul 2020 07:29:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83AC1386102E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593588590; bh=8M2wIhaFUWfqUFEAqC8ela4bt7qUpw3qhJDQSyEex+I=; h=From:To:Subject:Date:From; b=xGralDAYkBMYBd/bStFvLy5jTcjNk86oyHGJIKSeXvh4sG1pDrgALBL1ppSKCRyGx 4GJG3xRa/dImYTitiGEBBZCS3RR7F/Rv5hS5agX2kuDTU+wM+IvlEes5XwI9bzHUs9 rEInvX0gLlaQ1N3/Ij4OZhXUey8pPHUhssR7l2t8= From: "slyfox at inbox dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96015] New: [regression] gcc-10.1.0 miscompiles Python on hppa Date: Wed, 01 Jul 2020 07:29:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at inbox dot ru X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jul 2020 07:29:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96015 Bug ID: 96015 Summary: [regression] gcc-10.1.0 miscompiles Python on hppa Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at inbox dot ru CC: dave.anglin at bell dot net, law at redhat dot com Target Milestone: --- Target: hppa2.0-unknown-linux-gnu Originally reported as https://bugs.gentoo.org/729570 where gcc-10.1.0 miscompiles Python into generating invalid bytecode. I shrunk Python's code into single file that illustrates the problem: // $ cat bug_test.c /* The test is extracted from Python-3.9.0 miscompilation on hppa2.0: https://bugs.gentoo.org/729570 Original bug happens as an invalid bytecode generation due to bad results from 'long_richcompare(0xFFFFffff, 1, EQ)' calls. Failure example: $ hppa2.0-unknown-linux-gnu-gcc -lm -Wsign-compare -Wall -O1 bug_test.c -o good-bug $ hppa2.0-unknown-linux-gnu-gcc -lm -Wsign-compare -Wall -O2 bug_test.c -o bad-bug $ ./good-bug long_richcompare(2, 1, EQ) =3D FALSE (expect FALSE) $ ./bad-bug long_richcompare(2, 1, EQ) =3D TRUE (expect FALSE) */ // We use '__attribute__((noipa));' aggressively to simulate // unavailable function definitions from outside translation units. static int cmp(int *lhs, int *rhs) { int sign =3D *lhs - *rhs; // semantically this should be 'return 0;' but this condition is not // supposed to trigger on our input data. if (sign =3D=3D 0) return 1; return sign; } static int yes(void) __attribute__((noipa)); static int yes(void) { return 1; } static int long_richcompare(int *self, int *other, int op) __attribute__((noipa)); static int long_richcompare(int *self, int *other, int op) { int result; if (!yes() || !yes()) return 0; if (self =3D=3D other) result =3D 0; else result =3D cmp(self, other); // has to force jump table switch (op) { // only 0 case is used on actual data case 0: return (result =3D=3D 0); case 1: return 0; case 3: return 0; case 5: if (result =3D=3D 0) return 1; else return 0; default: __builtin_unreachable(); } } #include int main() { int l =3D 2; int r =3D 1; int res =3D long_richcompare(&l, &r, 0); printf("long_richcompare(2, 1, EQ) =3D %s (expect FALSE)\n", res ? "TRU= E" : "FALSE"); }=