As suggested on D76788, this switches the LVI implementation to return Optional<ValueLatticeElement> from various methods, instead of passing in a ValueLatticeElement reference and returning a boolean.
Details
Diff Detail
Event Timeline
lib/Analysis/LazyValueInfo.cpp | ||
---|---|---|
839 | My C++ foo is weak... would the proper way to write this without copying the lattice value be TrueValue = *std::move(OptTrueVal)? |
lib/Analysis/LazyValueInfo.cpp | ||
---|---|---|
839 | Hm, it looks like moving an Optional moves the value (rather than making the Optional empty). As ValueLatticeElement does not specify a move constructor, I guess that means it would end up being copied, so that probably doesn't make sense. |
lib/Analysis/LazyValueInfo.cpp | ||
---|---|---|
839 | Can this just be ValueLatticeElement &TrueVal? |
lib/Analysis/LazyValueInfo.cpp | ||
---|---|---|
839 | Right, I went with that variant now. The use of Optional will still make for a small but measurable regression (~0.1%), but that seems acceptable to me. I'll also submit a followup to add a move constructor to ValueLatticeElement. It makes no difference for performance in practice, because we usually deal with APInts <= 64 bits, so move and copy constructor do about the same work. It would make a difference for large APInts. |
My C++ foo is weak... would the proper way to write this without copying the lattice value be TrueValue = *std::move(OptTrueVal)?