Skip to content

Commit fcd62f6

Browse files
[TargetParser][AArch64] Believe runtime feature detection
1 parent f5c02dd commit fcd62f6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

llvm/lib/TargetParser/Host.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,9 +1941,10 @@ const StringMap<bool> sys::getHostCPUFeatures() {
19411941
}
19421942

19431943
#if defined(__aarch64__)
1944-
// If we have all crypto bits we can add the feature
1945-
if (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2))
1946-
Features["crypto"] = true;
1944+
// LLVM has decided some AArch64 CPUs have all the instructions they _may_
1945+
// have, as opposed to all the instructions they _must_ have, so allow runtime
1946+
// information to correct us on that.
1947+
Features["crypto"] = (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2));
19471948
#endif
19481949

19491950
return Features;
@@ -1952,12 +1953,13 @@ const StringMap<bool> sys::getHostCPUFeatures() {
19521953
const StringMap<bool> sys::getHostCPUFeatures() {
19531954
StringMap<bool> Features;
19541955

1955-
if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
1956-
Features["neon"] = true;
1957-
if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE))
1958-
Features["crc"] = true;
1959-
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE))
1960-
Features["crypto"] = true;
1956+
// If we're asking the OS at runtime, believe what the OS says
1957+
Features["neon"] =
1958+
IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
1959+
Features["crc"] =
1960+
IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
1961+
Features["crypto"] =
1962+
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
19611963

19621964
return Features;
19631965
}

0 commit comments

Comments
 (0)