Skip to content

Commit

Permalink
Opaque Pointers: codegen/static_array_init.d (ldc-developers#4218)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator authored Sep 23, 2022
1 parent bf7659c commit 5d2bbcb
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions tests/codegen/static_array_init.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ void bytes_scalar()

// CHECK: define {{.*}}_D17static_array_init12bytes_scalarFZv
// CHECK-NEXT: %myBytes = alloca [32 x i8], align 1
// CHECK-NEXT: %1 = bitcast [32 x i8]* %myBytes to i8*
// CHECK-NEXT: call void @llvm.memset{{.*}}(i8*{{[a-z0-9 ]*}} %1, i8 123, i{{(32|64)}} 32
// CHECK: call void @llvm.memset{{.*}}({{i8\*|ptr}}{{[a-z0-9 ]*}} {{%.*}}, i8 123, i{{(32|64)}} 32
}

void bytes_scalar(byte arg)
Expand All @@ -18,10 +17,9 @@ void bytes_scalar(byte arg)
// CHECK: define {{.*}}_D17static_array_init12bytes_scalarFgZv
// CHECK-NEXT: %arg = alloca i8, align 1
// CHECK-NEXT: %myBytes = alloca [32 x i8], align 1
// CHECK-NEXT: store i8 %arg_arg, i8* %arg
// CHECK-NEXT: %1 = bitcast [32 x i8]* %myBytes to i8*
// CHECK-NEXT: %2 = load {{.*}}i8* %arg
// CHECK-NEXT: call void @llvm.memset{{.*}}(i8*{{[a-z0-9 ]*}} %1, i8 %2, i{{(32|64)}} 32
// CHECK-NEXT: store i8 %arg_arg, {{i8\*|ptr}} %arg
// CHECK: {{%.}} = load {{.*}}{{i8\*|ptr}} %arg
// CHECK-NEXT: call void @llvm.memset{{.*}}({{i8\*|ptr}}{{[a-z0-9 ]*}} {{%.*}}, i8 {{%.}}, i{{(32|64)}} 32
}

void ints_scalar()
Expand All @@ -30,9 +28,9 @@ void ints_scalar()

// CHECK: define {{.*}}_D17static_array_init11ints_scalarFZv
// CHECK: arrayinit.cond:
// CHECK-NEXT: %[[I1:[0-9]+]] = load {{.*i(32|64)}}* %arrayinit.itr
// CHECK-NEXT: %[[I1:[0-9]+]] = load {{.*}}{{i(32|64)\*|ptr}} %arrayinit.itr
// CHECK-NEXT: %arrayinit.condition = icmp ne i{{(32|64)}} %[[I1]], 32
// CHECK: store i32 123, i32* %arrayinit.arrayelem
// CHECK: store i32 123, {{i32\*|ptr}} %arrayinit.arrayelem
}

void ints_scalar(int arg)
Expand All @@ -41,10 +39,10 @@ void ints_scalar(int arg)

// CHECK: define {{.*}}_D17static_array_init11ints_scalarFiZv
// CHECK: arrayinit.cond:
// CHECK-NEXT: %[[I2:[0-9]+]] = load {{.*i(32|64)}}* %arrayinit.itr
// CHECK-NEXT: %[[I2:[0-9]+]] = load {{.*}}{{i(32|64)\*|ptr}} %arrayinit.itr
// CHECK-NEXT: %arrayinit.condition = icmp ne i{{(32|64)}} %[[I2]], 32
// CHECK: %[[E2:[0-9]+]] = load {{.*}}i32* %arg
// CHECK-NEXT: store i32 %[[E2]], i32* %arrayinit.arrayelem
// CHECK: %[[E2:[0-9]+]] = load {{.*}}{{i32\*|ptr}} %arg
// CHECK-NEXT: store i32 %[[E2]], {{i32\*|ptr}} %arrayinit.arrayelem
}

void bytes()
Expand All @@ -53,7 +51,7 @@ void bytes()

// CHECK: define {{.*}}_D17static_array_init5bytesFZv
// CHECK-NEXT: %myBytes = alloca [4 x i8], align 1
// CHECK-NEXT: store [4 x i8] c"\01\02\03\04", [4 x i8]* %myBytes
// CHECK-NEXT: store [4 x i8] c"\01\02\03\04", {{\[4 x i8\]\*|ptr}} %myBytes
}

