[llvm] 8da3b7d - [CMake] Don't LTO optimize targets on Darwin, but only if its not ThinLTO

Azharuddin Mohammed via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 22:40:08 PDT 2021


Author: Azharuddin Mohammed
Date: 2021-07-23T22:38:35-07:00
New Revision: 8da3b7d857298a306973ea8f78c35adb5ba89837

URL: https://github.com/llvm/llvm-project/commit/8da3b7d857298a306973ea8f78c35adb5ba89837
DIFF: https://github.com/llvm/llvm-project/commit/8da3b7d857298a306973ea8f78c35adb5ba89837.diff

LOG: [CMake] Don't LTO optimize targets on Darwin, but only if its not ThinLTO

This is just a workaround. Pass the `-mllvm,-O0` link flags only if its
not ThinLTO. Doing that with ThinLTO currently results in an error:

```
Remaining virtual register operands
UNREACHABLE executed at .../llvm/lib/CodeGen/MachineRegisterInfo.cpp:209!
```

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 1f44b7b48326..3e009f5061d3 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -231,7 +231,7 @@ function(add_link_opts target_name)
       elseif(LINKER_IS_LLD_LINK)
         set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                       LINK_FLAGS " /opt:lldlto=0")
-      elseif(APPLE)
+      elseif(APPLE AND NOT uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
         set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                       LINK_FLAGS " -Wl,-mllvm,-O0")
       endif()
@@ -1470,7 +1470,7 @@ function(add_unittest test_suite test_name)
     elseif(LINKER_IS_LLD_LINK)
       set_property(TARGET ${test_name} APPEND_STRING PROPERTY
                     LINK_FLAGS " /opt:lldlto=0")
-    elseif(APPLE)
+    elseif(APPLE AND NOT uppercase_LLVM_ENABLE_LTO STREQUAL "THIN")
       set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                     LINK_FLAGS " -Wl,-mllvm,-O0")
     endif()


        


More information about the llvm-commits mailing list