[PATCH] D63977: [NFC][clang] Adding ability to skip compiler phases in clang driver.
Puyan Lotfi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 30 10:28:04 PDT 2019
plotfi updated this revision to Diff 207227.
plotfi added a comment.
Add full context, change std::set to llvm::SmallSet
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63977/new/
https://reviews.llvm.org/D63977
Files:
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Phases.h
clang/lib/Driver/Driver.cpp
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -262,10 +262,11 @@
// Determine which compilation mode we are in. We look for options which
// affect the phase, starting with the earliest phases, and record which
// option we used to determine the final phase.
-phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
- Arg **FinalPhaseArg) const {
+phases::PhasesToRun Driver::getPhasesToRun(const DerivedArgList &DAL,
+ Arg **FinalPhaseArg) const {
Arg *PhaseArg = nullptr;
phases::ID FinalPhase;
+ llvm::SmallSet<phases::ID, 6> SkipPhases;
// -{E,EP,P,M,MM} only run the preprocessor.
if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) ||
@@ -306,7 +307,7 @@
if (FinalPhaseArg)
*FinalPhaseArg = PhaseArg;
- return FinalPhase;
+ return { FinalPhase, SkipPhases };
}
static Arg *MakeInputArg(DerivedArgList &Args, OptTable &Opts,
@@ -3148,7 +3149,8 @@
}
Arg *FinalPhaseArg;
- phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
+ phases::PhasesToRun PhasesToRun = getPhasesToRun(Args, &FinalPhaseArg);
+ phases::ID FinalPhase = PhasesToRun.FinalPhase;
if (FinalPhase == phases::Link) {
if (Args.hasArg(options::OPT_emit_llvm))
@@ -3307,6 +3309,10 @@
if (Phase > FinalPhase)
break;
+ // If we find Phase in the SkipPhases, then skip it.
+ if (llvm::is_contained(PhasesToRun.SkipPhases, Phase))
+ continue;
+
// Add any offload action the host action depends on.
Current = OffloadBuilder.addDeviceDependencesToHostAction(
Current, InputArg, Phase, FinalPhase, PL);
Index: clang/include/clang/Driver/Phases.h
===================================================================
--- clang/include/clang/Driver/Phases.h
+++ clang/include/clang/Driver/Phases.h
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
+#include <llvm/ADT/SmallSet.h>
+
#ifndef LLVM_CLANG_DRIVER_PHASES_H
#define LLVM_CLANG_DRIVER_PHASES_H
@@ -23,6 +25,11 @@
Link
};
+ struct PhasesToRun {
+ ID FinalPhase;
+ llvm::SmallSet<ID, 6> SkipPhases;
+ };
+
enum {
MaxNumberOfPhases = Link + 1
};
Index: clang/include/clang/Driver/Driver.h
===================================================================
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -251,10 +251,11 @@
llvm::opt::DerivedArgList *
TranslateInputArgs(const llvm::opt::InputArgList &Args) const;
- // getFinalPhase - Determine which compilation mode we are in and record
- // which option we used to determine the final phase.
- phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
- llvm::opt::Arg **FinalPhaseArg = nullptr) const;
+ // getPhasesToRun - Determine which compilation mode we are in and record
+ // which option we used to determine the final phase and the phases to skip.
+ phases::PhasesToRun
+ getPhasesToRun(const llvm::opt::DerivedArgList &DAL,
+ llvm::opt::Arg **FinalPhaseArg = nullptr) const;
// Before executing jobs, sets up response files for commands that need them.
void setUpResponseFiles(Compilation &C, Command &Cmd);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63977.207227.patch
Type: text/x-patch
Size: 3412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190630/6c56b2ab/attachment-0001.bin>
More information about the cfe-commits
mailing list