aboutsummaryrefslogtreecommitdiffstats
path: root/tools/driver
diff options
context:
space:
mode:
Diffstat (limited to 'tools/driver')
-rw-r--r--tools/driver/cc1_main.cpp44
-rw-r--r--tools/driver/cc1as_main.cpp38
-rw-r--r--tools/driver/driver.cpp8
3 files changed, 48 insertions, 42 deletions
diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp
index 7315a1357089..9e4f32da884f 100644
--- a/tools/driver/cc1_main.cpp
+++ b/tools/driver/cc1_main.cpp
@@ -194,8 +194,8 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// Register the support for object-file-wrapped Clang modules.
auto PCHOps = Clang->getPCHContainerOperations();
- PCHOps->registerWriter(llvm::make_unique<ObjectFilePCHContainerWriter>());
- PCHOps->registerReader(llvm::make_unique<ObjectFilePCHContainerReader>());
+ PCHOps->registerWriter(std::make_unique<ObjectFilePCHContainerWriter>());
+ PCHOps->registerReader(std::make_unique<ObjectFilePCHContainerReader>());
// Initialize targets first, so that --version shows registered targets.
llvm::InitializeAllTargets();
@@ -213,12 +213,13 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
- bool Success = CompilerInvocation::CreateFromArgs(
- Clang->getInvocation(), Argv.begin(), Argv.end(), Diags);
-
- if (Clang->getFrontendOpts().TimeTrace)
- llvm::timeTraceProfilerInitialize();
+ bool Success =
+ CompilerInvocation::CreateFromArgs(Clang->getInvocation(), Argv, Diags);
+ if (Clang->getFrontendOpts().TimeTrace) {
+ llvm::timeTraceProfilerInitialize(
+ Clang->getFrontendOpts().TimeTraceGranularity);
+ }
// --print-supported-cpus takes priority over the actual compilation.
if (Clang->getFrontendOpts().PrintSupportedCPUs)
return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
@@ -252,26 +253,23 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// If any timers were active but haven't been destroyed yet, print their
// results now. This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());
+ llvm::TimerGroup::clearAll();
if (llvm::timeTraceProfilerEnabled()) {
SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
llvm::sys::path::replace_extension(Path, "json");
- auto profilerOutput =
- Clang->createOutputFile(Path.str(),
- /*Binary=*/false,
- /*RemoveFileOnSignal=*/false, "",
- /*Extension=*/"json",
- /*useTemporary=*/false);
-
- llvm::timeTraceProfilerWrite(*profilerOutput);
- // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
- profilerOutput->flush();
- llvm::timeTraceProfilerCleanup();
-
- llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n";
- llvm::errs()
- << "Use chrome://tracing or Speedscope App "
- "(https://www.speedscope.app) for flamegraph visualization\n";
+ if (auto profilerOutput =
+ Clang->createOutputFile(Path.str(),
+ /*Binary=*/false,
+ /*RemoveFileOnSignal=*/false, "",
+ /*Extension=*/"json",
+ /*useTemporary=*/false)) {
+
+ llvm::timeTraceProfilerWrite(*profilerOutput);
+ // FIXME(ibiryukov): make profilerOutput flush in destructor instead.
+ profilerOutput->flush();
+ llvm::timeTraceProfilerCleanup();
+ }
}
// Our error handler depends on the Diagnostics object, which we're
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index a2902b6aa926..ae58a95f36f5 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -131,6 +131,7 @@ struct AssemblerInvocation {
unsigned RelaxAll : 1;
unsigned NoExecStack : 1;
unsigned FatalWarnings : 1;
+ unsigned NoWarn : 1;
unsigned IncrementalLinkerCompatible : 1;
unsigned EmbedBitcode : 1;
@@ -156,6 +157,7 @@ public:
RelaxAll = 0;
NoExecStack = 0;
FatalWarnings = 0;
+ NoWarn = 0;
IncrementalLinkerCompatible = 0;
DwarfVersion = 0;
EmbedBitcode = 0;
@@ -174,12 +176,12 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
bool Success = true;
// Parse the arguments.
- std::unique_ptr<OptTable> OptTbl(createDriverOptTable());
+ const OptTable &OptTbl = getDriverOptTable();
const unsigned IncludedFlagsBitmask = options::CC1AsOption;
unsigned MissingArgIndex, MissingArgCount;
- InputArgList Args = OptTbl->ParseArgs(Argv, MissingArgIndex, MissingArgCount,
- IncludedFlagsBitmask);
+ InputArgList Args = OptTbl.ParseArgs(Argv, MissingArgIndex, MissingArgCount,
+ IncludedFlagsBitmask);
// Check for missing argument error.
if (MissingArgCount) {
@@ -192,7 +194,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
for (const Arg *A : Args.filtered(OPT_UNKNOWN)) {
auto ArgString = A->getAsString(Args);
std::string Nearest;
- if (OptTbl->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
+ if (OptTbl.findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1)
Diags.Report(diag::err_drv_unknown_argument) << ArgString;
else
Diags.Report(diag::err_drv_unknown_argument_with_suggestion)
@@ -285,6 +287,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
+ Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
Opts.TargetABI = Args.getLastArgValue(OPT_target_abi);
Opts.IncrementalLinkerCompatible =
@@ -312,8 +315,8 @@ getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {
sys::RemoveFileOnSignal(Path);
std::error_code EC;
- auto Out = llvm::make_unique<raw_fd_ostream>(
- Path, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));
+ auto Out = std::make_unique<raw_fd_ostream>(
+ Path, EC, (Binary ? sys::fs::OF_None : sys::fs::OF_Text));
if (EC) {
Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
return nullptr;
@@ -374,7 +377,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
// MCObjectFileInfo needs a MCContext reference in order to initialize itself.
std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
- MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
+ MCTargetOptions MCOptions;
+ MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr, &MCOptions);
bool PIC = false;
if (Opts.RelocationModel == "static") {
@@ -431,7 +435,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
raw_pwrite_stream *Out = FDOS.get();
std::unique_ptr<buffer_ostream> BOS;
- MCTargetOptions MCOptions;
+ MCOptions.MCNoWarn = Opts.NoWarn;
+ MCOptions.MCFatalWarnings = Opts.FatalWarnings;
MCOptions.ABIName = Opts.TargetABI;
// FIXME: There is a bit of code duplication with addPassesToEmitFile.
@@ -445,7 +450,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
std::unique_ptr<MCAsmBackend> MAB(
TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions));
- auto FOut = llvm::make_unique<formatted_raw_ostream>(*Out);
+ auto FOut = std::make_unique<formatted_raw_ostream>(*Out);
Str.reset(TheTarget->createAsmStreamer(
Ctx, std::move(FOut), /*asmverbose*/ true,
/*useDwarfDirectory*/ true, IP, std::move(CE), std::move(MAB),
@@ -456,7 +461,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
assert(Opts.OutputType == AssemblerInvocation::FT_Obj &&
"Invalid file type!");
if (!FDOS->supportsSeeking()) {
- BOS = make_unique<buffer_ostream>(*FDOS);
+ BOS = std::make_unique<buffer_ostream>(*FDOS);
Out = BOS.get();
}
@@ -569,11 +574,11 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
return 1;
if (Asm.ShowHelp) {
- std::unique_ptr<OptTable> Opts(driver::createDriverOptTable());
- Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
- "Clang Integrated Assembler",
- /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
- /*ShowAllAliases=*/false);
+ getDriverOptTable().PrintHelp(
+ llvm::outs(), "clang -cc1as [options] file...",
+ "Clang Integrated Assembler",
+ /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
+ /*ShowAllAliases=*/false);
return 0;
}
@@ -590,7 +595,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// FIXME: Remove this, one day.
if (!Asm.LLVMArgs.empty()) {
unsigned NumArgs = Asm.LLVMArgs.size();
- auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
+ auto Args = std::make_unique<const char*[]>(NumArgs + 2);
Args[0] = "clang (LLVM option parsing)";
for (unsigned i = 0; i != NumArgs; ++i)
Args[i + 1] = Asm.LLVMArgs[i].c_str();
@@ -604,6 +609,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
// If any timers were active but haven't been destroyed yet, print their
// results now.
TimerGroup::printAll(errs());
+ TimerGroup::clearAll();
return !!Failed;
}
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index dfc96d308ab5..f1600490017d 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -13,6 +13,7 @@
#include "clang/Driver/Driver.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/Stack.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
@@ -270,10 +271,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
static DiagnosticOptions *
CreateAndPopulateDiagOpts(ArrayRef<const char *> argv) {
auto *DiagOpts = new DiagnosticOptions;
- std::unique_ptr<OptTable> Opts(createDriverOptTable());
unsigned MissingArgIndex, MissingArgCount;
- InputArgList Args =
- Opts->ParseArgs(argv.slice(1), MissingArgIndex, MissingArgCount);
+ InputArgList Args = getDriverOptTable().ParseArgs(
+ argv.slice(1), MissingArgIndex, MissingArgCount);
// We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
// Any errors that would be diagnosed here will also be diagnosed later,
// when the DiagnosticsEngine actually exists.
@@ -319,6 +319,7 @@ static int ExecuteCC1Tool(ArrayRef<const char *> argv, StringRef Tool) {
}
int main(int argc_, const char **argv_) {
+ noteBottomOfStack();
llvm::InitLLVM X(argc_, argv_);
SmallVector<const char *, 256> argv(argv_, argv_ + argc_);
@@ -498,6 +499,7 @@ int main(int argc_, const char **argv_) {
// If any timers were active but haven't been destroyed yet, print their
// results now. This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());
+ llvm::TimerGroup::clearAll();
#ifdef _WIN32
// Exit status should not be negative on Win32, unless abnormal termination.