2015-07-10 01:21:52 +08:00
|
|
|
/*===- InstrProfilingUtil.h - Support library for PGO instrumentation -----===*\
|
|
|
|
|*
|
|
|
|
|* The LLVM Compiler Infrastructure
|
|
|
|
|*
|
|
|
|
|* This file is distributed under the University of Illinois Open Source
|
|
|
|
|* License. See LICENSE.TXT for details.
|
|
|
|
|*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#ifndef PROFILE_INSTRPROFILINGUTIL_H
|
|
|
|
#define PROFILE_INSTRPROFILINGUTIL_H
|
|
|
|
|
Add some minimal portability code paths for PS4.
Summary:
Hi David, SCE folks,
What is implemented in this patch is enough for the upstream libprofile to
work for PGO with the PS4 game codebase I tested ("game7" for you SCE
folks; this is with a standalone build of compiler-rt).
The first change, which is simple, is to stub out gethostname. PS4
doesn't have a simple analog for this that doesn't bring in extra
OS libraries, so for now we do not support `%h` expansion.
This is consistent with internal B#136272.
The second change implies future work, but is a simple change at present.
PS4 does not have `getenv`, so for now we will introduce a shim.
This obviously makes it impossible for many of the tests to be run since
they require setting `LLVM_PROFILE_FILE=`.
I see two paths forward:
1. In the tests we are already wrapping execution with `%run` and so by
setting a PS4-specific expansion for `%run` we can pass the information
in another way We can adapt the getenv shim as appropriate.
We will need to experiment with this internally.
Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we
may need to get into some PS4 vagaries. I'm thinking a fake getenv
library that uses some side channel for communication.
2. Another possibility which is more verbose is to use a separate clang
invocation with `-profile-generate=<filename>` to set the filename in
each test.
This might require redundant clang invocations though which may be
undesirable for upstream. David, thoughts?
Also, this is a fairly libprofile-specific workaround, so it e.g.
doesn't help Filipe's ASan work.
Overall, this approach sounds like a bit of a hack to me.
Small detail:
InstrProfilingPort.h seems like the natural place for the getenv shim,
but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently
the only header common between InstrProfilingFile.c and GCDAProfiling.c.
I can move the shim to InstrProfilingPort.h and add an include to
GCDAProfiling.c as per your preference David.
Reviewers: davidxl, MaggieYi, phillip.power, filcab
Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D17676
llvm-svn: 262527
2016-03-03 06:05:46 +08:00
|
|
|
#include <stddef.h>
|
2016-06-06 11:17:58 +08:00
|
|
|
#include <stdio.h>
|
Add some minimal portability code paths for PS4.
Summary:
Hi David, SCE folks,
What is implemented in this patch is enough for the upstream libprofile to
work for PGO with the PS4 game codebase I tested ("game7" for you SCE
folks; this is with a standalone build of compiler-rt).
The first change, which is simple, is to stub out gethostname. PS4
doesn't have a simple analog for this that doesn't bring in extra
OS libraries, so for now we do not support `%h` expansion.
This is consistent with internal B#136272.
The second change implies future work, but is a simple change at present.
PS4 does not have `getenv`, so for now we will introduce a shim.
This obviously makes it impossible for many of the tests to be run since
they require setting `LLVM_PROFILE_FILE=`.
I see two paths forward:
1. In the tests we are already wrapping execution with `%run` and so by
setting a PS4-specific expansion for `%run` we can pass the information
in another way We can adapt the getenv shim as appropriate.
We will need to experiment with this internally.
Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we
may need to get into some PS4 vagaries. I'm thinking a fake getenv
library that uses some side channel for communication.
2. Another possibility which is more verbose is to use a separate clang
invocation with `-profile-generate=<filename>` to set the filename in
each test.
This might require redundant clang invocations though which may be
undesirable for upstream. David, thoughts?
Also, this is a fairly libprofile-specific workaround, so it e.g.
doesn't help Filipe's ASan work.
Overall, this approach sounds like a bit of a hack to me.
Small detail:
InstrProfilingPort.h seems like the natural place for the getenv shim,
but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently
the only header common between InstrProfilingFile.c and GCDAProfiling.c.
I can move the shim to InstrProfilingPort.h and add an include to
GCDAProfiling.c as per your preference David.
Reviewers: davidxl, MaggieYi, phillip.power, filcab
Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D17676
llvm-svn: 262527
2016-03-03 06:05:46 +08:00
|
|
|
|
2015-07-10 01:21:52 +08:00
|
|
|
/*! \brief Create a directory tree. */
|
|
|
|
void __llvm_profile_recursive_mkdir(char *Pathname);
|
|
|
|
|
2018-08-01 07:37:24 +08:00
|
|
|
/*! Set the mode used when creating profile directories. */
|
|
|
|
void __llvm_profile_set_dir_mode(unsigned Mode);
|
|
|
|
|
|
|
|
/*! Return the directory creation mode. */
|
|
|
|
unsigned __llvm_profile_get_dir_mode(void);
|
|
|
|
|
2017-12-15 03:01:04 +08:00
|
|
|
int lprofLockFd(int fd);
|
|
|
|
int lprofUnlockFd(int fd);
|
|
|
|
|
2016-06-06 11:17:58 +08:00
|
|
|
/*! Open file \c Filename for read+write with write
|
|
|
|
* lock for exclusive access. The caller will block
|
|
|
|
* if the lock is already held by another process. */
|
|
|
|
FILE *lprofOpenFileEx(const char *Filename);
|
Add some minimal portability code paths for PS4.
Summary:
Hi David, SCE folks,
What is implemented in this patch is enough for the upstream libprofile to
work for PGO with the PS4 game codebase I tested ("game7" for you SCE
folks; this is with a standalone build of compiler-rt).
The first change, which is simple, is to stub out gethostname. PS4
doesn't have a simple analog for this that doesn't bring in extra
OS libraries, so for now we do not support `%h` expansion.
This is consistent with internal B#136272.
The second change implies future work, but is a simple change at present.
PS4 does not have `getenv`, so for now we will introduce a shim.
This obviously makes it impossible for many of the tests to be run since
they require setting `LLVM_PROFILE_FILE=`.
I see two paths forward:
1. In the tests we are already wrapping execution with `%run` and so by
setting a PS4-specific expansion for `%run` we can pass the information
in another way We can adapt the getenv shim as appropriate.
We will need to experiment with this internally.
Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we
may need to get into some PS4 vagaries. I'm thinking a fake getenv
library that uses some side channel for communication.
2. Another possibility which is more verbose is to use a separate clang
invocation with `-profile-generate=<filename>` to set the filename in
each test.
This might require redundant clang invocations though which may be
undesirable for upstream. David, thoughts?
Also, this is a fairly libprofile-specific workaround, so it e.g.
doesn't help Filipe's ASan work.
Overall, this approach sounds like a bit of a hack to me.
Small detail:
InstrProfilingPort.h seems like the natural place for the getenv shim,
but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently
the only header common between InstrProfilingFile.c and GCDAProfiling.c.
I can move the shim to InstrProfilingPort.h and add an include to
GCDAProfiling.c as per your preference David.
Reviewers: davidxl, MaggieYi, phillip.power, filcab
Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D17676
llvm-svn: 262527
2016-03-03 06:05:46 +08:00
|
|
|
/* PS4 doesn't have getenv. Define a shim. */
|
2016-05-17 01:22:32 +08:00
|
|
|
#if __ORBIS__
|
Add some minimal portability code paths for PS4.
Summary:
Hi David, SCE folks,
What is implemented in this patch is enough for the upstream libprofile to
work for PGO with the PS4 game codebase I tested ("game7" for you SCE
folks; this is with a standalone build of compiler-rt).
The first change, which is simple, is to stub out gethostname. PS4
doesn't have a simple analog for this that doesn't bring in extra
OS libraries, so for now we do not support `%h` expansion.
This is consistent with internal B#136272.
The second change implies future work, but is a simple change at present.
PS4 does not have `getenv`, so for now we will introduce a shim.
This obviously makes it impossible for many of the tests to be run since
they require setting `LLVM_PROFILE_FILE=`.
I see two paths forward:
1. In the tests we are already wrapping execution with `%run` and so by
setting a PS4-specific expansion for `%run` we can pass the information
in another way We can adapt the getenv shim as appropriate.
We will need to experiment with this internally.
Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we
may need to get into some PS4 vagaries. I'm thinking a fake getenv
library that uses some side channel for communication.
2. Another possibility which is more verbose is to use a separate clang
invocation with `-profile-generate=<filename>` to set the filename in
each test.
This might require redundant clang invocations though which may be
undesirable for upstream. David, thoughts?
Also, this is a fairly libprofile-specific workaround, so it e.g.
doesn't help Filipe's ASan work.
Overall, this approach sounds like a bit of a hack to me.
Small detail:
InstrProfilingPort.h seems like the natural place for the getenv shim,
but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently
the only header common between InstrProfilingFile.c and GCDAProfiling.c.
I can move the shim to InstrProfilingPort.h and add an include to
GCDAProfiling.c as per your preference David.
Reviewers: davidxl, MaggieYi, phillip.power, filcab
Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D17676
llvm-svn: 262527
2016-03-03 06:05:46 +08:00
|
|
|
static inline char *getenv(const char *name) { return NULL; }
|
2016-05-17 01:22:32 +08:00
|
|
|
#endif /* #if __ORBIS__ */
|
Add some minimal portability code paths for PS4.
Summary:
Hi David, SCE folks,
What is implemented in this patch is enough for the upstream libprofile to
work for PGO with the PS4 game codebase I tested ("game7" for you SCE
folks; this is with a standalone build of compiler-rt).
The first change, which is simple, is to stub out gethostname. PS4
doesn't have a simple analog for this that doesn't bring in extra
OS libraries, so for now we do not support `%h` expansion.
This is consistent with internal B#136272.
The second change implies future work, but is a simple change at present.
PS4 does not have `getenv`, so for now we will introduce a shim.
This obviously makes it impossible for many of the tests to be run since
they require setting `LLVM_PROFILE_FILE=`.
I see two paths forward:
1. In the tests we are already wrapping execution with `%run` and so by
setting a PS4-specific expansion for `%run` we can pass the information
in another way We can adapt the getenv shim as appropriate.
We will need to experiment with this internally.
Maggie, Phillip, Filipe? Any ideas? Maybe ping me internally since we
may need to get into some PS4 vagaries. I'm thinking a fake getenv
library that uses some side channel for communication.
2. Another possibility which is more verbose is to use a separate clang
invocation with `-profile-generate=<filename>` to set the filename in
each test.
This might require redundant clang invocations though which may be
undesirable for upstream. David, thoughts?
Also, this is a fairly libprofile-specific workaround, so it e.g.
doesn't help Filipe's ASan work.
Overall, this approach sounds like a bit of a hack to me.
Small detail:
InstrProfilingPort.h seems like the natural place for the getenv shim,
but GCDAProfiling.c needs it as well. InstrProfilingUtil.h is currently
the only header common between InstrProfilingFile.c and GCDAProfiling.c.
I can move the shim to InstrProfilingPort.h and add an include to
GCDAProfiling.c as per your preference David.
Reviewers: davidxl, MaggieYi, phillip.power, filcab
Subscribers: simon.f.whittaker, slingn, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D17676
llvm-svn: 262527
2016-03-03 06:05:46 +08:00
|
|
|
|
2016-07-20 04:31:46 +08:00
|
|
|
/* GCOV_PREFIX and GCOV_PREFIX_STRIP support */
|
|
|
|
/* Return the path prefix specified by GCOV_PREFIX environment variable.
|
|
|
|
* If GCOV_PREFIX_STRIP is also specified, the strip level (integer value)
|
|
|
|
* is returned via \c *PrefixStrip. The prefix length is stored in *PrefixLen.
|
|
|
|
*/
|
|
|
|
const char *lprofGetPathPrefix(int *PrefixStrip, size_t *PrefixLen);
|
|
|
|
/* Apply the path prefix specified in \c Prefix to path string in \c PathStr,
|
|
|
|
* and store the result to buffer pointed to by \c Buffer. If \c PrefixStrip
|
|
|
|
* is not zero, path prefixes are stripped from \c PathStr (the level of
|
|
|
|
* stripping is specified by \c PrefixStrip) before \c Prefix is added.
|
|
|
|
*/
|
|
|
|
void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
|
|
|
|
size_t PrefixLen, int PrefixStrip);
|
|
|
|
|
2016-07-20 04:48:00 +08:00
|
|
|
/* Returns a pointer to the first occurrence of \c DIR_SEPARATOR char in
|
|
|
|
* the string \c Path, or NULL if the char is not found. */
|
|
|
|
const char *lprofFindFirstDirSeparator(const char *Path);
|
|
|
|
/* Returns a pointer to the last occurrence of \c DIR_SEPARATOR char in
|
|
|
|
* the string \c Path, or NULL if the char is not found. */
|
|
|
|
const char *lprofFindLastDirSeparator(const char *Path);
|
|
|
|
|
2016-03-06 12:52:45 +08:00
|
|
|
int lprofGetHostName(char *Name, int Len);
|
|
|
|
|
2016-03-07 21:42:17 +08:00
|
|
|
unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
|
2016-05-17 07:01:03 +08:00
|
|
|
void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
|
2016-03-06 08:55:20 +08:00
|
|
|
|
2017-03-18 02:41:33 +08:00
|
|
|
/* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed.
|
|
|
|
* Other return values mean no restore is needed.
|
|
|
|
*/
|
2017-08-31 23:51:23 +08:00
|
|
|
int lprofSuspendSigKill();
|
2017-03-18 02:41:33 +08:00
|
|
|
|
|
|
|
/* Restore previously suspended SIGKILL. */
|
2017-08-31 23:51:23 +08:00
|
|
|
void lprofRestoreSigKill();
|
2017-03-18 02:41:33 +08:00
|
|
|
|
2016-05-17 07:01:03 +08:00
|
|
|
#endif /* PROFILE_INSTRPROFILINGUTIL_H */
|