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

Alternative version of TypeGeneralizing #6108

Draft
wants to merge 124 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
536d82e
nfc
kripken Nov 9, 2023
bb938c7
nfc2
kripken Nov 9, 2023
b23f119
nfc3: extract to header
kripken Nov 9, 2023
d08b516
format
kripken Nov 9, 2023
732a478
start
kripken Nov 9, 2023
1bdcaa6
yolo
kripken Nov 9, 2023
273fd71
clarify
kripken Nov 9, 2023
6a29894
progress
kripken Nov 9, 2023
91297d8
work
kripken Nov 10, 2023
1d32545
work
kripken Nov 10, 2023
620fd2b
work
kripken Nov 10, 2023
e490e38
sketch
kripken Nov 10, 2023
e09630a
fix
kripken Nov 10, 2023
5f72f28
builds
kripken Nov 10, 2023
cdc183d
start.test
kripken Nov 10, 2023
ae6554a
fix
kripken Nov 10, 2023
7e60472
builds
kripken Nov 10, 2023
8b34182
fix
kripken Nov 10, 2023
f69a93d
builds
kripken Nov 10, 2023
e7f74c4
builds
kripken Nov 10, 2023
6e66fa4
work
kripken Nov 10, 2023
e925f84
fix
kripken Nov 10, 2023
c5ce054
initial results
kripken Nov 10, 2023
d1202b3
work
kripken Nov 10, 2023
02b2c31
work
kripken Nov 10, 2023
2751798
tests pass
kripken Nov 10, 2023
4107d40
work
kripken Nov 10, 2023
9f820d0
format
kripken Nov 10, 2023
d77ba7b
work
kripken Nov 10, 2023
698474c
work
kripken Nov 10, 2023
6e003dd
work
kripken Nov 10, 2023
0b3e742
Notes
kripken Nov 10, 2023
dddcc8e
[NFC] Add LocalLocation for future use
kripken Nov 10, 2023
8ce1726
[NFC] Refactor out subtyping discovery code
kripken Nov 10, 2023
6be166d
undo
kripken Nov 10, 2023
0162cfe
Revert "undo"
kripken Nov 10, 2023
c557148
clean
kripken Nov 10, 2023
38d9b0a
Merge remote-tracking branch 'origin/alt.1' into alt.rock
kripken Nov 10, 2023
b7dc668
Merge remote-tracking branch 'origin/alt.3' into alt.rock
kripken Nov 10, 2023
d22b5e2
comment
kripken Nov 10, 2023
81d5c0b
Merge remote-tracking branch 'origin/alt.1' into alt.2
kripken Nov 10, 2023
3dd6a0d
Merge branch 'alt.2' into alt.3
kripken Nov 10, 2023
6203fc4
Merge branch 'alt.3' into alt.rock
kripken Nov 10, 2023
5c15ced
cleanup
kripken Nov 10, 2023
61c3b87
Merge remote-tracking branch 'origin/main' into alt.rock
kripken Nov 13, 2023
090992b
Use analysis framework
kripken Nov 13, 2023
a0fe083
Feedback
kripken Nov 14, 2023
63abaf9
Update src/ir/subtype-exprs.h
kripken Nov 14, 2023
18d8ca5
fix
kripken Nov 14, 2023
260a023
Merge branch 'alt.2' into alt.3
kripken Nov 14, 2023
e9c3b60
Merge branch 'alt.3' into alt.rock
kripken Nov 14, 2023
aca25ec
fix
kripken Nov 14, 2023
8792e2e
fix
kripken Nov 14, 2023
539b439
fix
kripken Nov 14, 2023
3a24bb5
format
kripken Nov 14, 2023
d7637a2
fix
kripken Nov 14, 2023
e5f0194
validator
kripken Nov 14, 2023
bd5e73d
fix
kripken Nov 14, 2023
3ae4a9e
fix
kripken Nov 14, 2023
0e46261
fix
kripken Nov 14, 2023
a5eb321
fix
kripken Nov 14, 2023
116849d
fix
kripken Nov 14, 2023
72acbba
fix
kripken Nov 14, 2023
bee3702
update
kripken Nov 14, 2023
06a5e14
format
kripken Nov 14, 2023
c37206a
prep
kripken Nov 14, 2023
6c04dcb
prep
kripken Nov 14, 2023
da9791e
prep
kripken Nov 14, 2023
57ed68a
rework
kripken Nov 14, 2023
4d7fc7c
prep
kripken Nov 14, 2023
d9cc371
prep
kripken Nov 14, 2023
02c5dc4
prep
kripken Nov 14, 2023
7b7eb45
workey
kripken Nov 14, 2023
a83e39d
clean
kripken Nov 14, 2023
22b833b
work
kripken Nov 15, 2023
7cafa05
format
kripken Nov 15, 2023
45406e6
work
kripken Nov 15, 2023
c894d75
work
kripken Nov 15, 2023
0879c3c
work
kripken Nov 15, 2023
09632bd
work
kripken Nov 15, 2023
14c7bf3
work
kripken Nov 15, 2023
d345d2b
format
kripken Nov 15, 2023
1809f1a
prep
kripken Nov 15, 2023
b6ec0b6
prep
kripken Nov 15, 2023
9d17e24
clean
kripken Nov 15, 2023
c8abfd6
prep
kripken Nov 15, 2023
dce5608
prep
kripken Nov 15, 2023
19611bf
fix
kripken Nov 15, 2023
dd7a433
work
kripken Nov 15, 2023
90733d4
work
kripken Nov 15, 2023
4ee38d0
format
kripken Nov 15, 2023
4335a51
simpl
kripken Nov 15, 2023
66fa71f
Merge remote-tracking branch 'origin/main' into alt.rock
kripken Nov 16, 2023
e805de6
format
kripken Nov 16, 2023
4b33124
refactor
kripken Nov 16, 2023
5d84b72
should
kripken Nov 16, 2023
a24407a
fix
kripken Nov 16, 2023
c481c15
refactor
kripken Nov 16, 2023
8798878
work
kripken Nov 16, 2023
b542296
work
kripken Nov 16, 2023
6a48d60
format
kripken Nov 16, 2023
70a48a2
clean
kripken Nov 16, 2023
ba3c762
fix
kripken Nov 16, 2023
8886fca
format
kripken Nov 16, 2023
dcec3fc
better
kripken Nov 16, 2023
13093b7
better
kripken Nov 16, 2023
0a8c404
better
kripken Nov 16, 2023
b1e3b2f
format
kripken Nov 16, 2023
de94c78
better
kripken Nov 16, 2023
89d4e85
better
kripken Nov 16, 2023
4f69788
better
kripken Nov 16, 2023
aeb1489
better
kripken Nov 16, 2023
54ad325
better
kripken Nov 16, 2023
e20ed51
format
kripken Nov 16, 2023
67c42ac
better
kripken Nov 16, 2023
d3be3ee
type debugging utils [to split out]
kripken Nov 16, 2023
5e0bd0a
format
kripken Nov 16, 2023
f5babc4
simplify
kripken Nov 16, 2023
c008cd1
simplify
kripken Nov 16, 2023
9c45a7a
simplify
kripken Nov 16, 2023
3903ea3
simplify
kripken Nov 17, 2023
9c6e4d9
Merge remote-tracking branch 'origin/main' into alt.rock
kripken Nov 17, 2023
b3e433d
comment
kripken Nov 17, 2023
1b939f7
work
kripken Nov 17, 2023
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
35 changes: 27 additions & 8 deletions src/ir/subtype-exprs.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
void visitRefNull(RefNull* curr) {}
void visitRefIsNull(RefIsNull* curr) {}
void visitRefFunc(RefFunc* curr) {}
void visitRefEq(RefEq* curr) {}
void visitRefEq(RefEq* curr) {
self()->noteSubtype(curr->left, Type(HeapType::eq, Nullable));
self()->noteSubtype(curr->right, Type(HeapType::eq, Nullable));
}
void visitTableGet(TableGet* curr) {}
void visitTableSet(TableSet* curr) {
self()->noteSubtype(curr->value,
Expand Down Expand Up @@ -223,12 +226,27 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
void visitTupleMake(TupleMake* curr) {}
void visitTupleExtract(TupleExtract* curr) {}
void visitRefI31(RefI31* curr) {}
void visitI31Get(I31Get* curr) {}
void visitI31Get(I31Get* curr) {
self()->noteSubtype(curr->i31, Type(HeapType::i31, Nullable));
}
void visitCallRef(CallRef* curr) {
if (!curr->target->type.isSignature()) {
return;
// Even if we are unreachable, the target must be valid, and in particular
// it cannot be funcref - it must be a proper signature type. We could
// perhaps have |addStrictSubtype| to handle that, but for now just require
// that the target keep its type.
//
// Note that even if we are reachable, there is an interaction between the
// target and the the types of the parameters and results (the target's type
// must support the parameter and result types properly), and so it is not
// obvious how users would want to optimize here (if they are trying to
// generalize, should they generalize the target more or the parameters
// more? etc.), so we do the simple thing here for now of requiring the
// target type not generalize.
self()->noteSubtype(curr->target, curr->target->type);

if (curr->target->type.isSignature()) {
handleCall(curr, curr->target->type.getHeapType().getSignature());
}
handleCall(curr, curr->target->type.getHeapType().getSignature());
}
void visitRefTest(RefTest* curr) {
self()->noteCast(curr->ref, curr->castType);
Expand Down Expand Up @@ -284,13 +302,14 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
self()->noteSubtype(value, array.element.type);
}
}

void visitArrayGet(ArrayGet* curr) {}
void visitArraySet(ArraySet* curr) {
if (!curr->ref->type.isArray()) {
return;
}
auto array = curr->ref->type.getHeapType().getArray();
self()->noteSubtype(curr->value->type, array.element.type);
self()->noteSubtype(curr->value, array.element.type);
}
void visitArrayLen(ArrayLen* curr) {}
void visitArrayCopy(ArrayCopy* curr) {
Expand All @@ -306,7 +325,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
return;
}
auto array = curr->ref->type.getHeapType().getArray();
self()->noteSubtype(curr->value->type, array.element.type);
self()->noteSubtype(curr->value, array.element.type);
}
void visitArrayInitData(ArrayInitData* curr) {}
void visitArrayInitElem(ArrayInitElem* curr) {
Expand All @@ -317,7 +336,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
auto* seg = self()->getModule()->getElementSegment(curr->segment);
self()->noteSubtype(seg->type, array.element.type);
}
void visitRefAs(RefAs* curr) {}
void visitRefAs(RefAs* curr) { self()->noteCast(curr->value, curr); }
void visitStringNew(StringNew* curr) {}
void visitStringConst(StringConst* curr) {}
void visitStringMeasure(StringMeasure* curr) {}
Expand Down
1 change: 1 addition & 0 deletions src/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ set(passes_SOURCES
ReReloop.cpp
TrapMode.cpp
TypeGeneralizing.cpp
TypeGeneralizing2.cpp
TypeRefining.cpp
TypeMerging.cpp
TypeSSA.cpp
Expand Down
Loading
Loading