1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Remove LLVMContextImpl::optimizationRemarkEnabledFor.

Summary:
This patch moves the handling of -pass-remarks* over to
lib/DiagnosticInfo.cpp. This allows the removal of the
optimizationRemarkEnabledFor functions from LLVMContextImpl, as they're
not needed anymore.

Reviewers: qcolombet

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D3878

llvm-svn: 209453
This commit is contained in:
Diego Novillo 2014-05-22 17:19:01 +00:00
parent 98dd66445e
commit 42463a7789
5 changed files with 75 additions and 105 deletions

View File

@ -271,10 +271,7 @@ public:
/// or -pass-remarks-analysis). Note that this only handles the LLVM
/// flags. We cannot access Clang flags from here (they are handled
/// in BackendConsumer::OptimizationRemarkHandler).
///
/// \p pImpl points to the current LLVM context. It is needed to query the
/// value of the command line flag associated with this remark.
virtual bool isEnabled(LLVMContextImpl *pImpl) const = 0;
virtual bool isEnabled() const = 0;
/// Return true if location information is available for this diagnostic.
bool isLocationAvailable() const;
@ -332,7 +329,7 @@ public:
}
/// \see DiagnosticInfoOptimizationRemarkBase::isEnabled.
virtual bool isEnabled(LLVMContextImpl *pImpl) const override;
virtual bool isEnabled() const override;
};
/// Diagnostic information for missed-optimization remarks.
@ -359,7 +356,7 @@ public:
}
/// \see DiagnosticInfoOptimizationRemarkBase::isEnabled.
virtual bool isEnabled(LLVMContextImpl *pImpl) const override;
virtual bool isEnabled() const override;
};
/// Diagnostic information for optimization analysis remarks.
@ -387,7 +384,7 @@ public:
}
/// \see DiagnosticInfoOptimizationRemarkBase::isEnabled.
virtual bool isEnabled(LLVMContextImpl *pImpl) const override;
virtual bool isEnabled() const override;
};
// Create wrappers for C Binding types (see CBindingWrapping.h).

View File

