From 6c927f2a8659a8ca35d223b7ccc0c0a03e8a376a Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 6 Nov 2022 17:29:44 -0800 Subject: [PATCH] Canonicalize PowerPC detection macros to __powerpc__ --- llvm/include/llvm/Support/Threading.h | 5 ++--- llvm/lib/Support/Host.cpp | 4 ++-- llvm/lib/Support/Unix/Memory.inc | 10 +++------- llvm/unittests/ADT/PackedVectorTest.cpp | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h index 44e133d..7f2708d 100644 --- a/llvm/include/llvm/Support/Threading.h +++ b/llvm/include/llvm/Support/Threading.h @@ -26,14 +26,13 @@ #define LLVM_THREADING_USE_STD_CALL_ONCE 1 #elif defined(LLVM_ON_UNIX) && \ (defined(_LIBCPP_VERSION) || \ - !(defined(__NetBSD__) || defined(__OpenBSD__) || \ - (defined(__ppc__) || defined(__PPC__)))) + !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__powerpc__))) // std::call_once from libc++ is used on all Unix platforms. Other // implementations like libstdc++ are known to have problems on NetBSD, // OpenBSD and PowerPC. #define LLVM_THREADING_USE_STD_CALL_ONCE 1 #elif defined(LLVM_ON_UNIX) && \ - ((defined(__ppc__) || defined(__PPC__)) && defined(__LITTLE_ENDIAN__)) + (defined(__powerpc__) && defined(__LITTLE_ENDIAN__)) #define LLVM_THREADING_USE_STD_CALL_ONCE 1 #else #define LLVM_THREADING_USE_STD_CALL_ONCE 0 diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index bd8a206..732aa83 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -1251,7 +1251,7 @@ StringRef sys::getHostCPUName() { return "generic"; } -#elif defined(__APPLE__) && (defined(__ppc__) || defined(__powerpc__)) +#elif defined(__APPLE__) && defined(__powerpc__) StringRef sys::getHostCPUName() { host_basic_info_data_t hostInfo; mach_msg_type_number_t infoCount; @@ -1295,7 +1295,7 @@ StringRef sys::getHostCPUName() { return "generic"; } -#elif defined(__linux__) && (defined(__ppc__) || defined(__powerpc__)) +#elif defined(__linux__) && defined(__powerpc__) StringRef sys::getHostCPUName() { std::unique_ptr P = getProcCpuinfoContent(); StringRef Content = P ? P->getBuffer() : ""; diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc index 5e00806..e4454fe 100644 --- a/llvm/lib/Support/Unix/Memory.inc +++ b/llvm/lib/Support/Unix/Memory.inc @@ -50,8 +50,7 @@ static int getPosixProtectionFlags(unsigned Flags) { llvm::sys::Memory::MF_EXEC: return PROT_READ | PROT_WRITE | PROT_EXEC; case llvm::sys::Memory::MF_EXEC: -#if (defined(__FreeBSD__) || defined(__POWERPC__) || defined (__ppc__) || \ - defined(_POWER) || defined(_ARCH_PPC)) +#if defined(__FreeBSD__) || defined(__powerpc__) // On PowerPC, having an executable page that has no read permission // can have unintended consequences. The function InvalidateInstruction- // Cache uses instructions dcbf and icbi, both of which are treated by @@ -213,9 +212,7 @@ void Memory::InvalidateInstructionCache(const void *Addr, // icache invalidation for PPC and ARM. #if defined(__APPLE__) -# if (defined(__POWERPC__) || defined (__ppc__) || \ - defined(_POWER) || defined(_ARCH_PPC) || defined(__arm__) || \ - defined(__arm64__)) +# if (defined(__powerpc__) || defined(__arm__) || defined(__arm64__)) sys_icache_invalidate(const_cast(Addr), Len); # endif @@ -226,8 +223,7 @@ void Memory::InvalidateInstructionCache(const void *Addr, #else -# if (defined(__POWERPC__) || defined (__ppc__) || \ - defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__) +# if defined(__powerpc__) && defined(__GNUC__) const size_t LineSize = 32; const intptr_t Mask = ~(LineSize - 1); diff --git a/llvm/unittests/ADT/PackedVectorTest.cpp b/llvm/unittests/ADT/PackedVectorTest.cpp index 24df398..b4e0179 100644 --- a/llvm/unittests/ADT/PackedVectorTest.cpp +++ b/llvm/unittests/ADT/PackedVectorTest.cpp @@ -8,7 +8,7 @@ // BitVectorTest tests fail on PowerPC for unknown reasons, so disable this // as well since it depends on a BitVector. -#ifndef __ppc__ +#ifndef __powerpc__ #include "llvm/ADT/PackedVector.h" #include "gtest/gtest.h" -- 2.7.4