[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 7 09:44:55 PST 2018


ahatanak added inline comments.


================
Comment at: lib/CodeGen/CGExpr.cpp:4815
+    }
+  }
+
----------------
rjmccall wrote:
> Oh!  So it's an interesting point that the RHS might be used as the result expression, which means its use might not really be unique anymore.  It happens to work in some sense for non-trivial C++ class types (when they're passed indirectly, as under the Itanium ABI) because the temporary outlives the call; on the other hand, the call is allowed to mutate its argument, and it's not clear that it's okay to have those mutations be reflected in code that's using the result of the assignment.  Similarly, managed types (like non-trivial C structs, or ARC pointers) might be consumed by the call; if we're going to pass them, perhaps we need to copy the value before doing so.
> 
> What do you think?
> 
> I think the technical implication is that what you're doing here shouldn't be necessary; the OVE arguably should not be unique if its value is used in multiple places, and that includes being used as a result.
I made changes so that OVEs used as the result expression are not marked as unique. I wasn't sure whether treating such OVEs as unique would actually cause problems, but it's probably better to be on the safe side.


https://reviews.llvm.org/D39562





More information about the cfe-commits mailing list