[flang-commits] [flang] e87d2d2 - [Flang][Driver] Add support for backend passes in R_Group
Victor Kingi via flang-commits
flang-commits at lists.llvm.org
Thu Aug 31 07:40:39 PDT 2023
Author: Victor Kingi
Date: 2023-08-31T14:40:33Z
New Revision: e87d2d2cc9c4ffd3423a45eec5768989666242bc
URL: https://github.com/llvm/llvm-project/commit/e87d2d2cc9c4ffd3423a45eec5768989666242bc
DIFF: https://github.com/llvm/llvm-project/commit/e87d2d2cc9c4ffd3423a45eec5768989666242bc.diff
LOG: [Flang][Driver] Add support for backend passes in R_Group
Previously, R_Group options only reported middle-end passes.
This patch allows backend passes to be reported as well.
Depends on D158174. That patch adds backend support to R_Group
options.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D159260
Added:
flang/test/Driver/optimization-remark-backend.f90
Modified:
flang/lib/Frontend/FrontendActions.cpp
Removed:
################################################################################
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 9e5efb8d6ed688..e61178bb83ddc5 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -48,6 +48,7 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
+#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
#include "llvm/IR/LLVMRemarkStreamer.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Verifier.h"
@@ -1014,6 +1015,18 @@ class BackendRemarkConsumer : public llvm::DiagnosticHandler {
optimizationRemarkHandler(
llvm::cast<llvm::OptimizationRemarkAnalysis>(di));
break;
+ case llvm::DK_MachineOptimizationRemark:
+ optimizationRemarkHandler(
+ llvm::cast<llvm::MachineOptimizationRemark>(di));
+ break;
+ case llvm::DK_MachineOptimizationRemarkMissed:
+ optimizationRemarkHandler(
+ llvm::cast<llvm::MachineOptimizationRemarkMissed>(di));
+ break;
+ case llvm::DK_MachineOptimizationRemarkAnalysis:
+ optimizationRemarkHandler(
+ llvm::cast<llvm::MachineOptimizationRemarkAnalysis>(di));
+ break;
default:
break;
}
diff --git a/flang/test/Driver/optimization-remark-backend.f90 b/flang/test/Driver/optimization-remark-backend.f90
new file mode 100644
index 00000000000000..a38b024b7b8d20
--- /dev/null
+++ b/flang/test/Driver/optimization-remark-backend.f90
@@ -0,0 +1,23 @@
+! This file tests backend passes emitted by the -Rpass family of flags
+! loop-delete isn't enabled at O0 so we use at least O1
+
+! DEFINE: %{output} = -S -o /dev/null 2>&1
+
+! Check full -Rpass-missed message is emitted
+! RUN: %flang %s -O1 -Rpass-missed %{output} 2>&1 | FileCheck %s --check-prefix=MISSED
+
+! Check full -Rpass-analysis message is emitted
+! RUN: %flang %s -O1 -Rpass-analysis %{output} 2>&1 | FileCheck %s --check-prefix=ANALYSIS
+
+! MISSED: remark: {{[0-9]+}} virtual registers copies {{.*}} total copies cost generated in function
+! ANALYSIS: remark: BasicBlock:
+
+program forttest
+ implicit none
+ integer :: n
+
+ do n = 1,2
+ print *, ""
+ end do
+
+end program forttest
More information about the flang-commits
mailing list