[Bug middle-end/114391] catch() and immediate throw; could be optimized to noop
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114391 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement CC||pinskia at gcc dot gnu.org
[Bug middle-end/114391] catch() and immediate throw; could be optimized to noop
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114391 --- Comment #2 from Antony Polukhin --- > Is there something to optimize when foo() cannot be tail-called? Yes. Just `catch (...) { throw; }`, no more restrictions. I do not even think, that it should be the outer most EH region: void foo(); void bar(); void test() { try { foo(); } catch (...) { throw; } bar(); } is fine to optimize to just void test() { foo(); bar(); }
[Bug middle-end/114391] catch() and immediate throw; could be optimized to noop
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114391 Richard Biener changed: What|Removed |Added Last reconfirmed||2024-03-19 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- Is there something to optimize when foo() cannot be tail-called? IMO that would be best done separately. Consider int foo(); int test() { try { return foo() + 1; } catch (...) { throw; } } wouldn't it be valid to turn this into int test() { return foo () + 1; } so the requirement is that the try {} catch (...) { throw; } is the outermost EH handling region, nothing more? And then we can elide it?