-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
4 changed files
with
37 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters