From 6632180745a2679cfd4631a607759ccc519e5da5 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Tue, 1 Mar 2022 16:33:26 -0500 Subject: [PATCH] [OpenMP][NFC] Add an option to print the module before in OpenMPOpt Previously there was a debug flag to print the module after optimizations. Sometimes we wanted to print the module before optimizations so this is being split into two flags. `-openmp-opt-print-module` is now `-openmp-opt-print-module-after`. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D120768 --- llvm/lib/Transforms/IPO/OpenMPOpt.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 57a854f..7b70082 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -110,10 +110,15 @@ static cl::opt DisableOpenMPOptBarrierElimination( cl::Hidden, cl::init(false)); static cl::opt PrintModuleAfterOptimizations( - "openmp-opt-print-module", cl::ZeroOrMore, + "openmp-opt-print-module-after", cl::ZeroOrMore, cl::desc("Print the current module after OpenMP optimizations."), cl::Hidden, cl::init(false)); +static cl::opt PrintModuleBeforeOptimizations( + "openmp-opt-print-module-before", cl::ZeroOrMore, + cl::desc("Print the current module before OpenMP optimizations."), + cl::Hidden, cl::init(false)); + static cl::opt AlwaysInlineDeviceFunctions( "openmp-opt-inline-device", cl::ZeroOrMore, cl::desc("Inline all applicible functions on the device."), cl::Hidden, @@ -4916,6 +4921,9 @@ PreservedAnalyses OpenMPOptPass::run(Module &M, ModuleAnalysisManager &AM) { AM.getResult(M).getManager(); KernelSet Kernels = getDeviceKernels(M); + if (PrintModuleBeforeOptimizations) + LLVM_DEBUG(dbgs() << TAG << "Module before OpenMPOpt Module Pass:\n" << M); + auto IsCalled = [&](Function &F) { if (Kernels.contains(&F)) return true; @@ -5018,6 +5026,9 @@ PreservedAnalyses OpenMPOptCGSCCPass::run(LazyCallGraph::SCC &C, Module &M = *C.begin()->getFunction().getParent(); + if (PrintModuleBeforeOptimizations) + LLVM_DEBUG(dbgs() << TAG << "Module before OpenMPOpt CGSCC Pass:\n" << M); + KernelSet Kernels = getDeviceKernels(M); FunctionAnalysisManager &FAM = -- 2.7.4