Skip to content

Conversation

@jroelofs
Copy link
Contributor

@jroelofs jroelofs commented Jul 9, 2025

The footgun here was that the preprocessor diagnostic that looks for __ARM_FP would fire when included on targets like x86_64, but the suggestion it gives in that case is totally bogus. Avoid giving bad advice, by first checking whether we're being built for an appropriate target, and only then do the soft-fp check.

rdar://155449666

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jul 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 9, 2025

@llvm/pr-subscribers-clang

Author: Jon Roelofs (jroelofs)

Changes

The footgun here was that the preprocessor diagnostic that looks for __ARM_FP would fire when included on targets like x86_64, but the suggestion it gives in that case is totally bogus. Avoid giving bad advice, by first checking whether we're being built for an appropriate target, and only then do the soft-fp check.

rdar://155449666


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

1 Files Affected:

  • (modified) clang/utils/TableGen/NeonEmitter.cpp (+4-1)
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 409f1c4f71834..f4025c649a43e 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2417,7 +2417,10 @@ void NeonEmitter::run(raw_ostream &OS) {
   OS << "#ifndef __ARM_NEON_H\n";
   OS << "#define __ARM_NEON_H\n\n";
 
-  OS << "#ifndef __ARM_FP\n";
+  OS << "#if !defined(__arm__) && !defined(__aarch64__) && !defined(__arm64ec__)\n";
+  OS << "#error \"<arm_neon.h> is intended only for ARM and AArch64 targets\"\n";
+  OS << "#endif\n";
+  OS << "#elif !defined(__ARM_FP)\n";
   OS << "#error \"NEON intrinsics not available with the soft-float ABI. "
         "Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";
   OS << "#else\n\n";

@github-actions
Copy link

github-actions bot commented Jul 9, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

…ed targets

The footgun here was that the preprocessor diagnostic that looks for __ARM_FP
would fire when included on targets like x86_64, but the suggestion it gives in
that case is totally bogus. Avoid giving bad advice, by first checking whether
we're being built for an appropriate target, and only then do the soft-fp
check.

rdar://155449666
@jroelofs jroelofs force-pushed the jroelofs/rdar155449666-arm_neon-guards branch from 28c161e to 0e8f630 Compare July 9, 2025 20:27
Copy link
Collaborator

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

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

LGTM

@jroelofs jroelofs merged commit a0fcb50 into llvm:main Jul 11, 2025
9 checks passed
@jroelofs jroelofs deleted the jroelofs/rdar155449666-arm_neon-guards branch July 11, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants