blob: 64ba0fbdb7a506a35d439e9f5e3a24f080e76d68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// RUN: rm -rf %t.dir && mkdir -p %t.dir
// RUN: %clang_pgogen -o %t.exe %s
//
// Note: %%p is needed here, not %p, because of lit's path substitution.
// RUN: env LLVM_PROFILE_FILE="%t.dir/%c-%%p" %run %t.exe
#include <stdlib.h>
#include <string.h>
extern int __llvm_profile_is_continuous_mode_enabled(void);
extern const char *__llvm_profile_get_filename(void);
extern int getpid(void);
int main() {
// Check that continuous mode is enabled.
if (!__llvm_profile_is_continuous_mode_enabled())
return 1;
// Check that the PID is actually in the filename.
const char *Filename = __llvm_profile_get_filename();
int Len = strlen(Filename);
--Len;
while (Filename[Len] != '-')
--Len;
const char *PidStr = Filename + Len + 1;
int Pid = atoi(PidStr);
if (Pid != getpid())
return 1;
return 0;
}
|