Author: Nikita Popov Date: 2023-06-08T16:39:57+02:00 New Revision: 32791f19fd354f58aea9114b6c56301966bdd802
URL: https://github.com/llvm/llvm-project/commit/32791f19fd354f58aea9114b6c56301966bdd802 DIFF: https://github.com/llvm/llvm-project/commit/32791f19fd354f58aea9114b6c56301966bdd802.diff LOG: [Clang] Convert some tests to opaque pointers (NFC) These tests all require some adjustments to make sure that struct types still get generated, mostly done by stripping pointer indirections. Some of this may no longer test the situation it was originally intended for, e.g. the issue from pr18962 just doesn't really exist anymore with opaque pointers, as we no longer generate recursive types. Added: Modified: clang/test/CodeGenCXX/class-layout.cpp clang/test/CodeGenCXX/member-data-pointers.cpp clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp clang/test/CodeGenCXX/pr18962.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGenCXX/class-layout.cpp b/clang/test/CodeGenCXX/class-layout.cpp index 22f38540a5670..9e2e9cd74c70f 100644 --- a/clang/test/CodeGenCXX/class-layout.cpp +++ b/clang/test/CodeGenCXX/class-layout.cpp @@ -1,21 +1,21 @@ -// RUN: %clang_cc1 -no-opaque-pointers %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s // An extra byte should be allocated for an empty class. namespace Test1 { // CHECK: %"struct.Test1::A" = type { i8 } - struct A { } *a; + struct A { } a; } namespace Test2 { // No need to add tail padding here. - // CHECK: %"struct.Test2::A" = type { i8*, i32 } - struct A { void *a; int b; } *a; + // CHECK: %"struct.Test2::A" = type { ptr, i32 } + struct A { void *a; int b; } a; } namespace Test3 { // C should have a vtable pointer. - // CHECK: %"struct.Test3::A" = type <{ i32 (...)**, i32, [4 x i8] }> - struct A { virtual void f(); int a; } *a; + // CHECK: %"struct.Test3::A" = type <{ ptr, i32, [4 x i8] }> + struct A { virtual void f(); int a; } a; } namespace Test4 { @@ -30,7 +30,7 @@ namespace Test4 { struct B : public A { short d; double e; - } *b; + } b; } namespace Test5 { @@ -43,7 +43,7 @@ namespace Test5 { struct B : A { char b : 1; char c; - } *b; + } b; } // PR10912: don't crash @@ -83,12 +83,12 @@ namespace Test6 { namespace Test7 { #pragma pack (1) class A {}; - // CHECK: %"class.Test7::B" = type <{ i32 (...)**, %"class.Test7::A" }> + // CHECK: %"class.Test7::B" = type <{ ptr, %"class.Test7::A" }> class B { virtual ~B(); A a; }; - B* b; + B test(B b) { return b; } #pragma pack () } diff --git a/clang/test/CodeGenCXX/member-data-pointers.cpp b/clang/test/CodeGenCXX/member-data-pointers.cpp index 22cc1016fa7f1..8b4e8d2797072 100644 --- a/clang/test/CodeGenCXX/member-data-pointers.cpp +++ b/clang/test/CodeGenCXX/member-data-pointers.cpp @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s -// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s struct A; typedef int A::*param_t; struct { const char *name; param_t par; -} *ptr; +} ptr; void test_ptr() { (void) ptr; } // forced use -// GLOBAL-LP64: type { i8*, i64 } -// GLOBAL-LP32: type { i8*, i32 } +// GLOBAL-LP64: type { ptr, i64 } +// GLOBAL-LP32: type { ptr, i32 } diff --git a/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp b/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp index d64fc60d15f99..2d218e2aab10d 100644 --- a/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp +++ b/clang/test/CodeGenCXX/microsoft-inaccessible-base.cpp @@ -1,20 +1,25 @@ -// RUN: %clang_cc1 -no-opaque-pointers -fms-compatibility -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -fms-compatibility -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s // Make sure we choose the *direct* base path when doing these conversions. -// CHECK: %struct.C = type { %struct.A, %struct.B } -// CHECK: %struct.D = type { %struct.B, %struct.A } - struct A { int a; }; struct B : A { int b; }; struct C : A, B { }; extern "C" A *a_from_c(C *p) { return p; } -// CHECK-LABEL: define dso_local %struct.A* @a_from_c(%struct.C* noundef %{{.*}}) -// CHECK: bitcast %struct.C* %{{.*}} to %struct.A* +// CHECK-LABEL: define dso_local ptr @a_from_c(ptr noundef %{{.*}}) +// CHECK: [[P_ADDR:%.*]] = alloca ptr +// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]] +// CHECK-NEXT: [[RET:%.*]] = load ptr, ptr [[P_ADDR]] +// CHECK-NEXT: ret ptr [[RET]] struct D : B, A { }; extern "C" A *a_from_d(D *p) { return p; } -// CHECK-LABEL: define dso_local %struct.A* @a_from_d(%struct.D* noundef %{{.*}}) -// CHECK: %[[p_i8:[^ ]*]] = bitcast %struct.D* %{{.*}} to i8* -// CHECK: getelementptr inbounds i8, i8* %[[p_i8]], i64 8 +// CHECK-LABEL: define dso_local ptr @a_from_d(ptr noundef %{{.*}}) +// CHECK: [[P_ADDR:%.*]] = alloca ptr +// CHECK-NEXT: store ptr [[P:%.*]], ptr [[P_ADDR]] +// CHECK-NEXT: [[P_RELOAD:%.*]] = load ptr, ptr [[P_ADDR]] +// CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P_RELOAD]], null +// CHECK: [[ADD_PTR:%.*]] = getelementptr inbounds i8, ptr [[P_RELOAD]], i64 8 +// CHECK: [[RET:%.*]] = phi ptr [ [[ADD_PTR]], {{.*}} ], [ null, %entry ] +// CHECK-NEXT: ret ptr [[RET]] diff --git a/clang/test/CodeGenCXX/pr18962.cpp b/clang/test/CodeGenCXX/pr18962.cpp index df85cfb71c833..b564a7b9a73af 100644 --- a/clang/test/CodeGenCXX/pr18962.cpp +++ b/clang/test/CodeGenCXX/pr18962.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -no-opaque-pointers -triple i686-linux-gnu %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple i686-linux-gnu %s -emit-llvm -o - | FileCheck %s class A { // append has to have the same prototype as fn1 to tickle the bug. @@ -17,16 +17,13 @@ class C { }; class D : C {}; -void fn1(A *p1) { -} - -void -fn2(C *) { -} +A p1; +C p2; +D p3; // We end up using an opaque type for 'append' to avoid circular references. -// CHECK: %class.A = type { {}* } -// CHECK: %class.C = type <{ %class.D*, %class.B, [3 x i8] }> -// CHECK: %class.D = type { %class.C.base, [3 x i8] } -// CHECK: %class.C.base = type <{ %class.D*, %class.B }> +// CHECK: %class.A = type { ptr } +// CHECK: %class.C = type <{ ptr, %class.B, [3 x i8] }> // CHECK: %class.B = type { i8 } +// CHECK: %class.D = type { %class.C.base, [3 x i8] } +// CHECK: %class.C.base = type <{ ptr, %class.B }> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits