Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / Inputs / instrprof-dlopen-main.c
blobec357fe05bd53fdd2189d57e0bde4c34d24d8feb
2 #include <stdio.h>
3 #include <stdlib.h>
5 #ifdef DLOPEN_FUNC_DIR
6 #include <dlfcn.h>
7 #else
8 void func(int K);
9 void func2(int K);
10 #endif
12 int main(int argc, char *argv[]) {
13 #ifdef DLOPEN_FUNC_DIR
14 dlerror();
15 void *f1_handle = dlopen(DLOPEN_FUNC_DIR"/func.shared", DLOPEN_FLAGS);
16 if (f1_handle == NULL) {
17 fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func.shared': %s\n",
18 dlerror());
19 return EXIT_FAILURE;
22 void (*func)(int) = (void (*)(int))dlsym(f1_handle, "func");
23 if (func == NULL) {
24 fprintf(stderr, "unable to lookup symbol 'func': %s\n", dlerror());
25 return EXIT_FAILURE;
28 void *f2_handle = dlopen(DLOPEN_FUNC_DIR"/func2.shared", DLOPEN_FLAGS);
29 if (f2_handle == NULL) {
30 fprintf(stderr, "unable to open '" DLOPEN_FUNC_DIR "/func2.shared': %s\n",
31 dlerror());
32 return EXIT_FAILURE;
35 void (*func2)(int) = (void (*)(int))dlsym(f2_handle, "func2");
36 if (func2 == NULL) {
37 fprintf(stderr, "unable to lookup symbol 'func2': %s\n", dlerror());
38 return EXIT_FAILURE;
40 #endif
42 func(1);
43 func2(0);
45 return EXIT_SUCCESS;