From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E51C6385801D; Mon, 2 Nov 2020 21:53:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E51C6385801D From: "schwab@linux-m68k.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97682] New: Miscompiled tail call with -fPIC Date: Mon, 02 Nov 2020 21:53:36 +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.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: schwab@linux-m68k.org 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget attachments.created 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: Mon, 02 Nov 2020 21:53:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97682 Bug ID: 97682 Summary: Miscompiled tail call with -fPIC Product: gcc Version: 10.2.1 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: schwab@linux-m68k.org Target Milestone: --- Target: riscv64-*-* Created attachment 49488 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49488&action=3Dedit BlockFrequencyInfo.ii When the attached file is compiled with -fPIC -O3, the tail call to std::vector >::_M_default_append(unsigned long) is missing in llvm::BlockFrequencyInfoImpl::initializeRPOT(): .L2924: li t1,4096 #, add sp,sp,t1 #,, ld ra,376(sp) #, ld s0,368(sp) #, ld s1,360(sp) #, ld s3,344(sp) #, ld s4,336(sp) #, ld s5,328(sp) #, ld s6,320(sp) #, ld s7,312(sp) #, ld s8,304(sp) #, ld s9,296(sp) #, ld s10,288(sp) #, ld s11,280(sp) #, # /usr/include/c++/10/bits/stl_vector.h:940: _M_default_append(__new_s= ize - size()); addi a0,s2,8 #,, this ld s2,352(sp) #, # /usr/include/c++/10/bits/stl_vector.h:940: _M_default_append(__new_s= ize - size()); sub a1,a5,a1 #, _680, tmp1548 addi sp,sp,384 #,, # /usr/include/c++/10/bits/stl_vector.h:940: _M_default_append(__new_s= ize - size()); jr t1 # Without -fPIC, the last line has the correct tail call: tail=20=20=20 _ZNSt6vectorIN4llvm26BlockFrequencyInfoImplBase13FrequencyDataESaIS2_EE17_M= _default_appendEm #=