[Mlir-commits] [mlir] [clang] [llvm] [clang-tools-extra] [lldb] [compiler-rt] Fix Multiple Build Errors on different platforms (PR #77216)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Jan 6 17:22:50 PST 2024
https://github.com/trcrsired created https://github.com/llvm/llvm-project/pull/77216
Particularly for canadian compilation
>From a1156a564c798192cb7608e28ce9b9ed846a8b1c Mon Sep 17 00:00:00 2001
From: trcrsired <uwgghhbcad at gmail.com>
Date: Sat, 6 Jan 2024 20:21:06 -0500
Subject: [PATCH] Fix Multiple Build Errors on different platforms
Particularly for canadian compilation
---
.../pseudo/include/CMakeLists.txt | 12 +-
clang/lib/Tooling/CMakeLists.txt | 10 +-
compiler-rt/lib/builtins/fp_compare_impl.inc | 3 +
lldb/source/Host/android/HostInfoAndroid.cpp | 4 +
lldb/source/Host/android/LibcGlue.cpp | 2 +
llvm/include/llvm/TargetParser/Triple.h | 287 +++++++-----------
llvm/lib/Support/Unix/Unix.h | 17 +-
mlir/lib/ExecutionEngine/CRunnerUtils.cpp | 4 +-
8 files changed, 147 insertions(+), 192 deletions(-)
diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt b/clang-tools-extra/pseudo/include/CMakeLists.txt
index 2334cfa12e3376..605f17dd4591a0 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -3,10 +3,18 @@ set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf)
setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target)
+if(NOT DEFINED CLANG_PSEUDO_GEN)
+ if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+ set(CLANG_PSEUDO_GEN "${LLVM_NATIVE_TOOL_DIR}/clang_pseudo_gen")
+ else()
+ set(CLANG_PSEUDO_GEN "${pseudo_gen}")
+ endif()
+endif()
+
# Generate inc files.
set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
add_custom_command(OUTPUT ${cxx_symbols_inc}
- COMMAND "${pseudo_gen}"
+ COMMAND "${CLANG_PSEUDO_GEN}"
--grammar ${cxx_bnf}
--emit-symbol-list
-o ${cxx_symbols_inc}
@@ -16,7 +24,7 @@ add_custom_command(OUTPUT ${cxx_symbols_inc}
set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
add_custom_command(OUTPUT ${cxx_bnf_inc}
- COMMAND "${pseudo_gen}"
+ COMMAND "${CLANG_PSEUDO_GEN}"
--grammar ${cxx_bnf}
--emit-grammar-content
-o ${cxx_bnf_inc}
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0b..1510f5fb8a0810 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,14 @@ else()
list(APPEND implicitDirs -I ${implicitDir})
endforeach()
+ if(NOT DEFINED CLANG_AST_DUMP)
+ if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+ set(CLANG_AST_DUMP ${LLVM_NATIVE_TOOL_DIR}/clang-ast-dump)
+ else()
+ set(CLANG_AST_DUMP $<TARGET_FILE:clang-ast-dump>)
+ endif()
+ endif()
+
include(GetClangResourceDir)
get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
add_custom_command(
@@ -60,7 +68,7 @@ else()
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
DEPENDS clang-ast-dump clang-resource-headers
COMMAND
- $<TARGET_FILE:clang-ast-dump>
+ ${CLANG_AST_DUMP}
# Skip this in debug mode because parsing AST.h is too slow
--skip-processing=${skip_expensive_processing}
-I ${resource_dir}/include
diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe4..b2ebd0737df033 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -18,6 +18,9 @@ typedef int CMP_RESULT;
#elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
// LLP64 ABIs use long long instead of long.
typedef long long CMP_RESULT;
+#elif defined(__wasm64__)
+// GCC uses int as CMP_RESULT
+typedef int CMP_RESULT;
#elif __AVR__
// AVR uses a single byte for the return value.
typedef char CMP_RESULT;
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp b/lldb/source/Host/android/HostInfoAndroid.cpp
index 68440e016afe4b..5ba2f0e24a8d24 100644
--- a/lldb/source/Host/android/HostInfoAndroid.cpp
+++ b/lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#ifdef __ANDROID__
+
#include "lldb/Host/android/HostInfoAndroid.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec) {
return FileSystem::Instance().Exists(file_spec);
}
+
+#endif
diff --git a/lldb/source/Host/android/LibcGlue.cpp b/lldb/source/Host/android/LibcGlue.cpp
index 877d735823feee..82b257719c2c8a 100644
--- a/lldb/source/Host/android/LibcGlue.cpp
+++ b/lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,7 @@
// This files adds functions missing from libc on earlier versions of Android
+#ifdef __ANDROID__
#include <android/api-level.h>
#include <sys/syscall.h>
@@ -26,3 +27,4 @@ time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
#endif
+#endif
diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..e022ad68c96511 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -46,64 +46,64 @@ class Triple {
enum ArchType {
UnknownArch,
- arm, // ARM (little endian): arm, armv.*, xscale
- armeb, // ARM (big endian): armeb
- aarch64, // AArch64 (little endian): aarch64
- aarch64_be, // AArch64 (big endian): aarch64_be
- aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
- arc, // ARC: Synopsys ARC
- avr, // AVR: Atmel AVR microcontroller
- bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
- bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
- csky, // CSKY: csky
- dxil, // DXIL 32-bit DirectX bytecode
- hexagon, // Hexagon: hexagon
- loongarch32, // LoongArch (32-bit): loongarch32
- loongarch64, // LoongArch (64-bit): loongarch64
- m68k, // M68k: Motorola 680x0 family
- mips, // MIPS: mips, mipsallegrex, mipsr6
- mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
- mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
- mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
- msp430, // MSP430: msp430
- ppc, // PPC: powerpc
- ppcle, // PPCLE: powerpc (little endian)
- ppc64, // PPC64: powerpc64, ppu
- ppc64le, // PPC64LE: powerpc64le
- r600, // R600: AMD GPUs HD2XXX - HD6XXX
- amdgcn, // AMDGCN: AMD GCN GPUs
- riscv32, // RISC-V (32-bit): riscv32
- riscv64, // RISC-V (64-bit): riscv64
- sparc, // Sparc: sparc
- sparcv9, // Sparcv9: Sparcv9
- sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
- systemz, // SystemZ: s390x
- tce, // TCE (http://tce.cs.tut.fi/): tce
- tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
- thumb, // Thumb (little endian): thumb, thumbv.*
- thumbeb, // Thumb (big endian): thumbeb
- x86, // X86: i[3-9]86
- x86_64, // X86-64: amd64, x86_64
- xcore, // XCore: xcore
- xtensa, // Tensilica: Xtensa
- nvptx, // NVPTX: 32-bit
- nvptx64, // NVPTX: 64-bit
- le32, // le32: generic little-endian 32-bit CPU (PNaCl)
- le64, // le64: generic little-endian 64-bit CPU (PNaCl)
- amdil, // AMDIL
- amdil64, // AMDIL with 64-bit pointers
- hsail, // AMD HSAIL
- hsail64, // AMD HSAIL with 64-bit pointers
- spir, // SPIR: standard portable IR for OpenCL 32-bit version
- spir64, // SPIR: standard portable IR for OpenCL 64-bit version
- spirv, // SPIR-V with logical memory layout.
- spirv32, // SPIR-V with 32-bit pointers
- spirv64, // SPIR-V with 64-bit pointers
- kalimba, // Kalimba: generic kalimba
- shave, // SHAVE: Movidius vector VLIW processors
- lanai, // Lanai: Lanai 32-bit
- wasm32, // WebAssembly with 32-bit pointers
- wasm64, // WebAssembly with 64-bit pointers
+ arm, // ARM (little endian): arm, armv.*, xscale
+ armeb, // ARM (big endian): armeb
+ aarch64, // AArch64 (little endian): aarch64
+ aarch64_be, // AArch64 (big endian): aarch64_be
+ aarch64_32, // AArch64 (little endian) ILP32: aarch64_32
+ arc, // ARC: Synopsys ARC
+ avr, // AVR: Atmel AVR microcontroller
+ bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
+ bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
+ csky, // CSKY: csky
+ dxil, // DXIL 32-bit DirectX bytecode
+ hexagon, // Hexagon: hexagon
+ loongarch32, // LoongArch (32-bit): loongarch32
+ loongarch64, // LoongArch (64-bit): loongarch64
+ m68k, // M68k: Motorola 680x0 family
+ mips, // MIPS: mips, mipsallegrex, mipsr6
+ mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el
+ mips64, // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
+ mips64el, // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
+ msp430, // MSP430: msp430
+ ppc, // PPC: powerpc
+ ppcle, // PPCLE: powerpc (little endian)
+ ppc64, // PPC64: powerpc64, ppu
+ ppc64le, // PPC64LE: powerpc64le
+ r600, // R600: AMD GPUs HD2XXX - HD6XXX
+ amdgcn, // AMDGCN: AMD GCN GPUs
+ riscv32, // RISC-V (32-bit): riscv32
+ riscv64, // RISC-V (64-bit): riscv64
+ sparc, // Sparc: sparc
+ sparcv9, // Sparcv9: Sparcv9
+ sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
+ systemz, // SystemZ: s390x
+ tce, // TCE (http://tce.cs.tut.fi/): tce
+ tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele
+ thumb, // Thumb (little endian): thumb, thumbv.*
+ thumbeb, // Thumb (big endian): thumbeb
+ x86, // X86: i[3-9]86
+ x86_64, // X86-64: amd64, x86_64
+ xcore, // XCore: xcore
+ xtensa, // Tensilica: Xtensa
+ nvptx, // NVPTX: 32-bit
+ nvptx64, // NVPTX: 64-bit
+ le32, // le32: generic little-endian 32-bit CPU (PNaCl)
+ le64, // le64: generic little-endian 64-bit CPU (PNaCl)
+ amdil, // AMDIL
+ amdil64, // AMDIL with 64-bit pointers
+ hsail, // AMD HSAIL
+ hsail64, // AMD HSAIL with 64-bit pointers
+ spir, // SPIR: standard portable IR for OpenCL 32-bit version
+ spir64, // SPIR: standard portable IR for OpenCL 64-bit version
+ spirv, // SPIR-V with logical memory layout.
+ spirv32, // SPIR-V with 32-bit pointers
+ spirv64, // SPIR-V with 64-bit pointers
+ kalimba, // Kalimba: generic kalimba
+ shave, // SHAVE: Movidius vector VLIW processors
+ lanai, // Lanai: Lanai 32-bit
+ wasm32, // WebAssembly with 32-bit pointers
+ wasm64, // WebAssembly with 64-bit pointers
renderscript32, // 32-bit RenderScript
renderscript64, // 64-bit RenderScript
ve, // NEC SX-Aurora Vector Engine
@@ -193,7 +193,7 @@ class Triple {
IOS,
KFreeBSD,
Linux,
- Lv2, // PS3
+ Lv2, // PS3
MacOSX,
NetBSD,
OpenBSD,
@@ -203,17 +203,17 @@ class Triple {
ZOS,
Haiku,
RTEMS,
- NaCl, // Native Client
+ NaCl, // Native Client
AIX,
- CUDA, // NVIDIA CUDA
- NVCL, // NVIDIA OpenCL
- AMDHSA, // AMD HSA Runtime
+ CUDA, // NVIDIA CUDA
+ NVCL, // NVIDIA OpenCL
+ AMDHSA, // AMD HSA Runtime
PS4,
PS5,
ELFIAMCU,
- TvOS, // Apple tvOS
- WatchOS, // Apple watchOS
- DriverKit, // Apple DriverKit
+ TvOS, // Apple tvOS
+ WatchOS, // Apple watchOS
+ DriverKit, // Apple DriverKit
Mesa3D,
AMDPAL, // AMD PAL Runtime
HermitCore, // HermitCore Unikernel/Multikernel
@@ -252,7 +252,7 @@ class Triple {
Cygnus,
CoreCLR,
Simulator, // Simulator variants of other systems, e.g., Apple's iOS
- MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
+ MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
// Shader Stages
// The order of these values matters, and must be kept in sync with the
@@ -332,9 +332,7 @@ class Triple {
ObjectFormat == Other.ObjectFormat;
}
- bool operator!=(const Triple &Other) const {
- return !(*this == Other);
- }
+ bool operator!=(const Triple &Other) const { return !(*this == Other); }
/// @}
/// @name Normalization
@@ -366,9 +364,7 @@ class Triple {
OSType getOS() const { return OS; }
/// Does this triple have the optional environment (fourth) component?
- bool hasEnvironment() const {
- return getEnvironmentName() != "";
- }
+ bool hasEnvironment() const { return getEnvironmentName() != ""; }
/// Get the parsed environment type of this triple.
EnvironmentType getEnvironment() const { return Environment; }
@@ -490,23 +486,15 @@ class Triple {
/// changes, i.e., if the two operating systems diverge or their version
/// numbers get out of sync, that will need to be changed.
/// watchOS has completely different version numbers so it is not included.
- bool isiOS() const {
- return getOS() == Triple::IOS || isTvOS();
- }
+ bool isiOS() const { return getOS() == Triple::IOS || isTvOS(); }
/// Is this an Apple tvOS triple.
- bool isTvOS() const {
- return getOS() == Triple::TvOS;
- }
+ bool isTvOS() const { return getOS() == Triple::TvOS; }
/// Is this an Apple watchOS triple.
- bool isWatchOS() const {
- return getOS() == Triple::WatchOS;
- }
+ bool isWatchOS() const { return getOS() == Triple::WatchOS; }
- bool isWatchABI() const {
- return getSubArch() == Triple::ARMSubArch_v7k;
- }
+ bool isWatchABI() const { return getSubArch() == Triple::ARMSubArch_v7k; }
/// Is this an Apple DriverKit triple.
bool isDriverKit() const { return getOS() == Triple::DriverKit; }
@@ -532,31 +520,19 @@ class Triple {
isMacCatalystEnvironment()));
}
- bool isOSNetBSD() const {
- return getOS() == Triple::NetBSD;
- }
+ bool isOSNetBSD() const { return getOS() == Triple::NetBSD; }
- bool isOSOpenBSD() const {
- return getOS() == Triple::OpenBSD;
- }
+ bool isOSOpenBSD() const { return getOS() == Triple::OpenBSD; }
- bool isOSFreeBSD() const {
- return getOS() == Triple::FreeBSD;
- }
+ bool isOSFreeBSD() const { return getOS() == Triple::FreeBSD; }
- bool isOSFuchsia() const {
- return getOS() == Triple::Fuchsia;
- }
+ bool isOSFuchsia() const { return getOS() == Triple::Fuchsia; }
bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
- bool isOSSolaris() const {
- return getOS() == Triple::Solaris;
- }
+ bool isOSSolaris() const { return getOS() == Triple::Solaris; }
- bool isOSIAMCU() const {
- return getOS() == Triple::ELFIAMCU;
- }
+ bool isOSIAMCU() const { return getOS() == Triple::ELFIAMCU; }
bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
@@ -570,19 +546,13 @@ class Triple {
}
/// Tests whether the OS is Haiku.
- bool isOSHaiku() const {
- return getOS() == Triple::Haiku;
- }
+ bool isOSHaiku() const { return getOS() == Triple::Haiku; }
/// Tests whether the OS is UEFI.
- bool isUEFI() const {
- return getOS() == Triple::UEFI;
- }
+ bool isUEFI() const { return getOS() == Triple::UEFI; }
/// Tests whether the OS is Windows.
- bool isOSWindows() const {
- return getOS() == Triple::Win32;
- }
+ bool isOSWindows() const { return getOS() == Triple::Win32; }
/// Checks if the environment is MSVC.
bool isKnownWindowsMSVCEnvironment() const {
@@ -629,34 +599,22 @@ class Triple {
}
/// Tests whether the OS is NaCl (Native Client)
- bool isOSNaCl() const {
- return getOS() == Triple::NaCl;
- }
+ bool isOSNaCl() const { return getOS() == Triple::NaCl; }
/// Tests whether the OS is Linux.
- bool isOSLinux() const {
- return getOS() == Triple::Linux;
- }
+ bool isOSLinux() const { return getOS() == Triple::Linux; }
/// Tests whether the OS is kFreeBSD.
- bool isOSKFreeBSD() const {
- return getOS() == Triple::KFreeBSD;
- }
+ bool isOSKFreeBSD() const { return getOS() == Triple::KFreeBSD; }
/// Tests whether the OS is Hurd.
- bool isOSHurd() const {
- return getOS() == Triple::Hurd;
- }
+ bool isOSHurd() const { return getOS() == Triple::Hurd; }
/// Tests whether the OS is WASI.
- bool isOSWASI() const {
- return getOS() == Triple::WASI;
- }
+ bool isOSWASI() const { return getOS() == Triple::WASI; }
/// Tests whether the OS is Emscripten.
- bool isOSEmscripten() const {
- return getOS() == Triple::Emscripten;
- }
+ bool isOSEmscripten() const { return getOS() == Triple::Emscripten; }
/// Tests whether the OS uses glibc.
bool isOSGlibc() const {
@@ -666,41 +624,27 @@ class Triple {
}
/// Tests whether the OS is AIX.
- bool isOSAIX() const {
- return getOS() == Triple::AIX;
- }
+ bool isOSAIX() const { return getOS() == Triple::AIX; }
- bool isOSSerenity() const {
- return getOS() == Triple::Serenity;
- }
+ bool isOSSerenity() const { return getOS() == Triple::Serenity; }
/// Tests whether the OS uses the ELF binary format.
- bool isOSBinFormatELF() const {
- return getObjectFormat() == Triple::ELF;
- }
+ bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; }
/// Tests whether the OS uses the COFF binary format.
- bool isOSBinFormatCOFF() const {
- return getObjectFormat() == Triple::COFF;
- }
+ bool isOSBinFormatCOFF() const { return getObjectFormat() == Triple::COFF; }
/// Tests whether the OS uses the GOFF binary format.
bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
/// Tests whether the environment is MachO.
- bool isOSBinFormatMachO() const {
- return getObjectFormat() == Triple::MachO;
- }
+ bool isOSBinFormatMachO() const { return getObjectFormat() == Triple::MachO; }
/// Tests whether the OS uses the Wasm binary format.
- bool isOSBinFormatWasm() const {
- return getObjectFormat() == Triple::Wasm;
- }
+ bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; }
/// Tests whether the OS uses the XCOFF binary format.
- bool isOSBinFormatXCOFF() const {
- return getObjectFormat() == Triple::XCOFF;
- }
+ bool isOSBinFormatXCOFF() const { return getObjectFormat() == Triple::XCOFF; }
/// Tests whether the OS uses the DXContainer binary format.
bool isOSBinFormatDXContainer() const {
@@ -709,16 +653,14 @@ class Triple {
/// Tests whether the target is the PS4 platform.
bool isPS4() const {
- return getArch() == Triple::x86_64 &&
- getVendor() == Triple::SCEI &&
+ return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
getOS() == Triple::PS4;
}
/// Tests whether the target is the PS5 platform.
bool isPS5() const {
- return getArch() == Triple::x86_64 &&
- getVendor() == Triple::SCEI &&
- getOS() == Triple::PS5;
+ return getArch() == Triple::x86_64 && getVendor() == Triple::SCEI &&
+ getOS() == Triple::PS5;
}
/// Tests whether the target is the PS4 or PS5 platform.
@@ -757,13 +699,9 @@ class Triple {
bool isOSLiteOS() const { return getOS() == Triple::LiteOS; }
/// Tests whether the target is DXIL.
- bool isDXIL() const {
- return getArch() == Triple::dxil;
- }
+ bool isDXIL() const { return getArch() == Triple::dxil; }
- bool isShaderModelOS() const {
- return getOS() == Triple::ShaderModel;
- }
+ bool isShaderModelOS() const { return getOS() == Triple::ShaderModel; }
bool isShaderStageEnvironment() const {
EnvironmentType Env = getEnvironment();
@@ -789,9 +727,7 @@ class Triple {
}
/// Tests whether the target is SPIR-V Logical
- bool isSPIRVLogical() const {
- return getArch() == Triple::spirv;
- }
+ bool isSPIRVLogical() const { return getArch() == Triple::spirv; }
/// Tests whether the target is NVPTX (32- or 64-bit).
bool isNVPTX() const {
@@ -902,9 +838,7 @@ class Triple {
}
/// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
- bool isMIPS() const {
- return isMIPS32() || isMIPS64();
- }
+ bool isMIPS() const { return isMIPS32() || isMIPS64(); }
/// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
bool isPPC() const {
@@ -960,9 +894,7 @@ class Triple {
bool isSPARC() const { return isSPARC32() || isSPARC64(); }
/// Tests whether the target is SystemZ.
- bool isSystemZ() const {
- return getArch() == Triple::systemz;
- }
+ bool isSystemZ() const { return getArch() == Triple::systemz; }
/// Tests whether the target is x86 (32- or 64-bit).
bool isX86() const {
@@ -970,9 +902,7 @@ class Triple {
}
/// Tests whether the target is VE
- bool isVE() const {
- return getArch() == Triple::ve;
- }
+ bool isVE() const { return getArch() == Triple::ve; }
/// Tests whether the target is wasm (32- and 64-bit).
bool isWasm() const {
@@ -980,9 +910,7 @@ class Triple {
}
// Tests whether the target is CSKY
- bool isCSKY() const {
- return getArch() == Triple::csky;
- }
+ bool isCSKY() const { return getArch() == Triple::csky; }
/// Tests whether the target is the Apple "arm64e" AArch64 subarch.
bool isArm64e() const {
@@ -1012,7 +940,7 @@ class Triple {
/// Note: Android API level 29 (10) introduced ELF TLS.
bool hasDefaultEmulatedTLS() const {
return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
- isWindowsCygwinEnvironment() || isOHOSFamily();
+ isOSCygMing() || isOHOSFamily();
}
/// Tests whether the target uses -data-sections as default.
@@ -1157,7 +1085,6 @@ class Triple {
const VersionTuple &Version);
};
-} // End llvm namespace
-
+} // namespace llvm
#endif
diff --git a/llvm/lib/Support/Unix/Unix.h b/llvm/lib/Support/Unix/Unix.h
index 1599241a344af8..ddeb72c7adb32c 100644
--- a/llvm/lib/Support/Unix/Unix.h
+++ b/llvm/lib/Support/Unix/Unix.h
@@ -1,4 +1,5 @@
-//===- llvm/Support/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===//
+//===- llvm/Support/Unix/Unix.h - Common Unix Include File -------*- C++
+//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -37,16 +38,16 @@
#endif
#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+#include <sys/time.h>
#endif
#include <time.h>
#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
+#include <dlfcn.h>
#endif
#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
+#include <fcntl.h>
#endif
/// This function builds an error message into \p ErrMsg using the \p prefix
@@ -56,8 +57,8 @@
///
/// If the error number can be converted to a string, it will be
/// separated from prefix by ": ".
-static inline bool MakeErrMsg(
- std::string* ErrMsg, const std::string& prefix, int errnum = -1) {
+static inline bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix,
+ int errnum = -1) {
if (!ErrMsg)
return true;
if (errnum == -1)
@@ -78,7 +79,9 @@ namespace sys {
/// Convert a struct timeval to a duration. Note that timeval can be used both
/// as a time point and a duration. Be sure to check what the input represents.
-inline std::chrono::microseconds toDuration(const struct timeval &TV) {
+
+template <typename timevaltype>
+inline std::chrono::microseconds toDuration(const timevaltype &TV) {
return std::chrono::seconds(TV.tv_sec) +
std::chrono::microseconds(TV.tv_usec);
}
diff --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
index e28e75eb110303..8aa9ad8693ecbb 100644
--- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -16,7 +16,7 @@
#include "mlir/ExecutionEngine/Msan.h"
#ifndef _WIN32
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)
#include <cstdlib>
#else
@@ -139,7 +139,7 @@ extern "C" void *mlirAlloc(uint64_t size) { return malloc(size); }
extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) {
#ifdef _WIN32
return _aligned_malloc(size, alignment);
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || (defined(__ANDROID_API__) && __ANDROID_API__ <= 28)
// aligned_alloc was added in MacOS 10.15. Fall back to posix_memalign to also
// support older versions.
void *result = nullptr;
More information about the Mlir-commits
mailing list