forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inlining heuristic: return value demotion adds arg (FuelLabs#4518)
## Description We currently don't support compiling functions with more than 6 args. Such functions are inlined. However, the inliner heuristic that checks this fails to say "inline" if there are 6 args, but the return type will be demoted later on, adding an additional arg. Fix that. Fixes FuelLabs#4477. ## Checklist - [x] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [x] I have added tests that prove my fix is effective or that my feature works. - [x] 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.
- Loading branch information
1 parent
b3cfea4
commit f4422d4
Showing
7 changed files
with
86 additions
and
5 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
16 changes: 16 additions & 0 deletions
16
test/src/e2e_vm_tests/test_programs/should_pass/language/arg_demotion_inline/Forc.lock
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,16 @@ | ||
[[package]] | ||
name = 'arg_demotion_inline' | ||
source = 'member' | ||
dependencies = [ | ||
'core', | ||
'std', | ||
] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-603115901A793008' | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-603115901A793008' | ||
dependencies = ['core'] |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/language/arg_demotion_inline/Forc.toml
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,9 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "arg_demotion_inline" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } | ||
std = { path = "../../../../../../../sway-lib-std" } |
42 changes: 42 additions & 0 deletions
42
test/src/e2e_vm_tests/test_programs/should_pass/language/arg_demotion_inline/src/main.sw
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,42 @@ | ||
contract; | ||
|
||
abi MyContract { | ||
fn test_function() -> bool; | ||
} | ||
|
||
struct Foo { | ||
a: u64, | ||
b: u64, | ||
c: u64, | ||
d: u64, | ||
e: u64, | ||
f: u64, | ||
} | ||
|
||
impl Foo { | ||
fn new( | ||
a: u64, | ||
b: u64, | ||
c: u64, | ||
d: u64, | ||
e: u64, | ||
f: u64, | ||
) -> Self { | ||
Self { | ||
a, | ||
b, | ||
c, | ||
d, | ||
e, | ||
f, | ||
} | ||
} | ||
} | ||
|
||
impl MyContract for Contract { | ||
fn test_function() -> bool { | ||
let bar1 = Foo::new(0,0,0,0,0,0); | ||
let bar2 = Foo::new(0,0,0,0,0,0); | ||
true | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
test/src/e2e_vm_tests/test_programs/should_pass/language/arg_demotion_inline/test.toml
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,2 @@ | ||
category = "compile" | ||
expected_warnings = 8 |
6 changes: 3 additions & 3 deletions
6
test/src/e2e_vm_tests/test_programs/should_pass/unit_tests/stack_indexing_overflow/Forc.lock
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 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-6BF9CEE717879469' | ||
source = 'path+from-root-E733504800A298D4' | ||
|
||
[[package]] | ||
name = 'script_multi_test' | ||
name = 'stack_indexing_overflow' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-6BF9CEE717879469' | ||
source = 'path+from-root-E733504800A298D4' | ||
dependencies = ['core'] |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "script_multi_test" | ||
name = "stack_indexing_overflow" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../../../sway-lib-std" } |