void bytes(byte[] arg)
Expand All @@ -62,8 +60,7 @@ void bytes(byte[] arg)

// CHECK: define {{.*}}_D17static_array_init5bytesFAgZv
// CHECK: %myBytes = alloca [4 x i8], align 1
// CHECK: %1 = bitcast [4 x i8]* %myBytes to i8*
// CHECK: call void @llvm.memcpy{{.*}}(i8*{{[a-z0-9 ]*}} %1, i8*{{[a-z0-9 ]*}} %.ptr, i{{(32|64)}} 4
// CHECK: call void @llvm.memcpy{{.*}}({{(i8\*|ptr)[a-z0-9 ]*}} %{{.*}}, {{(i8\*|ptr)[a-z0-9 ]*}} %.ptr, i{{(32|64)}} 4
}

void ints()
Expand All @@ -72,7 +69,7 @@ void ints()

// CHECK: define {{.*}}_D17static_array_init4intsFZv
// CHECK-NEXT: %myInts = alloca [4 x i32], align 4
// CHECK-NEXT: store [4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32]* %myInts
// CHECK-NEXT: store [4 x i32] [i32 1, i32 2, i32 3, i32 4], {{\[4 x i32\]\*|ptr}} %myInts
}

void ints(ref int[4] arg)
Expand All @@ -81,11 +78,7 @@ void ints(ref int[4] arg)

// CHECK: define {{.*}}_D17static_array_init4intsFKG4iZv
// CHECK-NEXT: %myInts = alloca [4 x i32], align 4
// CHECK-NEXT: %1 = bitcast [4 x i32]* %myInts to i32*
// CHECK-NEXT: %2 = bitcast i32* %1 to i8*
// CHECK-NEXT: %3 = bitcast [4 x i32]* %arg to i32*
// CHECK-NEXT: %4 = bitcast i32* %3 to i8*
// CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8*{{[a-z0-9 ]*}} %2, i8*{{[a-z0-9 ]*}} %4, i{{(32|64)}} 16
// CHECK: call void @llvm.memcpy{{.*}}({{(i8\*|ptr)[a-z0-9 ]*}} %{{.*}}, {{(i8\*|ptr)[a-z0-9 ]*}} %{{.*}}, i{{(32|64)}} 16
}

void bytes_scalar_2d()
Expand All @@ -94,9 +87,7 @@ void bytes_scalar_2d()

// CHECK: define {{.*}}_D17static_array_init15bytes_scalar_2dFZv
// CHECK-NEXT: %myBytes = alloca [8 x [4 x i8]], align 1
// CHECK-NEXT: %1 = bitcast [8 x [4 x i8]]* %myBytes to [32 x i8]*
// CHECK-NEXT: %2 = bitcast [32 x i8]* %1 to i8*
// CHECK-NEXT: call void @llvm.memset{{.*}}(i8*{{[a-z0-9 ]*}} %2, i8 123, i{{(32|64)}} 32
// CHECK: call void @llvm.memset{{.*}}({{(i8\*|ptr)[a-z0-9 ]*}} %{{.*}}, i8 123, i{{(32|64)}} 32
}

void ints_scalar_2d(immutable int arg)
Expand All @@ -105,8 +96,8 @@ void ints_scalar_2d(immutable int arg)

// CHECK: define {{.*}}_D17static_array_init14ints_scalar_2dFyiZv
// CHECK: arrayinit.cond:
// CHECK-NEXT: %[[I3:[0-9]+]] = load {{.*i(32|64)}}* %arrayinit.itr
// CHECK-NEXT: %[[I3:[0-9]+]] = load {{.*}}{{i(32|64)\*|ptr}} %arrayinit.itr
// CHECK-NEXT: %arrayinit.condition = icmp ne i{{(32|64)}} %[[I3]], 32
// CHECK: %[[E3:[0-9]+]] = load {{.*}}i32* %arg
// CHECK-NEXT: store i32 %[[E3]], i32* %arrayinit.arrayelem
// CHECK: %[[E3:[0-9]+]] = load {{.*}}{{i32\*|ptr}} %arg
// CHECK-NEXT: store i32 %[[E3]], {{i32\*|ptr}} %arrayinit.arrayelem
}

0 comments on commit 5d2bbcb

Please sign in to comment.