Skip to content

[Gardening] Sprinkle Const Qualification Around the Frontend #29155

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 9 commits into from
Jan 14, 2020

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jan 12, 2020

Const-qualify a bunch of frontend-related data structures like the compiler instance, compiler invocation, and frontend options wherever as much as possible. This entailed pushing state callers would previously mutate down as parameters.

Goes a long way towards rdar://57122646

@CodaFi CodaFi requested a review from davidungar January 12, 2020 06:05
@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 12, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - cfc4426220fd6b9aae38563d2d44339f1317f64a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - cfc4426220fd6b9aae38563d2d44339f1317f64a

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 13, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 203da7ddbf00b57636e01b8814da112eeb176dfe

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 203da7ddbf00b57636e01b8814da112eeb176dfe

Copy link
Contributor

@davidungar davidungar left a comment

Choose a reason for hiding this comment

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

Great to see this!! I love it.

The changes I feel are important are the places where I mentioned adding a comment to explain what's going on. The others are optional, IMO.

I didn't check any algorithmic changes for correctness.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 13, 2020

swiftlang/llvm-project#563

@swift-ci smoke test

@@ -111,6 +111,59 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
}
}

// FIXME: This function is a bit of a layering violation. It should be
// dispersed into IRGen option parsing if possible.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to explain specifically how it violates layering--would help a noobie. Also since it is required to preserve the incoming settings, where do they come from?

CodaFi added a commit to CodaFi/llvm-project that referenced this pull request Jan 14, 2020
@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

swiftlang/llvm-project#563

@swift-ci smoke test macOS platform

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

swiftlang/llvm-project#563

@swift-ci clean smoke test macOS platform

Use the presence or absence of the PGO reader instead.  SILGen was wiping out this option then checking for it being wiped out anyways.
This was being done at an odd point in the frontend presumably because by that point the private discriminator had been fully computed.  Instead, push the conditions for generating the prefix data down to debug info generation and stop mutating IRGenOptions::DebugFlag in the frontend.
Add an extra phase after all the argument parsing has completed that sets inter-option-dependent flags.  This allows for the const-qualification of IRGenOptions, and removes some weird state flipping in FrontendTool.
The REPL was using the CompilerInstance to stash this parameter, then it would immediately move it into IRGen.  Drop the setter and pass this data directly.
@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

swiftlang/llvm-project#563

@swift-ci smoke test

For those operations that do not need to emit diagnostics or manipulate modules, there's no reason to mutate the passed instance.
@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

swiftlang/llvm-project#563

@swift-ci smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

swiftlang/llvm-project#563

@swift-ci clean smoke test macOS platform

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

Ugh, finally.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jan 14, 2020

⛵️

@CodaFi CodaFi merged commit 5e155d9 into swiftlang:master Jan 14, 2020
CodaFi added a commit to swiftlang/llvm-project that referenced this pull request Jan 14, 2020
CodaFi added a commit to CodaFi/llvm-project that referenced this pull request Jan 14, 2020
@CodaFi CodaFi deleted the west-const-story branch January 14, 2020 20:01
JDevlieghere pushed a commit to swiftlang/llvm-project that referenced this pull request Jan 16, 2020
CodaFi added a commit to swiftlang/llvm-project that referenced this pull request Jan 21, 2020
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