diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -64,6 +64,12 @@ cl::location(llvm::PotentialConstantIntValuesState::MaxPotentialValues), cl::init(7)); +// TODO turn this into one flag not two +static cl::opt DisableOpenMPOptDeglobalization2( + "openmp-opt-disable-deglobalization2", cl::ZeroOrMore, + cl::desc("Disable OpenMP optimizations involving deglobalization 2 of 2."), + cl::Hidden, cl::init(false)); + STATISTIC(NumAAs, "Number of abstract attributes created"); // Some helper macros to deal with statistics tracking. @@ -5644,6 +5650,11 @@ } void initialize(Attributor &A) override { + // If we have disabled deglobalization, stop + // TODO need to make these into one flag + if (DisableOpenMPOptDeglobalization2) + indicatePessimisticFixpoint(); + AAHeapToStack::initialize(A); const Function *F = getAnchorScope(); diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -72,6 +72,27 @@ " transfers"), cl::Hidden, cl::init(false)); +// TODO turn this into one flag +static cl::opt DisableOpenMPOptDeglobalization1( + "openmp-opt-disable-deglobalization1", cl::ZeroOrMore, + cl::desc("Disable OpenMP optimizations involving deglobalization 1 if 2."), + cl::Hidden, cl::init(false)); + +static cl::opt DisableOpenMPOptSPMDization( + "openmp-opt-disable-spmdization", cl::ZeroOrMore, + cl::desc("Disable OpenMP optimizations involving SPMD-ization."), + cl::Hidden, cl::init(false)); + +static cl::opt DisableOpenMPOptFolding( + "openmp-opt-disable-folding", cl::ZeroOrMore, + cl::desc("Disable OpenMP optimizations involving folding."), cl::Hidden, + cl::init(false)); + +static cl::opt DisableOpenMPOptStateMachineRewrite( + "openmp-opt-disable-state-machine-rewrite", cl::ZeroOrMore, + cl::desc("Disable OpenMP optimizations that replace the state machine."), + cl::Hidden, cl::init(false)); + STATISTIC(NumOpenMPRuntimeCallsDeduplicated, "Number of OpenMP runtime calls deduplicated"); STATISTIC(NumOpenMPParallelRegionsDeleted, @@ -1877,6 +1898,10 @@ if (!KernelParallelRFI) return Changed; + // If we have disabled state machine changes, exit + if (DisableOpenMPOptStateMachineRewrite) + return Changed; + for (Function *F : SCC) { // Check if the function is a use in a __kmpc_parallel_51 call at @@ -2595,6 +2620,10 @@ } void initialize(Attributor &A) override { + // If deglobalization disabled, do not init + if (DisableOpenMPOptDeglobalization1) + indicatePessimisticFixpoint(); + auto &OMPInfoCache = static_cast(A.getInfoCache()); auto &RFI = OMPInfoCache.RFIs[OMPRTL___kmpc_alloc_shared]; @@ -2921,6 +2950,10 @@ } bool changeToSPMDMode(Attributor &A) { + // If we have disabled SPMD-ization, stop + if (DisableOpenMPOptSPMDization) + indicatePessimisticFixpoint(); + auto &OMPInfoCache = static_cast(A.getInfoCache()); if (!SPMDCompatibilityTracker.isAssumed()) { @@ -3001,6 +3034,10 @@ }; ChangeStatus buildCustomStateMachine(Attributor &A) { + // If we have disabled state machine rewrites, don't make a custom one + if (DisableOpenMPOptStateMachineRewrite) + return indicatePessimisticFixpoint(); + assert(ReachedKnownParallelRegions.isValidState() && "Custom state machine with invalid parallel region states?"); @@ -3597,6 +3634,10 @@ } void initialize(Attributor &A) override { + // If we have disabled folding, stop + if (DisableOpenMPOptFolding) + indicatePessimisticFixpoint(); + Function *Callee = getAssociatedFunction(); auto &OMPInfoCache = static_cast(A.getInfoCache());