This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65143] [C++11] missing devirtualization for virtual base in "final" classes
- From: "maltsevm at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 15 Mar 2015 06:45:20 +0000
- Subject: [Bug c++/65143] [C++11] missing devirtualization for virtual base in "final" classes
- Auto-submitted: auto-generated
- References: <bug-65143-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65143
Mikhail Maltsev <maltsevm at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maltsevm at gmail dot com
--- Comment #3 from Mikhail Maltsev <maltsevm at gmail dot com> ---
This optimization is still missing in current trunk:
$ cat ./test.cc
struct A
{
int j;
};
struct B : public virtual A
{
};
struct C final : public B
{
int get();
};
int C::get()
{
return A::j;
}
$ /opt/gcc-5.0.0/bin/g++ -O -std=c++11 -c -S ./test.cc -o test_gcc.s && cat
./test_gcc.s
.file "test.cc"
.text
.align 2
.globl _ZN1C3getEv
.type _ZN1C3getEv, @function
_ZN1C3getEv:
.LFB0:
.cfi_startproc
movq (%rdi), %rax
movq -24(%rax), %rax
movl (%rdi,%rax), %eax
ret
.cfi_endproc
.LFE0:
.size _ZN1C3getEv, .-_ZN1C3getEv
.ident "GCC: (GNU) 5.0.0 20150315 (experimental)"
.section .note.GNU-stack,"",@progbits
(Note: optimization flags like -O3 and -fdevirtualize-speculatively don't
affect this behavior; neither method calls nor data member accesses get
devirtualized)
$ clang++ -O -std=c++11 -c -S ./test.cc -o test_clang.s && cat ./test_clang.s
.text
.file "./test.cc"
.globl _ZN1C3getEv
.align 16, 0x90
.type _ZN1C3getEv,@function
_ZN1C3getEv: # @_ZN1C3getEv
.cfi_startproc
# BB#0: # %entry
movl 8(%rdi), %eax
retq
.Ltmp0:
.size _ZN1C3getEv, .Ltmp0-_ZN1C3getEv
.cfi_endproc
.ident "clang version 3.7.0 (trunk 228487)"
.section ".note.GNU-stack","",@progbits
So, I can confirm it in sense "reproduce" (I don't have a right to change the
status of PR)