We need the compiler generated variable to override the weak symbol of the same name inside the profile runtime, but using LinkOnceODRLinkage results in weak symbol being emitted in which case the symbol selected by the linker is going to depend on the order of inputs which can be fragile. This change replaces the use of weak definition inside the runtime with a weak alias. We place the compiler generated symbol inside a COMDAT group so dead definition can be garbage collected by the linker. We also disable the use of runtime counter relocation on Darwin since Mach-O doesn't support weak external references, but Darwin already uses a different continous mode that relies on overmapping so runtime counter relocation isn't needed there. Differential Revision: https://reviews.llvm.org/D105176
27 lines
801 B
C
27 lines
801 B
C
/*===- InstrProfilingInternal.c - Support library for PGO instrumentation -===*\
|
|
|*
|
|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|* See https://llvm.org/LICENSE.txt for license information.
|
|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|*
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
// Note: This is linked into the Darwin kernel, and must remain compatible
|
|
// with freestanding compilation. See `darwin_add_builtin_libraries`.
|
|
|
|
#if !defined(__Fuchsia__)
|
|
|
|
#include "InstrProfilingInternal.h"
|
|
|
|
static unsigned ProfileDumped = 0;
|
|
|
|
COMPILER_RT_VISIBILITY unsigned lprofProfileDumped() {
|
|
return ProfileDumped;
|
|
}
|
|
|
|
COMPILER_RT_VISIBILITY void lprofSetProfileDumped(unsigned Value) {
|
|
ProfileDumped = Value;
|
|
}
|
|
|
|
#endif
|