/// \brief Run the analysis pass over a function and produce BFI.
Result run(Function &F, FunctionAnalysisManager &AM);
};
-
-namespace yaml {
-template <> struct MappingTraits<DiagnosticInfoOptimizationBase *> {
- static void mapping(IO &io, DiagnosticInfoOptimizationBase *&OptDiag);
-};
-}
}
#endif // LLVM_IR_OPTIMIZATIONDIAGNOSTICINFO_H
void print(DiagnosticPrinter &DP) const override;
};
+namespace yaml {
+template <> struct MappingTraits<DiagnosticInfoOptimizationBase *> {
+ static void mapping(IO &io, DiagnosticInfoOptimizationBase *&OptDiag);
+};
+} // namespace yaml
+
} // end namespace llvm
#endif // LLVM_IR_DIAGNOSTICINFO_H
return BFI->getBlockProfileCount(cast<BasicBlock>(V));
}
-namespace llvm {
-namespace yaml {
-
-void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
- IO &io, DiagnosticInfoOptimizationBase *&OptDiag) {
- assert(io.outputting() && "input not yet implemented");
-
- if (io.mapTag("!Passed",
- (OptDiag->getKind() == DK_OptimizationRemark ||
- OptDiag->getKind() == DK_MachineOptimizationRemark)))
- ;
- else if (io.mapTag(
- "!Missed",
- (OptDiag->getKind() == DK_OptimizationRemarkMissed ||
- OptDiag->getKind() == DK_MachineOptimizationRemarkMissed)))
- ;
- else if (io.mapTag(
- "!Analysis",
- (OptDiag->getKind() == DK_OptimizationRemarkAnalysis ||
- OptDiag->getKind() == DK_MachineOptimizationRemarkAnalysis)))
- ;
- else if (io.mapTag("!AnalysisFPCommute",
- OptDiag->getKind() ==
- DK_OptimizationRemarkAnalysisFPCommute))
- ;
- else if (io.mapTag("!AnalysisAliasing",
- OptDiag->getKind() ==
- DK_OptimizationRemarkAnalysisAliasing))
- ;
- else if (io.mapTag("!Failure", OptDiag->getKind() == DK_OptimizationFailure))
- ;
- else
- llvm_unreachable("Unknown remark type");
-
- // These are read-only for now.
- DiagnosticLocation DL = OptDiag->getLocation();
- StringRef FN =
- GlobalValue::dropLLVMManglingEscape(OptDiag->getFunction().getName());
-
- StringRef PassName(OptDiag->PassName);
- io.mapRequired("Pass", PassName);
- io.mapRequired("Name", OptDiag->RemarkName);
- if (!io.outputting() || DL.isValid())
- io.mapOptional("DebugLoc", DL);
- io.mapRequired("Function", FN);
- io.mapOptional("Hotness", OptDiag->Hotness);
- io.mapOptional("Args", OptDiag->Args);
-}
-
-template <> struct MappingTraits<DiagnosticLocation> {
- static void mapping(IO &io, DiagnosticLocation &DL) {
- assert(io.outputting() && "input not yet implemented");
-
- StringRef File = DL.getFilename();
- unsigned Line = DL.getLine();
- unsigned Col = DL.getColumn();
-
- io.mapRequired("File", File);
- io.mapRequired("Line", Line);
- io.mapRequired("Column", Col);
- }
-
- static const bool flow = true;
-};
-
-// Implement this as a mapping for now to get proper quotation for the value.
-template <> struct MappingTraits<DiagnosticInfoOptimizationBase::Argument> {
- static void mapping(IO &io, DiagnosticInfoOptimizationBase::Argument &A) {
- assert(io.outputting() && "input not yet implemented");
- io.mapRequired(A.Key.data(), A.Val);
- if (A.Loc.isValid())
- io.mapOptional("DebugLoc", A.Loc);
- }
-};
-
-} // end namespace yaml
-} // end namespace llvm
-
-LLVM_YAML_IS_SEQUENCE_VECTOR(DiagnosticInfoOptimizationBase::Argument)
-
void OptimizationRemarkEmitter::computeHotness(
DiagnosticInfoIROptimization &OptDiag) {
const Value *V = OptDiag.getCodeRegion();
return;
}
- yaml::Output *Out = F->getContext().getDiagnosticsOutputFile();
- if (Out) {
- // For remarks the << operator takes a reference to a pointer.
- auto *P = &OptDiagBase;
- *Out << P;
- }
F->getContext().diagnose(OptDiag);
}
return;
}
- yaml::Output *Out = Ctx.getDiagnosticsOutputFile();
- if (Out) {
- auto *P = &const_cast<DiagnosticInfoOptimizationBase &>(OptDiagCommon);
- *Out << P;
- }
-
Ctx.diagnose(OptDiag);
}
OS << Arg.Val;
return OS.str();
}
+
+namespace llvm {
+namespace yaml {
+
+void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
+ IO &io, DiagnosticInfoOptimizationBase *&OptDiag) {
+ assert(io.outputting() && "input not yet implemented");
+
+ if (io.mapTag("!Passed",
+ (OptDiag->getKind() == DK_OptimizationRemark ||
+ OptDiag->getKind() == DK_MachineOptimizationRemark)))
+ ;
+ else if (io.mapTag(
+ "!Missed",
+ (OptDiag->getKind() == DK_OptimizationRemarkMissed ||
+ OptDiag->getKind() == DK_MachineOptimizationRemarkMissed)))
+ ;
+ else if (io.mapTag(
+ "!Analysis",
+ (OptDiag->getKind() == DK_OptimizationRemarkAnalysis ||
+ OptDiag->getKind() == DK_MachineOptimizationRemarkAnalysis)))
+ ;
+ else if (io.mapTag("!AnalysisFPCommute",
+ OptDiag->getKind() ==
+ DK_OptimizationRemarkAnalysisFPCommute))
+ ;
+ else if (io.mapTag("!AnalysisAliasing",
+ OptDiag->getKind() ==
+ DK_OptimizationRemarkAnalysisAliasing))
+ ;
+ else if (io.mapTag("!Failure", OptDiag->getKind() == DK_OptimizationFailure))
+ ;
+ else
+ llvm_unreachable("Unknown remark type");
+
+ // These are read-only for now.
+ DiagnosticLocation DL = OptDiag->getLocation();
+ StringRef FN =
+ GlobalValue::dropLLVMManglingEscape(OptDiag->getFunction().getName());
+
+ StringRef PassName(OptDiag->PassName);
+ io.mapRequired("Pass", PassName);
+ io.mapRequired("Name", OptDiag->RemarkName);
+ if (!io.outputting() || DL.isValid())
+ io.mapOptional("DebugLoc", DL);
+ io.mapRequired("Function", FN);
+ io.mapOptional("Hotness", OptDiag->Hotness);
+ io.mapOptional("Args", OptDiag->Args);
+}
+
+template <> struct MappingTraits<DiagnosticLocation> {
+ static void mapping(IO &io, DiagnosticLocation &DL) {
+ assert(io.outputting() && "input not yet implemented");
+
+ StringRef File = DL.getFilename();
+ unsigned Line = DL.getLine();
+ unsigned Col = DL.getColumn();
+
+ io.mapRequired("File", File);
+ io.mapRequired("Line", Line);
+ io.mapRequired("Column", Col);
+ }
+
+ static const bool flow = true;
+};
+
+// Implement this as a mapping for now to get proper quotation for the value.
+template <> struct MappingTraits<DiagnosticInfoOptimizationBase::Argument> {
+ static void mapping(IO &io, DiagnosticInfoOptimizationBase::Argument &A) {
+ assert(io.outputting() && "input not yet implemented");
+ io.mapRequired(A.Key.data(), A.Val);
+ if (A.Loc.isValid())
+ io.mapOptional("DebugLoc", A.Loc);
+ }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(DiagnosticInfoOptimizationBase::Argument)
}
void LLVMContext::diagnose(const DiagnosticInfo &DI) {
+ if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) {
+ yaml::Output *Out = getDiagnosticsOutputFile();
+ if (Out) {
+ // For remarks the << operator takes a reference to a pointer.
+ auto *P = const_cast<DiagnosticInfoOptimizationBase *>(OptDiagBase);
+ *Out << P;
+ }
+ }
// If there is a report handler, use it.
if (pImpl->DiagHandler &&
(!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) &&