Skip to content

Commit 618b0b9

Browse files
committed
Add doesActionPerformEndOfPipelineActions
For now, force the clang-based actions to skip the end of the pipeline. This restores the previous behavior of the frontend, but may not be desirable in the long run. For example, one may want to dump clang stats after running an -emit-pch job, but that is impossible without forcing the end of the pipeline to be more tolerant of ObjCHeader/modulemap-only inputs. rdar://68587228
1 parent d4b2e16 commit 618b0b9

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ class FrontendOptions {
304304
/// \return true if the given action requires input files to be provided.
305305
static bool doesActionRequireInputs(ActionType action);
306306

307+
/// \return true if the given action requires input files to be provided.
308+
static bool doesActionPerformEndOfPipelineActions(ActionType action);
309+
307310
/// Return a hash code of any components from these options that should
308311
/// contribute to a Swift Bridging PCH hash.
309312
llvm::hash_code getPCHHashComponents() const {

lib/Frontend/FrontendOptions.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
4242
case ActionType::DumpScopeMaps:
4343
case ActionType::DumpTypeRefinementContexts:
4444
case ActionType::DumpPCM:
45-
return false;
4645
case ActionType::EmitPCH:
46+
return false;
4747
case ActionType::EmitSILGen:
4848
case ActionType::EmitSIL:
4949
case ActionType::EmitSIBGen:
@@ -171,6 +171,47 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
171171
llvm_unreachable("Unknown ActionType");
172172
}
173173

174+
bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
175+
switch (action) {
176+
case ActionType::NoneAction:
177+
case ActionType::PrintVersion:
178+
case ActionType::EmitPCH:
179+
case ActionType::EmitPCM:
180+
case ActionType::DumpPCM:
181+
return false;
182+
case ActionType::REPL:
183+
case ActionType::Parse:
184+
case ActionType::DumpParse:
185+
case ActionType::EmitSyntax:
186+
case ActionType::DumpInterfaceHash:
187+
case ActionType::EmitImportedModules:
188+
case ActionType::ScanDependencies:
189+
case ActionType::ScanClangDependencies:
190+
case ActionType::CompileModuleFromInterface:
191+
case ActionType::TypecheckModuleFromInterface:
192+
case ActionType::ResolveImports:
193+
case ActionType::Typecheck:
194+
case ActionType::DumpAST:
195+
case ActionType::PrintAST:
196+
case ActionType::DumpScopeMaps:
197+
case ActionType::DumpTypeRefinementContexts:
198+
case ActionType::EmitSILGen:
199+
case ActionType::EmitSIL:
200+
case ActionType::EmitModuleOnly:
201+
case ActionType::MergeModules:
202+
case ActionType::EmitSIBGen:
203+
case ActionType::EmitSIB:
204+
case ActionType::Immediate:
205+
case ActionType::EmitAssembly:
206+
case ActionType::EmitIR:
207+
case ActionType::EmitBC:
208+
case ActionType::EmitObject:
209+
case ActionType::DumpTypeInfo:
210+
return true;
211+
}
212+
llvm_unreachable("Unknown ActionType");
213+
}
214+
174215
void FrontendOptions::forAllOutputPaths(
175216
const InputFile &input, llvm::function_ref<void(StringRef)> fn) const {
176217
if (RequestedAction != FrontendOptions::ActionType::EmitModuleOnly &&

lib/FrontendTool/FrontendTool.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,8 +1876,6 @@ static bool performAction(CompilerInstance &Instance,
18761876
"removed; use the LLDB-enhanced REPL instead.");
18771877

18781878
// MARK: Actions for Clang and Clang Modules
1879-
// We've been asked to precompile a bridging header or module; we want to
1880-
// avoid touching any other inputs and just parse, emit and exit.
18811879
case FrontendOptions::ActionType::EmitPCH:
18821880
return precompileBridgingHeader(Instance);
18831881
case FrontendOptions::ActionType::EmitPCM:
@@ -1983,7 +1981,7 @@ static bool performCompile(CompilerInstance &Instance,
19831981
const FrontendOptions::ActionType Action = opts.RequestedAction;
19841982

19851983
// To compile LLVM IR, just pass it off unmodified.
1986-
if (Instance.getInvocation().getInputKind() == InputFileKind::LLVM)
1984+
if (Invocation.getInputKind() == InputFileKind::LLVM)
19871985
return compileLLVMIR(Instance);
19881986

19891987
// If we aren't in a parse-only context and expect an implicit stdlib import,
@@ -2014,7 +2012,7 @@ static bool performCompile(CompilerInstance &Instance,
20142012
// We might have freed the ASTContext already, but in that case we would
20152013
// have already performed these actions.
20162014
if (Instance.hasASTContext() &&
2017-
FrontendOptions::doesActionRequireInputs(Action)) {
2015+
FrontendOptions::doesActionPerformEndOfPipelineActions(Action)) {
20182016
performEndOfPipelineActions(Instance);
20192017
hadError |= Instance.getASTContext().hadError();
20202018
}

0 commit comments

Comments
 (0)