From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22D97385800D; Fri, 5 Mar 2021 00:00:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22D97385800D From: "zhendong.su at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/99373] unused static function not being removed in some cases after optimization Date: Fri, 05 Mar 2021 00:00:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: zhendong.su at inf dot ethz.ch X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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: Fri, 05 Mar 2021 00:00:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99373 --- Comment #2 from Zhendong Su --- The following might be the same/related. The dead call is eliminated if b is changed to: static int b(int *c) { foo(); d++; } [623] % gcctk -O3 -S small.c [624] % [624] % cat small.c extern void foo(void); static int a, d; static int b(int *c) { while (1) { foo(); d++; } } int main () { a && b(&a); return 0; } [625] % [625] % cat small.s .file "small.c" .text .section .text.startup,"ax",@progbits .p2align 4 .globl main .type main, @function main: .LFB1:=20=20 .cfi_startproc movl a(%rip), %edx testl %edx, %edx jne .L7 xorl %eax, %eax ret .L7: pushq %rax .cfi_def_cfa_offset 16 .L3: call foo addl $1, d(%rip) jmp .L3 .cfi_endproc .LFE1:=20=20 .size main, .-main .local d .comm d,4,4 .local a .comm a,4,4 .ident "GCC: (GNU) 11.0.1 20210304 (experimental) [master revision cdfc2f6a6dc:ab3cea6cccd:f3641ac70eb0ae9f8983b7ddb1660c92439565de]" .section .note.GNU-stack,"",@progbits=