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

[clang] Lower non-builtin sincos[f|l] calls to llvm.sincos.* when -fno-math-errno is set #121763

Merged
merged 5 commits into from
Feb 19, 2025

Conversation

MacDue
Copy link
Member

@MacDue MacDue commented Jan 6, 2025

This will allow vectorizing these calls (after a few more patches). This should not change the codegen for targets that enable the use of AA during the codegen (in TargetSubtargetInfo::useAA()). This includes targets such as AArch64. This notably does not include x86 but can be worked around by passing -mllvm -combiner-global-alias-analysis=true to clang.

Follow up to #114086.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen labels Jan 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 6, 2025

@llvm/pr-subscribers-backend-aarch64

@llvm/pr-subscribers-clang

Author: Benjamin Maxwell (MacDue)

Changes

This will allow vectorizing these calls (after a few more patches). This should not change the codegen for targets that enable the use of AA during the codegen (in TargetSubtargetInfo::useAA()). This includes targets such as AArch64. This notably does not include x86 but can be worked around by passing -mllvm -combiner-global-alias-analysis=true to clang.

Follow up to #114086.


Full diff: https://github.com/llvm/llvm-project/pull/121763.diff

2 Files Affected:

  • (modified) clang/lib/CodeGen/CGBuiltin.cpp (+3)
  • (modified) clang/test/CodeGen/AArch64/sincos.c (+19-5)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c419fb0cc055e0..9a859e7a22f5e3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3264,6 +3264,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
       return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
           *this, E, Intrinsic::sinh, Intrinsic::experimental_constrained_sinh));
 
+    case Builtin::BIsincos:
+    case Builtin::BIsincosf:
+    case Builtin::BIsincosl:
     case Builtin::BI__builtin_sincos:
     case Builtin::BI__builtin_sincosf:
     case Builtin::BI__builtin_sincosf16:
diff --git a/clang/test/CodeGen/AArch64/sincos.c b/clang/test/CodeGen/AArch64/sincos.c
index b77d98ceab4869..fde277716ddddb 100644
--- a/clang/test/CodeGen/AArch64/sincos.c
+++ b/clang/test/CodeGen/AArch64/sincos.c
@@ -1,5 +1,19 @@
-// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - | FileCheck --check-prefix=NO-MATH-ERRNO %s
-// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - | FileCheck --check-prefix=MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - -DUSE_BUILTIN | FileCheck --check-prefix=NO-MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - -DUSE_BUILTIN | FileCheck --check-prefix=MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - -DUSE_C_DECL | FileCheck --check-prefix=NO-MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - -DUSE_C_DECL | FileCheck --check-prefix=MATH-ERRNO %s
+
+#if defined(USE_BUILTIN)
+  #define sincos __builtin_sincos
+  #define sincosf __builtin_sincosf
+  #define sincosl __builtin_sincosl
+#elif defined(USE_C_DECL)
+  void sincos(double, double*, double*);
+  void sincosf(float, float*, float*);
+  void sincosl(long double, long double*, long double*);
+#else
+    #error Expected USE_BUILTIN or USE_C_DECL to be defined.
+#endif
 
 // NO-MATH-ERRNO-LABEL: @sincos_f32
 //      NO-MATH-ERRNO:    [[SINCOS:%.*]] = tail call { float, float } @llvm.sincos.f32(float {{.*}})
@@ -12,7 +26,7 @@
 //      MATH-ERRNO:    call void @sincosf(
 //
 void sincos_f32(float x, float* fp0, float* fp1) {
-  __builtin_sincosf(x, fp0, fp1);
+  sincosf(x, fp0, fp1);
 }
 
 // NO-MATH-ERRNO-LABEL: @sincos_f64
