about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2021-09-06 13:10:11 +0200
committerAmanieu d'Antras <amanieu@gmail.com>2021-09-11 16:13:30 +0100
commit007bd17a68a502aef3df4799c7fa7c07985d7747 (patch)
tree0cb1b9a1bf6d9f827deed10f15ef8f24930688ac /compiler/rustc_codegen_llvm/src
parent8c7a05a23f427625f99b74ca506a0f5d8eb9bc11 (diff)
downloadrust-007bd17a68a502aef3df4799c7fa7c07985d7747.tar.gz
rust-007bd17a68a502aef3df4799c7fa7c07985d7747.zip
Apply noreturn and nounwind LLVM attributes to callsites
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/abi.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index cd55a61cbaf..b7180fd84c3 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -511,7 +511,12 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
     }
 
     fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value) {
-        // FIXME(wesleywiser, eddyb): We should apply `nounwind` and `noreturn` as appropriate to this callsite.
+        if self.ret.layout.abi.is_uninhabited() {
+            llvm::Attribute::NoReturn.apply_callsite(llvm::AttributePlace::Function, callsite);
+        }
+        if !self.can_unwind {
+            llvm::Attribute::NoUnwind.apply_callsite(llvm::AttributePlace::Function, callsite);
+        }
 
         let mut i = 0;
         let mut apply = |cx: &CodegenCx<'_, '_>, attrs: &ArgAttributes| {