Skip to content

Commit

Permalink
Merge pull request #75 from rimrul/small-llvm
Browse files Browse the repository at this point in the history
shrink LLVM
  • Loading branch information
rimrul authored Oct 19, 2023
2 parents 05d4c11 + 608ca46 commit a27cc2b
Show file tree
Hide file tree
Showing 27 changed files with 528 additions and 1,110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ diff --git a/cmake/modules/GetHostTriple.cmake b/cmake/modules/GetHostTriple.cma
index 0cad1db4eff..47e9f986e15 100644
--- a/cmake/modules/GetHostTriple.cmake
+++ b/cmake/modules/GetHostTriple.cmake
@@ -8,11 +8,11 @@ function( get_host_triple var )
@@ -16,7 +16,7 @@
else()
set( value "i686-pc-win32" )
set( value "i686-pc-windows-msvc" )
endif()
- elseif( MINGW AND NOT MSYS )
+ elseif( MINGW )
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( value "x86_64-w64-mingw32" )
else()
- set( value "i686-pc-mingw32" )
+ set( value "i686-w64-mingw32" )
endif()
else( MSVC )
set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
--
# CMake doesn't provide COMPILER_ARCHITECTURE_ID for Clang/GCC,
# but it does for MSVC.
if( CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "ARM.*" )
2.13.3

36 changes: 0 additions & 36 deletions mingw-w64-clang/0001-mingw-w64-use-MSVC-style-ByteAlignment.patch

This file was deleted.

16 changes: 16 additions & 0 deletions mingw-w64-clang/0002-Fix-Findzstd-on-MINGW.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- a/cmake/modules/Findzstd.cmake
+++ b/cmake/modules/Findzstd.cmake
@@ -29,11 +29,11 @@
)

if(zstd_FOUND)
- if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$")
+ if(zstd_LIBRARY MATCHES "${zstd_STATIC_LIBRARY_SUFFIX}$" AND NOT MINGW)
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
- if(MSVC)
+ if(WIN32)
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ diff --git a/lib/Support/CMakeLists.txt b/lib/Support/CMakeLists.txt
index 0a8e3897cce..de9cda5dda3 100644
--- a/lib/Support/CMakeLists.txt
+++ b/lib/Support/CMakeLists.txt
@@ -2,6 +2,9 @@ set(system_libs)
if( MSVC OR MINGW )
@@ -6,6 +6,9 @@ set(system_libs)
# libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
set(system_libs ${system_libs} psapi shell32 ole32 uuid)
# advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
set(system_libs ${system_libs} psapi shell32 ole32 uuid advapi32)
+ if( MINGW )
+ set(system_libs ${system_libs} pthread)
+ endif()
Expand Down
11 changes: 11 additions & 0 deletions mingw-w64-clang/0004-enable-emutls-for-mingw.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/include/llvm/TargetParser/Triple.h
+++ b/include/llvm/TargetParser/Triple.h
@@ -993,7 +993,7 @@
/// 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.

This file was deleted.

75 changes: 75 additions & 0 deletions mingw-w64-clang/0005-aarch64-unwind-seh.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
From cef120a2e5abba06c1d7a699a4fd4a17e488d6af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Sun, 1 Oct 2023 00:08:23 +0300
Subject: [PATCH] [AArch64] Disable loop alignment for Windows targets

This should fix #66912. When emitting SEH unwind info, we need to
be able to calculate the exact length of functions before alignments
are fixed. Until that limitation is overcome, just disable all
loop alignment on Windows targets.
---
llvm/lib/MC/MCWin64EH.cpp | 3 +++
.../Target/AArch64/AArch64ISelLowering.cpp | 7 ++++++-
llvm/test/CodeGen/AArch64/sched-loop-align.ll | 21 +++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/CodeGen/AArch64/sched-loop-align.ll

