diff options
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 8cca1de0fb2b..0f3ebef2cf2f 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -277,7 +277,8 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { // Add a default value of -mlinker-version=, if one was given and the user // didn't specify one. #if defined(HOST_LINK_VERSION) - if (!Args.hasArg(options::OPT_mlinker_version_EQ)) { + if (!Args.hasArg(options::OPT_mlinker_version_EQ) && + strlen(HOST_LINK_VERSION) > 0) { DAL->AddJoinedArg(0, Opts->getOption(options::OPT_mlinker_version_EQ), HOST_LINK_VERSION); DAL->getLastArg(options::OPT_mlinker_version_EQ)->claim(); @@ -814,9 +815,12 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { return true; } +// Display an action graph human-readably. Action A is the "sink" node +// and latest-occuring action. Traversal is in pre-order, visiting the +// inputs to each action before printing the action itself. static unsigned PrintActions1(const Compilation &C, Action *A, std::map<Action*, unsigned> &Ids) { - if (Ids.count(A)) + if (Ids.count(A)) // A was already visited. return Ids[A]; std::string str; @@ -847,6 +851,8 @@ static unsigned PrintActions1(const Compilation &C, Action *A, return Id; } +// Print the action graphs in a compilation C. +// For example "clang -c file1.c file2.c" is composed of two subgraphs. void Driver::PrintActions(const Compilation &C) const { std::map<Action*, unsigned> Ids; for (ActionList::const_iterator it = C.getActions().begin(), @@ -1356,7 +1362,7 @@ Driver::ConstructPhaseAction(const ToolChain &TC, const ArgList &Args, types::TY_LLVM_BC); } case phases::Backend: { - if (IsUsingLTO(TC, Args)) { + if (IsUsingLTO(Args)) { types::ID Output = Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC; return llvm::make_unique<BackendJobAction>(std::move(Input), Output); @@ -1377,14 +1383,8 @@ Driver::ConstructPhaseAction(const ToolChain &TC, const ArgList &Args, llvm_unreachable("invalid phase in ConstructPhaseAction"); } -bool Driver::IsUsingLTO(const ToolChain &TC, const ArgList &Args) const { - if (TC.getSanitizerArgs().needsLTO()) - return true; - - if (Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false)) - return true; - - return false; +bool Driver::IsUsingLTO(const ArgList &Args) const { + return Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false); } void Driver::BuildJobs(Compilation &C) const { @@ -1563,8 +1563,9 @@ void Driver::BuildJobsForAction(Compilation &C, if (Input.getOption().matches(options::OPT_INPUT)) { const char *Name = Input.getValue(); Result = InputInfo(Name, A->getType(), Name); - } else + } else { Result = InputInfo(&Input, A->getType(), ""); + } return; } @@ -1738,7 +1739,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, // Determine what the derived output name should be. const char *NamedOutput; - if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC) && + if (JA.getType() == types::TY_Object && C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) { // The /Fo or /o flag decides the object filename. StringRef Val = C.getArgs().getLastArg(options::OPT__SLASH_Fo, @@ -2099,6 +2100,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, TC = new toolchains::Hexagon_TC(*this, Target, Args); else if (Target.getArch() == llvm::Triple::xcore) TC = new toolchains::XCore(*this, Target, Args); + else if (Target.getArch() == llvm::Triple::shave) + TC = new toolchains::SHAVEToolChain(*this, Target, Args); else if (Target.isOSBinFormatELF()) TC = new toolchains::Generic_ELF(*this, Target, Args); else if (Target.isOSBinFormatMachO()) @@ -2112,13 +2115,12 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, } bool Driver::ShouldUseClangCompiler(const JobAction &JA) const { - // Check if user requested no clang, or clang doesn't understand this type (we - // only handle single inputs for now). + // Say "no" if there is not exactly one input of a type clang understands. if (JA.size() != 1 || !types::isAcceptedByClang((*JA.begin())->getType())) return false; - // Otherwise make sure this is an action clang understands. + // And say "no" if this is not a kind of action clang understands. if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA)) return false; |