about summary refs log tree commit diff
diff options
context:
space:
mode:
authorquaternic <57393910+quaternic@users.noreply.github.com>2025-07-27 08:26:58 +0300
committerGitHub <noreply@github.com>2025-07-27 00:26:58 -0500
commitc061e73d9ff3fa07dcb005a40453e124302bdeb8 (patch)
treebc563f150e947f4ac930effc8bc262eb5245743f
parent474315828b5a6eca321b2e2816829ccd530b210b (diff)
downloadrust-c061e73d9ff3fa07dcb005a40453e124302bdeb8.tar.gz
rust-c061e73d9ff3fa07dcb005a40453e124302bdeb8.zip
Avoid inlining `floor` into `rem_pio2`
Possible workaround for
https://github.com/rust-lang/compiler-builtins/pull/976#issuecomment-3085530354

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)]`.
-rw-r--r--library/compiler-builtins/libm/src/math/rem_pio2_large.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/library/compiler-builtins/libm/src/math/rem_pio2_large.rs b/library/compiler-builtins/libm/src/math/rem_pio2_large.rs
index 6d679bbe98c..792c09fb17e 100644
--- a/library/compiler-builtins/libm/src/math/rem_pio2_large.rs
+++ b/library/compiler-builtins/libm/src/math/rem_pio2_large.rs
@@ -11,7 +11,7 @@
  * ====================================================
  */
 
-use super::{floor, scalbn};
+use super::scalbn;
 
 // initial value for jk
 const INIT_JK: [usize; 4] = [3, 4, 4, 6];
@@ -223,6 +223,14 @@ const PIO2: [f64; 8] = [
 /// independent of the exponent of the input.
 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
 pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 {
+    // FIXME(rust-lang/rust#144518): Inline assembly would cause `no_panic` to fail
+    // on the callers of this function. As a workaround, avoid inlining `floor` here
+    // when implemented with assembly.
+    #[cfg_attr(x86_no_sse, inline(never))]
+    extern "C" fn floor(x: f64) -> f64 {
+        super::floor(x)
+    }
+
     let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24
     let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24)