From 6b622ebea01b3ece8b8e475f15c5ce16a4cdc9f8 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Wed, 6 Mar 2019 14:52:37 +0000 Subject: Revert "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer" This reverts commit 2e8c4997a2089f8228c843fd81b148d903472e02. Breaks bots. llvm-svn: 355511 --- llvm/lib/IR/CMakeLists.txt | 1 - llvm/lib/IR/DiagnosticInfo.cpp | 1 - llvm/lib/IR/LLVMContext.cpp | 26 +++++++++++++------------- llvm/lib/IR/LLVMContextImpl.h | 3 +-- llvm/lib/IR/RemarkStreamer.cpp | 28 ---------------------------- 5 files changed, 14 insertions(+), 45 deletions(-) delete mode 100644 llvm/lib/IR/RemarkStreamer.cpp (limited to 'llvm/lib/IR') diff --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt index b1293194800..2ea01b8a767 100644 --- a/llvm/lib/IR/CMakeLists.txt +++ b/llvm/lib/IR/CMakeLists.txt @@ -46,7 +46,6 @@ add_llvm_library(LLVMCore PassManager.cpp PassRegistry.cpp PassTimingInfo.cpp - RemarkStreamer.cpp SafepointIRVerifier.cpp ProfileSummary.cpp Statepoint.cpp diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 020305d76cb..14bee35dc29 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -27,7 +27,6 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" -#include "llvm/IR/RemarkStreamer.h" #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" #include "llvm/Support/Casting.h" diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index 75d0218bcc8..1cea21461f4 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -21,7 +21,6 @@ #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" -#include "llvm/IR/RemarkStreamer.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -161,15 +160,12 @@ uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const { return pImpl->DiagnosticsHotnessThreshold; } -RemarkStreamer *LLVMContext::getRemarkStreamer() { - return pImpl->RemarkStreamer.get(); +yaml::Output *LLVMContext::getDiagnosticsOutputFile() { + return pImpl->DiagnosticsOutputFile.get(); } -const RemarkStreamer *LLVMContext::getRemarkStreamer() const { - return const_cast(this)->getRemarkStreamer(); -} -void LLVMContext::setRemarkStreamer( - std::unique_ptr RemarkStreamer) { - pImpl->RemarkStreamer = std::move(RemarkStreamer); + +void LLVMContext::setDiagnosticsOutputFile(std::unique_ptr F) { + pImpl->DiagnosticsOutputFile = std::move(F); } DiagnosticHandler::DiagnosticHandlerTy @@ -232,10 +228,14 @@ LLVMContext::getDiagnosticMessagePrefix(DiagnosticSeverity Severity) { } void LLVMContext::diagnose(const DiagnosticInfo &DI) { - if (auto *OptDiagBase = dyn_cast(&DI)) - if (RemarkStreamer *RS = getRemarkStreamer()) - RS->emit(*OptDiagBase); - + if (auto *OptDiagBase = dyn_cast(&DI)) { + yaml::Output *Out = getDiagnosticsOutputFile(); + if (Out) { + // For remarks the << operator takes a reference to a pointer. + auto *P = const_cast(OptDiagBase); + *Out << P; + } + } // If there is a report handler, use it. if (pImpl->DiagHandler && (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index b8974ef9767..f7038ace035 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -37,7 +37,6 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Metadata.h" -#include "llvm/IR/RemarkStreamer.h" #include "llvm/IR/TrackingMDRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" @@ -1227,7 +1226,7 @@ public: bool RespectDiagnosticFilters = false; bool DiagnosticsHotnessRequested = false; uint64_t DiagnosticsHotnessThreshold = 0; - std::unique_ptr RemarkStreamer; + std::unique_ptr DiagnosticsOutputFile; LLVMContext::YieldCallbackTy YieldCallback = nullptr; void *YieldOpaqueHandle = nullptr; diff --git a/llvm/lib/IR/RemarkStreamer.cpp b/llvm/lib/IR/RemarkStreamer.cpp deleted file mode 100644 index 0b983408e46..00000000000 --- a/llvm/lib/IR/RemarkStreamer.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===- llvm/IR/RemarkStreamer.cpp - Remark Streamer -*- C++ -------------*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// This file contains the implementation of the remark outputting as part of -// LLVMContext. -// -//===----------------------------------------------------------------------===// - -#include "llvm/IR/RemarkStreamer.h" - -using namespace llvm; - -RemarkStreamer::RemarkStreamer(StringRef Filename, raw_ostream &OS) - : Filename(Filename), OS(OS), - YAMLOutput(OS, reinterpret_cast(this)) { - assert(!Filename.empty() && "This needs to be a real filename."); -} - -void RemarkStreamer::emit(const DiagnosticInfoOptimizationBase &Diag) { - DiagnosticInfoOptimizationBase *DiagPtr = - const_cast(&Diag); - YAMLOutput << DiagPtr; -} -- cgit v1.2.3