Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / test / offloading / dynamic_module_load.c
blob935d402ef2be1fb9d8beb187dd4dd3fabbf861dd
1 // RUN: %libomptarget-compile-generic -DSHARED -fPIC -shared -o %t.so && %clang %flags %s -o %t -ldl && %libomptarget-run-generic %t.so 2>&1 | %fcheck-generic
3 #ifdef SHARED
4 #include <stdio.h>
5 int foo() {
6 #pragma omp target
8 printf("%s\n", "DONE.");
9 return 0;
11 #else
12 #include <dlfcn.h>
13 #include <stdio.h>
14 int main(int argc, char **argv) {
15 void *Handle = dlopen(argv[1], RTLD_NOW);
16 int (*Foo)(void);
18 if (Handle == NULL) {
19 printf("dlopen() failed: %s\n", dlerror());
20 return 1;
22 Foo = (int (*)(void))dlsym(Handle, "foo");
23 if (Handle == NULL) {
24 printf("dlsym() failed: %s\n", dlerror());
25 return 1;
27 // CHECK: DONE.
28 // CHECK-NOT: {{abort|fault}}
29 return Foo();
31 #endif