Merge add_handler into catch_switch
Some codegen backends may require all handlers to be immediately known
This commit is contained in:
parent
e9646fa76b
commit
7a164509d3
5 changed files with 18 additions and 20 deletions
|
@ -1291,11 +1291,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn catch_switch(&mut self, _parent: Option<RValue<'gcc>>, _unwind: Option<Block<'gcc>>, _num_handlers: usize) -> RValue<'gcc> {
|
fn catch_switch(
|
||||||
unimplemented!();
|
&mut self,
|
||||||
}
|
_parent: Option<RValue<'gcc>>,
|
||||||
|
_unwind: Option<Block<'gcc>>,
|
||||||
fn add_handler(&mut self, _catch_switch: RValue<'gcc>, _handler: Block<'gcc>) {
|
_handlers: &[Block<'gcc>],
|
||||||
|
) -> RValue<'gcc> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1028,7 +1028,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
parent: Option<&'ll Value>,
|
parent: Option<&'ll Value>,
|
||||||
unwind: Option<&'ll BasicBlock>,
|
unwind: Option<&'ll BasicBlock>,
|
||||||
num_handlers: usize,
|
handlers: &[&'ll BasicBlock],
|
||||||
) -> &'ll Value {
|
) -> &'ll Value {
|
||||||
let name = cstr!("catchswitch");
|
let name = cstr!("catchswitch");
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
|
@ -1036,18 +1036,18 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
self.llbuilder,
|
self.llbuilder,
|
||||||
parent,
|
parent,
|
||||||
unwind,
|
unwind,
|
||||||
num_handlers as c_uint,
|
handlers.len() as c_uint,
|
||||||
name.as_ptr(),
|
name.as_ptr(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
ret.expect("LLVM does not have support for catchswitch")
|
let ret = ret.expect("LLVM does not have support for catchswitch");
|
||||||
}
|
for handler in handlers {
|
||||||
|
|
||||||
fn add_handler(&mut self, catch_switch: &'ll Value, handler: &'ll BasicBlock) {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustAddHandler(catch_switch, handler);
|
llvm::LLVMRustAddHandler(ret, handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
// Atomic Operations
|
// Atomic Operations
|
||||||
fn atomic_cmpxchg(
|
fn atomic_cmpxchg(
|
||||||
|
|
|
@ -525,9 +525,8 @@ fn codegen_msvc_try<'ll>(
|
||||||
|
|
||||||
normal.ret(bx.const_i32(0));
|
normal.ret(bx.const_i32(0));
|
||||||
|
|
||||||
let cs = catchswitch.catch_switch(None, None, 2);
|
let cs =
|
||||||
catchswitch.add_handler(cs, catchpad_rust.llbb());
|
catchswitch.catch_switch(None, None, &[catchpad_rust.llbb(), catchpad_foreign.llbb()]);
|
||||||
catchswitch.add_handler(cs, catchpad_foreign.llbb());
|
|
||||||
|
|
||||||
// We can't use the TypeDescriptor defined in libpanic_unwind because it
|
// We can't use the TypeDescriptor defined in libpanic_unwind because it
|
||||||
// might be in another DLL and the SEH encoding only supports specifying
|
// might be in another DLL and the SEH encoding only supports specifying
|
||||||
|
|
|
@ -1346,8 +1346,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let mut cp_bx = self.new_block(&format!("cp_funclet{:?}", bb));
|
let mut cp_bx = self.new_block(&format!("cp_funclet{:?}", bb));
|
||||||
ret_llbb = cs_bx.llbb();
|
ret_llbb = cs_bx.llbb();
|
||||||
|
|
||||||
let cs = cs_bx.catch_switch(None, None, 1);
|
let cs = cs_bx.catch_switch(None, None, &[cp_bx.llbb()]);
|
||||||
cs_bx.add_handler(cs, cp_bx.llbb());
|
|
||||||
|
|
||||||
// The "null" here is actually a RTTI type descriptor for the
|
// The "null" here is actually a RTTI type descriptor for the
|
||||||
// C++ personality function, but `catch (...)` has no type so
|
// C++ personality function, but `catch (...)` has no type so
|
||||||
|
|
|
@ -441,9 +441,8 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
&mut self,
|
&mut self,
|
||||||
parent: Option<Self::Value>,
|
parent: Option<Self::Value>,
|
||||||
unwind: Option<Self::BasicBlock>,
|
unwind: Option<Self::BasicBlock>,
|
||||||
num_handlers: usize,
|
handlers: &[Self::BasicBlock],
|
||||||
) -> Self::Value;
|
) -> Self::Value;
|
||||||
fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock);
|
|
||||||
|
|
||||||
fn atomic_cmpxchg(
|
fn atomic_cmpxchg(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue