]> git.lizzy.rs Git - rust.git/commitdiff
Merge landing_pad and set_cleanup into cleanup_landing_pad
authorbjorn3 <bjorn3@users.noreply.github.com>
Mon, 24 Jan 2022 12:57:32 +0000 (13:57 +0100)
committerbjorn3 <bjorn3@users.noreply.github.com>
Mon, 24 Jan 2022 13:10:05 +0000 (14:10 +0100)
compiler/rustc_codegen_gcc/src/builder.rs
compiler/rustc_codegen_llvm/src/builder.rs
compiler/rustc_codegen_ssa/src/mir/block.rs
compiler/rustc_codegen_ssa/src/traits/builder.rs

index 185aa3a5b40905f55593f7bd88531e477a81463a..ffb77e16a14863c505b199efdf2acdb02e9118a8 100644 (file)
@@ -1260,7 +1260,7 @@ fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
         // TODO(antoyo)
     }
 
-    fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> {
+    fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>) -> RValue<'gcc> {
         let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
         let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
         let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
@@ -1271,10 +1271,6 @@ fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses:
         // rustc_codegen_ssa now calls the unwinding builder methods even on panic=abort.
     }
 
-    fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) {
-        // TODO(antoyo)
-    }
-
     fn resume(&mut self, _exn: RValue<'gcc>) {
         unimplemented!();
     }
index 02b9f23c4d6a6171a64a19d34580dd4721159817..c9a04e6280f4092d4537ffec4e535a12ffafa805 100644 (file)
@@ -962,25 +962,12 @@ fn set_personality_fn(&mut self, personality: &'ll Value) {
         }
     }
 
-    fn landing_pad(
-        &mut self,
-        ty: &'ll Type,
-        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, None, num_clauses as c_uint, UNNAMED)
-        }
-    }
-
-    fn set_cleanup(&mut self, landing_pad: &'ll Value) {
+    fn cleanup_landing_pad(&mut self, ty: &'ll Type, pers_fn: &'ll Value) -> &'ll Value {
+        let landing_pad = self.landing_pad(ty, pers_fn, 1 /* FIXME should this be 0? */);
         unsafe {
             llvm::LLVMSetCleanup(landing_pad, llvm::True);
         }
+        landing_pad
     }
 
     fn resume(&mut self, exn: &'ll Value) {
@@ -1477,4 +1464,19 @@ fn fptoint_sat(
             None
         }
     }
+
+    pub(crate) fn landing_pad(
+        &mut self,
+        ty: &'ll Type,
+        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, None, num_clauses as c_uint, UNNAMED)
+        }
+    }
 }
index ee7ca7f6e4661cb5b1bb9e62fe11ca78fd67a1b3..4c7a09ca1e94b2ede7ff45f957aaf240552c3a8e 100644 (file)
@@ -1373,8 +1373,7 @@ fn landing_pad_for_uncached(&mut self, bb: mir::BasicBlock) -> Bx::BasicBlock {
 
             let llpersonality = self.cx.eh_personality();
             let llretty = self.landing_pad_type();
-            let lp = bx.landing_pad(llretty, llpersonality, 1);
-            bx.set_cleanup(lp);
+            let lp = bx.cleanup_landing_pad(llretty, llpersonality);
 
             let slot = self.get_personality_slot(&mut bx);
             slot.storage_live(&mut bx);
index 6c88241350f9d678ce3482861330ecf3c57d4a7c..53fb21b269a12f46a3696388ff69324d1f773132 100644 (file)
@@ -424,13 +424,7 @@ fn select(
     fn set_personality_fn(&mut self, personality: Self::Value);
 
     // These are used by everyone except msvc
-    fn landing_pad(
-        &mut self,
-        ty: Self::Type,
-        pers_fn: Self::Value,
-        num_clauses: usize,
-    ) -> Self::Value;
-    fn set_cleanup(&mut self, landing_pad: Self::Value);
+    fn cleanup_landing_pad(&mut self, ty: Self::Type, pers_fn: Self::Value) -> Self::Value;
     fn resume(&mut self, exn: Self::Value);
 
     // These are used only by msvc