@@ -274,32 +274,35 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
274
274
(PhaseArg = DAL.getLastArg (options::OPT__SLASH_P))) {
275
275
FinalPhase = phases::Preprocess;
276
276
277
- // --precompile only runs up to precompilation.
277
+ // --precompile only runs up to precompilation.
278
278
} else if ((PhaseArg = DAL.getLastArg (options::OPT__precompile))) {
279
279
FinalPhase = phases::Precompile;
280
280
281
- // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
281
+ // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
282
282
} else if ((PhaseArg = DAL.getLastArg (options::OPT_fsyntax_only)) ||
283
283
(PhaseArg = DAL.getLastArg (options::OPT_print_supported_cpus)) ||
284
284
(PhaseArg = DAL.getLastArg (options::OPT_module_file_info)) ||
285
285
(PhaseArg = DAL.getLastArg (options::OPT_verify_pch)) ||
286
286
(PhaseArg = DAL.getLastArg (options::OPT_rewrite_objc)) ||
287
287
(PhaseArg = DAL.getLastArg (options::OPT_rewrite_legacy_objc)) ||
288
288
(PhaseArg = DAL.getLastArg (options::OPT__migrate)) ||
289
- (PhaseArg = DAL.getLastArg (options::OPT_emit_iterface_stubs)) ||
290
289
(PhaseArg = DAL.getLastArg (options::OPT__analyze)) ||
291
290
(PhaseArg = DAL.getLastArg (options::OPT_emit_ast))) {
292
291
FinalPhase = phases::Compile;
293
292
294
- // -S only runs up to the backend.
293
+ // clang interface stubs
294
+ } else if ((PhaseArg = DAL.getLastArg (options::OPT_emit_iterface_stubs))) {
295
+ FinalPhase = phases::IfsMerge;
296
+
297
+ // -S only runs up to the backend.
295
298
} else if ((PhaseArg = DAL.getLastArg (options::OPT_S))) {
296
299
FinalPhase = phases::Backend;
297
300
298
- // -c compilation only runs up to the assembler.
301
+ // -c compilation only runs up to the assembler.
299
302
} else if ((PhaseArg = DAL.getLastArg (options::OPT_c))) {
300
303
FinalPhase = phases::Assemble;
301
304
302
- // Otherwise do everything.
305
+ // Otherwise do everything.
303
306
} else
304
307
FinalPhase = phases::Link;
305
308
@@ -3337,6 +3340,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
3337
3340
// Construct the actions to perform.
3338
3341
HeaderModulePrecompileJobAction *HeaderModuleAction = nullptr ;
3339
3342
ActionList LinkerInputs;
3343
+ ActionList MergerInputs;
3340
3344
3341
3345
for (auto &I : Inputs) {
3342
3346
types::ID InputType = I.first ;
@@ -3374,6 +3378,17 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
3374
3378
break ;
3375
3379
}
3376
3380
3381
+ // TODO: Consider removing this because the merged may not end up being
3382
+ // the final Phase in the pipeline. Perhaps the merged could just merge
3383
+ // and then pass an artifact of some sort to the Link Phase.
3384
+ // Queue merger inputs.
3385
+ if (Phase == phases::IfsMerge) {
3386
+ assert (Phase == PL.back () && " merging must be final compilation step." );
3387
+ MergerInputs.push_back (Current);
3388
+ Current = nullptr ;
3389
+ break ;
3390
+ }
3391
+
3377
3392
// Each precompiled header file after a module file action is a module
3378
3393
// header of that same module file, rather than being compiled to a
3379
3394
// separate PCH.
@@ -3423,6 +3438,11 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
3423
3438
Actions.push_back (LA);
3424
3439
}
3425
3440
3441
+ // Add an interface stubs merge action if necessary.
3442
+ if (!MergerInputs.empty ())
3443
+ Actions.push_back (
3444
+ C.MakeAction <IfsMergeJobAction>(MergerInputs, types::TY_Image));
3445
+
3426
3446
// If --print-supported-cpus, -mcpu=? or -mtune=? is specified, build a custom
3427
3447
// Compile phase that prints out supported cpu models and quits.
3428
3448
if (Arg *A = Args.getLastArg (options::OPT_print_supported_cpus)) {
@@ -3459,6 +3479,8 @@ Action *Driver::ConstructPhaseAction(
3459
3479
switch (Phase) {
3460
3480
case phases::Link:
3461
3481
llvm_unreachable (" link action invalid here." );
3482
+ case phases::IfsMerge:
3483
+ llvm_unreachable (" ifsmerge action invalid here." );
3462
3484
case phases::Preprocess: {
3463
3485
types::ID OutputTy;
3464
3486
// -M and -MM specify the dependency file name by altering the output type,
@@ -3523,7 +3545,7 @@ Action *Driver::ConstructPhaseAction(
3523
3545
if (Args.hasArg (options::OPT_verify_pch))
3524
3546
return C.MakeAction <VerifyPCHJobAction>(Input, types::TY_Nothing);
3525
3547
if (Args.hasArg (options::OPT_emit_iterface_stubs))
3526
- return C.MakeAction <CompileJobAction>(Input, types::TY_IFS );
3548
+ return C.MakeAction <CompileJobAction>(Input, types::TY_IFS_CPP );
3527
3549
return C.MakeAction <CompileJobAction>(Input, types::TY_LLVM_BC);
3528
3550
}
3529
3551
case phases::Backend: {
0 commit comments