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: sch...@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 #