diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs index c9f84066da8d..ff030470634f 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs @@ -2942,14 +2942,11 @@ impl MachInstEmit for Inst { let offset = sink.cur_offset(); sink.push_user_stack_map(state, offset, s); } - sink.add_call_site(); - // Add exception info, if any, at this point (which will - // be the return address on stack). if let Some(try_call) = info.try_call_info.as_ref() { - for &(tag, label) in &try_call.exception_dests { - sink.add_exception_handler(tag, label); - } + sink.add_call_site(&try_call.exception_dests); + } else { + sink.add_call_site(&[]); } if info.callee_pop_size > 0 { @@ -2989,14 +2986,11 @@ impl MachInstEmit for Inst { let offset = sink.cur_offset(); sink.push_user_stack_map(state, offset, s); } - sink.add_call_site(); - // Add exception info, if any, at this point (which will - // be the return address on stack). if let Some(try_call) = info.try_call_info.as_ref() { - for &(tag, label) in &try_call.exception_dests { - sink.add_exception_handler(tag, label); - } + sink.add_call_site(&try_call.exception_dests); + } else { + sink.add_call_site(&[]); } if info.callee_pop_size > 0 { @@ -3035,7 +3029,7 @@ impl MachInstEmit for Inst { // for the target, but rather a function relocation. sink.add_reloc(Reloc::Arm64Call, &info.dest, 0); sink.put4(enc_jump26(0b000101, 0)); - sink.add_call_site(); + sink.add_call_site(&[]); // `emit_return_call_common_sequence` emits an island if // necessary, so we can safely disable the worst-case-size check @@ -3050,7 +3044,7 @@ impl MachInstEmit for Inst { targets: vec![], } .emit(sink, emit_info, state); - sink.add_call_site(); + sink.add_call_site(&[]); // `emit_return_call_common_sequence` emits an island if // necessary, so we can safely disable the worst-case-size check diff --git a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs index d0b741467758..bf226a0e7dda 100644 --- a/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs +++ b/cranelift/codegen/src/isa/pulley_shared/inst/emit.rs @@ -182,14 +182,11 @@ fn pulley_emit
( let offset = sink.cur_offset(); sink.push_user_stack_map(state, offset, s); } - sink.add_call_site(); - // Add exception info, if any, at this point (which will - // be the return address on stack). if let Some(try_call) = info.try_call_info.as_ref() { - for &(tag, label) in &try_call.exception_dests { - sink.add_exception_handler(tag, label); - } + sink.add_call_site(&try_call.exception_dests); + } else { + sink.add_call_site(&[]); } let adjust = -i32::try_from(info.callee_pop_size).unwrap(); @@ -226,14 +223,10 @@ fn pulley_emit
( sink.push_user_stack_map(state, offset, s); } - sink.add_call_site(); - - // Add exception info, if any, at this point (which will - // be the return address on stack). if let Some(try_call) = info.try_call_info.as_ref() { - for &(tag, label) in &try_call.exception_dests { - sink.add_exception_handler(tag, label); - } + sink.add_call_site(&try_call.exception_dests); + } else { + sink.add_call_site(&[]); } let adjust = -i32::try_from(info.callee_pop_size).unwrap(); @@ -295,7 +288,7 @@ fn pulley_emit
(
let offset = sink.cur_offset();
sink.push_user_stack_map(state, offset, s);
}
- sink.add_call_site();
+ sink.add_call_site(&[]);
// If a callee pop is happening here that means that something has
// messed up, these are expected to be "very simple" signatures.
diff --git a/cranelift/codegen/src/isa/riscv64/inst/emit.rs b/cranelift/codegen/src/isa/riscv64/inst/emit.rs
index 966176c6374e..805f88ac8690 100644
--- a/cranelift/codegen/src/isa/riscv64/inst/emit.rs
+++ b/cranelift/codegen/src/isa/riscv64/inst/emit.rs
@@ -1123,7 +1123,6 @@ impl Inst {
}
&Inst::Call { ref info } => {
- sink.add_call_site();
sink.add_reloc(Reloc::RiscvCallPlt, &info.dest, 0);
Inst::construct_auipc_and_jalr(Some(writable_link_reg()), writable_link_reg(), 0)
@@ -1135,12 +1134,10 @@ impl Inst {
sink.push_user_stack_map(state, offset, s);
}
- // Add exception info, if any, at this point (which will
- // be the return address on stack).
if let Some(try_call) = info.try_call_info.as_ref() {
- for &(tag, label) in &try_call.exception_dests {
- sink.add_exception_handler(tag, label);
- }
+ sink.add_call_site(&try_call.exception_dests);
+ } else {
+ sink.add_call_site(&[]);
}
let callee_pop_size = i32::try_from(info.callee_pop_size).unwrap();
@@ -1181,14 +1178,10 @@ impl Inst {
sink.push_user_stack_map(state, offset, s);
}
- sink.add_call_site();
-
- // Add exception info, if any, at this point (which will
- // be the return address on stack).
if let Some(try_call) = info.try_call_info.as_ref() {
- for &(tag, label) in &try_call.exception_dests {
- sink.add_exception_handler(tag, label);
- }
+ sink.add_call_site(&try_call.exception_dests);
+ } else {
+ sink.add_call_site(&[]);
}
let callee_pop_size = i32::try_from(info.callee_pop_size).unwrap();
@@ -1220,7 +1213,7 @@ impl Inst {
&Inst::ReturnCall { ref info } => {
emit_return_call_common_sequence(sink, emit_info, state, info);
- sink.add_call_site();
+ sink.add_call_site(&[]);
sink.add_reloc(Reloc::RiscvCallPlt, &info.dest, 0);
Inst::construct_auipc_and_jalr(None, writable_spilltmp_reg(), 0)
.into_iter()
diff --git a/cranelift/codegen/src/isa/s390x/inst/emit.rs b/cranelift/codegen/src/isa/s390x/inst/emit.rs
index aa13cadeb397..45cb6b88c705 100644
--- a/cranelift/codegen/src/isa/s390x/inst/emit.rs
+++ b/cranelift/codegen/src/isa/s390x/inst/emit.rs
@@ -3216,14 +3216,11 @@ impl Inst {
sink.push_user_stack_map(state, offset, s);
}
put(sink, enc);
- sink.add_call_site();
- // Add exception info, if any, at this point (which will
- // be the return address on stack).
if let Some(try_call) = info.try_call_info.as_ref() {
- for &(tag, label) in &try_call.exception_dests {
- sink.add_exception_handler(tag, label);
- }
+ sink.add_call_site(&try_call.exception_dests);
+ } else {
+ sink.add_call_site(&[]);
}
state.nominal_sp_offset -= info.callee_pop_size;
@@ -3264,7 +3261,7 @@ impl Inst {
}
};
put(sink, enc);
- sink.add_call_site();
+ sink.add_call_site(&[]);
}
&Inst::ElfTlsGetOffset { ref symbol, .. } => {
let opcode = 0xc05; // BRASL
@@ -3281,7 +3278,7 @@ impl Inst {
}
put(sink, &enc_ril_b(opcode, gpr(14), 0));
- sink.add_call_site();
+ sink.add_call_site(&[]);
}
&Inst::Args { .. } => {}
&Inst::Rets { .. } => {}
diff --git a/cranelift/codegen/src/isa/x64/inst/emit.rs b/cranelift/codegen/src/isa/x64/inst/emit.rs
index b086c215c92d..56ffc3e11ca4 100644
--- a/cranelift/codegen/src/isa/x64/inst/emit.rs
+++ b/cranelift/codegen/src/isa/x64/inst/emit.rs
@@ -1611,14 +1611,11 @@ pub(crate) fn emit(
// beginning of the immediate field.
emit_reloc(sink, Reloc::X86CallPCRel4, &call_info.dest, -4);
sink.put4(0);
- sink.add_call_site();
- // Add exception info, if any, at this point (which will
- // be the return address on stack).
if let Some(try_call) = call_info.try_call_info.as_ref() {
- for &(tag, label) in &try_call.exception_dests {
- sink.add_exception_handler(tag, label);
- }
+ sink.add_call_site(&try_call.exception_dests);
+ } else {
+ sink.add_call_site(&[]);
}
// Reclaim the outgoing argument area that was released by the callee, to ensure that
@@ -1663,7 +1660,7 @@ pub(crate) fn emit(
// beginning of the immediate field.
emit_reloc(sink, Reloc::X86CallPCRel4, &call_info.dest, -4);
sink.put4(0);
- sink.add_call_site();
+ sink.add_call_site(&[]);
}
Inst::ReturnCallUnknown { info: call_info } => {
@@ -1675,7 +1672,7 @@ pub(crate) fn emit(
target: RegMem::reg(callee),
}
.emit(sink, info, state);
- sink.add_call_site();
+ sink.add_call_site(&[]);
}
Inst::CallUnknown {
@@ -1717,14 +1714,10 @@ pub(crate) fn emit(
sink.push_user_stack_map(state, offset, s);
}
- sink.add_call_site();
-
- // Add exception info, if any, at this point (which will
- // be the return address on stack).
if let Some(try_call) = call_info.try_call_info.as_ref() {
- for &(tag, label) in &try_call.exception_dests {
- sink.add_exception_handler(tag, label);
- }
+ sink.add_call_site(&try_call.exception_dests);
+ } else {
+ sink.add_call_site(&[]);
}
// Reclaim the outgoing argument area that was released by the callee, to ensure that
diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs
index 2b1ac7ca07e3..ddfbc05d8f5c 100644
--- a/cranelift/codegen/src/machinst/buffer.rs
+++ b/cranelift/codegen/src/machinst/buffer.rs
@@ -172,7 +172,7 @@
use crate::binemit::{Addend, CodeOffset, Reloc};
use crate::ir::function::FunctionParameters;
-use crate::ir::{ExternalName, RelSourceLoc, SourceLoc, TrapCode};
+use crate::ir::{ExceptionTag, ExternalName, RelSourceLoc, SourceLoc, TrapCode};
use crate::isa::unwind::UnwindInst;
use crate::machinst::{
BlockIndex, MachInstLabelUse, TextSectionBuilder, VCodeConstant, VCodeConstants, VCodeInst,
@@ -180,6 +180,7 @@ use crate::machinst::{
use crate::trace;
use crate::{ir, MachInstEmitState};
use crate::{timing, VCodeConstantData};
+use core::ops::Range;
use cranelift_control::ControlPlane;
use cranelift_entity::packed_option::PackedOption;
use cranelift_entity::{entity_impl, PrimaryMap};
@@ -250,6 +251,8 @@ pub struct MachBuffer