[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
This commit is contained in:
Joseph Huber 2022-03-01 16:33:26 -05:00
parent 026fe5ffc3
commit 6632180745

View File

@ -110,10 +110,15 @@ static cl::opt<bool> DisableOpenMPOptBarrierElimination(
cl::Hidden, cl::init(false));
static cl::opt<bool> 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<bool> 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<bool> 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<FunctionAnalysisManagerModuleProxy>(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 =