This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Check target feature support for __builtin_arm_crc*
ClosedPublic

Authored by MaskRay on Sep 18 2022, 12:57 AM.

Details

Summary

__builtin_arm_crc* requires the target feature crc which is available on armv8
and above. Calling the fuctions for armv7 leads to a SelectionDAG crash.

% clang -c --target=armv7-unknown-linux-gnueabi -c a.c
fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b
PLEASE submit a bug report to ...

Add TARGET_BUILTIN and define required features for these builtins to
report an error in CodeGenFunction::checkTargetFeatures. The problem is quite widespread.
I will add TARGET_BUILTIN for more builtins later.

Fix https://github.com/llvm/llvm-project/issues/57802

Diff Detail

Event Timeline

MaskRay created this revision.Sep 18 2022, 12:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2022, 12:57 AM
MaskRay requested review of this revision.Sep 18 2022, 12:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2022, 12:57 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay edited the summary of this revision. (Show Details)Sep 18 2022, 12:59 AM

This looks like a subset of D133359?

This looks like a subset of D133359?

D133359 looks like it is for AArch64 and may change the diagnostic in a more aggressive way.
This patch seems to be in a suitable granule to fix just this clang crash problem for AArch32...

The arm_acle.h header is shared across Arm and AArch64 - they use the same builtin names even if they are replicated to a certain degree across the backends. As this is used in both it would be good to fix them at the same time. It doesn't need to change the guards as D133359 does, the better error message from TARGET_BUILTIN is a good starts (and helps to simplify D133359).

dmgreen accepted this revision.Sep 21 2022, 6:44 AM

Whether you do that here or in another patch, the change LGTM.

This revision is now accepted and ready to land.Sep 21 2022, 6:44 AM

Whether you do that here or in another patch, the change LGTM.

Thanks:) I'll learn more about arm_acle.h

This revision was automatically updated to reflect the committed changes.