From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1123A385DC26; Wed, 26 May 2021 21:12:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1123A385DC26 From: "tlwang at uwaterloo dot ca" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/100781] New: Emitted binary code changes when -g is enabled at -O2 Date: Wed, 26 May 2021 21:12:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tlwang at uwaterloo dot ca 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 target_milestone 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, 26 May 2021 21:12:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100781 Bug ID: 100781 Summary: Emitted binary code changes when -g is enabled at -O2 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tlwang at uwaterloo dot ca Target Milestone: --- The .text section for the following program (transformed_program0.c) changes after toggling the -g flag.=20 $ cat transformed_program0.c struct a { int b; }; long c(short d, long e, struct a f) { g:; int h =3D f.b <=3D e, i =3D d, n =3D h >=3D d; if (!n) goto j; goto k; j:; long l =3D 5; if (l) goto m; d =3D 0; m: if (d) return f.b; k: goto g; } int main() {} $ $ gcc-trunk -v Using built-in specs. COLLECT_GCC=3Dgcc-trunk COLLECT_LTO_WRAPPER=3D/scratch/software/gcc-trunk/libexec/gcc/x86_64-pc-lin= ux-gnu/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /tmp/tmp.tVhv2eaPzV-gcc-builder/gcc/configure --enable-languages=3Dc,c++,lto --enable-checking-yes --enable-multiarch --prefix=3D/scratch/software/gcc-trunk --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210526 (experimental) [master revision :21638bbbf:1fd76b24306ed4df4cf9e797d900699ed59ce7f7] (GCC) $ $ gcc-trunk transformed_program0.c -O2 -w ; objdump --disassemble a.out > "no-g.txt" $ gcc-trunk transformed_program0.c -O2 -w -g; objdump --disassemble a.out > "g.txt" $ diff no-g.txt g.txt 108,111c108,111 < 401125: 89 f9 mov %edi,%ecx < 401127: 0f bf ff movswl %di,%edi < 40112a: 49 39 f0 cmp %rsi,%r8 < 40112d: 0f 9e c0 setle %al --- > 401125: 0f bf ff movswl %di,%edi > 401128: 4c 39 c6 cmp %r8,%rsi > 40112b: 0f 9d c0 setge %al > 40112e: 66 90 xchg %ax,%ax 114,118c114,117 < 401134: 66 85 c9 test %cx,%cx < 401137: 74 f7 je 401130 < 401139: 4c 89 c0 mov %r8,%rax < 40113c: c3 retq < 40113d: 0f 1f 00 nopl (%rax) --- > 401134: 4c 89 c0 mov %r8,%rax > 401137: c3 retq > 401138: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) > 40113f: 00=