[PATCH] D105374: [SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to transfer execution to unreachable
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 2 15:24:22 PDT 2021
efriedma added inline comments.
================
Comment at: llvm/test/CodeGen/PowerPC/2007-11-16-landingpad-split.ll:86-87
catch i8* null
call void @llvm.stackrestore(i8* %tmp4)
resume { i8*, i32 } %exn
----------------
nikic wrote:
> lebedev.ri wrote:
> > What happens here is that `call void @llvm.stackrestore()` ends up being located
> > right before `unreachable`, and we now happily erase it.
> > I think that makes sense, because `resume` would cause us to "return" from the function,
> > freeing all the stack anyways.
> This test is probably supposed to have a `cleanup` on the landingpad.
>
> Speaking of, can someone point me to the relevant wording in LangRef/ExceptionHandling on why resuming from a non-cleanup landingpad is UB? At least that's how I understand the DwarfEHPrepare code.
I'm not sure it's really justified anywhere.
In practice, I think it works out for clang because we only use "resume" for cleanups; to rethrow an exception, we use `__cxa_rethrow()`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105374/new/
https://reviews.llvm.org/D105374
More information about the llvm-commits
mailing list