<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><span class=""><blockquote type="cite" class="">On Nov 8, 2017, at 1:13 PM, Justin Bogner <<a href="mailto:mail@justinbogner.com" class="">mail@justinbogner.com</a>> wrote:<br class=""><br class="">Vedant Kumar <<a href="mailto:vsk@apple.com" class="">vsk@apple.com</a>> writes:<br class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class="">On Nov 8, 2017, at 10:46 AM, Justin Bogner <mail@justinbogner.com> wrote:<br class=""><br class="">Vedant Kumar <vsk@apple.com> writes:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Nov 7, 2017, at 5:22 PM, Justin Bogner <mail@justinbogner.com> wrote:<br class=""><br class="">Vedant Kumar via llvm-commits <llvm-commits@lists.llvm.org> writes:<br class=""><blockquote type="cite" class="">Author: vedantk<br class="">Date: Wed Sep 20 10:16:01 2017<br class="">New Revision: 313770<br class=""><br class="">URL: http://llvm.org/viewvc/llvm-project?rev=313770&view=rev<br class="">Log:<br class="">[cmake] Add an option to build llvm with IR PGO<br class=""><br class="">This adds an LLVM_ENABLE_IR_PGO option to enable building llvm and its<br class="">tools with IR PGO instrumentation.<br class=""><br class="">Usage: -DLLVM_BUILD_INSTRUMENTED=On -DLLVM_ENABLE_IR_PGO=On (both<br class="">options must be enabled)<br class=""></blockquote><br class="">Why not make LLVM_BUILD_INSTRUMENTED a string like "FE" or "IR" instead<br class="">of a bool?<br class=""></blockquote><br class="">I didn't want to break setups which set LLVM_BUILD_INSTRUMENTED:BOOL.<br class=""></blockquote><br class="">See how LLVM_ENABLE_LTO handled that - it treats bools in that spot as<br class="">the old way and then handles the explicit options the new way. If you<br class="">think that overloads the flag too much that's fine though.<br class=""></blockquote><br class="">Thanks. I think it'd be nice to have one option to control PGO instrumentation.<br class=""><br class="">How does this look?<br class=""><br class="">   - This deprecates LLVM_ENABLE_IR_PGO but keeps it around for now.<br class="">   - Errors out when LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE<br class="">     are both set.<br class=""></blockquote><br class="">This is pretty much exactly what I was thinking. LGTM.<br class=""></blockquote><br class="">Done, r317725.<br class=""></span><span class=""><br class="">vedant<br class=""></span><span class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">commit 11e5df29a5a73b8465e39cf78bd3a7e6de403d0a (HEAD -> master)<br class="">Author: Vedant Kumar <<a href="mailto:vsk@apple.com" class="">vsk@apple.com</a>><br class="">Date:   Wed Nov 8 11:17:35 2017<br class=""><br class="">   [cmake] Allow LLVM_BUILD_INSTRUMENTED to be set to IR or Frontend<br class=""><br class="">   - This deprecates LLVM_ENABLE_IR_PGO but keeps it around for now.<br class="">   - Errors out when LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE<br class="">     are both set.<br class=""><br class="">diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake<br class="">index cf1ece24848..c5390371845 100644<br class="">--- a/cmake/modules/HandleLLVMOptions.cmake<br class="">+++ b/cmake/modules/HandleLLVMOptions.cmake<br class="">@@ -738,14 +738,15 @@ if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)<br class="">  message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")<br class="">endif()<br class=""><br class="">-option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (experimental)" Off)<br class="">+option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (deprecated)" Off)<br class="">mark_as_advanced(LLVM_ENABLE_IR_PGO)<br class=""><br class="">-option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation" Off)<br class="">+set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR or Frontend")<br class="">mark_as_advanced(LLVM_BUILD_INSTRUMENTED)<br class="">+string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)<br class=""><br class="">if (LLVM_BUILD_INSTRUMENTED)<br class="">-  if (LLVM_ENABLE_IR_PGO)<br class="">+  if (LLVM_ENABLE_IR_PGO OR uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "IR")<br class="">    append("-fprofile-generate='${LLVM_PROFILE_DATA_DIR}'"<br class="">      CMAKE_CXX_FLAGS<br class="">      CMAKE_C_FLAGS<br class="">@@ -768,6 +769,10 @@ append_if(LLVM_BUILD_INSTRUMENTED_COVERAGE "-fprofile-instr-generate='${LLVM_PRO<br class="">  CMAKE_EXE_LINKER_FLAGS<br class="">  CMAKE_SHARED_LINKER_FLAGS)<br class=""><br class="">+if (LLVM_BUILD_INSTRUMENTED AND LLVM_BUILD_INSTRUMENTED_COVERAGE)<br class="">+  message(FATAL_ERROR "LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE cannot both be specified")<br class="">+endif()<br class="">+<br class="">if(LLVM_ENABLE_LTO AND LLVM_ON_WIN32 AND NOT LINKER_IS_LLD_LINK)<br class="">  message(FATAL_ERROR "When compiling for Windows, LLVM_ENABLE_LTO requires using lld as the linker (point CMAKE_LINKER at lld-link.exe)")<br class="">endif()<br class=""><br class=""><br class=""><br class="">vedant<br class=""><br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">There's some prior art for that approach with how the<br class="">LLVM_ENABLE_LTO flag works. Having to specify two parameters for this<br class="">(and the fact that LLVM_ENABLE_IR_PGO is meaningless without the other)<br class="">is awkward.<br class=""></blockquote><br class="">It makes sense to make LLVM_ENABLE_IR_PGO meaningful by itself. We<br class="">just need to update the PGO cmake cache accordingly.<br class=""><br class="">vedant<br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">Differential Revision: https://reviews.llvm.org/D38066<br class=""><br class="">Modified:<br class=""> llvm/trunk/CMakeLists.txt<br class=""> llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br class=""><br class="">Modified: llvm/trunk/CMakeLists.txt<br class="">URL:<br class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=313770&r1=313769&r2=313770&view=diff<br class="">==============================================================================<br class=""><br class="">--- llvm/trunk/CMakeLists.txt (original)<br class="">+++ llvm/trunk/CMakeLists.txt Wed Sep 20 10:16:01 2017<br class="">@@ -548,7 +548,8 @@ else()<br class="">set(LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION FALSE CACHE INTERNAL "For Visual Studio 2013, manually copy natvis files to Documents\\Visual Studio 2013\\Visualizers" FORCE)<br class="">endif()<br class=""><br class="">-if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE)<br class="">+if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR<br class="">+    LLVM_ENABLE_IR_PGO)<br class="">if(NOT LLVM_PROFILE_MERGE_POOL_SIZE)<br class="">  # A pool size of 1-2 is probably sufficient on a SSD. 3-4 should be fine<br class="">  # for spining disks. Anything higher may only help on slower mediums.<br class="">@@ -556,10 +557,9 @@ if (LLVM_BUILD_INSTRUMENTED OR LLVM_BUIL<br class="">endif()<br class="">if(NOT LLVM_PROFILE_FILE_PATTERN)<br class="">  if(NOT LLVM_PROFILE_DATA_DIR)<br class="">-      file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)<br class="">-    else()<br class="">-      file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)<br class="">+      file(TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles" LLVM_PROFILE_DATA_DIR)<br class="">  endif()<br class="">+<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>file(TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN)<br class="">endif()<br class="">endif()<br class=""><br class=""><br class="">Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake<br class="">URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=313770&r1=313769&r2=313770&view=diff<br class="">==============================================================================<br class="">--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)<br class="">+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Sep 20 10:16:01 2017<br class="">@@ -730,13 +730,27 @@ if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RT<br class="">message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")<br class="">endif()<br class=""><br class="">+option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (experimental)" Off)<br class="">+mark_as_advanced(LLVM_ENABLE_IR_PGO)<br class="">+<br class="">option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation" Off)<br class="">mark_as_advanced(LLVM_BUILD_INSTRUMENTED)<br class="">-append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"<br class="">-  CMAKE_CXX_FLAGS<br class="">-  CMAKE_C_FLAGS<br class="">-  CMAKE_EXE_LINKER_FLAGS<br class="">-  CMAKE_SHARED_LINKER_FLAGS)<br class="">+<br class="">+if (LLVM_BUILD_INSTRUMENTED)<br class="">+  if (LLVM_ENABLE_IR_PGO)<br class="">+    append("-fprofile-generate='${LLVM_PROFILE_DATA_DIR}'"<br class="">+      CMAKE_CXX_FLAGS<br class="">+      CMAKE_C_FLAGS<br class="">+      CMAKE_EXE_LINKER_FLAGS<br class="">+      CMAKE_SHARED_LINKER_FLAGS)<br class="">+  else()<br class="">+    append("-fprofile-instr-generate='${LLVM_PROFILE_FILE_PATTERN}'"<br class="">+      CMAKE_CXX_FLAGS<br class="">+      CMAKE_C_FLAGS<br class="">+      CMAKE_EXE_LINKER_FLAGS<br class="">+      CMAKE_SHARED_LINKER_FLAGS)<br class="">+  endif()<br class="">+endif()<br class=""><br class="">option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)<br class="">mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class="">llvm-commits@lists.llvm.org<br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote></span><br class=""></body></html>