Skip to content

Commit 1449894

Browse files
committed
Fix to use Function instead of RValue
1 parent 5735bb3 commit 1449894

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/builder.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,16 +1570,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
15701570
aggregate_value
15711571
}
15721572

1573-
fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
1573+
fn set_personality_fn(&mut self, _personality: Function<'gcc>) {
15741574
#[cfg(feature = "master")]
1575-
{
1576-
let personality = self.rvalue_as_function(_personality);
1577-
self.current_func().set_personality_function(personality);
1578-
}
1575+
self.current_func().set_personality_function(_personality);
15791576
}
15801577

15811578
#[cfg(feature = "master")]
1582-
fn cleanup_landing_pad(&mut self, pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1579+
fn cleanup_landing_pad(&mut self, pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
15831580
self.set_personality_fn(pers_fn);
15841581

15851582
// NOTE: insert the current block in a variable so that a later call to invoke knows to
@@ -1610,7 +1607,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
16101607
(value1, value2)
16111608
}
16121609

1613-
fn filter_landing_pad(&mut self, pers_fn: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
1610+
fn filter_landing_pad(&mut self, pers_fn: Function<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
16141611
// TODO(antoyo): generate the correct landing pad
16151612
self.cleanup_landing_pad(pers_fn)
16161613
}

src/context.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
120120
/// A counter that is used for generating local symbol names
121121
local_gen_sym_counter: Cell<usize>,
122122

123-
eh_personality: Cell<Option<RValue<'gcc>>>,
123+
eh_personality: Cell<Option<Function<'gcc>>>,
124124
#[cfg(feature = "master")]
125125
pub rust_try_fn: Cell<Option<(Type<'gcc>, Function<'gcc>)>>,
126126

@@ -428,7 +428,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
428428
ptr
429429
}
430430

431-
fn eh_personality(&self) -> RValue<'gcc> {
431+
fn eh_personality(&self) -> Function<'gcc> {
432432
// The exception handling personality function.
433433
//
434434
// If our compilation unit has the `eh_personality` lang item somewhere
@@ -466,18 +466,15 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
466466
let symbol_name = tcx.symbol_name(instance).name;
467467
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
468468
self.linkage.set(FunctionType::Extern);
469-
let func = self.declare_fn(symbol_name, fn_abi);
470-
let func: RValue<'gcc> = unsafe { std::mem::transmute(func) };
471-
func
469+
self.declare_fn(symbol_name, fn_abi)
472470
}
473471
_ => {
474472
let name = if wants_msvc_seh(self.sess()) {
475473
"__CxxFrameHandler3"
476474
} else {
477475
"rust_eh_personality"
478476
};
479-
let func = self.declare_func(name, self.type_i32(), &[], true);
480-
unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) }
477+
self.declare_func(name, self.type_i32(), &[], true)
481478
}
482479
};
483480
// TODO(antoyo): apply target cpu attributes.

0 commit comments

Comments
 (0)