Skip to content

Commit 8fa01b8

Browse files
ironcevvaivaswatha
andauthored
Eliminate mem_copy_vals when accessing global constants (#7348)
## Description This PR properly treats `InstOp::GetGlobal` in the `memory_utils::get_symbols`. Before, when analysis hit `GetGlobal` as a pointer source, it didn't know that there cannot be a symbol behind that pointer. That's why it was treated the resulting `ReferredSymbols` as incomplete. This harmed `memcpyopt` optimizations. E.g., in this example: ```sway script; const ADDRESS: b256 = 0x9999999999999999999999999999999999999999999999999999999999999999; fn main() { poke(ADDRESS); } #[inline(never)] fn poke<T>(_t: T) { } ``` the resulting final IR in `release` build was: ``` entry_orig fn main_0() -> (), !13 { local mut b256 __aggr_memcpy_0 <<<--- Additional local. local b256 __tmp_arg entry(): v0 = get_global __ptr b256, storage_all_layouts::ADDRESS, !14 v1 = get_local __ptr b256, __aggr_memcpy_0 mem_copy_val v1, v0 <<<--- Additional `mem_cpy_val`. v2 = get_local __ptr b256, __tmp_arg mem_copy_val v2, v1 v3 = call poke_1(v2) v12 = const unit () ret () v12 } ``` After this change, the resulting IR becomes: ``` entry_orig fn main_0() -> (), !13 { local b256 __tmp_arg entry(): v0 = get_global __ptr b256, storage_all_layouts::ADDRESS, !14 v1 = get_local __ptr b256, __tmp_arg mem_copy_val v1, v0 v3 = call poke_1(v1) v12 = const unit () ret () v12 } ``` The change didn't affect the bytecode or gas usage of most of the `should_pass` tests. Only the following `should_pass/language` snapshot tests decreased in bytecode size and gas usage: | Test | Bytecode before | Bytecode after | | ---- | --------------- | -------------- | | const_generics | 9.560 | 9.536 | | panic_expression/panicking_contract | 8.136 | 8.048 | | panic_expression/panic_handling_in_unit_tests | 9.552 | 9.392 | The only test in which the bytecode size and gas usage went up was `should_pass/language/intrinsics/dbg` test run in `debug` mode. When run in `release` mode, the usage of `_dbg` intrinsic didn't cause any increases (the `dbg_release` test). ## Checklist - [ ] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Vaivaswatha N <vaivaswatha.nagaraj@fuel.sh>
1 parent 1148710 commit 8fa01b8

File tree

8 files changed

+77
-46
lines changed

8 files changed

+77
-46
lines changed

sway-ir/src/analysis/memory_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ fn get_symbols(context: &Context, val: Value, gep_only: bool) -> ReferredSymbols
283283
op: InstOp::GetConfig(_, _),
284284
..
285285
}) if !gep_only => (),
286+
// We've reached a global at the top of the chain.
287+
// There cannot be a symbol behind it, and so the returned set is complete.
288+
ValueDatum::Instruction(Instruction {
289+
op: InstOp::GetGlobal(_),
290+
..
291+
}) if !gep_only => (),
286292
// Note that in this case, the pointer itself is coming from a `Load`,
287293
// and not an address. So, we just continue following the pointer.
288294
ValueDatum::Instruction(Instruction {

test/src/e2e_vm_tests/test_programs/should_pass/language/array/array_repeat/stdout.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: test/src/snapshot/mod.rs
3+
assertion_line: 162
34
---
45
> forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/array/array_repeat --experimental const_generics --ir final --asm final --bytecode
56
exit status: 0
@@ -1235,7 +1236,7 @@ output:
12351236
Finished debug [unoptimized + fuel] target(s) [6.648 KB] in ???
12361237
script array_repeat
12371238
Bytecode size: 6648 bytes (6.648 KB)
1238-
Bytecode hash: 0x0ae596de91be50b99f5af33b3ffdf03b48086eef74ff481547652feb85078b94
1239+
Bytecode hash: 0x556fd20a12eccbbba1405bdda2eb527e6da68804f20c081c92bd630a22877ead
12391240
Running 1 test, filtered 0 tests
12401241

12411242
tested -- array_repeat

test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics/stdout.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ warning
444444
____
445445

446446
Compiled script "const_generics" with 2 warnings.
447-
Finished debug [unoptimized + fuel] target(s) [9.56 KB] in ???
447+
Finished debug [unoptimized + fuel] target(s) [9.536 KB] in ???
448448
Running 1 test, filtered 0 tests
449449

450450
tested -- const_generics
451451

452-
test run_main ... ok (???, 17574 gas)
452+
test run_main ... ok (???, 17350 gas)
453453
debug output:
454454
[src/main.sw:105:13] a = [1, 2]
455455
[src/main.sw:109:13] [C {}].len() = 1

test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ output:
7272
Building test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg
7373
Compiling library std (sway-lib-std)
7474
Compiling script dbg (test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg)
75-
Finished debug [unoptimized + fuel] target(s) [42.296 KB] in ???
75+
Finished debug [unoptimized + fuel] target(s) [42.456 KB] in ???
7676
Running 1 test, filtered 0 tests
7777

7878
tested -- dbg
7979

80-
test call_main ... ok (???, 125935 gas)
80+
test call_main ... ok (???, 122721 gas)
8181
debug output:
8282
[src/main.sw:13:13] () = ()
8383
[src/main.sw:15:13] true = true

test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
source: test/src/snapshot/mod.rs
3+
assertion_line: 162
34
---
45
> forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests --logs --raw-logs --dbgs --reverts passing_
56
exit status: 0
@@ -18,20 +19,20 @@ warning: Error message is empty
1819
____
1920

2021
Compiled script "panic_handling_in_unit_tests" with 1 warning.
21-
Finished debug [unoptimized + fuel] target(s) [9.552 KB] in ???
22+
Finished debug [unoptimized + fuel] target(s) [9.392 KB] in ???
2223
Running 2 tests, filtered 18 tests
2324

2425
tested -- panic_handling_in_unit_tests
2526

26-
test passing_dbgs_and_logs ... ok (???, 2219 gas)
27+
test passing_dbgs_and_logs ... ok (???, 2175 gas)
2728
debug output:
2829
[src/main.sw:23:13] "This is a passing test containing `__dbg` outputs." = "This is a passing test containing `__dbg` outputs."
2930
[src/main.sw:25:13] x = 42
3031
decoded log values:
3132
AsciiString { data: "This is a log from the passing test." }, log rb: 10098701174489624218
3233
42, log rb: 1515152261580153489
3334
raw logs:
34-
[{"LogData":{"data":"0000000000000024546869732069732061206c6f672066726f6d207468652070617373696e6720746573742e","digest":"29d742ad9093cdf81404ff756467a44448729b85ab3c0d65197829fb61d2dd29","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":44,"pc":15824,"ptr":67107840,"ra":0,"rb":10098701174489624218}},{"LogData":{"data":"000000000000002a","digest":"a6bb133cb1e3638ad7b8a3ff0539668e9e56f9b850ef1b2a810f5422eaa6c323","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":16456,"ptr":67106816,"ra":0,"rb":1515152261580153489}}]
35+
[{"LogData":{"data":"0000000000000024546869732069732061206c6f672066726f6d207468652070617373696e6720746573742e","digest":"29d742ad9093cdf81404ff756467a44448729b85ab3c0d65197829fb61d2dd29","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":44,"pc":15664,"ptr":67107840,"ra":0,"rb":10098701174489624218}},{"LogData":{"data":"000000000000002a","digest":"a6bb133cb1e3638ad7b8a3ff0539668e9e56f9b850ef1b2a810f5422eaa6c323","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":16296,"ptr":67106816,"ra":0,"rb":1515152261580153489}}]
3536
test passing_no_dbgs_or_logs ... ok (???, 18 gas)
3637

3738
test result: OK. 2 passed; 0 failed; finished in ???
@@ -55,20 +56,20 @@ warning: Error message is empty
5556
____
5657

5758
Compiled script "panic_handling_in_unit_tests" with 1 warning.
58-
Finished debug [unoptimized + fuel] target(s) [9.552 KB] in ???
59+
Finished debug [unoptimized + fuel] target(s) [9.392 KB] in ???
5960
Running 20 tests, filtered 0 tests
6061

6162
tested -- panic_handling_in_unit_tests
6263

63-
test passing_dbgs_and_logs ... ok (???, 2219 gas)
64+
test passing_dbgs_and_logs ... ok (???, 2175 gas)
6465
test passing_no_dbgs_or_logs ... ok (???, 18 gas)
6566
test failing_revert_intrinsic ... FAILED (???, 19 gas)
66-
test failing_revert_function_with_dbgs_and_logs ... FAILED (???, 2346 gas)
67-
test failing_error_signal_assert ... FAILED (???, 497 gas)
68-
test failing_error_signal_assert_eq ... FAILED (???, 1394 gas)
69-
test failing_error_signal_assert_ne ... FAILED (???, 1389 gas)
70-
test failing_error_signal_require_str_error ... FAILED (???, 318 gas)
71-
test failing_error_signal_require_enum_error ... FAILED (???, 414 gas)
67+
test failing_revert_function_with_dbgs_and_logs ... FAILED (???, 2297 gas)
68+
test failing_error_signal_assert ... FAILED (???, 475 gas)
69+
test failing_error_signal_assert_eq ... FAILED (???, 1371 gas)
70+
test failing_error_signal_assert_ne ... FAILED (???, 1366 gas)
71+
test failing_error_signal_require_str_error ... FAILED (???, 320 gas)
72+
test failing_error_signal_require_enum_error ... FAILED (???, 416 gas)
7273
test failing_panic_no_arg ... FAILED (???, 197 gas)
7374
test failing_panic_unit_arg ... FAILED (???, 197 gas)
7475
test failing_panic_const_eval_str_arg ... FAILED (???, 19 gas)
@@ -102,7 +103,7 @@ AsciiString { data: "This is a log from the reverting test." }, log rb: 10098701
102103
"id": "0000000000000000000000000000000000000000000000000000000000000000",
103104
"is": 10368,
104105
"len": 46,
105-
"pc": 15824,
106+
"pc": 15664,
106107
"ptr": 67107840,
107108
"ra": 0,
108109
"rb": 10098701174489624218
@@ -136,7 +137,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
136137
"id": "0000000000000000000000000000000000000000000000000000000000000000",
137138
"is": 10368,
138139
"len": 64,
139-
"pc": 15824,
140+
"pc": 15664,
140141
"ptr": 67107840,
141142
"ra": 0,
142143
"rb": 10098701174489624218
@@ -149,7 +150,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
149150
"id": "0000000000000000000000000000000000000000000000000000000000000000",
150151
"is": 10368,
151152
"len": 8,
152-
"pc": 16456,
153+
"pc": 16296,
153154
"ptr": 67106816,
154155
"ra": 0,
155156
"rb": 1515152261580153489
@@ -162,7 +163,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
162163
"id": "0000000000000000000000000000000000000000000000000000000000000000",
163164
"is": 10368,
164165
"len": 8,
165-
"pc": 16456,
166+
"pc": 16296,
166167
"ptr": 67105792,
167168
"ra": 0,
168169
"rb": 1515152261580153489
@@ -189,7 +190,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
189190
"id": "0000000000000000000000000000000000000000000000000000000000000000",
190191
"is": 10368,
191192
"len": 64,
192-
"pc": 15824,
193+
"pc": 15664,
193194
"ptr": 67107840,
194195
"ra": 0,
195196
"rb": 10098701174489624218
@@ -202,7 +203,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
202203
"id": "0000000000000000000000000000000000000000000000000000000000000000",
203204
"is": 10368,
204205
"len": 8,
205-
"pc": 16456,
206+
"pc": 16296,
206207
"ptr": 67106816,
207208
"ra": 0,
208209
"rb": 1515152261580153489
@@ -215,7 +216,7 @@ AsciiString { data: "We will get logged the asserted values and this message." }
215216
"id": "0000000000000000000000000000000000000000000000000000000000000000",
216217
"is": 10368,
217218
"len": 8,
218-
"pc": 16456,
219+
"pc": 16296,
219220
"ptr": 67105792,
220221
"ra": 0,
221222
"rb": 1515152261580153489
@@ -238,7 +239,7 @@ AsciiString { data: "This is an error message in a `require` call." }, log rb: 1
238239
"id": "0000000000000000000000000000000000000000000000000000000000000000",
239240
"is": 10368,
240241
"len": 53,
241-
"pc": 15824,
242+
"pc": 15664,
242243
"ptr": 67107840,
243244
"ra": 0,
244245
"rb": 10098701174489624218
@@ -261,7 +262,7 @@ B(true), log rb: 8516346929033386016
261262
"id": "0000000000000000000000000000000000000000000000000000000000000000",
262263
"is": 10368,
263264
"len": 9,
264-
"pc": 13696,
265+
"pc": 13552,
265266
"ptr": 67107840,
266267
"ra": 0,
267268
"rb": 8516346929033386016
@@ -285,7 +286,7 @@ B(true), log rb: 8516346929033386016
285286
"id": "0000000000000000000000000000000000000000000000000000000000000000",
286287
"is": 10368,
287288
"len": 0,
288-
"pc": 13772,
289+
"pc": 13628,
289290
"ptr": 67107840,
290291
"ra": 0,
291292
"rb": 3330666440490685604
@@ -309,7 +310,7 @@ B(true), log rb: 8516346929033386016
309310
"id": "0000000000000000000000000000000000000000000000000000000000000000",
310311
"is": 10368,
311312
"len": 0,
312-
"pc": 13832,
313+
"pc": 13688,
313314
"ptr": 67107840,
314315
"ra": 0,
315316
"rb": 3330666440490685604
@@ -351,7 +352,7 @@ AsciiString { data: "Panicked with a non-const evaluated string argument." }, lo
351352
"id": "0000000000000000000000000000000000000000000000000000000000000000",
352353
"is": 10368,
353354
"len": 60,
354-
"pc": 18436,
355+
"pc": 18276,
355356
"ptr": 67107840,
356357
"ra": 0,
357358
"rb": 10098701174489624218
@@ -375,7 +376,7 @@ AsciiString { data: "" }, log rb: 10098701174489624218
375376
"id": "0000000000000000000000000000000000000000000000000000000000000000",
376377
"is": 10368,
377378
"len": 8,
378-
"pc": 18436,
379+
"pc": 18276,
379380
"ptr": 67107840,
380381
"ra": 0,
381382
"rb": 10098701174489624218
@@ -399,7 +400,7 @@ AsciiString { data: " " }, log rb: 10098701174489624218
399400
"id": "0000000000000000000000000000000000000000000000000000000000000000",
400401
"is": 10368,
401402
"len": 12,
402-
"pc": 18436,
403+
"pc": 18276,
403404
"ptr": 67107840,
404405
"ra": 0,
405406
"rb": 10098701174489624218
@@ -424,7 +425,7 @@ B(true), log rb: 8516346929033386016
424425
"id": "0000000000000000000000000000000000000000000000000000000000000000",
425426
"is": 10368,
426427
"len": 9,
427-
"pc": 14284,
428+
"pc": 14140,
428429
"ptr": 67107840,
429430
"ra": 0,
430431
"rb": 8516346929033386016
@@ -449,7 +450,7 @@ C(AsciiString { data: "This is an error with an empty error message." }), log rb
449450
"id": "0000000000000000000000000000000000000000000000000000000000000000",
450451
"is": 10368,
451452
"len": 61,
452-
"pc": 14412,
453+
"pc": 14268,
453454
"ptr": 67107840,
454455
"ra": 0,
455456
"rb": 8516346929033386016
@@ -474,7 +475,7 @@ D(AsciiString { data: "This is an error with a whitespace error message." }), lo
474475
"id": "0000000000000000000000000000000000000000000000000000000000000000",
475476
"is": 10368,
476477
"len": 65,
477-
"pc": 14540,
478+
"pc": 14396,
478479
"ptr": 67107840,
479480
"ra": 0,
480481
"rb": 8516346929033386016

test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,78 +9,78 @@ output:
99
Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core)
1010
Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib)
1111
Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract)
12-
Finished release [optimized + fuel] target(s) [8.136 KB] in ???
12+
Finished release [optimized + fuel] target(s) [8.048 KB] in ???
1313
Running 11 tests, filtered 0 tests
1414

