[compiler-rt] r205256 - InstrProf: Add simple compiler-rt test

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Mar 31 15:45:37 PDT 2014


Author: dexonsmith
Date: Mon Mar 31 17:45:37 2014
New Revision: 205256

URL: http://llvm.org/viewvc/llvm-project?rev=205256&view=rev
Log:
InstrProf: Add simple compiler-rt test

Add the test infrastructure for testing lib/profile and a single test.
This initial commit only enables the tests on Darwin, but they'll be
enabled on Linux soon after.

<rdar://problem/16458307>

Added:
    compiler-rt/trunk/test/profile/
    compiler-rt/trunk/test/profile/CMakeLists.txt
    compiler-rt/trunk/test/profile/instrprof-basic.c
    compiler-rt/trunk/test/profile/lit.cfg
    compiler-rt/trunk/test/profile/lit.site.cfg.in
Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/profile/CMakeLists.txt
    compiler-rt/trunk/test/CMakeLists.txt

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=205256&r1=205255&r2=205256&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Mon Mar 31 17:45:37 2014
@@ -332,6 +332,7 @@ filter_available_targets(ASAN_SUPPORTED_
 filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64)
 filter_available_targets(LSAN_SUPPORTED_ARCH x86_64)
 filter_available_targets(MSAN_SUPPORTED_ARCH x86_64)
+filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 arm)
 filter_available_targets(TSAN_SUPPORTED_ARCH x86_64)
 filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386)
 

Modified: compiler-rt/trunk/lib/profile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/CMakeLists.txt?rev=205256&r1=205255&r2=205256&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/profile/CMakeLists.txt Mon Mar 31 17:45:37 2014
@@ -1,5 +1,3 @@
-filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 arm)
-
 add_custom_target(profile)
 
 if(APPLE)

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=205256&r1=205255&r2=205256&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Mon Mar 31 17:45:37 2014
@@ -36,6 +36,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
   if(MSAN_SUPPORTED_ARCH)
     add_subdirectory(msan)
   endif()
+  if(PROFILE_SUPPORTED_ARCH)
+    add_subdirectory(profile)
+  endif()
   if(SANITIZER_COMMON_SUPPORTED_ARCH)
     add_subdirectory(sanitizer_common)
   endif()

Added: compiler-rt/trunk/test/profile/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/CMakeLists.txt?rev=205256&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/CMakeLists.txt (added)
+++ compiler-rt/trunk/test/profile/CMakeLists.txt Mon Mar 31 17:45:37 2014
@@ -0,0 +1,15 @@
+set(PROFILE_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+set(PROFILE_TEST_DEPS)
+if(NOT COMPILER_RT_STANDALONE_BUILD)
+  list(APPEND PROFILE_TEST_DEPS profile clang llvm-profdata FileCheck)
+endif()
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+add_lit_testsuite(check-profile "Running the profile tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS ${PROFILE_TEST_DEPS})
+set_target_properties(check-profile PROPERTIES FOLDER "Profile tests")

Added: compiler-rt/trunk/test/profile/instrprof-basic.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-basic.c?rev=205256&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/instrprof-basic.c (added)
+++ compiler-rt/trunk/test/profile/instrprof-basic.c Mon Mar 31 17:45:37 2014
@@ -0,0 +1,12 @@
+// RUN: %clang_profgen -o %t -O3 -flto  %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
+
+int main(int argc, const char *argv[]) {
+  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1
+  if (argc)
+    return 0;
+  return 1;
+}
+// CHECK: !1 = metadata !{metadata !"branch_weights", i32 2, i32 1}

Added: compiler-rt/trunk/test/profile/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/lit.cfg?rev=205256&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/lit.cfg (added)
+++ compiler-rt/trunk/test/profile/lit.cfg Mon Mar 31 17:45:37 2014
@@ -0,0 +1,22 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = 'Profile'
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
+
+# Add clang substitutions.
+config.substitutions.append( ("%clang ", config.clang + " ") )
+config.substitutions.append( ("%clang_profgen ", config.clang + " -fprofile-instr-generate ") )
+config.substitutions.append( ("%clang_profuse=", config.clang + " -fprofile-instr-use=") )
+
+# Profile tests are currently supported on Linux and Darwin only.
+# TODO: change to: if config.host_os not in ['Linux', 'Darwin']:
+if config.host_os not in ['Darwin']:
+  config.unsupported = True

Added: compiler-rt/trunk/test/profile/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/lit.site.cfg.in?rev=205256&view=auto
==============================================================================
--- compiler-rt/trunk/test/profile/lit.site.cfg.in (added)
+++ compiler-rt/trunk/test/profile/lit.site.cfg.in Mon Mar 31 17:45:37 2014
@@ -0,0 +1,8 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@PROFILE_LIT_SOURCE_DIR@/lit.cfg")





More information about the llvm-commits mailing list