@@ -26,7 +40,7 @@ void sincos_f32(float x, float* fp0, float* fp1) {
 //      MATH-ERRNO:    call void @sincos(
 //
 void sincos_f64(double x, double* dp0, double* dp1) {
-  __builtin_sincos(x, dp0, dp1);
+  sincos(x, dp0, dp1);
 }
 
 // NO-MATH-ERRNO-LABEL: @sincos_f128
@@ -40,5 +54,5 @@ void sincos_f64(double x, double* dp0, double* dp1) {
 //      MATH-ERRNO:    call void @sincosl(
 //
 void sincos_f128(long double x, long double* ldp0, long double* ldp1) {
-  __builtin_sincosl(x, ldp0, ldp1);
+  sincosl(x, ldp0, ldp1);
 }

@llvmbot
Copy link
Member

llvmbot commented Jan 6, 2025

@llvm/pr-subscribers-clang-codegen

Author: Benjamin Maxwell (MacDue)

Changes

This will allow vectorizing these calls (after a few more patches). This should not change the codegen for targets that enable the use of AA during the codegen (in TargetSubtargetInfo::useAA()). This includes targets such as AArch64. This notably does not include x86 but can be worked around by passing -mllvm -combiner-global-alias-analysis=true to clang.

Follow up to #114086.


Full diff: https://github.com/llvm/llvm-project/pull/121763.diff

2 Files Affected:

  • (modified) clang/lib/CodeGen/CGBuiltin.cpp (+3)
  • (modified) clang/test/CodeGen/AArch64/sincos.c (+19-5)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c419fb0cc055e0..9a859e7a22f5e3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3264,6 +3264,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
       return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(
           *this, E, Intrinsic::sinh, Intrinsic::experimental_constrained_sinh));
 
+    case Builtin::BIsincos:
+    case Builtin::BIsincosf:
+    case Builtin::BIsincosl:
     case Builtin::BI__builtin_sincos:
     case Builtin::BI__builtin_sincosf:
     case Builtin::BI__builtin_sincosf16:
diff --git a/clang/test/CodeGen/AArch64/sincos.c b/clang/test/CodeGen/AArch64/sincos.c
index b77d98ceab4869..fde277716ddddb 100644
--- a/clang/test/CodeGen/AArch64/sincos.c
+++ b/clang/test/CodeGen/AArch64/sincos.c
@@ -1,5 +1,19 @@
-// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - | FileCheck --check-prefix=NO-MATH-ERRNO %s
-// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - | FileCheck --check-prefix=MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - -DUSE_BUILTIN | FileCheck --check-prefix=NO-MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - -DUSE_BUILTIN | FileCheck --check-prefix=MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -O1 %s -o - -DUSE_C_DECL | FileCheck --check-prefix=NO-MATH-ERRNO %s
+// RUN: %clang_cc1 -triple=aarch64-gnu-linux -emit-llvm -fmath-errno %s -o - -DUSE_C_DECL | FileCheck --check-prefix=MATH-ERRNO %s
+
+#if defined(USE_BUILTIN)
+  #define sincos __builtin_sincos
+  #define sincosf __builtin_sincosf
+  #define sincosl __builtin_sincosl
+#elif defined(USE_C_DECL)
+  void sincos(double, double*, double*);
+  void sincosf(float, float*, float*);
+  void sincosl(long double, long double*, long double*);
+#else
+    #error Expected USE_BUILTIN or USE_C_DECL to be defined.
+#endif
 
 // NO-MATH-ERRNO-LABEL: @sincos_f32
 //      NO-MATH-ERRNO:    [[SINCOS:%.*]] = tail call { float, float } @llvm.sincos.f32(float {{.*}})
@@ -12,7 +26,7 @@
 //      MATH-ERRNO:    call void @sincosf(
 //
 void sincos_f32(float x, float* fp0, float* fp1) {
-  __builtin_sincosf(x, fp0, fp1);
+  sincosf(x, fp0, fp1);
 }
 
 // NO-MATH-ERRNO-LABEL: @sincos_f64
@@ -26,7 +40,7 @@ void sincos_f32(float x, float* fp0, float* fp1) {
 //      MATH-ERRNO:    call void @sincos(
 //
 void sincos_f64(double x, double* dp0, double* dp1) {
-  __builtin_sincos(x, dp0, dp1);
+  sincos(x, dp0, dp1);
 }
 
 // NO-MATH-ERRNO-LABEL: @sincos_f128
@@ -40,5 +54,5 @@ void sincos_f64(double x, double* dp0, double* dp1) {
 //      MATH-ERRNO:    call void @sincosl(
 //
 void sincos_f128(long double x, long double* ldp0, long double* ldp1) {
-  __builtin_sincosl(x, ldp0, ldp1);
+  sincosl(x, ldp0, ldp1);
 }

Copy link
Collaborator

@sdesmalen-arm sdesmalen-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RKSimon do you know if there is a reason CodeGen AA is not enabled for x86?

I'd otherwise be happy to approve this patch, lowering to the intrinsic seems like the right thing to do.

@RKSimon
Copy link
Collaborator

RKSimon commented Jan 20, 2025

@RKSimon do you know if there is a reason CodeGen AA is not enabled for x86?

I'd otherwise be happy to approve this patch, lowering to the intrinsic seems like the right thing to do.

I don't remember any reason for alias analysis to not be enabled on x86 - @phoebewang @topperc do you know?

@topperc
Copy link
Collaborator

topperc commented Jan 21, 2025

@RKSimon do you know if there is a reason CodeGen AA is not enabled for x86?
I'd otherwise be happy to approve this patch, lowering to the intrinsic seems like the right thing to do.

I don't remember any reason for alias analysis to not be enabled on x86 - @phoebewang @topperc do you know?

I don't remember either.

@phoebewang
Copy link
Contributor

@RKSimon do you know if there is a reason CodeGen AA is not enabled for x86?
I'd otherwise be happy to approve this patch, lowering to the intrinsic seems like the right thing to do.

I don't remember any reason for alias analysis to not be enabled on x86 - @phoebewang @topperc do you know?

I don't remember either.

Me neither. @clin111 do you happen to know it?

MacDue added a commit to MacDue/llvm-project that referenced this pull request Jan 21, 2025
This can still be disabled by setting the flag `-x86-use-aa=false`. All
tests have been updated to account for this change except:

test/CodeGen/X86/regalloc-advanced-split-cost.ll

Where the spill needed for part of the test disappears with codegen AA
enabled (so it is left disabled for that test).

Enabling AA during codegen makes X86 consistent with other targets such
as AArch64 and RISC-V. This will avoid regressing x86 targets when using
the new `llvm.sincos` intrinsic see: llvm#121763
@MacDue
Copy link
Member Author

MacDue commented Jan 21, 2025

@RKSimon do you know if there is a reason CodeGen AA is not enabled for x86?
I'd otherwise be happy to approve this patch, lowering to the intrinsic seems like the right thing to do.

I don't remember any reason for alias analysis to not be enabled on x86 - @phoebewang @topperc do you know?

I don't remember either.

Me neither. @clin111 do you happen to know it?

I've created a patch enabling it here: #123787 (maybe you'll spot why it's disabled there 😅). I've updated the generated tests, and gone over the handwritten ones more carefully, and updated them myself.

The handwritten tests that changed were:

llvm/test/CodeGen/X86/cfguard-x86-vectorcall.ll
llvm/test/CodeGen/X86/fixup-bw-inst.ll
llvm/test/CodeGen/X86/misched-matrix.ll
llvm/test/CodeGen/X86/regalloc-advanced-split-cost.ll
llvm/test/CodeGen/X86/vectorcall.ll
llvm/test/CodeGen/X86/win32-eh.ll

Someone more experienced with x86(_64) should double check the changes make sense. I am fairly confident the underlying transforms should be correct though as this feature is enabled for other targets (at least AArch64 and RISC-V, off the top of my head).

nikic pushed a commit to nikic/llvm-project that referenced this pull request Jan 21, 2025
This can still be disabled by setting the flag `-x86-use-aa=false`. All
tests have been updated to account for this change except:

test/CodeGen/X86/regalloc-advanced-split-cost.ll

Where the spill needed for part of the test disappears with codegen AA
enabled (so it is left disabled for that test).

Enabling AA during codegen makes X86 consistent with other targets such
as AArch64 and RISC-V. This will avoid regressing x86 targets when using
the new `llvm.sincos` intrinsic see: llvm#121763
@clin111
Copy link
Contributor

clin111 commented Jan 21, 2025

Looks like it was never enabled --- or tested on X86 --- since UseAA was introduced in https://reviews.llvm.org/D67266. Eventually the dead option was removed with c266776. Would advise some caution with regards to register pressure and compile time.

MacDue added a commit to MacDue/llvm-project that referenced this pull request Jan 23, 2025
This can still be disabled by setting the flag `-x86-use-aa=false`. All
tests have been updated to account for this change except:

test/CodeGen/X86/regalloc-advanced-split-cost.ll

Where the spill needed for part of the test disappears with codegen AA
enabled (so it is left disabled for that test).

Enabling AA during codegen makes X86 consistent with other targets such
as AArch64 and RISC-V. This will avoid regressing x86 targets when using
the new `llvm.sincos` intrinsic see: llvm#121763
@MacDue
Copy link
Member Author

MacDue commented Feb 7, 2025

Given it looks like #123787 won't be accepted (due to compile time regressions), I think we should restrict this lowering to AArch64 (and other supported targets) until there's a solution for targets without AA in codegen too. Does that seem reasonable?

…o-math-errno is set

This will allow vectorizing these calls (after a few more patches). This
should not change the codegen for targets that enable the use of AA
during the codegen (in `TargetSubtargetInfo::useAA()`). This includes
targets such as AArch64. This notably does not include x86 but can be
worked around by passing `-mllvm -combiner-global-alias-analysis=true`
to clang.
@MacDue
Copy link
Member Author

MacDue commented Feb 18, 2025

I've pushed a change to restrict this to AArch64 (other targets could enable it too) given no reply above, or progress on #123787.

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a hard no on making this a target dependent option. Just enable it unconditionally and take the regression

@MacDue
Copy link
Member Author

MacDue commented Feb 18, 2025

I'm a hard no on making this a target dependent option. Just enable it unconditionally and take the regression

Fine, I don't mind the regression as it does not affect targets I work on, I just wanted to make the changes needed for AArch64 without knowingly slightly regressing other targets.

@MacDue MacDue requested a review from arsenm February 18, 2025 15:35
@MacDue MacDue merged commit 7781e10 into llvm:main Feb 19, 2025
8 checks passed
@MacDue MacDue deleted the sincos_builtin_2 branch February 19, 2025 10:13
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 19, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-bootstrap-hwasan running on sanitizer-buildbot12 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/7267

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 83666 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/ppc64-toc-call-to-pcrel-long-jump.s (82727 of 83666)
******************** TEST 'lld :: ELF/ppc64-toc-call-to-pcrel-long-jump.s' FAILED ********************
Exit Code: 139

Command Output (stderr):
--
RUN: at line 2: split-file /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp
+ split-file /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp
RUN: at line 4: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/llvm-mc -filetype=obj -triple=powerpc64le /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/asm -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o
+ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/llvm-mc -filetype=obj -triple=powerpc64le /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/asm -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o
RUN: at line 5: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le
+ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le
ld.lld: warning: cannot find entry symbol _start; not setting start address
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000ae1a1085a318 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x47da318)
 #1 0x0000ae1a10858118 llvm::sys::RunSignalHandlers() (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x47d8118)
 #2 0x0000ae1a1085ab88 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x0000fdd3d64f98f8 (linux-vdso.so.1+0x8f8)
 #4 0x0000ae1a10abae94 lld::elf::Symbol::getVA(lld::elf::Ctx&, long) const (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x4a3ae94)
 #5 0x0000ae1a10ace8c4 lld::elf::PPC64LongBranchTargetSection::writeTo(unsigned char*) (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x4a4e8c4)
 #6 0x0000ae1a10a6c9cc void lld::elf::OutputSection::writeTo<llvm::object::ELFType<(llvm::endianness)1, true>>(lld::elf::Ctx&, unsigned char*, llvm::parallel::TaskGroup&)::'lambda'(unsigned long, unsigned long)::operator()(unsigned long, unsigned long) const OutputSections.cpp:0:0
 #7 0x0000ae1a108bed30 std::_Function_handler<void (), llvm::parallel::TaskGroup::spawn(std::function<void ()>)::$_0>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0
 #8 0x0000ae1a108be7fc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) Parallel.cpp:0:0
 #9 0x0000fdd3d5ee1ae0 (/lib/aarch64-linux-gnu/libstdc++.so.6+0xe1ae0)
#10 0x0000fdd3d5cc595c (/lib/aarch64-linux-gnu/libc.so.6+0x8595c)
#11 0x0000fdd3d5d2ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.script: line 13: 1217740 Segmentation fault      (core dumped) /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
23.47s: LLVM :: tools/llvm-reduce/parallel-workitem-kill.ll
21.54s: Clang :: Driver/fsanitize.c
14.54s: Clang :: Preprocessor/riscv-target-features.c
14.49s: Clang :: Driver/arm-cortex-cpus-2.c
14.00s: Clang :: Driver/arm-cortex-cpus-1.c
Step 14 (stage3/hwasan check) failure: stage3/hwasan check (failure)
...
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/lld-link
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 83666 tests, 72 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: lld :: ELF/ppc64-toc-call-to-pcrel-long-jump.s (82727 of 83666)
******************** TEST 'lld :: ELF/ppc64-toc-call-to-pcrel-long-jump.s' FAILED ********************
Exit Code: 139

Command Output (stderr):
--
RUN: at line 2: split-file /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp
+ split-file /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/ppc64-toc-call-to-pcrel-long-jump.s /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp
RUN: at line 4: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/llvm-mc -filetype=obj -triple=powerpc64le /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/asm -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o
+ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/llvm-mc -filetype=obj -triple=powerpc64le /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/asm -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o
RUN: at line 5: /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le
+ /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le
ld.lld: warning: cannot find entry symbol _start; not setting start address
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000ae1a1085a318 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x47da318)
 #1 0x0000ae1a10858118 llvm::sys::RunSignalHandlers() (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x47d8118)
 #2 0x0000ae1a1085ab88 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x0000fdd3d64f98f8 (linux-vdso.so.1+0x8f8)
 #4 0x0000ae1a10abae94 lld::elf::Symbol::getVA(lld::elf::Ctx&, long) const (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x4a3ae94)
 #5 0x0000ae1a10ace8c4 lld::elf::PPC64LongBranchTargetSection::writeTo(unsigned char*) (/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld+0x4a4e8c4)
 #6 0x0000ae1a10a6c9cc void lld::elf::OutputSection::writeTo<llvm::object::ELFType<(llvm::endianness)1, true>>(lld::elf::Ctx&, unsigned char*, llvm::parallel::TaskGroup&)::'lambda'(unsigned long, unsigned long)::operator()(unsigned long, unsigned long) const OutputSections.cpp:0:0
 #7 0x0000ae1a108bed30 std::_Function_handler<void (), llvm::parallel::TaskGroup::spawn(std::function<void ()>)::$_0>::_M_invoke(std::_Any_data const&) Parallel.cpp:0:0
 #8 0x0000ae1a108be7fc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) Parallel.cpp:0:0
 #9 0x0000fdd3d5ee1ae0 (/lib/aarch64-linux-gnu/libstdc++.so.6+0xe1ae0)
#10 0x0000fdd3d5cc595c (/lib/aarch64-linux-gnu/libc.so.6+0x8595c)
#11 0x0000fdd3d5d2ba4c (/lib/aarch64-linux-gnu/libc.so.6+0xeba4c)
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.script: line 13: 1217740 Segmentation fault      (core dumped) /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/bin/ld.lld -T /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp/lts /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp.o -o /home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build2_hwasan/tools/lld/test/ELF/Output/ppc64-toc-call-to-pcrel-long-jump.s.tmp_le

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Slowest Tests:
--------------------------------------------------------------------------
23.47s: LLVM :: tools/llvm-reduce/parallel-workitem-kill.ll
21.54s: Clang :: Driver/fsanitize.c
14.54s: Clang :: Preprocessor/riscv-target-features.c
14.49s: Clang :: Driver/arm-cortex-cpus-2.c
14.00s: Clang :: Driver/arm-cortex-cpus-1.c

Prakhar-Dixit pushed a commit to Prakhar-Dixit/llvm-project that referenced this pull request Feb 19, 2025
…o-math-errno is set (llvm#121763)

This will allow vectorizing these calls (after a few more patches). This
should not change the codegen for targets that enable the use of AA
during the codegen (in `TargetSubtargetInfo::useAA()`). This includes
targets such as AArch64. This notably does not include x86 but can be
worked around by passing `-mllvm -combiner-global-alias-analysis=true`
to clang.

Follow up to llvm#114086.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AArch64 clang:codegen clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants