Browse Source

Enable compiler optimizations and enforce x86-64-v2 on GCC/Clang (#9442)

* Testing LTO (#4)

* Testing LTO

* clang

* linux

* Added the rest of Blinkhawk's optimizations

* Unlikely asserts

* Removing LTO from Linux builds - GCC

* Removing LTO from Linux builds - Clang
Matías Locatti 3 years ago
parent
commit
fd1ea0fd84

+ 1 - 0
.ci/scripts/clang/docker.sh

@@ -11,6 +11,7 @@ ccache -s
 mkdir build || true && cd build
 mkdir build || true && cd build
 cmake .. \
 cmake .. \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_CXX_FLAGS="-march=x86-64-v2" \
       -DCMAKE_CXX_COMPILER=/usr/lib/ccache/clang++ \
       -DCMAKE_CXX_COMPILER=/usr/lib/ccache/clang++ \
       -DCMAKE_C_COMPILER=/usr/lib/ccache/clang \
       -DCMAKE_C_COMPILER=/usr/lib/ccache/clang \
       -DCMAKE_INSTALL_PREFIX="/usr" \
       -DCMAKE_INSTALL_PREFIX="/usr" \

+ 1 - 0
.ci/scripts/linux/docker.sh

@@ -12,6 +12,7 @@ mkdir build || true && cd build
 cmake .. \
 cmake .. \
       -DBoost_USE_STATIC_LIBS=ON \
       -DBoost_USE_STATIC_LIBS=ON \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_CXX_FLAGS="-march=x86-64-v2" \
       -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ \
       -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ \
       -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc \
       -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc \
       -DCMAKE_INSTALL_PREFIX="/usr" \
       -DCMAKE_INSTALL_PREFIX="/usr" \

+ 1 - 1
.ci/templates/build-msvc.yml

@@ -9,7 +9,7 @@ parameters:
 steps:
 steps:
 - script: choco install vulkan-sdk
 - script: choco install vulkan-sdk
   displayName: 'Install vulkan-sdk'
   displayName: 'Install vulkan-sdk'
-- script: refreshenv && mkdir build && cd build && cmake -G "Visual Studio 17 2022" -A x64 -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DYUZU_TESTS=OFF -DUSE_DISCORD_PRESENCE=ON -DENABLE_QT_TRANSLATION=ON -DDISPLAY_VERSION=${{ parameters['version'] }} -DCMAKE_BUILD_TYPE=Release -DYUZU_CRASH_DUMPS=ON .. && cd ..
+- script: refreshenv && mkdir build && cd build && cmake -E env CXXFLAGS="/Gw /GA /Gr /Ob2" cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_POLICY_DEFAULT_CMP0069=NEW -DYUZU_USE_BUNDLED_QT=1 -DYUZU_USE_BUNDLED_SDL2=1 -DYUZU_USE_QT_WEB_ENGINE=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${COMPAT} -DYUZU_TESTS=OFF -DUSE_DISCORD_PRESENCE=ON -DENABLE_QT_TRANSLATION=ON -DDISPLAY_VERSION=${{ parameters['version'] }} -DCMAKE_BUILD_TYPE=Release -DYUZU_CRASH_DUMPS=ON .. && cd ..
   displayName: 'Configure CMake'
   displayName: 'Configure CMake'
 - task: MSBuild@1
 - task: MSBuild@1
   displayName: 'Build'
   displayName: 'Build'

+ 2 - 2
src/common/assert.h

@@ -69,7 +69,7 @@ void assert_fail_impl();
 #define ASSERT_OR_EXECUTE(_a_, _b_)                                                                \
 #define ASSERT_OR_EXECUTE(_a_, _b_)                                                                \
     do {                                                                                           \
     do {                                                                                           \
         ASSERT(_a_);                                                                               \
         ASSERT(_a_);                                                                               \
-        if (!(_a_)) {                                                                              \
+        if (!(_a_)) [[unlikely]] {                                                                 \
             _b_                                                                                    \
             _b_                                                                                    \
         }                                                                                          \
         }                                                                                          \
     } while (0)
     } while (0)
@@ -78,7 +78,7 @@ void assert_fail_impl();
 #define ASSERT_OR_EXECUTE_MSG(_a_, _b_, ...)                                                       \
 #define ASSERT_OR_EXECUTE_MSG(_a_, _b_, ...)                                                       \
     do {                                                                                           \
     do {                                                                                           \
         ASSERT_MSG(_a_, __VA_ARGS__);                                                              \
         ASSERT_MSG(_a_, __VA_ARGS__);                                                              \
-        if (!(_a_)) {                                                                              \
+        if (!(_a_)) [[unlikely]] {                                                                 \
             _b_                                                                                    \
             _b_                                                                                    \
         }                                                                                          \
         }                                                                                          \
     } while (0)
     } while (0)