52
52
#include " llvm/Support/TimeProfiler.h"
53
53
#include " llvm/Support/Timer.h"
54
54
#include " llvm/Support/ToolOutputFile.h"
55
+ #include " llvm/Support/VirtualFileSystem.h"
55
56
#include " llvm/Support/raw_ostream.h"
56
57
#include " llvm/Target/TargetMachine.h"
57
58
#include " llvm/Target/TargetOptions.h"
@@ -123,6 +124,7 @@ class EmitAssemblyHelper {
123
124
const clang::TargetOptions &TargetOpts;
124
125
const LangOptions &LangOpts;
125
126
Module *TheModule;
127
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;
126
128
127
129
Timer CodeGenerationTime;
128
130
@@ -187,9 +189,10 @@ class EmitAssemblyHelper {
187
189
const HeaderSearchOptions &HeaderSearchOpts,
188
190
const CodeGenOptions &CGOpts,
189
191
const clang::TargetOptions &TOpts,
190
- const LangOptions &LOpts, Module *M)
192
+ const LangOptions &LOpts, Module *M,
193
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
191
194
: Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
192
- TargetOpts (TOpts), LangOpts(LOpts), TheModule(M),
195
+ TargetOpts (TOpts), LangOpts(LOpts), TheModule(M), VFS(std::move(VFS)),
193
196
CodeGenerationTime(" codegen" , " Code Generation Time" ),
194
197
TargetTriple(TheModule->getTargetTriple ()) {}
195
198
@@ -767,32 +770,33 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
767
770
768
771
if (CodeGenOpts.hasProfileIRInstr ())
769
772
// -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 );
775
778
else if (CodeGenOpts.hasProfileIRUse ()) {
776
779
// -fprofile-use.
777
780
auto CSAction = CodeGenOpts.hasProfileCSIRUse () ? PGOOptions::CSIRUse
778
781
: 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 );
782
786
} else if (!CodeGenOpts.SampleProfileFile .empty ())
783
787
// -fprofile-sample-use
784
788
PGOOpt = PGOOptions (
785
789
CodeGenOpts.SampleProfileFile , " " , CodeGenOpts.ProfileRemappingFile ,
786
- PGOOptions::SampleUse, PGOOptions::NoCSAction,
790
+ VFS, PGOOptions::SampleUse, PGOOptions::NoCSAction,
787
791
CodeGenOpts.DebugInfoForProfiling , CodeGenOpts.PseudoProbeForProfiling );
788
792
else if (CodeGenOpts.PseudoProbeForProfiling )
789
793
// -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 );
793
797
else if (CodeGenOpts.DebugInfoForProfiling )
794
798
// -fdebug-info-for-profiling
795
- PGOOpt = PGOOptions (" " , " " , " " , PGOOptions::NoAction,
799
+ PGOOpt = PGOOptions (" " , " " , " " , nullptr , PGOOptions::NoAction,
796
800
PGOOptions::NoCSAction, true );
797
801
798
802
// Check to see if we want to generate a CS profile.
@@ -810,12 +814,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
810
814
: CodeGenOpts.InstrProfileOutput ;
811
815
PGOOpt->CSAction = PGOOptions::CSIRInstr;
812
816
} 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 );
819
824
}
820
825
if (TM)
821
826
TM->setPGOOption (PGOOpt);
@@ -1219,9 +1224,9 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
1219
1224
const HeaderSearchOptions &HeaderOpts,
1220
1225
const CodeGenOptions &CGOpts,
1221
1226
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 ,
1225
1230
std::unique_ptr<raw_pwrite_stream> OS) {
1226
1231
1227
1232
llvm::TimeTraceScope TimeScope (" Backend" );
@@ -1264,7 +1269,7 @@ void clang::EmitBackendOutput(DiagnosticsEngine &Diags,
1264
1269
}
1265
1270
}
1266
1271
1267
- EmitAssemblyHelper AsmHelper (Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
1272
+ EmitAssemblyHelper AsmHelper (Diags, HeaderOpts, CGOpts, TOpts, LOpts, M, VFS );
1268
1273
AsmHelper.EmitAssembly (Action, std::move (OS));
1269
1274
1270
1275
// Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's
0 commit comments