diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -234,9 +234,7 @@ DenseMap SROAArgValues; /// Keep track of Allocas for which we believe we may get SROA optimization. - /// We don't delete entries in SROAArgValue because we still want - /// isAllocaDerivedArg to function correctly. - DenseSet EnabledSROAArgValues; + DenseSet EnabledSROAAllocas; /// Keep track of values which map to a pointer base and constant offset. DenseMap> ConstantOffsetPtrs; @@ -256,8 +254,7 @@ AllocaInst *getSROAArgForValueOrNull(Value *V) const { auto It = SROAArgValues.find(V); - if (It == SROAArgValues.end() || - EnabledSROAArgValues.count(It->second) == 0) + if (It == SROAArgValues.end() || EnabledSROAAllocas.count(It->second) == 0) return nullptr; return It->second; } @@ -513,7 +510,6 @@ assert(Arg != nullptr && "Should not initialize SROA costs for null value."); SROAArgCosts[Arg] = 0; - EnabledSROAArgValues.insert(Arg); } void onAggregateSROAUse(AllocaInst *SROAArg) override { @@ -651,7 +647,7 @@ void CallAnalyzer::disableSROAForArg(AllocaInst *SROAArg) { onDisableSROA(SROAArg); - EnabledSROAArgValues.erase(SROAArg); + EnabledSROAAllocas.erase(SROAArg); disableLoadElimination(); } /// If 'V' maps to a SROA candidate, disable SROA for it. @@ -1941,6 +1937,7 @@ if (auto *SROAArg = dyn_cast(PtrArg)) { SROAArgValues[&*FAI] = SROAArg; onInitializeSROAArg(SROAArg); + EnabledSROAAllocas.insert(SROAArg); } } }