Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 28 additions & 74 deletions llvm/include/llvm/IR/DiagnosticInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,93 +613,47 @@ class DiagnosticInfoOptimizationBase : public DiagnosticInfoWithLocationBase {
/// common base class. This allows returning the result of the insertion
/// directly by value, e.g. return OptimizationRemarkAnalysis(...) << "blah".
template <class RemarkT>
RemarkT &
operator<<(RemarkT &R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
StringRef>
S) {
decltype(auto) operator<<(
RemarkT &&R,
std::enable_if_t<std::is_base_of<DiagnosticInfoOptimizationBase,
std::remove_reference_t<RemarkT>>::value,
StringRef>
S) {
R.insert(S);
return R;
return std::forward<RemarkT>(R);
}

/// Also allow r-value for the remark to allow insertion into a
/// temporarily-constructed remark.
template <class RemarkT>
RemarkT &&
operator<<(RemarkT &&R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
StringRef>
S) {
R.insert(S);
return std::move(R);
}

template <class RemarkT>
RemarkT &
operator<<(RemarkT &R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::Argument>
A) {
R.insert(A);
return R;
}

template <class RemarkT>
RemarkT &&
operator<<(RemarkT &&R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::Argument>
A) {
decltype(auto) operator<<(
RemarkT &&R,
std::enable_if_t<std::is_base_of<DiagnosticInfoOptimizationBase,
std::remove_reference_t<RemarkT>>::value,
DiagnosticInfoOptimizationBase::Argument>
A) {
R.insert(A);
return std::move(R);
return std::forward<RemarkT>(R);
}

template <class RemarkT>
RemarkT &
operator<<(RemarkT &R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::setIsVerbose>
V) {
decltype(auto) operator<<(
RemarkT &&R,
std::enable_if_t<std::is_base_of<DiagnosticInfoOptimizationBase,
std::remove_reference_t<RemarkT>>::value,
DiagnosticInfoOptimizationBase::setIsVerbose>
V) {
R.insert(V);
return R;
}

template <class RemarkT>
RemarkT &&
operator<<(RemarkT &&R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::setIsVerbose>
V) {
R.insert(V);
return std::move(R);
}

template <class RemarkT>
RemarkT &
operator<<(RemarkT &R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::setExtraArgs>
EA) {
R.insert(EA);
return R;
return std::forward<RemarkT>(R);
}

template <class RemarkT>
RemarkT &&
operator<<(RemarkT &&R,
std::enable_if_t<
std::is_base_of<DiagnosticInfoOptimizationBase, RemarkT>::value,
DiagnosticInfoOptimizationBase::setExtraArgs>
EA) {
decltype(auto) operator<<(
RemarkT &&R,
std::enable_if_t<std::is_base_of<DiagnosticInfoOptimizationBase,
std::remove_reference_t<RemarkT>>::value,
DiagnosticInfoOptimizationBase::setExtraArgs>
EA) {
R.insert(EA);
return std::move(R);
return std::forward<RemarkT>(R);
}

/// Common features for diagnostics dealing with optimization remarks
Expand Down
11 changes: 3 additions & 8 deletions llvm/lib/Analysis/InlineAdvisor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ static raw_ostream &operator<<(raw_ostream &R, const ore::NV &Arg) {
return R << Arg.Val;
}

template <class RemarkT> RemarkT &operator<<(RemarkT &R, const InlineCost &IC) {
template <class RemarkT>
decltype(auto) operator<<(RemarkT &&R, const InlineCost &IC) {
using namespace ore;
if (IC.isAlways()) {
R << "(cost=always)";
Expand All @@ -349,13 +350,7 @@ template <class RemarkT> RemarkT &operator<<(RemarkT &R, const InlineCost &IC) {
}
if (const char *Reason = IC.getReason())
R << ": " << ore::NV("Reason", Reason);
return R;
}

template <class RemarkT>
RemarkT &&operator<<(RemarkT &&R, const InlineCost &IC) {
static_cast<RemarkT &>(R) << IC;
return std::move(R);
return std::forward<RemarkT>(R);
}
} // namespace llvm

Expand Down
Loading