This is an archive of the discontinued LLVM Phabricator instance.

Fix for aggregate copying of variable length arrays.
ClosedPublic

Authored by ABataev on May 19 2015, 6:40 AM.

Details

Summary

Patch fixes codegen for aggregate copying of VLAs. Currently method CodeGenFunction::EmitAggregateCopy() does not support copying of VLAs. Patch checks if the size of the type is 0, then checks if the type is actually a variable-length array. Then it calculates total length for this array and calculates total size of the array in bytes:

<total number of elements in array> * aligned_sizeof(ElementType) (if copy assignment is requested).

If simple copying is requested, size is calculated like:

<total number of elements in array> * aligned_sizeof(ElementType) - aligned_sizeof(ElementType) + sizeof(ElementType).

memcpy() is used with this calculated size of the VLA.

Diff Detail

Repository
rL LLVM

Event Timeline

ABataev updated this revision to Diff 26054.May 19 2015, 6:40 AM
ABataev retitled this revision from to Fix for aggregate copying of variable length arrays..
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added a reviewer: rjmccall.
ABataev added a subscriber: Unknown Object (MLST).
This revision was automatically updated to reflect the committed changes.