File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
clang/lib/Driver/ToolChains
lib/Transforms/Instrumentation Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 2121#include " llvm/ADT/StringSwitch.h"
2222#include " llvm/Option/ArgList.h"
2323#include " llvm/ProfileData/InstrProf.h"
24+ #include " llvm/ProfileData/MemProf.h"
2425#include " llvm/Support/Path.h"
2526#include " llvm/Support/ScopedPrinter.h"
2627#include " llvm/Support/Threading.h"
@@ -1619,7 +1620,9 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
16191620
16201621 if (Sanitize.needsMemProfRt ())
16211622 if (hasExportSymbolDirective (Args))
1622- addExportedSymbol (CmdArgs, " ___memprof_default_options_str" );
1623+ addExportedSymbol (
1624+ CmdArgs,
1625+ llvm::memprof::getMemprofOptionsSymbolDarwinLinkageName ().data ());
16231626
16241627 const XRayArgs &XRay = getXRayArgs ();
16251628 if (XRay.needsXRayRt ()) {
Original file line number Diff line number Diff line change 66#include " llvm/ADT/STLForwardCompat.h"
77#include " llvm/ADT/STLFunctionalExtras.h"
88#include " llvm/ADT/SmallVector.h"
9+ #include " llvm/ADT/StringRef.h"
910#include " llvm/IR/GlobalValue.h"
1011#include " llvm/ProfileData/MemProfData.inc"
1112#include " llvm/Support/BLAKE3.h"
@@ -42,6 +43,16 @@ constexpr uint64_t MaximumSupportedVersion = Version3;
4243// Verify that the minimum and maximum satisfy the obvious constraint.
4344static_assert (MinimumSupportedVersion <= MaximumSupportedVersion);
4445
46+ inline llvm::StringRef getMemprofOptionsSymbolDarwinLinkageName () {
47+ return " ___memprof_default_options_str" ;
48+ }
49+
50+ inline llvm::StringRef getMemprofOptionsSymbolName () {
51+ // Darwin linkage names are prefixed with an extra "_". See
52+ // DataLayout::getGlobalPrefix().
53+ return getMemprofOptionsSymbolDarwinLinkageName ().drop_front ();
54+ }
55+
4556enum class Meta : uint64_t {
4657 Start = 0 ,
4758#define MIBEntryDef (NameTag, Name, Type ) NameTag,
Original file line number Diff line number Diff line change @@ -568,10 +568,9 @@ void createMemprofHistogramFlagVar(Module &M) {
568568void createMemprofDefaultOptionsVar (Module &M) {
569569 Constant *OptionsConst = ConstantDataArray::getString (
570570 M.getContext (), MemprofRuntimeDefaultOptions, /* AddNull=*/ true );
571- GlobalVariable *OptionsVar =
572- new GlobalVariable (M, OptionsConst->getType (), /* isConstant=*/ true ,
573- GlobalValue::WeakAnyLinkage, OptionsConst,
574- " __memprof_default_options_str" );
571+ GlobalVariable *OptionsVar = new GlobalVariable (
572+ M, OptionsConst->getType (), /* isConstant=*/ true ,
573+ GlobalValue::WeakAnyLinkage, OptionsConst, getMemprofOptionsSymbolName ());
575574 Triple TT (M.getTargetTriple ());
576575 if (TT.supportsCOMDAT ()) {
577576 OptionsVar->setLinkage (GlobalValue::ExternalLinkage);
You can’t perform that action at this time.
0 commit comments