@@ -570,6 +570,27 @@ static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
570570
571571static void AppendPlatformPrefix (SmallString<128 > &Path, const llvm::Triple &T);
572572
573+ // / Check if the link command contains a symbol export directive.
574+ static bool hasExportSymbolDirective (const ArgList &Args) {
575+ for (Arg *A : Args) {
576+ if (A->getOption ().matches (options::OPT_exported__symbols__list))
577+ return true ;
578+ if (!A->getOption ().matches (options::OPT_Wl_COMMA) &&
579+ !A->getOption ().matches (options::OPT_Xlinker))
580+ continue ;
581+ if (A->containsValue (" -exported_symbols_list" ) ||
582+ A->containsValue (" -exported_symbol" ))
583+ return true ;
584+ }
585+ return false ;
586+ }
587+
588+ // / Add an export directive for \p Symbol to the link command.
589+ static void addExportedSymbol (ArgStringList &CmdArgs, const char *Symbol) {
590+ CmdArgs.push_back (" -exported_symbol" );
591+ CmdArgs.push_back (Symbol);
592+ }
593+
573594void darwin::Linker::ConstructJob (Compilation &C, const JobAction &JA,
574595 const InputInfo &Output,
575596 const InputInfoList &Inputs,
@@ -734,6 +755,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
734755
735756 getMachOToolChain ().addProfileRTLibs (Args, CmdArgs);
736757
758+ if (Args.hasArg (options::OPT_fmemory_profile_runtime_default_options_EQ))
759+ if (hasExportSymbolDirective (Args))
760+ addExportedSymbol (CmdArgs, " ___memprof_default_options_str" );
761+
737762 StringRef Parallelism = getLTOParallelism (Args, getToolChain ().getDriver ());
738763 if (!Parallelism.empty ()) {
739764 CmdArgs.push_back (" -mllvm" );
@@ -1433,27 +1458,6 @@ StringRef Darwin::getOSLibraryNameSuffix(bool IgnoreSim) const {
14331458 llvm_unreachable (" Unsupported platform" );
14341459}
14351460
1436- // / Check if the link command contains a symbol export directive.
1437- static bool hasExportSymbolDirective (const ArgList &Args) {
1438- for (Arg *A : Args) {
1439- if (A->getOption ().matches (options::OPT_exported__symbols__list))
1440- return true ;
1441- if (!A->getOption ().matches (options::OPT_Wl_COMMA) &&
1442- !A->getOption ().matches (options::OPT_Xlinker))
1443- continue ;
1444- if (A->containsValue (" -exported_symbols_list" ) ||
1445- A->containsValue (" -exported_symbol" ))
1446- return true ;
1447- }
1448- return false ;
1449- }
1450-
1451- // / Add an export directive for \p Symbol to the link command.
1452- static void addExportedSymbol (ArgStringList &CmdArgs, const char *Symbol) {
1453- CmdArgs.push_back (" -exported_symbol" );
1454- CmdArgs.push_back (Symbol);
1455- }
1456-
14571461// / Add a sectalign directive for \p Segment and \p Section to the maximum
14581462// / expected page size for Darwin.
14591463// /
0 commit comments