@@ -275,33 +275,36 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
275
275
(PhaseArg = DAL.getLastArg (options::OPT__SLASH_P))) {
276
276
FinalPhase = phases::Preprocess;
277
277
278
- // --precompile only runs up to precompilation.
278
+ // --precompile only runs up to precompilation.
279
279
} else if ((PhaseArg = DAL.getLastArg (options::OPT__precompile))) {
280
280
FinalPhase = phases::Precompile;
281
281
282
- // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
282
+ // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
283
283
} else if ((PhaseArg = DAL.getLastArg (options::OPT_fsyntax_only)) ||
284
284
(PhaseArg = DAL.getLastArg (options::OPT_print_supported_cpus)) ||
285
285
(PhaseArg = DAL.getLastArg (options::OPT_module_file_info)) ||
286
286
(PhaseArg = DAL.getLastArg (options::OPT_verify_pch)) ||
287
287
(PhaseArg = DAL.getLastArg (options::OPT_rewrite_objc)) ||
288
288
(PhaseArg = DAL.getLastArg (options::OPT_rewrite_legacy_objc)) ||
289
289
(PhaseArg = DAL.getLastArg (options::OPT__migrate)) ||
290
- (PhaseArg = DAL.getLastArg (options::OPT_emit_iterface_stubs)) ||
291
290
(PhaseArg = DAL.getLastArg (options::OPT__analyze)) ||
292
291
(PhaseArg = DAL.getLastArg (options::OPT_emit_ast))) {
293
292
FinalPhase = phases::Compile;
294
293
294
+ // clang interface stubs
295
+ } else if ((PhaseArg = DAL.getLastArg (options::OPT_emit_iterface_stubs))) {
296
+ FinalPhase = phases::IfsMerge;
297
+
295
298
// -S only runs up to the backend.
296
299
} else if ((PhaseArg = DAL.getLastArg (options::OPT_S)) ||
297
300
(PhaseArg = DAL.getLastArg (options::OPT_sycl_device_only))) {
298
301
FinalPhase = phases::Backend;
299
302
300
- // -c compilation only runs up to the assembler.
303
+ // -c compilation only runs up to the assembler.
301
304
} else if ((PhaseArg = DAL.getLastArg (options::OPT_c))) {
302
305
FinalPhase = phases::Assemble;
303
306
304
- // Otherwise do everything.
307
+ // Otherwise do everything.
305
308
} else
306
309
FinalPhase = phases::Link;
307
310
@@ -4085,6 +4088,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4085
4088
// Construct the actions to perform.
4086
4089
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr ;
4087
4090
ActionList LinkerInputs;
4091
+ ActionList MergerInputs;
4088
4092
4089
4093
llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PL;
4090
4094
for (auto &I : Inputs) {
@@ -4124,6 +4128,17 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4124
4128
break ;
4125
4129
}
4126
4130
4131
+ // TODO: Consider removing this because the merged may not end up being
4132
+ // the final Phase in the pipeline. Perhaps the merged could just merge
4133
+ // and then pass an artifact of some sort to the Link Phase.
4134
+ // Queue merger inputs.
4135
+ if (Phase == phases::IfsMerge) {
4136
+ assert (Phase == PL.back () && " merging must be final compilation step." );
4137
+ MergerInputs.push_back (Current);
4138
+ Current = nullptr ;
4139
+ break ;
4140
+ }
4141
+
4127
4142
// Each precompiled header file after a module file action is a module
4128
4143
// header of that same module file, rather than being compiled to a
4129
4144
// separate PCH.
@@ -4253,6 +4268,11 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4253
4268
Actions.push_back (LA);
4254
4269
}
4255
4270
4271
+ // Add an interface stubs merge action if necessary.
4272
+ if (!MergerInputs.empty ())
4273
+ Actions.push_back (
4274
+ C.MakeAction <IfsMergeJobAction>(MergerInputs, types::TY_Image));
4275
+
4256
4276
// If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a custom
4257
4277
// Compile phase that prints out supported cpu models and quits.
4258
4278
if (Arg *A = Args.getLastArg (options::OPT_print_supported_cpus)) {
@@ -4289,6 +4309,8 @@ Action *Driver::ConstructPhaseAction(
4289
4309
switch (Phase) {
4290
4310
case phases::Link:
4291
4311
llvm_unreachable (" link action invalid here." );
4312
+ case phases::IfsMerge:
4313
+ llvm_unreachable (" ifsmerge action invalid here." );
4292
4314
case phases::Preprocess: {
4293
4315
types::ID OutputTy;
4294
4316
// -M and -MM specify the dependency file name by altering the output type,
@@ -4353,7 +4375,7 @@ Action *Driver::ConstructPhaseAction(
4353
4375
if (Args.hasArg (options::OPT_verify_pch))
4354
4376
return C.MakeAction <VerifyPCHJobAction>(Input, types::TY_Nothing);
4355
4377
if (Args.hasArg (options::OPT_emit_iterface_stubs))
4356
- return C.MakeAction <CompileJobAction>(Input, types::TY_IFS );
4378
+ return C.MakeAction <CompileJobAction>(Input, types::TY_IFS_CPP );
4357
4379
return C.MakeAction <CompileJobAction>(Input, types::TY_LLVM_BC);
4358
4380
}
4359
4381
case phases::Backend: {
0 commit comments