[test-suite] r260358 - cmake: Add option to add apropriate -fprofile-instr-use= flags based on the executable name

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 19:56:45 PST 2016


Author: matze
Date: Tue Feb  9 21:56:44 2016
New Revision: 260358

URL: http://llvm.org/viewvc/llvm-project?rev=260358&view=rev
Log:
cmake: Add option to add apropriate -fprofile-instr-use= flags based on the executable name

Modified:
    test-suite/trunk/CMakeLists.txt
    test-suite/trunk/cmake/modules/SingleMultiSource.cmake
    test-suite/trunk/litsupport/profilegen.py

Modified: test-suite/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/CMakeLists.txt?rev=260358&r1=260357&r2=260358&view=diff
==============================================================================
--- test-suite/trunk/CMakeLists.txt (original)
+++ test-suite/trunk/CMakeLists.txt Tue Feb  9 21:56:44 2016
@@ -60,10 +60,16 @@ mark_as_advanced(TEST_SUITE_LLVM_PROFDAT
 # Set value to python style True/False
 if(TEST_SUITE_PROFILE_GENERATE)
   set(TEST_SUITE_PROFILE_GENERATE "True")
+  list(APPEND CFLAGS -fprofile-instr-generate)
+  list(APPEND CXXFLAGS -fprofile-instr-generate)
+  list(APPEND LDFLAGS -fprofile-instr-generate)
 else()
   set(TEST_SUITE_PROFILE_GENERATE "False")
 endif()
 
+set(TEST_SUITE_PROFILE_USE "FALSE" CACHE BOOL
+    "Add apropriate -fprofile-instr-use to CFLAGS/CXXFLAGS for each benchmark")
+
 include(MakefileFunctions)
 include(SingleMultiSource)
 find_package(YACC)

Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=260358&r1=260357&r2=260358&view=diff
==============================================================================
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Tue Feb  9 21:56:44 2016
@@ -136,6 +136,11 @@ macro(test_suite_add_executable name mai
     append_cflags(${source_exename} ${CPPFLAGS})
     append_cflags(${source_exename} ${CXXFLAGS})
     target_link_libraries(${source_exename} ${LDFLAGS})
+    if (TEST_SUITE_PROFILE_USE)
+      append_cflags(${source_exename} -fprofile-instr-use=${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.profdata)
+      target_link_libraries(${source_exename} -fprofile-instr-use=${CMAKE_CURRENT_BINARY_DIR}/${source_exename}.profdata)
+    endif()
+
     llvm_add_test(${name} ${source_exename})
     add_dependencies(${source_exename} timeit-host timeit-target fpcmp-host)
   endif()

Modified: test-suite/trunk/litsupport/profilegen.py
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/litsupport/profilegen.py?rev=260358&r1=260357&r2=260358&view=diff
==============================================================================
--- test-suite/trunk/litsupport/profilegen.py (original)
+++ test-suite/trunk/litsupport/profilegen.py Tue Feb  9 21:56:44 2016
@@ -1,4 +1,8 @@
 import shellcommand
+try:
+    from shlex import quote  # python 3.3 and above
+except:
+    from pipes import quote  # python 3.2 and earlier
 
 
 def wrapScript(context, script):
@@ -23,7 +27,8 @@ def getMergeProfilesScript(context):
     executable = shellcommand.getMainExecutable(context)
     if not executable:
         return None
-    profdatafile = executable + ".profdata"
-    mergecmd = [config.llvm_profdata, 'merge', '-output=%s' % profdatafile]
+    datafile = executable + ".profdata"
+    mergecmd = [context.config.llvm_profdata, 'merge', '-output=%s' % datafile]
     mergecmd += context.profilefiles
-    return [mergecmd]
+    cmdline = " ".join(map(quote, mergecmd))
+    return [cmdline]




More information about the llvm-commits mailing list