@ -23,10 +23,69 @@
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Atomic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Regex.h"
#include <string>
using namespace llvm;
namespace {
/// \brief Regular expression corresponding to the value given in one of the
/// -pass-remarks* command line flags. Passes whose name matches this regexp
/// will emit a diagnostic when calling the associated diagnostic function
/// (emitOptimizationRemark, emitOptimizationRemarkMissed or
/// emitOptimizationRemarkAnalysis).
struct PassRemarksOpt {
std::shared_ptr<Regex> Pattern;
void operator=(const std::string &Val) {
// Create a regexp object to match pass names for emitOptimizationRemark.
if (!Val.empty()) {
Pattern = std::make_shared<Regex>(Val);
std::string RegexError;
if (!Pattern->isValid(RegexError))
report_fatal_error("Invalid regular expression '" + Val +
"' in -pass-remarks: " + RegexError,
false);
}
};
};
static PassRemarksOpt PassRemarksOptLoc;
static PassRemarksOpt PassRemarksMissedOptLoc;
static PassRemarksOpt PassRemarksAnalysisOptLoc;
// -pass-remarks
// Command line flag to enable emitOptimizationRemark()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>>
PassRemarks("pass-remarks", cl::value_desc("pattern"),
cl::desc("Enable optimization remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
// -pass-remarks-missed
// Command line flag to enable emitOptimizationRemarkMissed()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>> PassRemarksMissed(
"pass-remarks-missed", cl::value_desc("pattern"),
cl::desc("Enable missed optimization remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksMissedOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
// -pass-remarks-analysis
// Command line flag to enable emitOptimizationRemarkAnalysis()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>>
PassRemarksAnalysis(
"pass-remarks-analysis", cl::value_desc("pattern"),
cl::desc(
"Enable optimization analysis remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksAnalysisOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
}
int llvm::getNextAvailablePluginDiagnosticKind() {
static sys::cas_flag PluginKindID = DK_FirstPluginKind;
return (int)sys::AtomicIncrement(&PluginKindID);
@ -94,19 +153,19 @@ void DiagnosticInfoOptimizationRemarkBase::print(DiagnosticPrinter &DP) const {
DP << getLocationStr() << ": " << getMsg();
}
bool
DiagnosticInfoOptimizationRemark::isEnabled(LLVMContextImpl *pImpl) const {
return pImpl->optimizationRemarkEnabledFor(this);
bool DiagnosticInfoOptimizationRemark::isEnabled() const {
return PassRemarksOptLoc.Pattern &&
PassRemarksOptLoc.Pattern->match(getPassName());
}
bool DiagnosticInfoOptimizationRemarkMissed::isEnabled(
LLVMContextImpl *pImpl) const {
return pImpl->optimizationRemarkEnabledFor(this);
bool DiagnosticInfoOptimizationRemarkMissed::isEnabled() const {
return PassRemarksMissedOptLoc.Pattern &&
PassRemarksMissedOptLoc.Pattern->match(getPassName());
}
bool DiagnosticInfoOptimizationRemarkAnalysis::isEnabled(
LLVMContextImpl *pImpl) const {
return pImpl->optimizationRemarkEnabledFor(this);
bool DiagnosticInfoOptimizationRemarkAnalysis::isEnabled() const {
return PassRemarksAnalysisOptLoc.Pattern &&
PassRemarksAnalysisOptLoc.Pattern->match(getPassName());
}
void llvm::emitOptimizationRemark(LLVMContext &Ctx, const char *PassName,

View File

@ -148,15 +148,15 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
// diagnostic and return.
switch (DI.getKind()) {
case llvm::DK_OptimizationRemark:
if (!cast<DiagnosticInfoOptimizationRemark>(DI).isEnabled(pImpl))
if (!cast<DiagnosticInfoOptimizationRemark>(DI).isEnabled())
return;
break;
case llvm::DK_OptimizationRemarkMissed:
if (!cast<DiagnosticInfoOptimizationRemarkMissed>(DI).isEnabled(pImpl))
if (!cast<DiagnosticInfoOptimizationRemarkMissed>(DI).isEnabled())
return;
break;
case llvm::DK_OptimizationRemarkAnalysis:
if (!cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI).isEnabled(pImpl))
if (!cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI).isEnabled())
return;
break;
default:

View File

@ -16,8 +16,6 @@
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Regex.h"
#include <algorithm>
using namespace llvm;
@ -47,81 +45,6 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C)
NamedStructTypesUniqueID = 0;
}
namespace {
/// \brief Regular expression corresponding to the value given in one of the
/// -pass-remarks* command line flags. Passes whose name matches this regexp
/// will emit a diagnostic when calling the associated diagnostic function
/// (emitOptimizationRemark, emitOptimizationRemarkMissed or
/// emitOptimizationRemarkAnalysis).
struct PassRemarksOpt {
std::shared_ptr<Regex> Pattern;
void operator=(const std::string &Val) {
// Create a regexp object to match pass names for emitOptimizationRemark.
if (!Val.empty()) {
Pattern = std::make_shared<Regex>(Val);
std::string RegexError;
if (!Pattern->isValid(RegexError))
report_fatal_error("Invalid regular expression '" + Val +
"' in -pass-remarks: " + RegexError,
false);
}
};
};
static PassRemarksOpt PassRemarksOptLoc;
static PassRemarksOpt PassRemarksMissedOptLoc;
static PassRemarksOpt PassRemarksAnalysisOptLoc;
// -pass-remarks
// Command line flag to enable emitOptimizationRemark()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>>
PassRemarks("pass-remarks", cl::value_desc("pattern"),
cl::desc("Enable optimization remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
// -pass-remarks-missed
// Command line flag to enable emitOptimizationRemarkMissed()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>> PassRemarksMissed(
"pass-remarks-missed", cl::value_desc("pattern"),
cl::desc("Enable missed optimization remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksMissedOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
// -pass-remarks-analysis
// Command line flag to enable emitOptimizationRemarkAnalysis()
static cl::opt<PassRemarksOpt, true, cl::parser<std::string>>
PassRemarksAnalysis(
"pass-remarks-analysis", cl::value_desc("pattern"),
cl::desc(
"Enable optimization analysis remarks from passes whose name match "
"the given regular expression"),
cl::Hidden, cl::location(PassRemarksAnalysisOptLoc), cl::ValueRequired,
cl::ZeroOrMore);
}
bool LLVMContextImpl::optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemark *DI) const {
return PassRemarksOptLoc.Pattern &&
PassRemarksOptLoc.Pattern->match(DI->getPassName());
}
bool LLVMContextImpl::optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemarkMissed *DI) const {
return PassRemarksMissedOptLoc.Pattern &&
PassRemarksMissedOptLoc.Pattern->match(DI->getPassName());
}
bool LLVMContextImpl::optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemarkAnalysis *DI) const {
return PassRemarksAnalysisOptLoc.Pattern &&
PassRemarksAnalysisOptLoc.Pattern->match(DI->getPassName());
}
namespace {
struct DropReferences {
// Takes the value_type of a ConstantUniqueMap's internal map, whose 'second'

View File

@ -374,15 +374,6 @@ public:
typedef DenseMap<const Function *, ReturnInst *> PrefixDataMapTy;
PrefixDataMapTy PrefixDataMap;
/// \brief Return true if the given pass name should emit optimization
/// remarks.
bool optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemark *DI) const;
bool optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemarkMissed *DI) const;
bool optimizationRemarkEnabledFor(
const DiagnosticInfoOptimizationRemarkAnalysis *DI) const;
int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);