Skip to content

Commit f6ce771

Browse files
committed
Merge landing_pad and set_cleanup into cleanup_landing_pad
1 parent 7a16450 commit f6ce771

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12601260
// TODO(antoyo)
12611261
}
12621262

1263-
fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> {
1263+
fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>) -> RValue<'gcc> {
12641264
let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
12651265
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
12661266
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
@@ -1271,10 +1271,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12711271
// rustc_codegen_ssa now calls the unwinding builder methods even on panic=abort.
12721272
}
12731273

1274-
fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) {
1275-
// TODO(antoyo)
1276-
}
1277-
12781274
fn resume(&mut self, _exn: RValue<'gcc>) {
12791275
unimplemented!();
12801276
}

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -962,25 +962,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
962962
}
963963
}
964964

965-
fn landing_pad(
966-
&mut self,
967-
ty: &'ll Type,
968-
pers_fn: &'ll Value,
969-
num_clauses: usize,
970-
) -> &'ll Value {
971-
// Use LLVMSetPersonalityFn to set the personality. It supports arbitrary Consts while,
972-
// LLVMBuildLandingPad requires the argument to be a Function (as of LLVM 12). The
973-
// personality lives on the parent function anyway.
974-
self.set_personality_fn(pers_fn);
975-
unsafe {
976-
llvm::LLVMBuildLandingPad(self.llbuilder, ty, None, num_clauses as c_uint, UNNAMED)
977-
}
978-
}
979-
980-
fn set_cleanup(&mut self, landing_pad: &'ll Value) {
965+
fn cleanup_landing_pad(&mut self, ty: &'ll Type, pers_fn: &'ll Value) -> &'ll Value {
966+
let landing_pad = self.landing_pad(ty, pers_fn, 1 /* FIXME should this be 0? */);
981967
unsafe {
982968
llvm::LLVMSetCleanup(landing_pad, llvm::True);
983969
}
970+
landing_pad
984971
}
985972

986973
fn resume(&mut self, exn: &'ll Value) {
@@ -1477,4 +1464,19 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14771464
None
14781465
}
14791466
}
1467+
1468+
pub(crate) fn landing_pad(
1469+
&mut self,
1470+
ty: &'ll Type,
1471+
pers_fn: &'ll Value,
1472+
num_clauses: usize,
1473+
) -> &'ll Value {
1474+
// Use LLVMSetPersonalityFn to set the personality. It supports arbitrary Consts while,
1475+
// LLVMBuildLandingPad requires the argument to be a Function (as of LLVM 12). The
1476+
// personality lives on the parent function anyway.
1477+
self.set_personality_fn(pers_fn);
1478+
unsafe {
1479+
llvm::LLVMBuildLandingPad(self.llbuilder, ty, None, num_clauses as c_uint, UNNAMED)
1480+
}
1481+
}
14801482
}

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13731373

13741374
let llpersonality = self.cx.eh_personality();
13751375
let llretty = self.landing_pad_type();
1376-
let lp = bx.landing_pad(llretty, llpersonality, 1);
1377-
bx.set_cleanup(lp);
1376+
let lp = bx.cleanup_landing_pad(llretty, llpersonality);
13781377

13791378
let slot = self.get_personality_slot(&mut bx);
13801379
slot.storage_live(&mut bx);

compiler/rustc_codegen_ssa/src/traits/builder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,7 @@ pub trait BuilderMethods<'a, 'tcx>:
424424
fn set_personality_fn(&mut self, personality: Self::Value);
425425

426426
// These are used by everyone except msvc
427-
fn landing_pad(
428-
&mut self,
429-
ty: Self::Type,
430-
pers_fn: Self::Value,
431-
num_clauses: usize,
432-
) -> Self::Value;
433-
fn set_cleanup(&mut self, landing_pad: Self::Value);
427+
fn cleanup_landing_pad(&mut self, ty: Self::Type, pers_fn: Self::Value) -> Self::Value;
434428
fn resume(&mut self, exn: Self::Value);
435429

436430
// These are used only by msvc

0 commit comments

Comments
 (0)