[llvm] [DenseMap] Fix constness issues with lookup_or (PR #139247)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 9 05:01:14 PDT 2025
================
@@ -9571,15 +9571,14 @@ getConstantEvolvingPHIOperands(Instruction *UseInst, const Loop *L,
if (!OpInst || !canConstantEvolve(OpInst, L)) return nullptr;
PHINode *P = dyn_cast<PHINode>(OpInst);
- if (!P)
+ if (!P) {
// If this operand is already visited, reuse the prior result.
// We may have P != PHI if this is the deepest point at which the
// inconsistent paths meet.
- P = PHIMap.lookup(OpInst);
- if (!P) {
// Recurse and memoize the results, whether a phi is found or not.
// This recursive call invalidates pointers into PHIMap.
- P = getConstantEvolvingPHIOperands(OpInst, L, PHIMap, Depth + 1);
+ P = PHIMap.lookup_or(
+ OpInst, getConstantEvolvingPHIOperands(OpInst, L, PHIMap, Depth + 1));
----------------
nikic wrote:
This is goign to unconditionally recurse to compute the default. The point of the check is to not do the recursion if the entry already exists...
https://github.com/llvm/llvm-project/pull/139247
More information about the llvm-commits
mailing list