-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Wasm EH: "Branch destination should be in scope" error #13515
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
Comments
A smaller testcase: extern bool getBoolean();
struct Class {
~Class();
};
int main() {
if (getBoolean()) {
try {
throw 0;
} catch(int) {
}
}
Class instance1;
if (getBoolean()) {
}
while (getBoolean()) {
}
} |
@aheejin I know you are currently working on #13514 (which I agree is best since that's the one we saw in real code). Do you have a sense for whether this is likely to be an independent bug from that? To me it looks like both of these result from control flow destinations not being in the stack, and a change to the grouping algorithm is likely to affect both of those (so in other words, my guess would be that it's not worth trying to investigate fixing this separately from a fix to #13514. does that sound right to you?) |
I had to investigate this in order to find out whether it is independent or not, and it is independent. But also while investigating this I think I found out the cause for this bug too. So not sure if it is advisable to ask you to fix this separately. |
OK yeah, if your tentative fix for #13514 works out, then it probably makes sense for you to pick this one up too. |
btw If you want to upload something to phabricator I'd be happy to throw some testing at it too. |
This appears to still happen after the fix landed, on other testcases. A reduced one: extern bool getBoolean();
struct Class {
Class();
~Class();
};
int main() {
if (getBoolean()) {
try {
throw 0;
} catch (int) {
}
try {
if (getBoolean()) {
}
throw 0;
} catch (int) {
}
}
Class instance1;
try {
getBoolean();
} catch (int) {
}
getBoolean();
} STR: |
Fixing catch unwind mismatches can sometimes invalidate existing branch destinations. This CL remaps those destinations after placing try-delegates. Fixes emscripten-core/emscripten#13515. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D97178
This is a case D97178 tried to solve but missed. D97178 could not handle the case when multiple consecutive delegates are generated: - Before: ``` block br (a) try catch end_try end_block <- (a) ``` - After ``` block br (a) try ... try try catch end_try <- (a) delegate delegate end_block <- (b) ``` (The `br` should point to (b) now) D97178 assumed `end_block` exists two BBs later than `end_try`, because it assumed the order as `end_try` BB -> `delegate` BB -> `end_block` BB. But it turned out there can be multiple `delegate`s in between. This patch changes the logic so we just search from `end_try` BB until we find `end_block`. Fixes emscripten-core/emscripten#13515. (More precisely, fixes emscripten-core/emscripten#13515 (comment).) Reviewed By: dschuff, tlively Differential Revision: https://reviews.llvm.org/D97569
Fixing catch unwind mismatches can sometimes invalidate existing branch destinations. This CL remaps those destinations after placing try-delegates. Fixes emscripten-core/emscripten#13515. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D97178
This is a case D97178 tried to solve but missed. D97178 could not handle the case when multiple consecutive delegates are generated: - Before: ``` block br (a) try catch end_try end_block <- (a) ``` - After ``` block br (a) try ... try try catch end_try <- (a) delegate delegate end_block <- (b) ``` (The `br` should point to (b) now) D97178 assumed `end_block` exists two BBs later than `end_try`, because it assumed the order as `end_try` BB -> `delegate` BB -> `end_block` BB. But it turned out there can be multiple `delegate`s in between. This patch changes the logic so we just search from `end_try` BB until we find `end_block`. Fixes emscripten-core/emscripten#13515. (More precisely, fixes emscripten-core/emscripten#13515 (comment).) Reviewed By: dschuff, tlively Differential Revision: https://reviews.llvm.org/D97569
STR:
emcc a.cpp -c -fwasm-exceptions
Found by #13485
cc @aheejin @dschuff
The text was updated successfully, but these errors were encountered: