Skip to content

Commit e7a120f

Browse files
committed
Avoid copying strings and PrimarySpecificPaths.
1 parent a2863a6 commit e7a120f

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

include/swift/IRGen/IRGenPublic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IRGenModule;
2626

2727
/// Create an IRGen module.
2828
std::pair<IRGenerator *, IRGenModule *>
29-
createIRGenModule(SILModule *SILMod, PrimarySpecificPaths PSPs,
29+
createIRGenModule(SILModule *SILMod, const PrimarySpecificPaths &PSPs,
3030
llvm::LLVMContext &LLVMContext);
3131

3232
/// Delete the IRGenModule and IRGenerator obtained by the above call.

include/swift/Subsystems.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ namespace swift {
260260
std::unique_ptr<llvm::Module>
261261
performIRGeneration(IRGenOptions &Opts, ModuleDecl *M,
262262
std::unique_ptr<SILModule> SILMod,
263-
StringRef ModuleName, PrimarySpecificPaths PSPs,
263+
StringRef ModuleName, const PrimarySpecificPaths &PSPs,
264264
llvm::LLVMContext &LLVMContext,
265265
ArrayRef<std::string> parallelOutputFilenames,
266266
llvm::GlobalVariable **outModuleHash = nullptr);
@@ -271,7 +271,7 @@ namespace swift {
271271
std::unique_ptr<llvm::Module>
272272
performIRGeneration(IRGenOptions &Opts, SourceFile &SF,
273273
std::unique_ptr<SILModule> SILMod,
274-
StringRef ModuleName, PrimarySpecificPaths PSPs,
274+
StringRef ModuleName, const PrimarySpecificPaths &PSPs,
275275
llvm::LLVMContext &LLVMContext,
276276
unsigned StartElem = 0,
277277
llvm::GlobalVariable **outModuleHash = nullptr);

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,11 +1082,11 @@ static bool serializeSIB(FrontendOptions &opts, SILModule *SM,
10821082
}
10831083

10841084
static void generateIR(IRGenOptions &IRGenOpts, std::unique_ptr<SILModule> SM,
1085-
PrimarySpecificPaths PSPs,
1085+
const PrimarySpecificPaths &PSPs,
10861086
StringRef OutputFilename, ModuleOrSourceFile MSF,
10871087
std::unique_ptr<llvm::Module> &IRModule,
10881088
llvm::GlobalVariable *&HashGlobal,
1089-
std::vector<std::string> parallelOutputFilenames) {
1089+
ArrayRef<std::string> parallelOutputFilenames) {
10901090
// FIXME: We shouldn't need to use the global context here, but
10911091
// something is persisting across calls to performIRGeneration.
10921092
auto &LLVMContext = getGlobalLLVMContext();
@@ -1316,12 +1316,13 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
13161316
return processCommandLineAndRunImmediately(
13171317
Invocation, Instance, std::move(SM), MSF, observer, ReturnValue);
13181318

1319-
const std::string OutputFilename = PSPs.OutputFilename;
1319+
StringRef OutputFilename = PSPs.OutputFilename;
1320+
std::vector<std::string> ParallelOutputFilenames = Invocation.getFrontendOptions().InputsAndOutputs.copyOutputFilenames();
13201321
std::unique_ptr<llvm::Module> IRModule;
13211322
llvm::GlobalVariable *HashGlobal;
13221323
generateIR(
13231324
IRGenOpts, std::move(SM), PSPs, OutputFilename, MSF, IRModule, HashGlobal,
1324-
Invocation.getFrontendOptions().InputsAndOutputs.copyOutputFilenames());
1325+
ParallelOutputFilenames);
13251326

13261327
// Walk the AST for indexing after IR generation. Walking it before seems
13271328
// to cause miscompilation issues.

lib/IRGen/IRGen.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ static void initLLVMModule(const IRGenModule &IGM) {
665665
}
666666

667667
std::pair<IRGenerator *, IRGenModule *>
668-
swift::irgen::createIRGenModule(SILModule *SILMod, PrimarySpecificPaths PSPs,
668+
swift::irgen::createIRGenModule(SILModule *SILMod,
669+
const PrimarySpecificPaths &PSPs,
669670
llvm::LLVMContext &LLVMContext) {
670671

671672
IRGenOptions Opts;
@@ -716,7 +717,7 @@ static std::unique_ptr<llvm::Module> performIRGeneration(IRGenOptions &Opts,
716717
swift::ModuleDecl *M,
717718
std::unique_ptr<SILModule> SILMod,
718719
StringRef ModuleName,
719-
const PrimarySpecificPaths PSPs,
720+
const PrimarySpecificPaths &PSPs,
720721
llvm::LLVMContext &LLVMContext,
721722
SourceFile *SF = nullptr,
722723
llvm::GlobalVariable **outModuleHash = nullptr,
@@ -867,7 +868,7 @@ static void ThreadEntryPoint(IRGenerator *irgen,
867868
static void performParallelIRGeneration(IRGenOptions &Opts,
868869
swift::ModuleDecl *M,
869870
std::unique_ptr<SILModule> SILMod,
870-
const PrimarySpecificPaths PSPs,
871+
const PrimarySpecificPaths &PSPs,
871872
StringRef ModuleName, int numThreads,
872873
ArrayRef<std::string> outputFilenames) {
873874

@@ -1083,7 +1084,7 @@ static void performParallelIRGeneration(IRGenOptions &Opts,
10831084
std::unique_ptr<llvm::Module> swift::
10841085
performIRGeneration(IRGenOptions &Opts, swift::ModuleDecl *M,
10851086
std::unique_ptr<SILModule> SILMod,
1086-
StringRef ModuleName, const PrimarySpecificPaths PSPs,
1087+
StringRef ModuleName, const PrimarySpecificPaths &PSPs,
10871088
llvm::LLVMContext &LLVMContext,
10881089
ArrayRef<std::string> parallelOutputFilenames,
10891090
llvm::GlobalVariable **outModuleHash) {
@@ -1103,7 +1104,7 @@ performIRGeneration(IRGenOptions &Opts, swift::ModuleDecl *M,
11031104
std::unique_ptr<llvm::Module> swift::
11041105
performIRGeneration(IRGenOptions &Opts, SourceFile &SF,
11051106
std::unique_ptr<SILModule> SILMod,
1106-
StringRef ModuleName, const PrimarySpecificPaths PSPs,
1107+
StringRef ModuleName, const PrimarySpecificPaths &PSPs,
11071108
llvm::LLVMContext &LLVMContext,
11081109
unsigned StartElem,
11091110
llvm::GlobalVariable **outModuleHash) {

lib/IRGen/IRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
125125
IRGenModule::IRGenModule(IRGenerator &irgen,
126126
std::unique_ptr<llvm::TargetMachine> &&target,
127127
SourceFile *SF, llvm::LLVMContext &LLVMContext,
128-
StringRef ModuleName, PrimarySpecificPaths PSPs)
128+
StringRef ModuleName, const PrimarySpecificPaths &PSPs)
129129
: IRGen(irgen), Context(irgen.SIL.getASTContext()),
130130
ClangCodeGen(createClangCodeGenerator(Context, LLVMContext, irgen.Opts,
131131
ModuleName)),

lib/IRGen/IRGenModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ private: \
10431043
std::unique_ptr<llvm::TargetMachine> &&target,
10441044
SourceFile *SF, llvm::LLVMContext &LLVMContext,
10451045
StringRef ModuleName,
1046-
PrimarySpecificPaths PSPs);
1046+
const PrimarySpecificPaths &PSPs);
10471047
~IRGenModule();
10481048

10491049
llvm::LLVMContext &getLLVMContext() const { return LLVMContext; }

0 commit comments

Comments
 (0)