1515
tested -- panicking_contract
1616

17-
test test_directly_panicking_method ... ok (???, 1595 gas)
17+
test test_directly_panicking_method ... ok (???, 1591 gas)
1818
revert code: ffffffff00000000
1919
├─ panic message: Error C.
2020
├─ panic value: C(true)
2121
└─ panicked in: panicking_contract@1.2.3, src/main.sw:22:9
2222
decoded log values:
2323
C(true), log rb: 5503570629422409978
24-
test test_nested_panic_inlined ... ok (???, 2921 gas)
24+
test test_nested_panic_inlined ... ok (???, 2917 gas)
2525
revert code: ffffffff00000005
2626
├─ panic message: Error E.
2727
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
2828
└─ panicked in: panicking_lib, src/lib.sw:41:9
2929
decoded log values:
3030
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
31-
test test_nested_panic_inlined_same_revert_code ... ok (???, 2921 gas)
31+
test test_nested_panic_inlined_same_revert_code ... ok (???, 2917 gas)
3232
revert code: ffffffff00000005
3333
├─ panic message: Error E.
3434
├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }])
3535
└─ panicked in: panicking_lib, src/lib.sw:41:9
3636
decoded log values:
3737
E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978
38-
test test_nested_panic_not_inlined ... ok (???, 3120 gas)
38+
test test_nested_panic_not_inlined ... ok (???, 3116 gas)
3939
revert code: ffffffff00000006
4040
├─ panic message: Error E.
4141
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
4242
└─ panicked in: panicking_lib, src/lib.sw:35:5
4343
decoded log values:
4444
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
45-
test test_nested_panic_not_inlined_same_revert_code ... ok (???, 3120 gas)
45+
test test_nested_panic_not_inlined_same_revert_code ... ok (???, 3116 gas)
4646
revert code: ffffffff00000006
4747
├─ panic message: Error E.
4848
├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }])
4949
└─ panicked in: panicking_lib, src/lib.sw:35:5
5050
decoded log values:
5151
E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978
52-
test test_generic_panic_with_unit ... ok (???, 2052 gas)
52+
test test_generic_panic_with_unit ... ok (???, 2048 gas)
5353
revert code: ffffffff00000004
5454
├─ panic value: ()
5555
└─ panicked in: panicking_lib, src/lib.sw:74:5
5656
decoded log values:
5757
(), log rb: 3330666440490685604
58-
test test_generic_panic_with_unit_same_revert_code ... ok (???, 2052 gas)
58+
test test_generic_panic_with_unit_same_revert_code ... ok (???, 2048 gas)
5959
revert code: ffffffff00000004
6060
├─ panic value: ()
6161
└─ panicked in: panicking_lib, src/lib.sw:74:5
6262
decoded log values:
6363
(), log rb: 3330666440490685604
64-
test test_generic_panic_with_str ... ok (???, 2062 gas)
64+
test test_generic_panic_with_str ... ok (???, 2058 gas)
6565
revert code: ffffffff00000002
6666
├─ panic message: generic panic with string
6767
└─ panicked in: panicking_lib, src/lib.sw:74:5
6868
decoded log values:
6969
AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218
70-
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1732 gas)
70+
test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1728 gas)
7171
revert code: ffffffff00000002
7272
├─ panic message: generic panic with different string
7373
└─ panicked in: panicking_lib, src/lib.sw:74:5
7474
decoded log values:
7575
AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218
76-
test test_generic_panic_with_error_type_enum ... ok (???, 1862 gas)
76+
test test_generic_panic_with_error_type_enum ... ok (???, 1858 gas)
7777
revert code: ffffffff00000003
7878
├─ panic message: Error A.
7979
├─ panic value: A
8080
└─ panicked in: panicking_lib, src/lib.sw:74:5
8181
decoded log values:
8282
A, log rb: 5503570629422409978
83-
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2031 gas)
83+
test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2026 gas)
8484
revert code: ffffffff00000003
8585
├─ panic message: Error B.
8686
├─ panic value: B(42)

