[compiler-rt] Add infrastructure for testing cpuid builtins (PR #101927)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 16:15:40 PDT 2024


================
@@ -0,0 +1,71 @@
+include(CheckCXXCompilerFlag)
+include(CompilerRTCompile)
+include(CompilerRTLink)
+
+set(BUILTINS_CPUMODEL_UNITTEST_CFLAGS
+  ${COMPILER_RT_UNITTEST_CFLAGS}
+  ${COMPILER_RT_GTEST_CFLAGS}
+  ${COMPILER_RT_GMOCK_CFLAGS}
+  ${SANITIZER_TEST_CXX_CFLAGS}
+  -fno-builtin
+  -I${COMPILER_RT_SOURCE_DIR}/lib/builtins
+  -I${CMAKE_CURRENT_SOURCE_DIR}
+  -nodefaultlibs)
+
+set(BUILTINS_CPUMODEL_UNITTEST_DEPS)
+if (TARGET cxx-headers OR HAVE_LIBCXX)
+  list(APPEND BUILTINS_CPUMODEL_UNITTEST_DEPS cxx-headers)
+endif()
+
+set(BUILTINS_CPUMODEL_UNITTESTS
+  x86.cpp)
+
+set(BUILTINS_CPUMODEL_SOURCES
+  ../../../../lib/builtins/cpu_model/x86.c
+  cpuid.cpp)
+
+set(BUILTINS_CPUMODEL_UNITTEST_LINK_LIBRARIES
+  ${COMPILER_RT_UNWINDER_LINK_LIBS}
+  ${SANITIZER_TEST_CXX_LIBRARIES})
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+set(BUILTINS_CPUMODEL_UNITTEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/cpuid.h)
+
+macro (add_builtins_cpumodel_tests_for_arch arch)
+  set(BUILTINS_CPUMODEL_TEST_RUNTIME_OBJECTS
+    $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+    $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+    $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+    $<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.${arch}>
+  )
+  set(BUILTINS_CPUMODEL_TEST_RUNTIME RTBuiltinsCPUModelTest.${arch})
+  add_library(${BUILTINS_CPUMODEL_TEST_RUNTIME} STATIC ${BUILTINS_CPUMODEL_TEST_RUNTIME_OBJECTS})
+  set_target_properties(${BUILTINS_CPUMODEL_TEST_RUNTIME} PROPERTIES
+    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    FOLDER "Compiler-RT Runtime tests")
+  set(BUILTSIN_CPUMODEL_TEST_OBJECTS)
+  generate_compiler_rt_tests(BUILTINS_CPUMODEL_TEST_OBJECTS
+    CtxProfileUnitTests "BuiltinsCPUModel-${arch}-UnitTest" ${arch}
----------------
boomanaiden154 wrote:

Good catch. Fixed.

https://github.com/llvm/llvm-project/pull/101927


More information about the llvm-commits mailing list