clang defines __ARM_FEATURE_CRC32 but crc32 instruction is not available

Originator:verbruggen.erik
Number:rdar://24788515 Date Originated:Feb. 23, 2016
Status:Closed Resolved:Wed Feb 24 09:57:49 PST 2016
Product:Developer Tools Product Version:7.2.1
Classification: Reproducible:Yes
 
Summary:
I'm using the built-in preprocessor define __ARM_FEATURE_CRC32 to check if the CPU supports the crc32 instructions. If so, I use the __crc32* intrinsics. However, when running on an iPhone6S, I get an EXC_BAD_INSTRUCTION.

Steps to Reproduce:
1. create an iOS UI application
2. open main.m
3. add: #include <arm_acle.h>
4. replace main with the code below
5. build&run on an iPhone6S (or probably any arm64 device)

Replacement main:

int main(int argc, char * argv[]) {
#if __ARM_FEATURE_CRC32
    NSLog(@"crc32 feature is there!");
    int result = __crc32b(argc, 1);
    NSLog(@"result: %d", result);
#else
    NSLog(@"no crc32 feature");
#endif
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}


Expected Results:
When the CPU does support the crc32 instruction, I expect no crash. If the CPU does NOT support it, I expect __ARM_FEATURE_CRC32 to either be defined as 0 (zero), or not defined at all.

So, for the example above, I would expect it to either show "no crc32 feature", or to show "crc32 feature is there!" followed by a line starting with "result:".

Actual Results:
This will show "crc32 feature is there!", but crash on the next line where the __crc32b intrinsic is called.

Version:
OSX 10.11.3
Xcode version: 7.2.1 (7C1002)
iOS version: 9.2.1 (13D15)

Notes:


Configuration:
Occurs always on an iPhone6S with iOS 9.2

Attachments:

Comments

See http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160222/151168.html

By verbruggen.erik at Aug. 10, 2018, 9:02 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!