forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More support to dynamic field - Sui framework compilation (#73)
* 061824-fixing-dynamic-fields: ini * 061824-fixing-dynamic-fields: cleanup in module_context.rs * 061824-fixing-dynamic-fields: dynamic-struct-example.move test added * 061824-fixing-dynamic-fields: renaming actual to expected in test * 062024-more-fixes-dynamic-struct: ini * 062024-more-fixes-dynamic-struct: fix Type::get_bitwidth
- Loading branch information
Showing
9 changed files
with
249 additions
and
17 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
77 changes: 77 additions & 0 deletions
77
...piler/tests/failure-tests/dynamic-struct-example-build/0x1__dynamic_structure.ll.expected
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
; ModuleID = '0x1__dynamic_structure' | ||
source_filename = "tests/failure-tests/dynamic-struct-example.move" | ||
target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" | ||
target triple = "sbf-solana-solana" | ||
|
||
%__move_rt_type = type { { ptr, i64 }, i64, ptr } | ||
%struct.dynamic_structure__Inner_u64.u64_ = type { i64, i64 } | ||
%struct.dynamic_structure__DynamicStruct_dynamic_structure__Inner_u64.u64__ = type { i64, %struct.dynamic_structure__Inner_u64.u64_ } | ||
|
||
@__move_rttydesc_signer = private unnamed_addr constant %__move_rt_type { { ptr, i64 } { ptr @__move_rttydesc_signer_name, i64 6 }, i64 9, ptr @__move_rttydesc_NOTHING_info } | ||
@__move_rttydesc_signer_name = private unnamed_addr constant [6 x i8] c"signer" | ||
@__move_rttydesc_NOTHING_info = private unnamed_addr constant i8 -1 | ||
|
||
declare i32 @memcmp(ptr, ptr, i64) | ||
|
||
define void @"0000000000000001_dynamic_structu_unit_test_poiso_EmvQWiAB3EnqkA"() { | ||
entry: | ||
%local_0 = alloca i64, align 8 | ||
%local_1 = alloca { ptr, i64, i64 }, align 8 | ||
store i64 0, ptr %local_0, align 8 | ||
%loaded_alloca = load i64, ptr %local_0, align 8 | ||
%retval = call { ptr, i64, i64 } @move_native_unit_test_create_signers_for_testing(i64 %loaded_alloca) | ||
store { ptr, i64, i64 } %retval, ptr %local_1, align 8 | ||
call void @move_rt_vec_destroy(ptr @__move_rttydesc_signer, ptr %local_1) | ||
ret void | ||
} | ||
|
||
declare { ptr, i64, i64 } @move_native_unit_test_create_signers_for_testing(i64) | ||
|
||
define void @"0000000000000001_dynamic_structu_test_fail_Fz3ntiKYooMYAv"() { | ||
entry: | ||
%local_0 = alloca i64, align 8 | ||
%local_1 = alloca i64, align 8 | ||
%local_2 = alloca i64, align 8 | ||
store i64 44, ptr %local_0, align 8 | ||
store i64 1, ptr %local_1, align 8 | ||
store i64 2, ptr %local_2, align 8 | ||
%call_arg_0 = load i64, ptr %local_0, align 8 | ||
%call_arg_1 = load i64, ptr %local_1, align 8 | ||
%call_arg_2 = load i64, ptr %local_2, align 8 | ||
call void @"0000000000000001_dynamic_structu_dynamic_struct_7V7jBxBPWFRsaZ"(i64 %call_arg_0, i64 %call_arg_1, i64 %call_arg_2) | ||
ret void | ||
} | ||
|
||
define private void @"0000000000000001_dynamic_structu_dynamic_struct_7V7jBxBPWFRsaZ"(i64 %0, i64 %1, i64 %2) { | ||
entry: | ||
%local_0 = alloca i64, align 8 | ||
%local_1 = alloca i64, align 8 | ||
%local_2 = alloca i64, align 8 | ||
%local_3__id = alloca i64, align 8 | ||
%local_4__key = alloca i64, align 8 | ||
%local_5__val = alloca i64, align 8 | ||
%local_6__s = alloca %struct.dynamic_structure__Inner_u64.u64_, align 8 | ||
%local_7 = alloca %struct.dynamic_structure__DynamicStruct_dynamic_structure__Inner_u64.u64__, align 8 | ||
store i64 %0, ptr %local_0, align 8 | ||
store i64 %1, ptr %local_1, align 8 | ||
store i64 %2, ptr %local_2, align 8 | ||
%load_store_tmp = load i64, ptr %local_0, align 8 | ||
store i64 %load_store_tmp, ptr %local_3__id, align 8 | ||
%load_store_tmp1 = load i64, ptr %local_1, align 8 | ||
store i64 %load_store_tmp1, ptr %local_4__key, align 8 | ||
%load_store_tmp2 = load i64, ptr %local_2, align 8 | ||
store i64 %load_store_tmp2, ptr %local_5__val, align 8 | ||
%fv.0 = load i64, ptr %local_4__key, align 8 | ||
%fv.1 = load i64, ptr %local_5__val, align 8 | ||
%insert_0 = insertvalue %struct.dynamic_structure__Inner_u64.u64_ undef, i64 %fv.0, 0 | ||
%insert_1 = insertvalue %struct.dynamic_structure__Inner_u64.u64_ %insert_0, i64 %fv.1, 1 | ||
store %struct.dynamic_structure__Inner_u64.u64_ %insert_1, ptr %local_6__s, align 8 | ||
%fv.03 = load i64, ptr %local_3__id, align 8 | ||
%fv.14 = load %struct.dynamic_structure__Inner_u64.u64_, ptr %local_6__s, align 8 | ||
%insert_05 = insertvalue %struct.dynamic_structure__DynamicStruct_dynamic_structure__Inner_u64.u64__ undef, i64 %fv.03, 0 | ||
%insert_16 = insertvalue %struct.dynamic_structure__DynamicStruct_dynamic_structure__Inner_u64.u64__ %insert_05, %struct.dynamic_structure__Inner_u64.u64_ %fv.14, 1 | ||
store %struct.dynamic_structure__DynamicStruct_dynamic_structure__Inner_u64.u64__ %insert_16, ptr %local_7, align 8 | ||
ret void | ||
} | ||
|
||
declare void @move_rt_vec_destroy(ptr nonnull readonly dereferenceable(32), ptr) |
30 changes: 30 additions & 0 deletions
30
...llvm-compiler/tests/failure-tests/dynamic-struct-example-build/0x1__unit_test.ll.expected
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; ModuleID = '0x1__unit_test' | ||
source_filename = "../../crates/move-stdlib/sources/unit_test.move" | ||
target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" | ||
target triple = "sbf-solana-solana" | ||
|
||
%__move_rt_type = type { { ptr, i64 }, i64, ptr } | ||
|
||
@__move_rttydesc_signer = private unnamed_addr constant %__move_rt_type { { ptr, i64 } { ptr @__move_rttydesc_signer_name, i64 6 }, i64 9, ptr @__move_rttydesc_NOTHING_info } | ||
@__move_rttydesc_signer_name = private unnamed_addr constant [6 x i8] c"signer" | ||
@__move_rttydesc_NOTHING_info = private unnamed_addr constant i8 -1 | ||
|
||
declare i32 @memcmp(ptr, ptr, i64) | ||
|
||
declare { ptr, i64, i64 } @move_native_unit_test_create_signers_for_testing(i64) | ||
|
||
declare void @move_native_unit_test_poison() | ||
|
||
define void @"0000000000000001_unit_test_unit_test_poiso_4afD3MScT99fc9"() { | ||
entry: | ||
%local_0 = alloca i64, align 8 | ||
%local_1 = alloca { ptr, i64, i64 }, align 8 | ||
store i64 0, ptr %local_0, align 8 | ||
%loaded_alloca = load i64, ptr %local_0, align 8 | ||
%retval = call { ptr, i64, i64 } @move_native_unit_test_create_signers_for_testing(i64 %loaded_alloca) | ||
store { ptr, i64, i64 } %retval, ptr %local_1, align 8 | ||
call void @move_rt_vec_destroy(ptr @__move_rttydesc_signer, ptr %local_1) | ||
ret void | ||
} | ||
|
||
declare void @move_rt_vec_destroy(ptr nonnull readonly dereferenceable(32), ptr) |
29 changes: 29 additions & 0 deletions
29
...-crates/move/solana/move-mv-llvm-compiler/tests/failure-tests/dynamic-struct-example.move
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module 0x1::dynamic_structure { | ||
struct Inner<K, V> has copy, drop, store { | ||
key: K, | ||
val: V, | ||
} | ||
|
||
struct DynamicStruct<S: drop> has copy, drop, store { | ||
id: u64, | ||
s: S, | ||
} | ||
|
||
public fun dynamic_struct<K: drop, V: drop>(id: u64, key: K, val: V) { | ||
DynamicStruct { | ||
id, | ||
s: Inner { key, val }, | ||
}; | ||
} | ||
public fun test_fail() { | ||
// If code is open then `dynamic_struct` is instantiated explicitly and | ||
// `dynamic_struct` call below will not fail. | ||
// DynamicStruct { | ||
// id: 44, | ||
// s: Inner { key: 1, val: 2 }, | ||
// }; | ||
|
||
// this was failing before commit `061824-fixing-dynamic-fields` | ||
dynamic_struct(44, 1, 2); | ||
} | ||
} |
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
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
Oops, something went wrong.