test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use basic_storage_abi::{BasicStorage, Quad};
44
#[cfg(experimental_new_encoding = false)]
55
const CONTRACT_ID = 0x94db39f409a31b9f2ebcadeea44378e419208c20de90f5d8e1e33dc1523754cb;
66
#[cfg(experimental_new_encoding = true)]
7-
const CONTRACT_ID = 0xbd57a0138d242c9386c3689c1280d5cbccdf3c6a7db820c5934e2e87682be1a4; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release
7+
const CONTRACT_ID = 0xdc8809151850786831a09319d9f4d556287b31a656001252dbdbd1c463b9cba9; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release
88

99
fn main() -> u64 {
1010
let addr = abi(BasicStorage, CONTRACT_ID);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// target-fuelvm
2+
script;
3+
4+
const ADDRESS: b256 = 0x9999999999999999999999999999999999999999999999999999999999999999;
5+
6+
fn main() {
7+
poke(ADDRESS);
8+
}
9+
10+
#[inline(never)]
11+
fn poke<T>(_t: T) { }
12+
13+
// ::check-ir::
14+
15+
// check: fn main() -> ()
16+
17+
// ::check-ir-optimized::
18+
// pass: o1
19+
20+
// check: v0 = get_global __ptr b256, test_lib::ADDRESS
21+
// nextln: v1 = get_local __ptr b256, __tmp_arg
22+
// nextln: mem_copy_val v1, v0
23+
// nextln: v2 = call poke_0(v1)

0 commit comments

Comments
 (0)