Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / instrprof-get-filename.c
blob031b75f12f3c2654684280899855f80499e615e4
1 // Test __llvm_profile_get_filename.
2 // RUN: %clang_pgogen -O2 -o %t %s
3 // RUN: %run %t
5 #include <stdio.h>
6 #include <string.h>
8 const char *__llvm_profile_get_filename();
9 void __llvm_profile_set_filename(const char *);
11 int main(int argc, const char *argv[]) {
12 int i;
13 const char *filename;
14 const char *new_filename = "/path/to/test.profraw";
16 filename = __llvm_profile_get_filename();
17 if (strncmp(filename, "default_", 8)) {
18 fprintf(stderr,
19 "Error: got filename %s, expected it to start with 'default_'\n",
20 filename);
21 return 1;
23 if (strcmp(filename + strlen(filename) - strlen(".profraw"), ".profraw")) {
24 fprintf(stderr,
25 "Error: got filename %s, expected it to end with '.profraw'\n",
26 filename);
27 return 1;
30 __llvm_profile_set_filename(new_filename);
31 filename = __llvm_profile_get_filename();
32 if (strcmp(filename, new_filename)) {
33 fprintf(stderr, "Error: got filename %s, expected '%s'\n", filename,
34 new_filename);
35 return 1;
38 return 0;