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,12 +64,6 @@ 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. @@ -5650,11 +5644,6 @@ } 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 @@ -73,8 +73,8 @@ cl::Hidden, cl::init(false)); // TODO turn this into one flag -static cl::opt DisableOpenMPOptDeglobalization1( - "openmp-opt-disable-deglobalization1", cl::ZeroOrMore, +static cl::opt DisableOpenMPOptDeglobalization( + "openmp-opt-disable-deglobalization", cl::ZeroOrMore, cl::desc("Disable OpenMP optimizations involving deglobalization 1 if 2."), cl::Hidden, cl::init(false)); @@ -2620,10 +2620,6 @@ } 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]; @@ -3866,14 +3862,17 @@ A.getOrCreateAAFor(IRPosition::function(F)); return false; }; - GlobalizationRFI.foreachUse(SCC, CreateAA); + // If we have disabled deglobalization, do not create HeapToShared AA + if (!DisableOpenMPOptDeglobalization) + GlobalizationRFI.foreachUse(SCC, CreateAA); // Create an ExecutionDomain AA for every function and a HeapToStack AA for // every function if there is a device kernel. + // If we have disabled deglobalization, skip making a HeapToStack AA for (auto *F : SCC) { if (!F->isDeclaration()) A.getOrCreateAAFor(IRPosition::function(*F)); - if (isOpenMPDevice(M)) + if (isOpenMPDevice(M) && !DisableOpenMPOptDeglobalization) A.getOrCreateAAFor(IRPosition::function(*F)); } }