Skip to content

Commit c4966f9

Browse files
authored
Avoid inlining floor into rem_pio2
Possible workaround for #976 (comment) Inline assembly in the body of a function currently causes the compiler to consider that function possibly unwinding, even if said asm originated from inlining an `extern "C"` function. This patch wraps the problematic callsite with `#[inline(never)]`.
1 parent c22b848 commit c4966f9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libm/src/math/rem_pio2_large.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* ====================================================
1212
*/
1313

14-
use super::{floor, scalbn};
14+
use super::scalbn;
1515

1616
// initial value for jk
1717
const INIT_JK: [usize; 4] = [3, 4, 4, 6];
@@ -223,6 +223,14 @@ const PIO2: [f64; 8] = [
223223
/// independent of the exponent of the input.
224224
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
225225
pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 {
226+
// FIXME(rust-lang/rust#144518): Inline assembly would cause `no_panic` to fail
227+
// on the callers of this function. As a workaround, avoid inlining `floor` here
228+
// when implemented with assembly.
229+
#[cfg_attr(x86_no_sse, inline(never))]
230+
extern "C" fn floor(x: f64) -> f64 {
231+
super::floor(x)
232+
}
233+
226234
let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24
227235
let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24)
228236

0 commit comments

Comments
 (0)