5252#include " llvm/Support/TimeProfiler.h"
5353#include " llvm/Support/Timer.h"
5454#include " llvm/Support/ToolOutputFile.h"
55+ #include " llvm/Support/VirtualFileSystem.h"
5556#include " llvm/Support/raw_ostream.h"
5657#include " llvm/Target/TargetMachine.h"
5758#include " llvm/Target/TargetOptions.h"
@@ -123,6 +124,7 @@ class EmitAssemblyHelper {
123124 const clang::TargetOptions &TargetOpts;
124125 const LangOptions &LangOpts;
125126 Module *TheModule;
127+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;
126128
127129 Timer CodeGenerationTime;
128130
@@ -187,9 +189,10 @@ class EmitAssemblyHelper {
187189 const HeaderSearchOptions &HeaderSearchOpts,
188190 const CodeGenOptions &CGOpts,
189191 const clang::TargetOptions &TOpts,
190- const LangOptions &LOpts, Module *M)
192+ const LangOptions &LOpts, Module *M,
193+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
191194 : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
192- TargetOpts (TOpts), LangOpts(LOpts), TheModule(M),
195+ TargetOpts (TOpts), LangOpts(LOpts), TheModule(M), VFS(std::move(VFS)),
193196 CodeGenerationTime(" codegen" , " Code Generation Time" ),
194197 TargetTriple(TheModule->getTargetTriple ()) {}
195198
@@ -767,32 +770,33 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
767770
768771 if (CodeGenOpts.hasProfileIRInstr ())
769772 // -fprofile-generate.
770- PGOOpt = PGOOptions (CodeGenOpts. InstrProfileOutput . empty ()
771- ? getDefaultProfileGenName ()
772- : CodeGenOpts.InstrProfileOutput ,
773- " " , " " , PGOOptions::IRInstr, PGOOptions::NoCSAction,
774- CodeGenOpts.DebugInfoForProfiling );
773+ PGOOpt = PGOOptions (
774+ CodeGenOpts. InstrProfileOutput . empty () ? getDefaultProfileGenName ()
775+ : CodeGenOpts.InstrProfileOutput ,
776+ " " , " " , nullptr , PGOOptions::IRInstr, PGOOptions::NoCSAction,
777+ CodeGenOpts.DebugInfoForProfiling );
775778 else if (CodeGenOpts.hasProfileIRUse ()) {
776779 // -fprofile-use.
777780 auto CSAction = CodeGenOpts.hasProfileCSIRUse () ? PGOOptions::CSIRUse
778781 : PGOOptions::NoCSAction;
779- PGOOpt = PGOOptions (CodeGenOpts.ProfileInstrumentUsePath , " " ,
780- CodeGenOpts.ProfileRemappingFile , PGOOptions::IRUse,
781- CSAction, CodeGenOpts.DebugInfoForProfiling );
782+ PGOOpt =
783+ PGOOptions (CodeGenOpts.ProfileInstrumentUsePath , " " ,
784+ CodeGenOpts.ProfileRemappingFile , VFS, PGOOptions::IRUse,
785+ CSAction, CodeGenOpts.DebugInfoForProfiling );
782786 } else if (!CodeGenOpts.SampleProfileFile .empty ())
783787 // -fprofile-sample-use
784788 PGOOpt = PGOOptions (
785789 CodeGenOpts.SampleProfileFile , " " , CodeGenOpts.ProfileRemappingFile ,
786- PGOOptions::SampleUse, PGOOptions::NoCSAction,
790+ VFS, PGOOptions::SampleUse, PGOOptions::NoCSAction,
787791 CodeGenOpts.DebugInfoForProfiling , CodeGenOpts.PseudoProbeForProfiling );
788792 else if (CodeGenOpts.PseudoProbeForProfiling )
789793 // -fpseudo-probe-for-profiling
790- PGOOpt =
791- PGOOptions ( " " , " " , " " , PGOOptions::NoAction, PGOOptions::NoCSAction,
792- CodeGenOpts.DebugInfoForProfiling , true );
794+ PGOOpt = PGOOptions ( " " , " " , " " , nullptr , PGOOptions::NoAction,
795+ PGOOptions::NoCSAction,
796+ CodeGenOpts.DebugInfoForProfiling , true );
793797 else if (CodeGenOpts.DebugInfoForProfiling )
794798 // -fdebug-info-for-profiling
795- PGOOpt = PGOOptions (" " , " " , " " , PGOOptions::NoAction,
799+ PGOOpt = PGOOptions (" " , " " , " " , nullptr , PGOOptions::NoAction,
796800 PGOOptions::NoCSAction, true );
797801
798802 // Check to see if we want to generate a CS profile.
@@ -810,12 +814,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
810814 : CodeGenOpts.InstrProfileOutput ;
811815 PGOOpt->CSAction = PGOOptions::CSIRInstr;
812816 } else
813- PGOOpt = PGOOptions (" " ,
814- CodeGenOpts.InstrProfileOutput .empty ()
815- ? getDefaultProfileGenName ()
816- : CodeGenOpts.InstrProfileOutput ,
817- " " , PGOOptions::NoAction, PGOOptions::CSIRInstr,
818- CodeGenOpts.DebugInfoForProfiling );
817+ PGOOpt =
818+ PGOOptions (" " ,
819+ CodeGenOpts.InstrProfileOutput .empty ()
820+ ? getDefaultProfileGenName ()
821+ : CodeGenOpts.InstrProfileOutput ,
822+ " " , nullptr , PGOOptions::NoAction, PGOOptions::CSIRInstr,
823+ CodeGenOpts.DebugInfoForProfiling );
819824 }
820825 if (TM)
821826 TM->setPGOOption (PGOOpt);
@@ -1219,9 +1224,9 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
12191224 const HeaderSearchOptions &HeaderOpts,
12201225 const CodeGenOptions &CGOpts,
12211226 const clang::TargetOptions &TOpts,
1222- const LangOptions &LOpts,
1223- StringRef TDesc, Module *M,
1224- BackendAction Action ,
1227+ const LangOptions &LOpts, StringRef TDesc,
1228+ Module *M, BackendAction Action ,
1229+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS ,
12251230 std::unique_ptr<raw_pwrite_stream> OS) {
12261231
12271232 llvm::TimeTraceScope TimeScope (" Backend" );
@@ -1264,7 +1269,7 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
12641269 }
12651270 }
12661271
1267- EmitAssemblyHelper AsmHelper (Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
1272+ EmitAssemblyHelper AsmHelper (Diags, HeaderOpts, CGOpts, TOpts, LOpts, M, VFS );
12681273 AsmHelper.EmitAssembly (Action, std::move (OS));
12691274
12701275 // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's
0 commit comments