1、抛出error信息并终止程序
使用DiagnosticInfoUnsupported可以向用户抛出error信息并且终止程序,效果如同report_fatal_error、Error。后端用法如下:
void xxxx::reportErrorMsg(const MachineFunction &MF)const {
const Function &F = MF.getFunction();
// Diagnostic information for unsupported feature in backend.
F.getContext().diagnose(DiagnosticInfoUnsupported{F, "report msg."});
}
2、优化pass中抛出警告信息之OptimizationRemark
使用时clang得加上-Rpass=name,llc得加上–pass-remarks=name才行,后端用法如下:
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
MachineFunctionPass::getAnalysisUsage(AU);
}
void xxx::reportWarningMsg(const MachineFunction &MF)const {
auto *ORE = &getAnalysis<OptimizationRemarkEmitterWr