2011-01-01 01:31:54 +08:00
|
|
|
//===--- Action.cpp - Abstract compilation steps --------------------------===//
|
2009-03-13 02:40:18 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Driver/Action.h"
|
2011-09-23 13:57:42 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-03-13 02:40:18 +08:00
|
|
|
#include <cassert>
|
|
|
|
using namespace clang::driver;
|
2013-06-15 01:17:23 +08:00
|
|
|
using namespace llvm::opt;
|
2009-03-13 02:40:18 +08:00
|
|
|
|
2009-03-18 10:55:38 +08:00
|
|
|
Action::~Action() {
|
2010-03-12 02:04:58 +08:00
|
|
|
if (OwnsInputs) {
|
|
|
|
for (iterator it = begin(), ie = end(); it != ie; ++it)
|
|
|
|
delete *it;
|
|
|
|
}
|
2009-03-18 10:55:38 +08:00
|
|
|
}
|
2009-03-13 20:17:08 +08:00
|
|
|
|
|
|
|
const char *Action::getClassName(ActionClass AC) {
|
|
|
|
switch (AC) {
|
|
|
|
case InputClass: return "input";
|
|
|
|
case BindArchClass: return "bind-arch";
|
2015-07-14 07:27:56 +08:00
|
|
|
case CudaDeviceClass: return "cuda-device";
|
|
|
|
case CudaHostClass: return "cuda-host";
|
2009-03-14 01:52:07 +08:00
|
|
|
case PreprocessJobClass: return "preprocessor";
|
|
|
|
case PrecompileJobClass: return "precompiler";
|
|
|
|
case AnalyzeJobClass: return "analyzer";
|
2012-03-07 04:06:33 +08:00
|
|
|
case MigrateJobClass: return "migrator";
|
2009-03-14 01:52:07 +08:00
|
|
|
case CompileJobClass: return "compiler";
|
Reapply "Change -save-temps to emit unoptimized bitcode files."
This reapplies r224503 along with a fix for compiling Fortran by having the
clang driver invoke gcc (see r224546, where it was reverted). I have added
a testcase for that as well.
Original commit message:
It is often convenient to use -save-temps to collect the intermediate
results of a compilation, e.g., when triaging a bug report. Besides the
temporary files for preprocessed source and assembly code, this adds the
unoptimized bitcode files as well.
This adds a new BackendJobAction, which is mostly mechanical, to run after
the CompileJobAction. When not using -save-temps, the BackendJobAction is
combined into one job with the CompileJobAction, similar to the way the
integrated assembler is handled. I've implemented this entirely as a
driver change, so under the hood, it is just using -disable-llvm-optzns
to get the unoptimized bitcode.
Based in part on a patch by Steven Wu.
rdar://problem/18909437
llvm-svn: 224688
2014-12-21 15:00:00 +08:00
|
|
|
case BackendJobClass: return "backend";
|
2009-03-14 01:52:07 +08:00
|
|
|
case AssembleJobClass: return "assembler";
|
|
|
|
case LinkJobClass: return "linker";
|
2009-03-13 20:17:08 +08:00
|
|
|
case LipoJobClass: return "lipo";
|
2010-06-05 02:28:36 +08:00
|
|
|
case DsymutilJobClass: return "dsymutil";
|
2014-02-07 02:53:25 +08:00
|
|
|
case VerifyDebugInfoJobClass: return "verify-debug-info";
|
|
|
|
case VerifyPCHJobClass: return "verify-pch";
|
2009-03-13 20:17:08 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2011-09-23 13:06:16 +08:00
|
|
|
llvm_unreachable("invalid class");
|
2009-03-13 20:17:08 +08:00
|
|
|
}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void InputAction::anchor() {}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
InputAction::InputAction(const Arg &_Input, types::ID _Type)
|
2009-03-14 07:08:03 +08:00
|
|
|
: Action(InputClass, _Type), Input(_Input) {
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void BindArchAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
|
|
|
|
const char *_ArchName)
|
|
|
|
: Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2015-07-14 07:27:56 +08:00
|
|
|
void CudaDeviceAction::anchor() {}
|
|
|
|
|
|
|
|
CudaDeviceAction::CudaDeviceAction(std::unique_ptr<Action> Input,
|
|
|
|
const char *ArchName, bool AtTopLevel)
|
|
|
|
: Action(CudaDeviceClass, std::move(Input)), GpuArchName(ArchName),
|
|
|
|
AtTopLevel(AtTopLevel) {}
|
|
|
|
|
|
|
|
void CudaHostAction::anchor() {}
|
|
|
|
|
|
|
|
CudaHostAction::CudaHostAction(std::unique_ptr<Action> Input,
|
|
|
|
const ActionList &_DeviceActions)
|
|
|
|
: Action(CudaHostClass, std::move(Input)), DeviceActions(_DeviceActions) {}
|
|
|
|
|
|
|
|
CudaHostAction::~CudaHostAction() {
|
|
|
|
for (iterator it = DeviceActions.begin(), ie = DeviceActions.end(); it != ie;
|
|
|
|
++it)
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void JobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
|
|
|
|
types::ID Type)
|
|
|
|
: Action(Kind, std::move(Input), Type) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
|
2009-03-14 07:08:03 +08:00
|
|
|
: Action(Kind, Inputs, Type) {
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void PreprocessJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void PrecompileJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void AnalyzeJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2012-03-07 04:06:33 +08:00
|
|
|
void MigrateJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(MigrateJobClass, std::move(Input), OutputType) {}
|
2012-03-07 04:06:33 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void CompileJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(CompileJobClass, std::move(Input), OutputType) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
Reapply "Change -save-temps to emit unoptimized bitcode files."
This reapplies r224503 along with a fix for compiling Fortran by having the
clang driver invoke gcc (see r224546, where it was reverted). I have added
a testcase for that as well.
Original commit message:
It is often convenient to use -save-temps to collect the intermediate
results of a compilation, e.g., when triaging a bug report. Besides the
temporary files for preprocessed source and assembly code, this adds the
unoptimized bitcode files as well.
This adds a new BackendJobAction, which is mostly mechanical, to run after
the CompileJobAction. When not using -save-temps, the BackendJobAction is
combined into one job with the CompileJobAction, similar to the way the
integrated assembler is handled. I've implemented this entirely as a
driver change, so under the hood, it is just using -disable-llvm-optzns
to get the unoptimized bitcode.
Based in part on a patch by Steven Wu.
rdar://problem/18909437
llvm-svn: 224688
2014-12-21 15:00:00 +08:00
|
|
|
void BackendJobAction::anchor() {}
|
|
|
|
|
|
|
|
BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(BackendJobClass, std::move(Input), OutputType) {}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void AssembleJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID OutputType)
|
|
|
|
: JobAction(AssembleJobClass, std::move(Input), OutputType) {}
|
2009-03-14 07:08:03 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void LinkJobAction::anchor() {}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
|
2009-03-14 07:08:03 +08:00
|
|
|
: JobAction(LinkJobClass, Inputs, Type) {
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void LipoJobAction::anchor() {}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
|
2009-03-14 07:08:03 +08:00
|
|
|
: JobAction(LipoJobClass, Inputs, Type) {
|
|
|
|
}
|
2010-06-05 02:28:36 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void DsymutilJobAction::anchor() {}
|
|
|
|
|
2010-06-05 02:28:36 +08:00
|
|
|
DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
|
|
|
|
: JobAction(DsymutilJobClass, Inputs, Type) {
|
|
|
|
}
|
2011-08-24 01:56:55 +08:00
|
|
|
|
2011-12-20 10:48:34 +08:00
|
|
|
void VerifyJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
VerifyJobAction::VerifyJobAction(ActionClass Kind,
|
|
|
|
std::unique_ptr<Action> Input, types::ID Type)
|
|
|
|
: JobAction(Kind, std::move(Input), Type) {
|
2014-02-07 02:53:25 +08:00
|
|
|
assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
|
|
|
|
"ActionClass is not a valid VerifyJobAction");
|
|
|
|
}
|
|
|
|
|
|
|
|
void VerifyDebugInfoJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
|
|
|
|
std::unique_ptr<Action> Input, types::ID Type)
|
|
|
|
: VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
|
2014-02-07 02:53:25 +08:00
|
|
|
|
|
|
|
void VerifyPCHJobAction::anchor() {}
|
|
|
|
|
2014-08-29 15:25:23 +08:00
|
|
|
VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
|
|
|
|
types::ID Type)
|
|
|
|
: VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}
|