diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-31 22:45:37 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-31 22:45:37 +0000 |
| commit | ae2f0bbcf1b8ac81295a59ac9ad6858a054a811a (patch) | |
| tree | 8fe950635022f3186353fb4add34e204f9534c03 | |
| parent | f067435026123765bcba8094676c813a69d28a88 (diff) | |
| download | bcm5719-llvm-ae2f0bbcf1b8ac81295a59ac9ad6858a054a811a.tar.gz bcm5719-llvm-ae2f0bbcf1b8ac81295a59ac9ad6858a054a811a.zip | |
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>
llvm-svn: 205256
| -rw-r--r-- | compiler-rt/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/profile/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | compiler-rt/test/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | compiler-rt/test/profile/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | compiler-rt/test/profile/instrprof-basic.c | 12 | ||||
| -rw-r--r-- | compiler-rt/test/profile/lit.cfg | 22 | ||||
| -rw-r--r-- | compiler-rt/test/profile/lit.site.cfg.in | 8 |
7 files changed, 61 insertions, 2 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 3b295e72d15..a2d40d97bef 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -332,6 +332,7 @@ filter_available_targets(ASAN_SUPPORTED_ARCH x86_64 i386 powerpc64) 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) diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt index 8d0a5d0d0fc..4165374fd7c 100644 --- a/compiler-rt/lib/profile/CMakeLists.txt +++ b/compiler-rt/lib/profile/CMakeLists.txt @@ -1,5 +1,3 @@ -filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 arm) - add_custom_target(profile) if(APPLE) diff --git a/compiler-rt/test/CMakeLists.txt b/compiler-rt/test/CMakeLists.txt index a714cdfa5a0..84772163530 100644 --- a/compiler-rt/test/CMakeLists.txt +++ b/compiler-rt/test/CMakeLists.txt @@ -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() diff --git a/compiler-rt/test/profile/CMakeLists.txt b/compiler-rt/test/profile/CMakeLists.txt new file mode 100644 index 00000000000..8038862cb8b --- /dev/null +++ b/compiler-rt/test/profile/CMakeLists.txt @@ -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") diff --git a/compiler-rt/test/profile/instrprof-basic.c b/compiler-rt/test/profile/instrprof-basic.c new file mode 100644 index 00000000000..0732d84df6f --- /dev/null +++ b/compiler-rt/test/profile/instrprof-basic.c @@ -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} diff --git a/compiler-rt/test/profile/lit.cfg b/compiler-rt/test/profile/lit.cfg new file mode 100644 index 00000000000..22b3f547190 --- /dev/null +++ b/compiler-rt/test/profile/lit.cfg @@ -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 diff --git a/compiler-rt/test/profile/lit.site.cfg.in b/compiler-rt/test/profile/lit.site.cfg.in new file mode 100644 index 00000000000..b760893ac85 --- /dev/null +++ b/compiler-rt/test/profile/lit.site.cfg.in @@ -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") |

