public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/97682] New: Miscompiled tail call with -fPIC
@ 2020-11-02 21:53 schwab@linux-m68k.org
  2020-11-02 22:08 ` [Bug target/97682] " schwab@linux-m68k.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2020-11-02 21:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97682

            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=49488&action=edit
BlockFrequencyInfo.ii

When the attached file is compiled with -fPIC -O3, the tail call to
std::vector<llvm::BlockFrequencyInfoImplBase::FrequencyData,
std::allocator<llvm::BlockFrequencyInfoImplBase::FrequencyData>
>::_M_default_append(unsigned long) is missing in
llvm::BlockFrequencyInfoImpl<llvm::BasicBlock>::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_size
- size());
        addi    a0,s2,8 #,, this
        ld      s2,352(sp)              #,
# /usr/include/c++/10/bits/stl_vector.h:940:      _M_default_append(__new_size
- size());
        sub     a1,a5,a1        #, _680, tmp1548
        addi    sp,sp,384       #,,
# /usr/include/c++/10/bits/stl_vector.h:940:      _M_default_append(__new_size
- size());
        jr      t1              #

Without -fPIC, the last line has the correct tail call:

        tail   
_ZNSt6vectorIN4llvm26BlockFrequencyInfoImplBase13FrequencyDataESaIS2_EE17_M_default_appendEm
           #

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-17  9:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02 21:53 [Bug target/97682] New: Miscompiled tail call with -fPIC schwab@linux-m68k.org
2020-11-02 22:08 ` [Bug target/97682] " schwab@linux-m68k.org
2020-11-02 23:15 ` schwab@linux-m68k.org
2020-11-03  7:25 ` kito at gcc dot gnu.org
2020-11-14  4:05 ` cvs-commit at gcc dot gnu.org
2020-11-17  3:53 ` cvs-commit at gcc dot gnu.org
2020-11-17  9:30 ` cvs-commit at gcc dot gnu.org
2020-11-17  9:59 ` kito at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).