C++ PATCH for lto/53808 (devirtualization of defaulted virtual dtor)

Andreas Schwab schwab@suse.de
Thu Feb 27 10:56:00 GMT 2014


Jason Merrill <jason@redhat.com> writes:

> diff --git a/gcc/testsuite/g++.dg/opt/devirt4.C b/gcc/testsuite/g++.dg/opt/devirt4.C
> new file mode 100644
> index 0000000..26e8ee6
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/opt/devirt4.C
> @@ -0,0 +1,16 @@
> +// PR c++/53808
> +// Devirtualization + inlining should produce a non-virtual
> +// call to ~foo.
> +// { dg-options "-O -fdevirtualize" }
> +// { dg-final { scan-assembler "_ZN3fooD2Ev" } }
> +
> +struct foo {
> + virtual ~foo();
> +};
> +struct bar : public foo {
> + virtual void zed();
> +};
> +void f() {
> + foo *x(new bar);
> + delete x;
> +}

$ gcc/xg++ -Bgcc/ ../gcc/testsuite/g++.dg/opt/devirt4.C -nostdinc++ -Iia64-suse-linux/libstdc++-v3/include/ia64-suse-linux -Iia64-suse-linux/libstdc++-v3/include -Ilibstdc++-v3/libsupc++ -I../libstdc++-v3/include/backward -I../libstdc++-v3/testsuite/util -std=gnu++11 -O -fdevirtualize -ffat-lto-objects -S -o devirt4.s
$ cat devirt4.s 
        .file   "devirt4.C"
        .pred.safe_across_calls p1-p5,p16-p63
        .sdata
        .align 8
.LC0:
        data8   _ZTV3bar#+16
        .align 8
.LC1:
        data8   _ZTV3bar#+32
        .text
        .align 16
        .global _Z1fv#
        .type   _Z1fv#, @function
        .proc _Z1fv#
_Z1fv:
[.LFB0:]
        .prologue 12, 32
        .save ar.pfs, r33
        alloc r33 = ar.pfs, 0, 3, 1, 0
        .save rp, r32
        mov r32 = b0
        mov r34 = r1
        .body
        addl r35 = 8, r0
        ;;
        br.call.sptk.many b0 = _Znwm#
        mov r1 = r34
        ;;
        addl r14 = @gprel(.LC0), gp
        ;;
        ld8 r14 = [r14]
        ;;
        st8 [r8] = r14
        cmp.eq p6, p7 = 0, r8
        (p6) br.cond.dpnt .L1
        mov r35 = r8
        addl r14 = @gprel(.LC1), gp
        ;;
        ld8 r14 = [r14]
        ;;
        ld8 r15 = [r14], 8
        ;;
        mov b6 = r15
        ld8 r1 = [r14]
        br.call.sptk.many b0 = b6
        ;;
        mov r1 = r34
.L1:
        mov ar.pfs = r33
        mov b0 = r32
        br.ret.sptk.many b0
        ;;
        .endp _Z1fv#
        .ident  "GCC: (GNU) 4.9.0 20140227 (experimental) [trunk revision 208194]"

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



More information about the Gcc-patches mailing list