From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BDCC38708F9; Sat, 20 Jun 2020 16:28:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BDCC38708F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592670519; bh=ABpyn3FHO8YqatSI9LH2KoIBA1+m/HLTmsVB3/ihMZQ=; h=From:To:Subject:Date:From; b=O09VslNyJzvhXyp0GdkmuA/UBqLvuQ6AXwsHnYHef/2nzvZ2ZaiFuyLCPeXWzll06 ktSN/sd8NgrUj4cLcos4Th6a6zWIxM7qQi4n+UFkc4zJdK4A42esBCq9WfAU2/113Q ZMm64X76wW8YldwciW3g0iXOO9L88MMr8QBqW/IQ= From: "yyc1992 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95786] New: Too aggressive target indirection elimination Date: Sat, 20 Jun 2020 16:28:38 +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: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yyc1992 at gmail dot com 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: Sat, 20 Jun 2020 16:28:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95786 Bug ID: 95786 Summary: Too aggressive target indirection elimination Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: yyc1992 at gmail dot com Target Milestone: --- I realize this issue when debugging PR95778 and PR95780 (ref https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548631.html) It seems that the indirection elimination logic does not take into account = the linkage and visibility of the callee and will eliminate the indirection eve= n in cases where a function without target attribute would have use a PLT and, f= or example, allows a override from a different library. The following code generates a direct call beween g2 and f2 without going through PLT. ``` __attribute__((target_clones("default,avx2"))) int f2(int *p) { asm volatile ("" :: "r"(p) : "memory"); return *p; } __attribute__((target_clones("default,avx2"))) int g2(int *p) { return f2(p); } ``` but removing the target_clones attribute uses the PLT.=