diff --git a/lib/MC/MCWin64EH.cpp b/lib/MC/MCWin64EH.cpp
index a2d61da722af870..bb3492bec8aad8a 100644
--- a/lib/MC/MCWin64EH.cpp
+++ b/lib/MC/MCWin64EH.cpp
@@ -1402,6 +1402,9 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info,
// here, but we'd have to emit the pdata, the xdata header, and the
// epilogue scopes later, since they depend on whether the we need to
// split the unwind data.
+ //
+ // If this is fixed, remove code in AArch64ISelLowering.cpp that
+ // disables loop alignment on Windows.
RawFuncLength = GetAbsDifference(streamer, info->FuncletOrFuncEnd,
info->Begin);
}
diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp
index 932b36587f0694e..46064bc7e46783f 100644
--- a/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1051,7 +1051,12 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
// Set required alignment.
setMinFunctionAlignment(Align(4));
// Set preferred alignments.
- setPrefLoopAlignment(STI.getPrefLoopAlignment());
+
+ // Don't align loops on Windows. The SEH unwind info generation needs to
+ // know the exact length of functions before the alignments have been
+ // expanded.
+ if (!Subtarget->isTargetWindows())
+ setPrefLoopAlignment(STI.getPrefLoopAlignment());
setMaxBytesForAlignment(STI.getMaxBytesForLoopAlignment());
setPrefFunctionAlignment(STI.getPrefFunctionAlignment());

diff --git a/test/CodeGen/AArch64/sched-loop-align.ll b/test/CodeGen/AArch64/sched-loop-align.ll
new file mode 100644
index 000000000000000..5b8e42c2790a439
--- /dev/null
+++ b/test/CodeGen/AArch64/sched-loop-align.ll
@@ -0,0 +1,21 @@
+; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s --check-prefix=WINDOWS
+; RUN: llc < %s -mtriple=aarch64-linux | FileCheck %s --check-prefix=LINUX
+
+define dso_local void @b() #0 {
+entry:
+ br label %for.cond
+
+for.cond:
+ tail call void @a()
+ br label %for.cond
+}
+
+declare dso_local void @a(...)
+
+attributes #0 = { noreturn nounwind uwtable "tune-cpu"="cortex-a53" }
+
+; LINUX-LABEL: b:
+; LINUX: .p2align 4
+
+; WINDOWS-LABEL: b:
+; WINDOWS-NOT: .p2align
9 changes: 0 additions & 9 deletions mingw-w64-clang/0006-fix-bugpoint-multiple-definition.patch

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ diff --git a/lib/Driver/ToolChains/MinGW.cpp b/lib/Driver/ToolChains/MinGW.cpp
index 632b76d92b..23da2d6376 100644
--- a/lib/Driver/ToolChains/MinGW.cpp
+++ b/lib/Driver/ToolChains/MinGW.cpp
@@ -215,7 +215,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -265,7 +265,7 @@
if (Args.hasArg(options::OPT_pg))
CmdArgs.push_back("-lgmon");

- if (Args.hasArg(options::OPT_pthread))
+ if (!Args.hasArg(options::OPT_no_pthread))
CmdArgs.push_back("-lpthread");

// add system libraries
if (Sanitize.needsAsanRt()) {
--
2.14.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1936,7 +1936,7 @@

void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
if (IsFlangMode()) {
- OS << getClangToolFullVersion("flang-new") << '\n';
+ OS << getClangToolFullVersion("flang") << '\n';
} else {
// FIXME: The following handlers should use a callback mechanism, we don't
// know what the client would like to do.
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -409,14 +409,12 @@

CmdArgs.push_back(Input.getFilename());

- // TODO: Replace flang-new with flang once the new driver replaces the
- // throwaway driver
- const char *Exec = Args.MakeArgString(D.GetProgramPath("flang-new", TC));
+ const char *Exec = Args.MakeArgString(D.GetProgramPath("flang", TC));
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileUTF8(),
Exec, CmdArgs, Inputs, Output));
}

-Flang::Flang(const ToolChain &TC) : Tool("flang-new", "flang frontend", TC) {}
+Flang::Flang(const ToolChain &TC) : Tool("flang", "flang frontend", TC) {}

Flang::~Flang() {}
25 changes: 0 additions & 25 deletions mingw-w64-clang/0102-fix-libclang-name-for-mingw.patch

This file was deleted.

This file was deleted.

Loading

0 comments on commit a27cc2b

Please sign in to comment.