Skip to content

Commit 007bd17

Browse files
committed
Apply noreturn and nounwind LLVM attributes to callsites
1 parent 8c7a05a commit 007bd17

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_codegen_llvm/src

1 file changed

+6
-1
lines changed

compiler/rustc_codegen_llvm/src/abi.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,12 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
511511
}
512512

513513
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
514-
// FIXME(wesleywiser, eddyb): We should apply `nounwind` and `noreturn` as appropriate to this callsite.
514+
if self.ret.layout.abi.is_uninhabited() {
515+
llvm::Attribute::NoReturn.apply_callsite(llvm::AttributePlace::Function, callsite);
516+
}
517+
if !self.can_unwind {
518+
llvm::Attribute::NoUnwind.apply_callsite(llvm::AttributePlace::Function, callsite);
519+
}
515520

516521
let mut i = 0;
517522
let mut apply = |cx: &CodegenCx<'_, '_>, attrs: &ArgAttributes| {

0 commit comments

Comments
 (0)