Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / tools / archer / tests / parallel / parallel-simple.c
blobdff410bd82ce694f04f707411084f373587d0eb7
1 /*
2 * parallel-simple.c -- Archer testcase
3 */
5 //===----------------------------------------------------------------------===//
6 //
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 //
9 // See tools/archer/LICENSE.txt for details.
10 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
12 //===----------------------------------------------------------------------===//
15 // RUN: %libarcher-compile && env OMP_TOOL_VERBOSE_INIT=stderr %libarcher-run 2>&1 | FileCheck %s --check-prefixes CHECK,TSAN_ON
16 // RUN: %clang-archer %openmp_flags %flags %s -o %t && env OMP_TOOL_VERBOSE_INIT=stderr %t 2>&1 | FileCheck %s --check-prefixes CHECK,TSAN_OFF
17 // REQUIRES: tsan
18 #include <omp.h>
19 #include <stdio.h>
21 // TSAN_ON: ----- START LOGGING OF TOOL REGISTRATION -----
22 // TSAN_ON-NEXT: Search for OMP tool in current address space... Failed.
23 // TSAN_ON-NEXT: No OMP_TOOL_LIBRARIES defined.
24 // TSAN_ON-NEXT: ...searching tool libraries failed. Using archer tool.
25 // TSAN_ON-NEXT: Opening libarcher.so... Success.
26 // TSAN_ON-NEXT: Searching for ompt_start_tool in libarcher.so... Success.
27 // TSAN_ON-NEXT: Tool was started and is using the OMPT interface.
28 // TSAN_ON-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
30 // TSAN_OFF: ----- START LOGGING OF TOOL REGISTRATION -----
31 // TSAN_OFF-NEXT: Search for OMP tool in current address space... Failed.
32 // TSAN_OFF-NEXT: No OMP_TOOL_LIBRARIES defined.
33 // TSAN_OFF-NEXT: ...searching tool libraries failed. Using archer tool.
34 // TSAN_OFF-NEXT: Opening libarcher.so... Success.
35 // TSAN_OFF-NEXT: Searching for ompt_start_tool in libarcher.so... Found but not using the OMPT interface.
36 // TSAN_OFF-NEXT: No OMP tool loaded.
37 // TSAN_OFF-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
40 int main(int argc, char *argv[]) {
41 int var = 0;
43 #pragma omp parallel num_threads(2) shared(var)
45 if (omp_get_thread_num() == 1) {
46 var++;
48 } // implicit barrier
50 var++;
52 fprintf(stderr, "DONE\n");
53 int error = (var != 2);
54 return error;
57 // CHECK-NOT: ThreadSanitizer: data race
58 // CHECK-NOT: ThreadSanitizer: reported
59 // CHECK-NOT: Warning: please export TSAN_OPTIONS
60 // CHECK: DONE