Skip to content

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

Merged
merged 13 commits into from
Jan 18, 2018

Conversation

davidungar
Copy link
Contributor

@davidungar davidungar commented Jan 17, 2018

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.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@davidungar
Copy link
Contributor Author

@swift-ci please clean test linux platform

Copy link
Contributor

@jrose-apple jrose-apple left a 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.

/// 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;
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return PrimaryBufferIDs.count(BufID) != 0;
}

/// Record in PrimaryBufferIDs the fact that \BufID is a primary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doxygen syntax: \p BufID

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in two places.

Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry--missed those. Fixed.

@@ -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() {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Identifier PD = PrimarySourceFile->getPrivateDiscriminator();
if (IRGenOpts.DebugInfoKind != IRGenDebugInfoKind::None &&
Instance.getPrimarySourceFile()) {
Identifier PD = Instance.getPrimarySourceFile()->getPrivateDiscriminator();
Copy link
Contributor

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.

@@ -437,6 +437,16 @@ class CompilerInstance {
return PrimarySourceFiles;
}

/// Gets the Primary Source File if one exists, otherwise the main
Copy link
Contributor

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…")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed them.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "the the"

Copy link
Contributor Author

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 {
Copy link
Contributor

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…")

Copy link
Contributor Author

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.

@@ -504,10 +504,17 @@ createOptRecordFile(StringRef Filename, DiagnosticEngine &DE) {
return File;
}

struct PostSILGenInputs {
std::unique_ptr<SILModule> TheSILModule;
bool astGuaranteedToCorrespondToSIL;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to AST...

}

if (SMs.empty()) {
auto mod = Instance.getMainModule();
if (PSGIs.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Changed.

@@ -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});
Copy link
Contributor

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.

Copy link
Contributor Author

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".

@jrose-apple
Copy link
Contributor

Hm, GitHub hid a bunch of the comments since you reformatting stuff afterwards, but I think they're still relevant.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a 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.

@@ -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() {
Copy link
Contributor

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.

return PrimaryBufferIDs.count(BufID) != 0;
}

/// Record in PrimaryBufferIDs the fact that \BufID is a primary.
Copy link
Contributor

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).

@@ -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()) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah--done!

@davidungar
Copy link
Contributor Author

Sorry I missed a couple of Doxygen blunders. Fixed them.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@@ -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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No const here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test linux platform

@davidungar davidungar merged commit 82d4386 into swiftlang:master Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants