https://gcc.gnu.org/g:3d0eda79500695abd5e5b5cb06346c50c2c7915e

commit r17-5210-g3d0eda79500695abd5e5b5cb06346c50c2c7915e
Author: Kewen Lin <[email protected]>
Date:   Thu Oct 15 05:34:38 2026 +0000

    testsuite: Check LTO linkage for pi-based builtins
    
    The pi-based builtins are library functions and must be recorded as
    undefined symbols in LTO object files.  Add a test that emits calls to
    all seven trigonometric pi-based function families and checks each
    symbol independently.
    
    This verifies their builtin_with_linkage_p classification and prevents
    missing LTO symbol references from changing archive and shared-library
    resolution.
    
    Assisted-by: LLM
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/builtin-pi-linkage.c: New test.
    
    Signed-off-by: Kewen Lin <[email protected]>

Diff:
---
 gcc/testsuite/gcc.dg/builtin-pi-linkage.c | 63 +++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/builtin-pi-linkage.c 
b/gcc/testsuite/gcc.dg/builtin-pi-linkage.c
new file mode 100644
index 000000000000..93c25e4226f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtin-pi-linkage.c
@@ -0,0 +1,63 @@
+/* { dg-do assemble } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-O2 -flto" } */
+
+/* LTO should record library references for all pi-based builtins.  */
+
+extern double acospi (double);
+extern double asinpi (double);
+extern double atan2pi (double, double);
+extern double atanpi (double);
+extern double cospi (double);
+extern double sinpi (double);
+extern double tanpi (double);
+
+double
+f1 (double x)
+{
+  return acospi (x);
+}
+
+double
+f2 (double x)
+{
+  return asinpi (x);
+}
+
+double
+f3 (double x, double y)
+{
+  return atan2pi (x, y);
+}
+
+double
+f4 (double x)
+{
+  return atanpi (x);
+}
+
+double
+f5 (double x)
+{
+  return cospi (x);
+}
+
+double
+f6 (double x)
+{
+  return sinpi (x);
+}
+
+double
+f7 (double x)
+{
+  return tanpi (x);
+}
+
+/* { dg-final { scan-symbol "acospi" } } */
+/* { dg-final { scan-symbol "asinpi" } } */
+/* { dg-final { scan-symbol "atan2pi" } } */
+/* { dg-final { scan-symbol "atanpi" } } */
+/* { dg-final { scan-symbol "cospi" } } */
+/* { dg-final { scan-symbol "sinpi" } } */
+/* { dg-final { scan-symbol "tanpi" } } */

Reply via email to