diff options
author | Xinliang David Li <davidxl@google.com> | 2015-12-07 21:18:16 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2015-12-07 21:18:16 +0000 |
commit | b20b9ad33533d0fdd4f694fec6c477c08469b94e (patch) | |
tree | 2c7a07a06c9d77afe8435f9293f389ee41c074f2 /lib/profile/InstrProfiling.c | |
parent | 826b9958d149615a76595d94821c0e5edeb05e2f (diff) |
[PGO] Stop leaking libc function to buffer API impl
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfiling.c')
-rw-r--r-- | lib/profile/InstrProfiling.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/profile/InstrProfiling.c b/lib/profile/InstrProfiling.c index d864d1bf4..0ba504aed 100644 --- a/lib/profile/InstrProfiling.c +++ b/lib/profile/InstrProfiling.c @@ -39,6 +39,8 @@ uint32_t BoolCmpXchg(void **Ptr, void *OldV, void *NewV) { __sync_bool_compare_and_swap(Ptr, OldV, NewV) #endif +char *(*GetEnvHook)(const char *) = 0; + LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_magic(void) { return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64) : (INSTR_PROF_RAW_MAGIC_32); @@ -203,7 +205,8 @@ __llvm_profile_instrument_target(uint64_t TargetValue, void *Data, data buffer. The size of the extra space is controlled by an environment varaible. */ static unsigned getVprofExtraBytes() { - const char *ExtraStr = getenv("LLVM_VALUE_PROF_BUFFER_EXTRA"); + const char *ExtraStr = + GetEnvHook ? GetEnvHook("LLVM_VALUE_PROF_BUFFER_EXTRA") : 0; if (!ExtraStr || !ExtraStr[0]) return 1024; return (unsigned)atoi(ExtraStr); |