From patchwork Mon Nov 30 14:02:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1408290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cl6PQ51Njz9sSs for ; Tue, 1 Dec 2020 01:02:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A83D0389200F; Mon, 30 Nov 2020 14:02:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id EEC86388CC19 for ; Mon, 30 Nov 2020 14:02:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EEC86388CC19 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C1740ACC4 for ; Mon, 30 Nov 2020 14:02:23 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] testsuite: remove LIT annotation and reduce To: gcc-patches@gcc.gnu.org Message-ID: Date: Mon, 30 Nov 2020 15:02:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" I noticed the test-case contains LIT annotation and it is possible to reduce. I did that with compiler that was affected by the PR. Ready for master? Tahnks, Martin gcc/testsuite/ChangeLog: * g++.dg/torture/pr93347.C: Reduce and remove LIT keywords. --- gcc/testsuite/g++.dg/torture/pr93347.C | 320 ++----------------------- 1 file changed, 17 insertions(+), 303 deletions(-) diff --git a/gcc/testsuite/g++.dg/torture/pr93347.C b/gcc/testsuite/g++.dg/torture/pr93347.C index 3b5cc265a1a..6e3b1af25f1 100644 --- a/gcc/testsuite/g++.dg/torture/pr93347.C +++ b/gcc/testsuite/g++.dg/torture/pr93347.C @@ -1,306 +1,20 @@ // { dg-additional-options "--param early-inlining-insns=3 --param ipa-cp-eval-threshold=100" } -namespace Test1 { - struct A { - virtual int f() final; - }; - // CHECK-LABEL: define i32 @_ZN5Test11fEPNS_1AE - int f(A *a) { - // CHECK: call i32 @_ZN5Test11A1fEv - return a->f(); - } -} - -namespace Test2 { - struct A final { - virtual int f(); - }; - - // CHECK-LABEL: define i32 @_ZN5Test21fEPNS_1AE - int f(A *a) { - // CHECK: call i32 @_ZN5Test21A1fEv - return a->f(); - } -} - -namespace Test2a { - struct A { - virtual ~A() final {} - virtual int f(); - }; - - // CHECK-LABEL: define i32 @_ZN6Test2a1fEPNS_1AE - int f(A *a) { - // CHECK: call i32 @_ZN6Test2a1A1fEv - return a->f(); - } -} - - -namespace Test3 { - struct A { - virtual int f(); }; - - struct B final : A { }; - - // CHECK-LABEL: define i32 @_ZN5Test31fEPNS_1BE - int f(B *b) { - // CHECK: call i32 @_ZN5Test31A1fEv - return b->f(); - } - - // CHECK-LABEL: define i32 @_ZN5Test31fERNS_1BE - int f(B &b) { - // CHECK: call i32 @_ZN5Test31A1fEv - return b.f(); - } - - // CHECK-LABEL: define i32 @_ZN5Test31fEPv - int f(void *v) { - // CHECK: call i32 @_ZN5Test31A1fEv - return static_cast(v)->f(); - } -} - -namespace Test4 { - struct A { - virtual void f(); - virtual int operator-(); - }; - - struct B final : A { - virtual void f(); - virtual int operator-(); - }; - - // CHECK-LABEL: define void @_ZN5Test41fEPNS_1BE - void f(B* d) { - // CHECK: call void @_ZN5Test41B1fEv - static_cast(d)->f(); - // CHECK: call i32 @_ZN5Test41BngEv - -static_cast(*d); - } -} - -namespace Test5 { - struct A { - virtual void f(); - virtual int operator-(); - }; - - struct B : A { - virtual void f(); - virtual int operator-(); - }; - - struct C final : B { - }; - - // CHECK-LABEL: define void @_ZN5Test51fEPNS_1CE - void f(C* d) { - // FIXME: It should be possible to devirtualize this case, but that is - // not implemented yet. - // CHECK: getelementptr - // CHECK-NEXT: %[[FUNC:.*]] = load - // CHECK-NEXT: call void %[[FUNC]] - static_cast(d)->f(); - } - // CHECK-LABEL: define void @_ZN5Test53fopEPNS_1CE - void fop(C* d) { - // FIXME: It should be possible to devirtualize this case, but that is - // not implemented yet. - // CHECK: getelementptr - // CHECK-NEXT: %[[FUNC:.*]] = load - // CHECK-NEXT: call i32 %[[FUNC]] - -static_cast(*d); - } -} - -namespace Test6 { - struct A { - virtual ~A(); - }; - - struct B : public A { - virtual ~B(); - }; - - struct C { - virtual ~C(); - }; - - struct D final : public C, public B { - }; - - // CHECK-LABEL: define void @_ZN5Test61fEPNS_1DE - void f(D* d) { - // CHECK: call void @_ZN5Test61DD1Ev - static_cast(d)->~A(); - } -} - -namespace Test7 { - struct foo { - virtual void g() {} - }; - - struct bar { - virtual int f() { return 0; } - }; - - struct zed final : public foo, public bar { - int z; - virtual int f() {return z;} - }; - - // CHECK-LABEL: define i32 @_ZN5Test71fEPNS_3zedE - int f(zed *z) { - // CHECK: alloca - // CHECK-NEXT: store - // CHECK-NEXT: load - // CHECK-NEXT: call i32 @_ZN5Test73zed1fEv - // CHECK-NEXT: ret - return static_cast(z)->f(); - } -} - -namespace Test8 { - struct A { virtual ~A() {} }; - struct B { - int b; - virtual int foo() { return b; } - }; - struct C final : A, B { }; - // CHECK-LABEL: define i32 @_ZN5Test84testEPNS_1CE - int test(C *c) { - // CHECK: %[[THIS:.*]] = phi - // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]]) - return static_cast(c)->foo(); - } -} - -namespace Test9 { - struct A { - int a; - }; - struct B { - int b; - }; - struct C : public B, public A { - }; - struct RA { - virtual A *f() { - return 0; - } - virtual A *operator-() { - return 0; - } - }; - struct RC final : public RA { - virtual C *f() { - C *x = new C(); - x->a = 1; - x->b = 2; - return x; - } - virtual C *operator-() { - C *x = new C(); - x->a = 1; - x->b = 2; - return x; - } - }; - // CHECK: define {{.*}} @_ZN5Test91fEPNS_2RCE - A *f(RC *x) { - // FIXME: It should be possible to devirtualize this case, but that is - // not implemented yet. - // CHECK: load - // CHECK: bitcast - // CHECK: [[F_PTR_RA:%.+]] = bitcast - // CHECK: [[VTABLE:%.+]] = load {{.+}} [[F_PTR_RA]] - // CHECK: [[VFN:%.+]] = getelementptr inbounds {{.+}} [[VTABLE]], i{{[0-9]+}} 0 - // CHECK-NEXT: %[[FUNC:.*]] = load {{.+}} [[VFN]] - // CHECK-NEXT: = call {{.*}} %[[FUNC]] - return static_cast(x)->f(); - } - // CHECK: define {{.*}} @_ZN5Test93fopEPNS_2RCE - A *fop(RC *x) { - // FIXME: It should be possible to devirtualize this case, but that is - // not implemented yet. - // CHECK: load - // CHECK: bitcast - // CHECK: [[F_PTR_RA:%.+]] = bitcast - // CHECK: [[VTABLE:%.+]] = load {{.+}} [[F_PTR_RA]] - // CHECK: [[VFN:%.+]] = getelementptr inbounds {{.+}} [[VTABLE]], i{{[0-9]+}} 1 - // CHECK-NEXT: %[[FUNC:.*]] = load {{.+}} [[VFN]] - // CHECK-NEXT: = call {{.*}} %[[FUNC]] - return -static_cast(*x); - } -} - -namespace Test10 { - struct A { - virtual int f(); - }; - - struct B : A { - int f() final; - }; - - // CHECK-LABEL: define i32 @_ZN6Test101fEPNS_1BE - int f(B *b) { - // CHECK: call i32 @_ZN6Test101B1fEv - return static_cast(b)->f(); - } -} - -namespace Test11 { - // Check that the definitions of Derived's operators are emitted. - - // CHECK-LABEL: define linkonce_odr void @_ZN6Test111SIiE4foo1Ev( - // CHECK: call void @_ZN6Test111SIiE7DerivedclEv( - // CHECK: call zeroext i1 @_ZN6Test111SIiE7DerivedeqERKNS_4BaseE( - // CHECK: call zeroext i1 @_ZN6Test111SIiE7DerivedntEv( - // CHECK: call dereferenceable(4) %"class.Test11::Base"* @_ZN6Test111SIiE7DerivedixEi( - // CHECK: define linkonce_odr void @_ZN6Test111SIiE7DerivedclEv( - // CHECK: define linkonce_odr zeroext i1 @_ZN6Test111SIiE7DerivedeqERKNS_4BaseE( - // CHECK: define linkonce_odr zeroext i1 @_ZN6Test111SIiE7DerivedntEv( - // CHECK: define linkonce_odr dereferenceable(4) %"class.Test11::Base"* @_ZN6Test111SIiE7DerivedixEi( - class Base { - public: - virtual void operator()() {} - virtual bool operator==(const Base &other) { return false; } - virtual bool operator!() { return false; } - virtual Base &operator[](int i) { return *this; } - }; - - template - struct S { - class Derived final : public Base { - public: - void operator()() override {} - bool operator==(const Base &other) override { return true; } - bool operator!() override { return true; } - Base &operator[](int i) override { return *this; } - }; - - Derived *ptr = nullptr, *ptr2 = nullptr; - - void foo1() { - if (ptr && ptr2) { - // These calls get devirtualized. Linkage fails if the definitions of - // the called functions are not emitted. - (*ptr)(); - (void)(*ptr == *ptr2); - (void)(!(*ptr)); - (void)((*ptr)[1]); - } - } - }; - - void foo2() { - S *s = new S; - s->foo1(); - } -} +struct A { + int a; +}; +struct B { + int b; +}; +struct C : B, A {}; +struct RA { + virtual A *operator-(); +}; +struct RC : RA { + C *operator-() { + C *x = new C(); + return x; + } +}; +void fop(RC *x) { -static_cast(*x); }