Skip to content

Commit

Permalink
[GR-53048] Backport 23.1: Workaround CPU features Xcode 15 miscomp is…
Browse files Browse the repository at this point in the history
…sue.

PullRequest: graal/17423
  • Loading branch information
fniephaus committed Apr 2, 2024
2 parents 25d87bf + bf168d1 commit e0f1473
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
#include <stdint.h>
#include <string.h>

#if defined(_MSC_VER) && !defined(__clang__)
#define NO_INLINE __declspec(noinline)
#else
#define NO_INLINE __attribute__((noinline))
#endif

#ifndef _WIN64
#include <alloca.h>
#else
Expand Down Expand Up @@ -381,8 +387,10 @@ static void initialize_cpuinfo(CpuidInfo *_cpuid_info)
}
}

// ported from from vm_version_x86.hpp::feature_flags
static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_info)
// ported from from vm_version_x86.cpp::feature_flags
// NO_INLINE is necessary to avoid an unexpected behavior if compiling on Darwin
// with Apple clang version 15.0.0 (included in Xcode 15.0).
NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_info)
{
if (_cpuid_info->std_cpuid1_edx.bits.cmpxchg8 != 0)
features->fCX8 = 1;
Expand Down

0 comments on commit e0f1473

Please sign in to comment.