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

Grand Unified Flow Analysis (GUFA) #4598

Merged
merged 888 commits into from Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
888 commits
Select commit Hold shift + click to select a range
4f1a6b1
Merge remote-tracking branch 'origin/main' into fgprop
kripken May 18, 2022
52535db
clean
kripken May 19, 2022
3a4a894
polish
kripken May 19, 2022
c3e3e30
polish
kripken May 19, 2022
8dfedaa
polish
kripken May 19, 2022
5457df6
polish
kripken May 19, 2022
9a2e636
better
kripken May 19, 2022
d18b933
rename
kripken May 19, 2022
13adac9
format
kripken May 19, 2022
adf9227
work
kripken May 19, 2022
aecfd18
fix
kripken May 19, 2022
eee2e30
fix
kripken May 19, 2022
0444b41
format
kripken May 19, 2022
bcaea49
test
kripken May 19, 2022
2270174
text
kripken May 19, 2022
9d01a3b
text
kripken May 19, 2022
0e496a9
work
kripken May 19, 2022
f620b76
text
kripken May 19, 2022
b74f427
text
kripken May 19, 2022
e0d0592
text
kripken May 19, 2022
4627648
text
kripken May 19, 2022
265c6f2
text
kripken May 19, 2022
152541f
text
kripken May 19, 2022
6faaa19
text
kripken May 19, 2022
34380e0
text
kripken May 19, 2022
7f07af0
text
kripken May 19, 2022
732d881
text
kripken May 19, 2022
7c73a1f
fix
kripken May 19, 2022
243a960
test
kripken May 19, 2022
e304cdf
test
kripken May 19, 2022
6e29761
test
kripken May 19, 2022
d6ccf0d
comment
kripken May 19, 2022
9c64e28
text
kripken May 19, 2022
1dc3d6d
better
kripken May 19, 2022
55c473b
better
kripken May 19, 2022
de91e5c
better
kripken May 19, 2022
3aeb649
test fix
kripken May 19, 2022
77ada29
move
kripken May 19, 2022
71d7589
format
kripken May 19, 2022
5618fee
work
kripken May 19, 2022
55b5e44
work
kripken May 19, 2022
2dcaccb
comment
kripken May 19, 2022
d57ecd3
test
kripken May 20, 2022
0f5fee1
comment
kripken May 20, 2022
fa0736c
test
kripken May 20, 2022
2a0ac9a
format
kripken May 20, 2022
9d2b4c1
comments
kripken May 20, 2022
7af8861
simpler
kripken May 20, 2022
8f9f1e4
names
kripken May 20, 2022
32f7766
add optimizing mode
kripken May 20, 2022
2607dcb
format
kripken May 20, 2022
141e6e2
comment
kripken May 20, 2022
e2632b6
test
kripken May 20, 2022
b8af191
work
kripken May 20, 2022
0559dd9
test
kripken May 20, 2022
ceb2dcd
fuzz
kripken May 20, 2022
e835f56
typo
kripken May 20, 2022
25bb0ca
typo
kripken May 20, 2022
9061659
typo
kripken May 20, 2022
8759f6c
comment
kripken May 20, 2022
64bb162
comment
kripken May 20, 2022
1e3cf3e
comment
kripken May 20, 2022
208c220
comment
kripken May 20, 2022
972211b
comment
kripken May 20, 2022
2734f78
comment
kripken May 20, 2022
6870508
comment
kripken May 20, 2022
5110432
comment
kripken May 20, 2022
f3b538e
comment
kripken May 20, 2022
d1a25ab
comments
kripken May 20, 2022
0402cab
text
kripken May 20, 2022
bab9e92
comment
kripken May 20, 2022
26fca84
comment
kripken May 20, 2022
2810bcd
test
kripken May 20, 2022
4a12da0
Revert "test"
kripken May 20, 2022
9135f6b
comment
kripken May 20, 2022
caccaaf
test
kripken May 20, 2022
7b5ed43
fix
kripken May 20, 2022
e312c97
Merge remote-tracking branch 'origin/main' into gufa
kripken May 21, 2022
2c17fd3
Merge branch 'fgprop' into gufa
kripken May 21, 2022
7da19ab
comment
kripken May 23, 2022
4f338ad
comment
kripken May 23, 2022
8f47f02
comment
kripken May 23, 2022
12a5b23
comment
kripken May 23, 2022
e52d735
Merge remote-tracking branch 'origin/main' into fgprop
kripken May 23, 2022
4a9c365
Merge remote-tracking branch 'origin/main' into fgprop
kripken May 23, 2022
1854e72
fix
kripken May 23, 2022
7179d2e
fix
kripken May 23, 2022
7d61a73
fix
kripken May 23, 2022
225f36d
comment
kripken May 23, 2022
13464df
Merge branch 'fgprop' into gufa
kripken May 23, 2022
d11181f
fix
kripken May 23, 2022
ba3a913
fix
kripken May 23, 2022
0ab23d4
debug CI-only failure on alpine
kripken May 24, 2022
e66dfb0
Revert "debug CI-only failure on alpine"
kripken May 24, 2022
51d0356
Revert "Revert "debug CI-only failure on alpine""
kripken May 24, 2022
68b8dd2
undo
kripken May 24, 2022
5f213cc
fix
kripken May 24, 2022
8272223
format
kripken May 24, 2022
218a82e
undo
kripken May 24, 2022
439061a
pre-gufa
kripken May 24, 2022
35de732
files
kripken May 24, 2022
5e14116
Merge branch 'pre-gufa' into gufa
kripken May 24, 2022
efa0d21
feedback
kripken May 25, 2022
cd74ec1
feedback
kripken May 25, 2022
2eb813c
feedback
kripken May 25, 2022
0a9631a
feedback
kripken May 25, 2022
84e7541
feedback
kripken May 25, 2022
ed46901
format
kripken May 25, 2022
55760eb
clarify
kripken May 25, 2022
f2cad07
Merge branch 'pre-gufa' into gufa
kripken May 25, 2022
4055e61
example => gtest
kripken May 25, 2022
d2550b2
test
kripken May 25, 2022
10fccbe
format
kripken May 25, 2022
167f8ce
cleanup
kripken May 25, 2022
73b0809
Merge branch 'pre-gufa' into gufa
kripken May 25, 2022
e7aae12
move
kripken May 25, 2022
e17b5bc
use fixtures
kripken May 25, 2022
1d15978
separate
kripken May 25, 2022
cb4ed59
fix
kripken May 25, 2022
e69625d
more
kripken May 26, 2022
bee4bb6
cleanup
kripken May 26, 2022
48b8d23
format
kripken May 26, 2022
7c3296f
isTypeExact => hasExactType
kripken May 26, 2022
1e8d548
Update src/ir/possible-contents.h
kripken May 26, 2022
1a42ee2
clarify
kripken May 26, 2022
eb3c7d1
Merge remote-tracking branch 'origin/pre-gufa' into pre-gufa
kripken May 26, 2022
0df4a40
typo
kripken May 26, 2022
036876f
comment
kripken May 26, 2022
206f139
test rename: func => nonNullFunc
kripken May 26, 2022
bd1214e
format
kripken May 26, 2022
8a770ff
Merge branch 'pre-gufa' into gufa
kripken May 26, 2022
0cc8e91
Update src/ir/possible-contents.cpp
kripken May 27, 2022
947b7da
CollectedInfo => CollectedFuncInfo
kripken May 27, 2022
19b52cb
fix
kripken May 27, 2022
3ad6228
comment
kripken May 27, 2022
36cc3c3
BranchLocation => BreakTargetLocation
kripken May 31, 2022
b0add64
add missing isRelevant
kripken May 31, 2022
e310cdb
Merge commit '36cc3c3acbf502c2620d484db78369b3946d4e04' into gufa
kripken May 31, 2022
52a0b30
Merge branch 'pre-gufa' into gufa
kripken May 31, 2022
5da22cd
feedback
kripken May 31, 2022
0d5d412
comment
kripken May 31, 2022
032ed51
comment
kripken May 31, 2022
5df4495
refactor+fix
kripken May 31, 2022
66f3017
fix
kripken May 31, 2022
cdd0391
fix
kripken May 31, 2022
da56b25
fix
kripken May 31, 2022
dcfbfc2
Merge branch 'pre-gufa' into gufa
kripken May 31, 2022
e06e7bc
comment
kripken May 31, 2022
f4fd087
comment
kripken May 31, 2022
54c0531
targetExpr => child
kripken May 31, 2022
14f4e6c
Merge branch 'pre-gufa' into gufa
kripken May 31, 2022
b1c51a1
typo
kripken May 31, 2022
1c41a12
comment
kripken May 31, 2022
5aa3e15
comment
kripken May 31, 2022
7cf666a
clarify aliasing
kripken May 31, 2022
224f3df
comment
kripken May 31, 2022
45556c3
comment
kripken May 31, 2022
c47f529
Merge remote-tracking branch 'origin/refehpop' into pre-gufa
kripken May 31, 2022
da8d09c
fix
kripken May 31, 2022
b58cf1e
Merge remote-tracking branch 'origin/refehpop' into pre-gufa
kripken May 31, 2022
a3ac146
fix
kripken May 31, 2022
b128bd8
document and support 0 pops
kripken May 31, 2022
4a752dc
Merge remote-tracking branch 'origin/refehpop' into pre-gufa
kripken May 31, 2022
b7851c8
Merge remote-tracking branch 'origin/main' into pre-gufa
kripken May 31, 2022
2de2cac
Merge remote-tracking branch 'origin/main' into pre-gufa
kripken Jun 1, 2022
727f7f0
Merge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
eb9c718
comment
kripken Jun 1, 2022
aa9643f
test improvements
kripken Jun 1, 2022
143a004
wip
kripken Jun 1, 2022
8598306
Merge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
728caf0
cleaner
kripken Jun 1, 2022
14714f8
Merge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
6015ecb
format
kripken Jun 1, 2022
67a5967
fix
kripken Jun 1, 2022
137eac4
fix
kripken Jun 1, 2022
3f64ccf
feedback
kripken Jun 1, 2022
67e9ea2
nMerge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
7f5c287
comment
kripken Jun 1, 2022
7da0a3f
fix
kripken Jun 1, 2022
1069efe
fix
kripken Jun 1, 2022
facff67
Merge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
1c5aa5c
rename
kripken Jun 1, 2022
03f8896
addSpecialChildParentLink => addChildParentLink
kripken Jun 1, 2022
678b9b1
simpler
kripken Jun 1, 2022
2f20952
Revert "simpler"
kripken Jun 1, 2022
55ef34d
format
kripken Jun 1, 2022
40671be
Merge remote-tracking branch 'origin/main' into pre-gufa
kripken Jun 1, 2022
cc75d3d
Merge branch 'pre-gufa' into gufa
kripken Jun 1, 2022
6c5affd
try to emit Exact{i32}
kripken Jun 6, 2022
8f4ff06
Merge branch 'pre-gufa' into gufa
kripken Jun 6, 2022
ec3de02
Optimize the case of Exact{i32} in the flow
kripken Jun 6, 2022
2c3fb78
comments
kripken Jun 6, 2022
8196125
fix
kripken Jun 6, 2022
815e40f
Merge branch 'pre-gufa' into gufa
kripken Jun 6, 2022
53a7d60
SpecialLocation=
kripken Jun 6, 2022
b733ada
Merge branch 'pre-gufa' into gufa
kripken Jun 6, 2022
3ddd0a8
isorecursive too
kripken Jun 6, 2022
e67e76d
comment
kripken Jun 7, 2022
a710d52
improve comment
kripken Jun 8, 2022
e3d371e
Merge remote-tracking branch 'origin/main' into pre-gufa
kripken Jun 8, 2022
97a9ae3
comment about flow
kripken Jun 8, 2022
372d2bd
comment
kripken Jun 8, 2022
ac23076
comment
kripken Jun 8, 2022
5bac7e2
Merge branch 'pre-gufa' into gufa
kripken Jun 8, 2022
ee1eb57
simplify
kripken Jun 8, 2022
7d3288e
Merge branch 'pre-gufa' into gufa
kripken Jun 8, 2022
b73b5cb
try to make clang-tidy happy
kripken Jun 8, 2022
c07d878
Merge branch 'pre-gufa' into gufa
kripken Jun 8, 2022
93e3404
feedback
kripken Jun 9, 2022
c46c375
Update src/ir/possible-contents.cpp
kripken Jun 9, 2022
0ff332f
Merge remote-tracking branch 'origin/pre-gufa' into gufa
kripken Jun 21, 2022
556e59f
Merge remote-tracking branch 'origin/main' into gufa
kripken Jun 21, 2022
9825e67
merge
kripken Jun 24, 2022
789293f
format
kripken Jun 24, 2022
8832b52
fix
kripken Jun 24, 2022
4ec50b6
format
kripken Jun 24, 2022
1973c77
Merge remote-tracking branch 'origin/main' into gufa
kripken Jun 28, 2022
91ac663
isorecursive too
kripken Jun 28, 2022
d2aea40
rename
kripken Jun 28, 2022
e1e9138
todo
kripken Jun 28, 2022
1725861
feedback
kripken Jun 30, 2022
41ae2f9
fix determinism
kripken Jun 30, 2022
295bc67
feedback
kripken Jul 1, 2022
4790669
todo
kripken Jul 1, 2022
5400a37
Rename and simplify test
kripken Jul 6, 2022
3d1051f
Update test/lit/passes/gufa-refs.wast
kripken Jul 6, 2022
3c65662
compute shallow effects when we'll keep children anyhow
kripken Jul 6, 2022
ce6a45d
Merge remote-tracking branch 'origin/main' into gufa
kripken Jul 6, 2022
0d53d84
Merge remote-tracking branch 'origin/gufa' into gufa
kripken Jul 6, 2022
e4987cb
fix
kripken Jul 6, 2022
adef90c
comment
kripken Jul 8, 2022
95b8ea5
[GUFA] Simplify routines for dropping children (NFC)
aheejin Jul 9, 2022
3704951
Restore comments
aheejin Jul 9, 2022
0da2d8c
clang-format
aheejin Jul 9, 2022
68fcea1
feedback
kripken Jul 11, 2022
483087c
4598
aheejin Jul 12, 2022
7988682
Merge branch '4598' into improve_remove
aheejin Jul 12, 2022
c00db9e
Revert "Fix binaryen.js to include allocate() explicitly (#4793)"
aheejin Jul 12, 2022
c6c0769
Revert "[Parser] Start to parse instructions (#4789)"
aheejin Jul 12, 2022
8f9e2a6
Revert "Revert "[Parser] Start to parse instructions (#4789)""
aheejin Jul 12, 2022
8955856
Revert "Revert "Fix binaryen.js to include allocate() explicitly (#47…
aheejin Jul 12, 2022
1eed7e0
Revert "Merge branch '4598' into improve_remove"
aheejin Jul 12, 2022
d556760
feedback
kripken Jul 11, 2022
14d83ef
Revert "feedback"
aheejin Jul 12, 2022
4a1ca02
Add `optimize = true`s
aheejin Jul 12, 2022
8925759
Test changes
aheejin Jul 12, 2022
5e3d67c
Merge remote-tracking branch 'origin/main' into gufa
kripken Jul 12, 2022
5198ccc
Simplify routines for dropping children
aheejin Jul 18, 2022
cd8aa1e
Revert "Simplify routines for dropping children"
aheejin Jul 18, 2022
4c3842b
Simplify routines for dropping children (NFC)
aheejin Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/fuzz_opt.py
Expand Up @@ -1158,6 +1158,8 @@ def write_commands(commands, filename):
["--global-refining"],
["--gsi"],
["--gto"],
["--gufa"],
["--gufa-optimizing"],
["--local-cse"],
["--heap2local"],
["--remove-unused-names", "--heap2local"],
Expand Down
8 changes: 4 additions & 4 deletions src/ir/drop.h
Expand Up @@ -32,10 +32,10 @@ namespace wasm {
//
// The caller must also pass in a last item to append to the output (which is
// typically what the original expression is replaced with).
Expression* getDroppedChildrenAndAppend(Expression* curr,
Module& wasm,
const PassOptions& options,
Expression* last) {
inline Expression* getDroppedChildrenAndAppend(Expression* curr,
Module& wasm,
const PassOptions& options,
Expression* last) {
Builder builder(wasm);
std::vector<Expression*> contents;
for (auto* child : ChildIterator(curr)) {
Expand Down
36 changes: 25 additions & 11 deletions src/ir/possible-contents.cpp
Expand Up @@ -42,9 +42,22 @@ std::ostream& operator<<(std::ostream& stream,
namespace wasm {

void PossibleContents::combine(const PossibleContents& other) {
auto type = getType();
auto otherType = other.getType();
// First handle the trivial cases of them being equal, or one of them is
// None or Many.
if (*this == other) {
// Nulls are a special case, since they compare equal even if their type is
// different. We would like to make this function symmetric, that is, that
// combine(a, b) == combine(b, a) (otherwise, things can be odd and we could
// get nondeterminism in the flow analysis which does not have a
// determinstic order). To fix that, pick the LUB.
if (isNull()) {
assert(other.isNull());
auto lub = HeapType::getLeastUpperBound(type.getHeapType(),
otherType.getHeapType());
value = Literal::makeNull(lub);
}
return;
}
if (other.isNone()) {
Expand All @@ -62,9 +75,6 @@ void PossibleContents::combine(const PossibleContents& other) {
return;
}

auto type = getType();
auto otherType = other.getType();

if (!type.isRef() || !otherType.isRef()) {
// At least one is not a reference. The only possibility left for a useful
// combination here is if they have the same type (since we've already ruled
Expand All @@ -83,6 +93,9 @@ void PossibleContents::combine(const PossibleContents& other) {

// Nulls are always equal to each other, even if their types differ.
if (isNull() || other.isNull()) {
// Only one of them can be null here, since we already checked if *this ==
// other, which would have been true had both been null.
assert(!isNull() || !other.isNull());
// If only one is a null, but the other's type is known exactly, then the
// combination is to add nullability (if the type is *not* known exactly,
// like for a global, then we cannot do anything useful here).
Expand All @@ -92,12 +105,6 @@ void PossibleContents::combine(const PossibleContents& other) {
} else if (!other.isNull() && other.hasExactType()) {
value = ExactType(Type(otherType.getHeapType(), Nullable));
return;
} else if (isNull() && other.isNull()) {
// Both are null. The result is a null, of the LUB.
auto lub = HeapType::getLeastUpperBound(type.getHeapType(),
otherType.getHeapType());
value = Literal::makeNull(lub);
return;
}
}

Expand Down Expand Up @@ -1258,7 +1265,13 @@ bool Flower::updateContents(LocationIndex locationIndex,
worthSendingMore = false;
}

if (contents == oldContents) {
// Check if anything changed. Note that we check not just the content but
// also its type. That handles the case of nulls, that compare equal even if
// their type differs. We want to keep flowing if the type can change, so that
// we always end up with a deterministic result no matter in what order the
// flow happens (the final result will be the LUB of all the types of nulls
// that can arrive).
if (contents == oldContents && contents.getType() == oldContents.getType()) {
// Nothing actually changed, so just return.
return worthSendingMore;
}
Expand All @@ -1268,7 +1281,8 @@ bool Flower::updateContents(LocationIndex locationIndex,
if (auto* globalLoc =
std::get_if<GlobalLocation>(&getLocation(locationIndex))) {
filterGlobalContents(contents, *globalLoc);
if (contents == oldContents) {
if (contents == oldContents &&
contents.getType() == oldContents.getType()) {
// Nothing actually changed after filtering, so just return.
return worthSendingMore;
}
Expand Down
1 change: 1 addition & 0 deletions src/passes/CMakeLists.txt
Expand Up @@ -40,6 +40,7 @@ set(passes_SOURCES
GlobalRefining.cpp
GlobalStructInference.cpp
GlobalTypeOptimization.cpp
GUFA.cpp
Heap2Local.cpp
I64ToI32Lowering.cpp
Inlining.cpp
Expand Down