Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PowerPC] fatal error: error in backend: Cannot select: 0x8e697e8320: f128,f128 = fsincos 0x8e697eb450 #76442

Closed
pkubaj opened this issue Dec 27, 2023 · 3 comments · Fixed by #76494
Assignees
Labels
backend:PowerPC crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@pkubaj
Copy link
Contributor

pkubaj commented Dec 27, 2023

Clang 17.0.6 on Linux (Gentoo ppc64le) and FreeBSD 15.0 (powerpc64le)

Test case:

# 1 "" 3
cpowl() { int theta = cosl(theta) * sinl(theta); }

Compile with:
/usr/lib/llvm/17/bin/clang-17 -cc1 -emit-obj -target-cpu ppc64le -mabi=ieeelongdouble -Werror -Weverything -Wno-gnu-line-marker -fgnuc-version=4.2.1 s_cpowl-062d88.c

Output:

fatal error: error in backend: Cannot select: 0x6d420285c0: f128,f128 = fsincos 0x6d4202b6f0
  0x6d4202b6f0: f128,ch,glue = CopyFromReg 0x6d4202b680, Register:f128 $v2, 0x6d4202b680:1
    0x6d42028b70: f128 = Register $v2
    0x6d4202b680: ch,glue = callseq_end 0x6d4202b610, TargetConstant:i64<32>, TargetConstant:i64<0>, 0x6d4202b610:1
      0x6d420288d0: i64 = TargetConstant<32>
      0x6d42028940: i64 = TargetConstant<0>
      0x6d4202b610: ch,glue = PPCISD::CALL_NOP 0x6d4202b530, TargetExternalSymbol:i64'__floatsikf', Register:i64 $x3, Register:i64 $x2, RegisterMask:Untyped, 0x6d4202b530:1
        0x6d4202b5a0: i64 = TargetExternalSymbol'__floatsikf'
        0x6d42028e80: i64 = Register $x3
        0x6d42028cc0: i64 = Register $x2
        0x6d42028d30: Untyped = RegisterMask
        0x6d4202b530: ch,glue = CopyToReg 0x6d420284e0, Register:i64 $x3, 0x6d42028320
          0x6d42028e80: i64 = Register $x3
          0x6d42028320: i64,ch = load<(dereferenceable load (s32) from %ir.theta), sext from i32> 0x6d41fd2050, FrameIndex:i64<1>, undef:i64
            0x6d420282b0: i64 = FrameIndex<1>
            0x6d42028390: i64 = undef
In function: cpowl

This issue has been confirmed to happen on Linux, but its origin is WIP patch to switch FreeBSD/powerpc64le to IEEE long double. The issue happens when building msun library (FreeBSD's libm).

@EugeneZelenko EugeneZelenko added backend:PowerPC crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Dec 27, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 27, 2023

@llvm/issue-subscribers-backend-powerpc

Author: None (pkubaj)

Clang 17.0.6 on Linux (Gentoo ppc64le) and FreeBSD 15.0 (powerpc64le)

Test case:

# 1 "" 3
cpowl() { int theta = cosl(theta) * sinl(theta); }

Compile with:
/usr/lib/llvm/17/bin/clang-17 -cc1 -emit-obj -target-cpu ppc64le -mabi=ieeelongdouble -Werror -Weverything -Wno-gnu-line-marker -fgnuc-version=4.2.1 s_cpowl-062d88.c

Output:

fatal error: error in backend: Cannot select: 0x6d420285c0: f128,f128 = fsincos 0x6d4202b6f0
  0x6d4202b6f0: f128,ch,glue = CopyFromReg 0x6d4202b680, Register:f128 $v2, 0x6d4202b680:1
    0x6d42028b70: f128 = Register $v2
    0x6d4202b680: ch,glue = callseq_end 0x6d4202b610, TargetConstant:i64&lt;32&gt;, TargetConstant:i64&lt;0&gt;, 0x6d4202b610:1
      0x6d420288d0: i64 = TargetConstant&lt;32&gt;
      0x6d42028940: i64 = TargetConstant&lt;0&gt;
      0x6d4202b610: ch,glue = PPCISD::CALL_NOP 0x6d4202b530, TargetExternalSymbol:i64'__floatsikf', Register:i64 $x3, Register:i64 $x2, RegisterMask:Untyped, 0x6d4202b530:1
        0x6d4202b5a0: i64 = TargetExternalSymbol'__floatsikf'
        0x6d42028e80: i64 = Register $x3
        0x6d42028cc0: i64 = Register $x2
        0x6d42028d30: Untyped = RegisterMask
        0x6d4202b530: ch,glue = CopyToReg 0x6d420284e0, Register:i64 $x3, 0x6d42028320
          0x6d42028e80: i64 = Register $x3
          0x6d42028320: i64,ch = load&lt;(dereferenceable load (s32) from %ir.theta), sext from i32&gt; 0x6d41fd2050, FrameIndex:i64&lt;1&gt;, undef:i64
            0x6d420282b0: i64 = FrameIndex&lt;1&gt;
            0x6d42028390: i64 = undef
In function: cpowl

This issue has been confirmed to happen on Linux, but its origin is WIP patch to switch FreeBSD/powerpc64le to IEEE long double. The issue happens when building msun library (FreeBSD's libm).

@ecnelises
Copy link
Member

Confirmed.

I modified the original case and removed -Werror a bit to make it compile:

// Reproduce with driver:
// clang -target powerpc64le -fno-math-errno test.c -mabi=ieeelongdouble
long double cosl(long double);
long double sinl(long double);
long double theta;
int mycpowl(void) { long double theta2 = cosl(theta) * sinl(theta); return 0; }

@pkubaj
Copy link
Contributor Author

pkubaj commented Dec 28, 2023

CC @DimitryAndric
Can you cherry-pick it to FreeBSD's main once @ecnelises commits it here?

freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Dec 29, 2023
  [PowerPC] Expand FSINCOS of fp128 (#76494)

This fixes "fatal error: error in backend: Cannot select: 0x6d420285c0:
f128,f128 = fsincos 0x6d4202b6f0" when compiling s_cpowl.c for
powerpc64le.

Upstream ticket: llvm/llvm-project#76442

Reported by:	pkubaj
MFC after:	3 days
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Jan 1, 2024
  [PowerPC] Expand FSINCOS of fp128 (#76494)

This fixes "fatal error: error in backend: Cannot select: 0x6d420285c0:
f128,f128 = fsincos 0x6d4202b6f0" when compiling s_cpowl.c for
powerpc64le.

Upstream ticket: llvm/llvm-project#76442

Reported by:	pkubaj
MFC after:	3 days

(cherry picked from commit 7963968)
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Jan 1, 2024
  [PowerPC] Expand FSINCOS of fp128 (#76494)

This fixes "fatal error: error in backend: Cannot select: 0x6d420285c0:
f128,f128 = fsincos 0x6d4202b6f0" when compiling s_cpowl.c for
powerpc64le.

Upstream ticket: llvm/llvm-project#76442

Reported by:	pkubaj
MFC after:	3 days

(cherry picked from commit 7963968)
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this issue Mar 13, 2024
  [PowerPC] Expand FSINCOS of fp128 (#76494)

This fixes "fatal error: error in backend: Cannot select: 0x6d420285c0:
f128,f128 = fsincos 0x6d4202b6f0" when compiling s_cpowl.c for
powerpc64le.

Upstream ticket: llvm/llvm-project#76442

Reported by:	pkubaj
MFC after:	3 days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:PowerPC crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants