Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / on_initialize_finalize_hooks.cpp
blob3f7b56bd636e7af08b9f1522dde6fb8fd101af10
1 // RUN: %clang_tsan -O1 %s -DBUILD_LIB=1 -fno-sanitize=thread -shared -fPIC -o %dynamiclib %ld_flags_rpath_so
2 // RUN: %clang_tsan -O1 %s -o %t %ld_flags_rpath_exe
3 // RUN: %run %t | FileCheck %s
5 // Test that initialization/finalization hooks are called, even when they are
6 // not defined in the main executable, but by another another library that
7 // doesn't directly link against the TSan runtime.
9 #include <stdio.h>
11 #if BUILD_LIB
13 extern "C" void __tsan_on_initialize() {
14 printf("__tsan_on_initialize()\n");
17 extern "C" int __tsan_on_finalize(int failed) {
18 printf("__tsan_on_finalize()\n");
19 return failed;
22 #else // BUILD_LIB
24 int main() {
25 printf("main()\n");
26 return 0;
29 #endif // BUILD_LIB
31 // CHECK: __tsan_on_initialize()
32 // CHECK: main()
33 // CHECK: __tsan_on_finalize()