chain-openmp-threadprivate.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // no PCH
  2. // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -emit-llvm -include %s -include %s %s -o - | FileCheck %s
  3. // with PCH
  4. // RUN: %clang_cc1 -fopenmp -fnoopenmp-use-tls -emit-llvm -chain-include %s -chain-include %s %s -o - | FileCheck %s
  5. // no PCH
  6. // RUN: %clang_cc1 -fopenmp -emit-llvm -include %s -include %s %s -o - | FileCheck %s -check-prefix=CHECK-TLS-1
  7. // RUN: %clang_cc1 -fopenmp -emit-llvm -include %s -include %s %s -o - | FileCheck %s -check-prefix=CHECK-TLS-2
  8. // with PCH
  9. // RUN: %clang_cc1 -fopenmp -emit-llvm -chain-include %s -chain-include %s %s -o - | FileCheck %s -check-prefix=CHECK-TLS-1
  10. // RUN: %clang_cc1 -fopenmp -emit-llvm -chain-include %s -chain-include %s %s -o - | FileCheck %s -check-prefix=CHECK-TLS-2
  11. // REQUIRES: tls
  12. #if !defined(PASS1)
  13. #define PASS1
  14. extern "C" int* malloc (int size);
  15. int *a = malloc(20);
  16. #elif !defined(PASS2)
  17. #define PASS2
  18. #pragma omp threadprivate(a)
  19. #else
  20. // CHECK: call {{.*}} @__kmpc_threadprivate_register(
  21. // CHECK-TLS-1: @{{a|\"\\01\?a@@3PE?AHE?A\"}} = {{.*}}thread_local {{.*}}global {{.*}}i32*
  22. // CHECK-LABEL: foo
  23. // CHECK-TLS-LABEL: foo
  24. int foo() {
  25. return *a;
  26. // CHECK: call {{.*}} @__kmpc_global_thread_num(
  27. // CHECK: call {{.*}} @__kmpc_threadprivate_cached(
  28. // CHECK-TLS-1: call {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}()
  29. }
  30. // CHECK-TLS-2: define {{.*}} @{{_ZTW1a|\"\\01\?\?__Ea@@YAXXZ\"}}()
  31. #endif