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

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 6 13:27:38 PST 2018

rjmccall added inline comments.

Comment at: include/clang/AST/Expr.h:875
+  /// is set to true.
+  bool IsUnique = false;
rjmccall wrote:
> Humor me and pack this in the bitfields in Stmt, please. :)

Comment at: lib/CodeGen/CGExpr.cpp:4815
+    }
+  }
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.


More information about the cfe-commits mailing list