summaryrefslogtreecommitdiff
path: root/tools/llc/llc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llc/llc.cpp')
-rw-r--r--tools/llc/llc.cpp62
1 files changed, 33 insertions, 29 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 2329fb3e87c97..76da843f065e6 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -1,9 +1,8 @@
//===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -32,6 +31,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/RemarkStreamer.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/MC/SubtargetFeature.h"
@@ -133,21 +133,33 @@ static cl::opt<bool> DiscardValueNames(
static cl::list<std::string> IncludeDirs("I", cl::desc("include search path"));
-static cl::opt<bool> PassRemarksWithHotness(
+static cl::opt<bool> RemarksWithHotness(
"pass-remarks-with-hotness",
cl::desc("With PGO, include profile count in optimization remarks"),
cl::Hidden);
-static cl::opt<unsigned> PassRemarksHotnessThreshold(
- "pass-remarks-hotness-threshold",
- cl::desc("Minimum profile count required for an optimization remark to be output"),
- cl::Hidden);
+static cl::opt<unsigned>
+ RemarksHotnessThreshold("pass-remarks-hotness-threshold",
+ cl::desc("Minimum profile count required for "
+ "an optimization remark to be output"),
+ cl::Hidden);
static cl::opt<std::string>
RemarksFilename("pass-remarks-output",
- cl::desc("YAML output filename for pass remarks"),
+ cl::desc("Output filename for pass remarks"),
cl::value_desc("filename"));
+static cl::opt<std::string>
+ RemarksPasses("pass-remarks-filter",
+ cl::desc("Only record optimization remarks from passes whose "
+ "names match the given regular expression"),
+ cl::value_desc("regex"));
+
+static cl::opt<std::string> RemarksFormat(
+ "pass-remarks-format",
+ cl::desc("The format used for serializing remarks (default: YAML)"),
+ cl::value_desc("format"), cl::init("yaml"));
+
namespace {
static ManagedStatic<std::vector<std::string>> RunPassNames;
@@ -302,6 +314,7 @@ int main(int argc, char **argv) {
initializeVectorization(*Registry);
initializeScalarizeMaskedMemIntrinPass(*Registry);
initializeExpandReductionsPass(*Registry);
+ initializeHardwareLoopsPass(*Registry);
// Initialize debugging passes.
initializeScavengerTestPass(*Registry);
@@ -319,24 +332,15 @@ int main(int argc, char **argv) {
llvm::make_unique<LLCDiagnosticHandler>(&HasError));
Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError);
- if (PassRemarksWithHotness)
- Context.setDiagnosticsHotnessRequested(true);
-
- if (PassRemarksHotnessThreshold)
- Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold);
-
- std::unique_ptr<ToolOutputFile> YamlFile;
- if (RemarksFilename != "") {
- std::error_code EC;
- YamlFile =
- llvm::make_unique<ToolOutputFile>(RemarksFilename, EC, sys::fs::F_None);
- if (EC) {
- WithColor::error(errs(), argv[0]) << EC.message() << '\n';
- return 1;
- }
- Context.setDiagnosticsOutputFile(
- llvm::make_unique<yaml::Output>(YamlFile->os()));
+ Expected<std::unique_ptr<ToolOutputFile>> RemarksFileOrErr =
+ setupOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
+ RemarksFormat, RemarksWithHotness,
+ RemarksHotnessThreshold);
+ if (Error E = RemarksFileOrErr.takeError()) {
+ WithColor::error(errs(), argv[0]) << toString(std::move(E)) << '\n';
+ return 1;
}
+ std::unique_ptr<ToolOutputFile> RemarksFile = std::move(*RemarksFileOrErr);
if (InputLanguage != "" && InputLanguage != "ir" &&
InputLanguage != "mir") {
@@ -351,8 +355,8 @@ int main(int argc, char **argv) {
if (int RetVal = compileModule(argv, Context))
return RetVal;
- if (YamlFile)
- YamlFile->keep();
+ if (RemarksFile)
+ RemarksFile->keep();
return 0;
}