CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
#include "mlir/Remark/RemarkStreamer.h"
|
|
#include "mlir/IR/MLIRContext.h"
|
|
#include "mlir/IR/Remarks.h"
|
|
|
|
#include "llvm/Remarks/RemarkSerializer.h"
|
|
#include "llvm/Remarks/RemarkStreamer.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include "llvm/Support/FileSystem.h"
|
|
#include "llvm/Support/ToolOutputFile.h"
|
|
|
|
namespace mlir::remark::detail {
|
|
|
|
FailureOr<std::unique_ptr<MLIRRemarkStreamerBase>>
|
|
LLVMRemarkStreamer::createToFile(llvm::StringRef path,
|
|
llvm::remarks::Format fmt) {
|
|
std::error_code ec;
|
|
// Use error_code ctor; YAML is text. (Bitstream also works fine here.)
|
|
auto f =
|
|
std::make_unique<llvm::ToolOutputFile>(path, ec, llvm::sys::fs::OF_Text);
|
|
if (ec)
|
|
return failure();
|
|
|
|
auto serOr = llvm::remarks::createRemarkSerializer(fmt, f->os());
|
|
if (!serOr) {
|
|
llvm::consumeError(serOr.takeError());
|
|
return failure();
|
|
}
|
|
|
|
auto rs =
|
|
std::make_unique<llvm::remarks::RemarkStreamer>(std::move(*serOr), path);
|
|
|
|
auto impl = std::unique_ptr<LLVMRemarkStreamer>(new LLVMRemarkStreamer());
|
|
impl->remarkStreamer = std::move(rs);
|
|
impl->file = std::move(f);
|
|
return std::unique_ptr<MLIRRemarkStreamerBase>(std::move(impl));
|
|
}
|
|
|
|
void LLVMRemarkStreamer::streamOptimizationRemark(const Remark &remark) {
|
|
if (!remarkStreamer->matchesFilter(remark.getCategoryName()))
|
|
return;
|
|
|
|
// First, convert the diagnostic to a remark.
|
|
llvm::remarks::Remark r = remark.generateRemark();
|
|
// Then, emit the remark through the serializer.
|
|
remarkStreamer->getSerializer().emit(r);
|
|
}
|
|
|
|
LLVMRemarkStreamer::~LLVMRemarkStreamer() {
|
|
if (file && remarkStreamer)
|
|
file->keep();
|
|
}
|
|
|
|
void LLVMRemarkStreamer::finalize() {
|
|
if (!remarkStreamer)
|
|
return;
|
|
remarkStreamer->releaseSerializer();
|
|
}
|
|
} // namespace mlir::remark::detail
|
|
|
|
namespace mlir::remark {
|
|
LogicalResult enableOptimizationRemarksWithLLVMStreamer(
|
|
MLIRContext &ctx, StringRef path, llvm::remarks::Format fmt,
|
|
std::unique_ptr<detail::RemarkEmittingPolicyBase> remarkEmittingPolicy,
|
|
const RemarkCategories &cat, bool printAsEmitRemarks) {
|
|
|
|
FailureOr<std::unique_ptr<detail::MLIRRemarkStreamerBase>> sOr =
|
|
detail::LLVMRemarkStreamer::createToFile(path, fmt);
|
|
if (failed(sOr))
|
|
return failure();
|
|
|
|
return remark::enableOptimizationRemarks(ctx, std::move(*sOr),
|
|
std::move(remarkEmittingPolicy), cat,
|
|
printAsEmitRemarks);
|
|
}
|
|
|
|
} // namespace mlir::remark
|