-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Preparing CompilerInstance for batch mode. #13982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test os x platform |
@swift-ci please smoke test linux platform |
@swift-ci please smoke test linux platform |
@swift-ci please clean test linux platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in pretty good shape! Great work, both of you.
include/swift/Frontend/Frontend.h
Outdated
/// Identifies the set of SourceFiles that are considered primaries. An | ||
/// invariant is that any SourceFile in this set with an associated | ||
/// buffer will also have its buffer ID in PrimaryBufferIDs. | ||
llvm::SetVector<SourceFile*> PrimarySourceFiles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we never test membership in this one, so you might as well just use a SmallVector (or std::vector).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
include/swift/Frontend/Frontend.h
Outdated
return PrimaryBufferIDs.count(BufID) != 0; | ||
} | ||
|
||
/// Record in PrimaryBufferIDs the fact that \BufID is a primary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doxygen syntax: \p BufID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in two places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one on this line and one above as well (at least).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry--missed those. Fixed.
include/swift/Frontend/Frontend.h
Outdated
@@ -413,9 +431,26 @@ class CompilerInstance { | |||
return Invocation.getFrontendOptions().EnableSourceImport; | |||
} | |||
|
|||
/// Gets the set of SourceFiles which are the primary inputs for this | |||
/// CompilerInstance. | |||
const llvm::SetVector<SourceFile*> &getPrimarySourceFiles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…and then this can just be an ArrayRef, if we don't care about its set-ness anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/FrontendTool/FrontendTool.cpp
Outdated
Identifier PD = PrimarySourceFile->getPrivateDiscriminator(); | ||
if (IRGenOpts.DebugInfoKind != IRGenDebugInfoKind::None && | ||
Instance.getPrimarySourceFile()) { | ||
Identifier PD = Instance.getPrimarySourceFile()->getPrivateDiscriminator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, we're going to need to do something better here soon.
include/swift/Frontend/Frontend.h
Outdated
@@ -437,6 +437,16 @@ class CompilerInstance { | |||
return PrimarySourceFiles; | |||
} | |||
|
|||
/// Gets the Primary Source File if one exists, otherwise the main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A list of conflicts crept into the commit message here. ("Sink a bunch of FrontendTool uses…")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed them.
lib/FrontendTool/FrontendTool.cpp
Outdated
auto astGuaranteedToCorrespondToSIL = false; | ||
if (!SM) { | ||
// The second boolean in each std::pair<> in this std::deque<> indicates | ||
// whether the SIL is guaranteed to correspond to the the AST. This might be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "the the"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer applies, AFAICT.
@@ -504,10 +504,17 @@ createOptRecordFile(StringRef Filename, DiagnosticEngine &DE) { | |||
return File; | |||
} | |||
|
|||
struct PostSILGenInputs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Conflicts" in this commit message too ("Thread the ModuleOrSourceFile of each…")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the conflicts parts of the commit messages.
lib/FrontendTool/FrontendTool.cpp
Outdated
@@ -504,10 +504,17 @@ createOptRecordFile(StringRef Filename, DiagnosticEngine &DE) { | |||
return File; | |||
} | |||
|
|||
struct PostSILGenInputs { | |||
std::unique_ptr<SILModule> TheSILModule; | |||
bool astGuaranteedToCorrespondToSIL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be consistent about initial case across struct fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to AST...
lib/FrontendTool/FrontendTool.cpp
Outdated
} | ||
|
||
if (SMs.empty()) { | ||
auto mod = Instance.getMainModule(); | ||
if (PSGIs.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Changed.
lib/FrontendTool/FrontendTool.cpp
Outdated
@@ -819,25 +824,26 @@ static bool performCompile(CompilerInstance &Instance, | |||
// once for each such input. | |||
for (auto *PrimaryFile : Instance.getPrimarySourceFiles()) { | |||
auto SM = performSILGeneration(*PrimaryFile, SILOpts, None); | |||
SMs.push_back(std::make_pair(std::move(SM), !fileIsSIB(PrimaryFile))); | |||
PSGIs.push_back(PostSILGenInputs{ | |||
std::move(SM), !fileIsSIB(PrimaryFile), PrimaryFile}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fileIsSIB
check is definitely going to be false
because SIB files are a kind of SerializedASTFile, not a SourceFile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Replace !fileIsSIB(...) with "true".
Hm, GitHub hid a bunch of the comments since you reformatting stuff afterwards, but I think they're still relevant. |
…ired after changes to introduce multiple primary files to CompilerInstance. Revealed by test Frontend/dependencies.swift.
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more, but they're all tiny. I think the DebugInfo one I made has already been addressed, too.
include/swift/Frontend/Frontend.h
Outdated
@@ -433,7 +433,7 @@ class CompilerInstance { | |||
|
|||
/// Gets the set of SourceFiles which are the primary inputs for this | |||
/// CompilerInstance. | |||
const llvm::SetVector<SourceFile*> &getPrimarySourceFiles() { | |||
const ArrayRef<SourceFile *> getPrimarySourceFiles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…no need for const
here again.
include/swift/Frontend/Frontend.h
Outdated
return PrimaryBufferIDs.count(BufID) != 0; | ||
} | ||
|
||
/// Record in PrimaryBufferIDs the fact that \BufID is a primary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one on this line and one above as well (at least).
lib/FrontendTool/FrontendTool.cpp
Outdated
@@ -798,8 +798,7 @@ static bool performCompile(CompilerInstance &Instance, | |||
if (auto SM = Instance.takeSILModule()) { | |||
PSGIs.push_back(PostSILGenInputs{std::move(SM), false, mod}); | |||
} | |||
|
|||
if (PSGIs.empty()) { | |||
else if (PSGIs.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just else
. The deque has just been declared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah--done!
Sorry I missed a couple of Doxygen blunders. Fixed them. |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
include/swift/Frontend/Frontend.h
Outdated
@@ -413,9 +431,36 @@ class CompilerInstance { | |||
return Invocation.getFrontendOptions().EnableSourceImport; | |||
} | |||
|
|||
/// Gets the set of SourceFiles which are the primary inputs for this | |||
/// CompilerInstance. | |||
const ArrayRef<SourceFile *> getPrimarySourceFiles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No const
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@swift-ci please smoke test |
@swift-ci please smoke test linux platform |
Use a SetVector for CompilerInstance::PrimaryBufferIDs, and create functions to test inclusion, test for WMO, and add a primary.
Split up performCompile and Invoke part 2, performCompileStepsPostSILGen, once for each primary.
Move diagnostic for emit_reference_dependencies_without_primary_file.
Includes Graydon's commits.