about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-07-07 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-07-10 15:43:05 +0200
commitae33a9714e73dda15030894821b6819f781ed7ba (patch)
tree5094a30eb1677b3791580accb761f860c78844b1 /compiler/rustc_codegen_llvm/src
parenta84d1b21aea9863f0fc5f436b4982d145dade646 (diff)
downloadrust-ae33a9714e73dda15030894821b6819f781ed7ba.tar.gz
rust-ae33a9714e73dda15030894821b6819f781ed7ba.zip
Set personality with LLVMSetPersonalityFn
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs6
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm/ffi.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 582c9354041..981ea95f2e0 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -937,8 +937,12 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
         pers_fn: &'ll Value,
         num_clauses: usize,
     ) -> &'ll Value {
+        // Use LLVMSetPersonalityFn to set the personality. It supports arbitrary Consts while,
+        // LLVMBuildLandingPad requires the argument to be a Function (as of LLVM 12). The
+        // personality lives on the parent function anyway.
+        self.set_personality_fn(pers_fn);
         unsafe {
-            llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, num_clauses as c_uint, UNNAMED)
+            llvm::LLVMBuildLandingPad(self.llbuilder, ty, None, num_clauses as c_uint, UNNAMED)
         }
     }
 
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 91923251018..b513e83bd19 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -1165,7 +1165,7 @@ extern "C" {
     pub fn LLVMBuildLandingPad(
         B: &Builder<'a>,
         Ty: &'a Type,
-        PersFn: &'a Value,
+        PersFn: Option<&'a Value>,
         NumClauses: c_uint,
         Name: *const c_char,
     ) -> &'a Value;