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

Mark all functions defined in compiler-builtins as nounwind #121605

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,21 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
return false;
}
}

// Functions in compiler builtins can never unwind.
//
// The `compiler-builtins` crate exports a bunch of LLVM intrinsics which are defined
// with the C ABI, so it must not unwind. If such functions call into unwindable
// functions, rustc will inject unwind guards to prevent unwind leaking out. This is
// normally okay, but for `compiler-builtins` crate it has the additional requirement to
// not call into libcore, so we *must not* generate such guards. One way to do it is to
// ensure those exported functions never call into unwindable functions, so we make
// every single function defined in compiler builtins nounwind.
//
// See rust-lang/compiler-builtins#578 for context.
if tcx.is_compiler_builtins(did.krate) && !tcx.is_foreign_item(did) {
return false;
}
}

// Otherwise if this isn't special then unwinding is generally determined by
Expand Down
Loading