Skip to content

Emit traps for unreachable nodes #41465

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

Merged
merged 2 commits into from
Jul 6, 2021
Merged

Emit traps for unreachable nodes #41465

merged 2 commits into from
Jul 6, 2021

Conversation

Keno
Copy link
Member

@Keno Keno commented Jul 5, 2021

Raw unreachable in LLVM is somewhat dangerous since LLVM will literally
stop emitting code there, so if the unreachable is wrong, execution will
crash into whatever subsequent code exists, causing strange and mysterious
errors and incorrect backtraces that are hard to debug without rr. As a
result, we basically always emit a safety trap call before an unreachable
terminator, which will abort execution at the point where unreachable was
executed and at least provide proper backtraces. However, we neglected
to do this for literal unreachables that came from Julia IR (i.e. ReturnNodes
with undef val field). Fix that to make debugging easier if unreachable
ever gets accidentally executed.

Raw `unreachable` in LLVM is somewhat dangerous since LLVM will literally
stop emitting code there, so if the unreachable is wrong, execution will
crash into whatever subsequent code exists, causing strange and mysterious
errors and incorrect backtraces that are hard to debug without rr. As a
result, we basically always emit a safety trap call before an `unreachable`
terminator, which will abort execution at the point where unreachable was
executed and at least provide proper backtraces. However, we neglected
to do this for literal unreachables that came from Julia IR (i.e. ReturnNodes
with undef val field). Fix that to make debugging easier if unreachable
ever gets accidentally executed.
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
@JeffBezanson JeffBezanson added the compiler:codegen Generation of LLVM IR and native code label Jul 6, 2021
@JeffBezanson JeffBezanson merged commit c73901e into master Jul 6, 2021
@JeffBezanson JeffBezanson deleted the kf/unreachabletrap branch July 6, 2021 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants