From c5e3c0cafbc21d9181b4105034c50b5164b1bfc5 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Fri, 5 Aug 2022 17:27:56 -0700 Subject: [PATCH] AArch64: don't assert inst within worst-case size when island emitted. (#4627) We assert after emitting each instruction that its size was less than the "worst-case size", which is used to determine when we need to proactively emit an island so pending branch fixups don't go out of bounds. However, the `EmitIsland` pseudo-inst itself can cause an arbitrarily large island to be emitted; this should not have to fit within the worst-case size (because island size is explicitly accounted for by the threshold computation). This PR fixes the assert accordingly. Fixes #4626. --- cranelift/codegen/src/isa/aarch64/inst/emit.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs index ab210acda8..4ebf4de994 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs @@ -3140,7 +3140,13 @@ impl MachInstEmit for Inst { } let end_off = sink.cur_offset(); - debug_assert!((end_off - start_off) <= Inst::worst_case_size()); + debug_assert!( + (end_off - start_off) <= Inst::worst_case_size() + || matches!(self, Inst::EmitIsland { .. }), + "Worst case size exceed for {:?}: {}", + self, + end_off - start_off + ); state.clear_post_insn(); }