[llvm] Use thinlto and pgo for x86_64 windows release packaging (PR #71067)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 04:44:10 PST 2023
https://github.com/zmodem updated https://github.com/llvm/llvm-project/pull/71067
>From 9ae604d3341c13119a7230ac07db68f806f402d8 Mon Sep 17 00:00:00 2001
From: Hans Wennborg <hans at chromium.org>
Date: Tue, 31 Oct 2023 18:36:29 +0100
Subject: [PATCH 1/3] Use thinlto and pgo for x86_64 windows release packaging
---
llvm/utils/release/build_llvm_release.bat | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat
index 3b4f431cee65646..896d890b0703d60 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -261,6 +261,23 @@ set all_cmake_flags=^
-DCMAKE_RC=%stage0_bin_dir%/llvm-windres.exe
set cmake_flags=%all_cmake_flags:\=/%
+
+REM Build Clang with instrumentation.
+mkdir build64.instr
+cd build64.instr
+cmake -GNinja %cmake_flags% -DLLVM_BUILD_INSTRUMENTED=IR ..\llvm-project\llvm || exit /b 1
+ninja clang || ninja clang || ninja clang || exit /b 1
+cd ..
+REM Run instrumented Clang to generate a profile.
+curl -L https://commondatastorage.googleapis.com/chromium-browser-clang/pgo_training-1.ii -o train.ii || exit /b 1
+set profile=%build_dir:\=/%/build64.instr/profile.profdata
+build64.instr\bin\clang++ -target x86_64-unknown-unknown -O2 -g -std=c++14 -fno-exceptions -fno-rtti -w -c train.ii
+%stage0_bin_dir%\llvm-profdata merge -output=%profile% build64.instr\profiles\*.profraw || exit /b 1
+set cmake_flags=%cmake_flags% -DLLVM_PROFDATA_FILE=%profile%
+
+REM Enable ThinLTO
+set cmake_flags=%cmake_flags% -DLLVM_ENABLE_LTO=Thin
+
mkdir build64
cd build64
cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
>From dd1d7cc8f88c61d63b30099aced1443c9934fa58 Mon Sep 17 00:00:00 2001
From: Hans Wennborg <hans at chromium.org>
Date: Fri, 3 Nov 2023 10:57:08 +0100
Subject: [PATCH 2/3] Train by building Sema.cpp instead.
---
llvm/utils/release/build_llvm_release.bat | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat
index 896d890b0703d60..6288eba1ab78107 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -268,10 +268,21 @@ cd build64.instr
cmake -GNinja %cmake_flags% -DLLVM_BUILD_INSTRUMENTED=IR ..\llvm-project\llvm || exit /b 1
ninja clang || ninja clang || ninja clang || exit /b 1
cd ..
-REM Run instrumented Clang to generate a profile.
-curl -L https://commondatastorage.googleapis.com/chromium-browser-clang/pgo_training-1.ii -o train.ii || exit /b 1
-set profile=%build_dir:\=/%/build64.instr/profile.profdata
-build64.instr\bin\clang++ -target x86_64-unknown-unknown -O2 -g -std=c++14 -fno-exceptions -fno-rtti -w -c train.ii
+REM Use that to buid some part of llvm to generate a profile.
+mkdir build64.train
+cd build64.train
+set instrumented_clang=%build_dir:\=/%/build64.instr/bin/clang-cl.exe
+cmake -GNinja %cmake_flags% ^
+ -DCMAKE_C_COMPILER=%instrumented_clang% ^
+ -DCMAKE_CXX_COMPILER=%instrumented_clang% ^
+ -DLLVM_ENABLE_PROJECTS=clang ^
+ -DLLVM_TARGETS_TO_BUILD=X86 ^
+ ..\llvm-project\llvm || exit /b 1
+REM Drop profiles from running cmake, those are not representative.
+del ..\build64.instr\profiles\*.profraw
+ninja tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.obj
+cd ..
+set profile=%build_dir:\=/%/profile.profdata
%stage0_bin_dir%\llvm-profdata merge -output=%profile% build64.instr\profiles\*.profraw || exit /b 1
set cmake_flags=%cmake_flags% -DLLVM_PROFDATA_FILE=%profile%
>From b84b93305c89a88cb25747a538bdf67cbea3e7d7 Mon Sep 17 00:00:00 2001
From: Hans Wennborg <hans at chromium.org>
Date: Tue, 7 Nov 2023 13:43:15 +0100
Subject: [PATCH 3/3] Drop ThinLTO
---
llvm/utils/release/build_llvm_release.bat | 3 ---
1 file changed, 3 deletions(-)
diff --git a/llvm/utils/release/build_llvm_release.bat b/llvm/utils/release/build_llvm_release.bat
index 6288eba1ab78107..7da1fad2cb4e1fe 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -286,9 +286,6 @@ set profile=%build_dir:\=/%/profile.profdata
%stage0_bin_dir%\llvm-profdata merge -output=%profile% build64.instr\profiles\*.profraw || exit /b 1
set cmake_flags=%cmake_flags% -DLLVM_PROFDATA_FILE=%profile%
-REM Enable ThinLTO
-set cmake_flags=%cmake_flags% -DLLVM_ENABLE_LTO=Thin
-
mkdir build64
cd build64
cmake -GNinja %cmake_flags% ..\llvm-project\llvm || exit /b 1
More information about the llvm-commits
mailing list