Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfei: don't generate if frame size is zero #5588

Merged
merged 9 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ impl AllocatedAbstractInstructionSet {
}
}

Either::Left(AllocatedOpcode::CFEI(ref op))
sudhackar marked this conversation as resolved.
Show resolved Hide resolved
| Either::Left(AllocatedOpcode::CFSI(ref op))
if op.value == 0 =>
{
0
}

// Another special case for the blob opcode, used for testing.
Either::Left(AllocatedOpcode::BLOB(ref count)) => count.value as u64,

Expand Down
2 changes: 2 additions & 0 deletions sway-core/src/asm_lang/allocated_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ impl AllocatedOp {

/* Memory Instructions */
ALOC(a) => op::ALOC::new(a.to_reg_id()).into(),
CFEI(a) if a.value == 0 => return Either::Left(vec![]),
CFEI(a) => op::CFEI::new(a.value.into()).into(),
CFSI(a) if a.value == 0 => return Either::Left(vec![]),
CFSI(a) => op::CFSI::new(a.value.into()).into(),
CFE(a) => op::CFE::new(a.to_reg_id()).into(),
CFS(a) => op::CFS::new(a.to_reg_id()).into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use array_of_structs_abi::{Id, TestContract, Wrapper};
use std::hash::*;

fn main() -> u64 {
let addr = abi(TestContract, 0xbd1e3ad7022f6c170c6fb3643a1a0c4ad0f666a5a1d735b11255dbfff74e5a05);
let addr = abi(TestContract, 0xe2a4f86301f8b57ff2c93ce68366669fc2f0926dccd26f9f6550b049cb324a2c);

let input = [Wrapper {
id: Id {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> bool {
let fuelcoin_asset_id = AssetId::new(fuelcoin_id, DEFAULT_SUB_ID);

// contract ID for sway/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/balance_test_contract/
let balance_test_id = ContractId::from(0x4a00baa517980432b9274a0e2f03c88735bdb483730816679c6eb37b4046d060);
let balance_test_id = ContractId::from(0xe50966cd6b1da8fe006e3e876e08f3df6948ce426e1a7cfe49fba411b0a11f89);

// todo: use correct type ContractId
let fuel_coin = abi(TestFuelCoin, fuelcoin_id.into());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use balance_test_abi::BalanceTest;

fn main() -> bool {
// @todo switch to using ContractId when abi signature changes.
let balance_test_contract_id = 0x4a00baa517980432b9274a0e2f03c88735bdb483730816679c6eb37b4046d060;
let balance_test_contract_id = 0xe50966cd6b1da8fe006e3e876e08f3df6948ce426e1a7cfe49fba411b0a11f89;

let balance_test_contract = abi(BalanceTest, balance_test_contract_id);
let number = balance_test_contract.get_42 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ script;
use abi_with_tuples::*;

fn main() -> bool {
let the_abi = abi(MyContract, 0xe507ae21649fbd2b48ccda116687d2ff164b190c09d33d9d480981323af16be7);
let the_abi = abi(MyContract, 0x1200d031e9c10f8d9bd9dd556a98a0c88e74a4da991047556f78b1bcc1be2ab6);

let param1 = (
Person {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ script;
use basic_storage_abi::{BasicStorage, Quad};

fn main() -> u64 {
let addr = abi(BasicStorage, 0x68c0e1ebcddb900439182bf0673a4dde93c02f8c14072305b55f1dd4d1470def);
let addr = abi(BasicStorage, 0xa4174c9ff114dc3a99eee9d8f43e417276852a6ba41b8ea469b54385a6596db4);
let key = 0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
let value = 4242;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ script;
use storage_enum_abi::*;

fn main() -> u64 {
let contract_id = 0x21ec4784feb8a4feda42fd1ccfb6c2496d42e03ff54f88be00602086491e1f7b;
let contract_id = 0x4c01b41e6f7fc88c88a7799c43d9f695e22ee01eed90478b99fe3bfa935e3e07;
let caller = abi(StorageEnum, contract_id);

let res = caller.read_write_enums();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use auth_testing_abi::AuthTesting;

// should be false in the case of a script
fn main() -> bool {
let caller = abi(AuthTesting, 0x10f04ba40bd185d6e2e326a9f8be6d1c1f96b7a021faecea1bd46fc4b5cce885);
let caller = abi(AuthTesting, 0x66d9f99ddeeff7d1c6d3b986afd5d20029860289cb74c64e30c255730966d24f);
let result = caller.returns_gm_one();
assert(result);
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use context_testing_abi::*;
fn main() -> bool {
let gas: u64 = u64::max();
let amount: u64 = 11;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);
let other_contract_id = ContractId::from(0x65dae4fedb02e2d70cdb56e2b82d23a2baa69a6acdbf01cc1271c7c1a1abe2cc);
let other_contract_id_b256: b256 = other_contract_id.into();
let base_asset_id = BASE_ASSET_ID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ script;
use nested_struct_args_abi::*;

fn main() -> bool {
let contract_id = 0xfa4bb608c7de0db473862926816eb23d17469ec2ef08685aab3c4ddd1892f9a8;
let contract_id = 0x0fd8fed83ef774a35708706495b49f93254cc5ded343c3bd4416a70c8eb47e01;
let caller = abi(NestedStructArgs, contract_id);

let param_one = StructOne {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ fn test_foo() {

#[test(should_revert)]
fn test_fail() {
let contract_id = 0xa5cd13d5d8ceaa436905f361853ba278f6760da2af5061ec86fe09b8a0cf59b4;
let contract_id = 0xd1cc94578ce1595d8f350cc3ea743fbf769e93ac1b7dc1731a28563109368e0a;
let caller = abi(MyContract, contract_id);
let result = caller.test_function {}();
assert(result == false)
}

#[test]
fn test_success() {
let contract_id = 0xa5cd13d5d8ceaa436905f361853ba278f6760da2af5061ec86fe09b8a0cf59b4;
let contract_id = 0xd1cc94578ce1595d8f350cc3ea743fbf769e93ac1b7dc1731a28563109368e0a;
let caller = abi(MyContract, contract_id);
let result = caller.test_function {}();
assert(result == true)
Expand Down
4 changes: 3 additions & 1 deletion test/src/ir_generation/tests/empty.sw
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fn main() {

// ::check-asm::
// The data section setup:
// check: move $$$$locbase $$sp
// check: cfei i0
sudhackar marked this conversation as resolved.
Show resolved Hide resolved
// check: ret $$zero
// nextln: .data:
// nextln: .data
// not: data_
Loading