summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenAction.cpp
diff options
context:
space:
mode:
authorTyler Nowicki <tnowicki@apple.com>2014-07-18 19:40:19 +0000
committerTyler Nowicki <tnowicki@apple.com>2014-07-18 19:40:19 +0000
commitf8a767df67f30054ad2427feb61d5cd8f5090511 (patch)
treeea0a61b0f9f6f555e6f8876394d6e97f7794f64a /clang/lib/CodeGen/CodeGenAction.cpp
parent55454c6c5a2113b83e828cbf34512d927307fcbf (diff)
downloadbcm5719-llvm-f8a767df67f30054ad2427feb61d5cd8f5090511.tar.gz
bcm5719-llvm-f8a767df67f30054ad2427feb61d5cd8f5090511.zip
Recommit: Handle diagnostic warnings in Frontend diagnostic handler.
Clang uses a diagnostic handler to grab diagnostic messages so it can print them with the line of source code they refer to. This patch extends this to handle optimization failures that were added to llvm to produce a warning when loop vectorization is explicitly specified (using a pragma clang loop directive) but fails. Update renames warning flag name to avoid indicating the flag's severity and adds a test. Reviewed by Alp Toker llvm-svn: 213400
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 559c2ef4bad..04d2cd9d53e 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -238,15 +238,16 @@ namespace clang {
/// \brief Specialized handlers for optimization remarks.
/// Note that these handlers only accept remarks and they always handle
/// them.
- void
- EmitOptimizationRemark(const llvm::DiagnosticInfoOptimizationBase &D,
- unsigned DiagID);
+ void EmitOptimizationMessage(const llvm::DiagnosticInfoOptimizationBase &D,
+ unsigned DiagID);
void
OptimizationRemarkHandler(const llvm::DiagnosticInfoOptimizationRemark &D);
void OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationRemarkMissed &D);
void OptimizationRemarkHandler(
const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D);
+ void OptimizationFailureHandler(
+ const llvm::DiagnosticInfoOptimizationFailure &D);
};
void BackendConsumer::anchor() {}
@@ -416,10 +417,11 @@ BackendConsumer::StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D) {
return false;
}
-void BackendConsumer::EmitOptimizationRemark(
+void BackendConsumer::EmitOptimizationMessage(
const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
- // We only support remarks.
- assert(D.getSeverity() == llvm::DS_Remark);
+ // We only support warnings and remarks.
+ assert(D.getSeverity() == llvm::DS_Remark ||
+ D.getSeverity() == llvm::DS_Warning);
SourceManager &SourceMgr = Context->getSourceManager();
FileManager &FileMgr = SourceMgr.getFileManager();
@@ -442,8 +444,9 @@ void BackendConsumer::EmitOptimizationRemark(
if (const Decl *FD = Gen->GetDeclForMangledName(D.getFunction().getName()))
Loc = FD->getASTContext().getFullLoc(FD->getBodyRBrace());
- Diags.Report(Loc, DiagID) << AddFlagValue(D.getPassName())
- << D.getMsg().str();
+ Diags.Report(Loc, DiagID)
+ << AddFlagValue(D.getPassName() ? D.getPassName() : "")
+ << D.getMsg().str();
if (DILoc.isInvalid())
// If we were not able to translate the file:line:col information
@@ -460,7 +463,7 @@ void BackendConsumer::OptimizationRemarkHandler(
// expression that matches the name of the pass name in \p D.
if (CodeGenOpts.OptimizationRemarkPattern &&
CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName()))
- EmitOptimizationRemark(D, diag::remark_fe_backend_optimization_remark);
+ EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark);
}
void BackendConsumer::OptimizationRemarkHandler(
@@ -470,8 +473,8 @@ void BackendConsumer::OptimizationRemarkHandler(
// name in \p D.
if (CodeGenOpts.OptimizationRemarkMissedPattern &&
CodeGenOpts.OptimizationRemarkMissedPattern->match(D.getPassName()))
- EmitOptimizationRemark(D,
- diag::remark_fe_backend_optimization_remark_missed);
+ EmitOptimizationMessage(D,
+ diag::remark_fe_backend_optimization_remark_missed);
}
void BackendConsumer::OptimizationRemarkHandler(
@@ -481,10 +484,15 @@ void BackendConsumer::OptimizationRemarkHandler(
// name in \p D.
if (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName()))
- EmitOptimizationRemark(
+ EmitOptimizationMessage(
D, diag::remark_fe_backend_optimization_remark_analysis);
}
+void BackendConsumer::OptimizationFailureHandler(
+ const llvm::DiagnosticInfoOptimizationFailure &D) {
+ EmitOptimizationMessage(D, diag::warn_fe_backend_optimization_failure);
+}
+
/// \brief This function is invoked when the backend needs
/// to report something to the user.
void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
@@ -518,6 +526,11 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
OptimizationRemarkHandler(
cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI));
return;
+ case llvm::DK_OptimizationFailure:
+ // Optimization failures are always handled completely by this
+ // handler.
+ OptimizationFailureHandler(cast<DiagnosticInfoOptimizationFailure>(DI));
+ return;
default:
// Plugin IDs are not bound to any value as they are set dynamically.
ComputeDiagRemarkID(Severity, backend_plugin, DiagID);
OpenPOWER on IntegriCloud