forked from OSchip/llvm-project
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
This commit is contained in:
parent
f067435026
commit
ae2f0bbcf1
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 arm)
|
||||
|
||||
add_custom_target(profile)
|
||||
|
||||
if(APPLE)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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")
|
|
@ -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}
|
|
@ -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
|
|
@ -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")
|
Loading…
Reference in New Issue