This is an archive of the discontinued LLVM Phabricator instance.

Fix for clang memcpyizer bugs 23911 and 23924
ClosedPublic

Authored by d.zobnin.bugzilla on Jul 7 2015, 5:05 AM.

Details

Summary

The fix is to remove duplicate copy-initialization of the only memcpy-able struct member and to correct the address of aggregately initialized members in destructors' calls during stack unwinding (in order to obtain address of struct member by using GEP instead of 'bitcast').

Diff Detail

Repository
rL LLVM

Event Timeline

d.zobnin.bugzilla retitled this revision from to Fix for clang memcpyizer bugs 23911 and 23924.
d.zobnin.bugzilla updated this object.
d.zobnin.bugzilla set the repository for this revision to rL LLVM.
d.zobnin.bugzilla added a subscriber: cfe-commits.
rjmccall added inline comments.Jul 7 2015, 10:11 AM
lib/CodeGen/CGClass.cpp
1105 ↗(On Diff #29161)

Wow, the old code here was really impressively broken. Saved by the rule of 3/5, I guess.

Okay, two code organization requests. Please add a method on CXXCtorInitializer to get the type of the initialized member. Then, please extract a function in this file to drill down to the initialized member of a CXXCtorInitializer.

With that combination, the code here should end up looking really straightforward.

Please also update EmitMemberInitializer to use your new functions.

d.zobnin.bugzilla removed rL LLVM as the repository for this revision.

A function to emit lvalue for any field initialization was added (it also drills down to the field of anonymous unions). The code was adapted to work with this new function.
In previous review there was a request to add a method to CXXCtorInitializer to get the type of the initialized member. I realized that this can be done simply by getAnyMember()->getType() and decided not to add this method, because the new code looks pretty straightforward, I think.

rjmccall edited edge metadata.Jul 13 2015, 11:26 AM

LGTM, thanks!

This revision was automatically updated to reflect the committed changes.