[compiler-rt] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

Jon Roelofs via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 15 10:19:59 PST 2023


================
@@ -0,0 +1,35 @@
+void __init_cpu_features_resolver(unsigned long hwcap,
+                                  const __ifunc_arg_t *arg) {
+  if (__aarch64_cpu_features.features)
+    return;
+
+  // ifunc resolvers don't have hwcaps in arguments on Android API lower
+  // than 30. If so, set feature detection done and keep all CPU features
+  // unsupported (zeros). To detect this case in runtime we check existence
+  // of memfd_create function from Standard C library which was introduced in
+  // Android API 30.
+  int memfd_create(const char *, unsigned int) __attribute__((weak));
+  if (!memfd_create)
+    return;
+
+  __init_cpu_features_constructor(hwcap, arg);
+}
+
+void CONSTRUCTOR_ATTRIBUTE __init_cpu_features(void) {
+  unsigned long hwcap = 0;
----------------
jroelofs wrote:

- [ ] FIXME: dead variables

https://github.com/llvm/llvm-project/pull/75635


More information about the llvm-commits mailing list