Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / instrprof-path.c
blobe4dc8961212c194b3234b17e84d7544a27cfbd00
1 // RUN: %clang_pgogen -O2 -o %t.0 %s
2 // RUN: %clang_pgogen=%/t.d1 -O2 -o %t.1 %s
3 // RUN: %clang_pgogen=%/t.d1/%:t.d2 -O2 -o %t.2 %s
4 //
5 // RUN: %run %t.0 ""
6 // RUN: env LLVM_PROFILE_FILE=%/t.d1/default.profraw %run %t.0 %/t.d1
7 // RUN: env LLVM_PROFILE_FILE=%/t.d1/%:t.d2/default.profraw %run %t.0 %/t.d1/%:t.d2
8 // RUN: %run %t.1 %/t.d1
9 // RUN: %run %t.2 %/t.d1/%:t.d2
10 // RUN: %run %t.2 %/t.d1/%:t.d2 %/t.d1/%:t.d2/%:t.d3/blah.profraw %/t.d1/%:t.d2/%:t.d3/
12 #include <string.h>
14 const char *__llvm_profile_get_path_prefix();
15 void __llvm_profile_set_filename(const char*);
17 int main(int argc, const char *argv[]) {
18 const char *expected;
19 const char *prefix;
20 if (argc < 2)
21 return 1;
23 expected = argv[1];
24 prefix = __llvm_profile_get_path_prefix();
26 // The last character should be a trailing slash. Ignore it in the comparison
27 // since it could be '/' or '\\'.
28 int slashpos = strlen(prefix);
29 if (slashpos > 0) {
30 --slashpos;
31 if (prefix[slashpos] != '/' && prefix[slashpos] != '\\')
32 return 1;
35 if (strncmp(prefix, expected, slashpos))
36 return 1;
38 if (argc == 4) {
39 __llvm_profile_set_filename(argv[2]);
40 prefix = __llvm_profile_get_path_prefix();
41 expected = argv[3];
42 if (strcmp(prefix, expected))
43 return 1;
46 return 0;