[PATCH] D78383: [LVI] Use Optional instead of out parameter (NFC)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 10:14:54 PDT 2020


nikic created this revision.
nikic added reviewers: fhahn, reames.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
nikic marked an inline comment as done.
nikic added inline comments.
nikic marked an inline comment as done.


================
Comment at: lib/Analysis/LazyValueInfo.cpp:839
+    return None;
+  ValueLatticeElement TrueVal = *OptTrueVal;
 
----------------
My C++ foo is weak... would the proper way to write this without copying the lattice value be `TrueValue = *std::move(OptTrueVal)`?


================
Comment at: lib/Analysis/LazyValueInfo.cpp:839
+    return None;
+  ValueLatticeElement TrueVal = *OptTrueVal;
 
----------------
nikic wrote:
> My C++ foo is weak... would the proper way to write this without copying the lattice value be `TrueValue = *std::move(OptTrueVal)`?
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.


As suggested on D76788 <https://reviews.llvm.org/D76788>, this switches the LVI implementation to return Optional<ValueLatticeElement> from various methods, instead of passing in a ValueLatticeElement reference and returning a boolean.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78383

Files:
  lib/Analysis/LazyValueInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78383.258356.patch
Type: text/x-patch
Size: 33609 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200417/7bee2f01/attachment.bin>


More information about the llvm-commits mailing list