This is an archive of the discontinued LLVM Phabricator instance.

Fix infinite recursion in MCAsmStreamer::EmitValueImpl
ClosedPublic

Authored by alexandru.guduleasa on Dec 23 2015, 4:09 AM.

Details

Summary

If a target can only emit 8-bits data, it will loop in EmitValueImpl since it will try to split a 32-bits data in 1 chunk of 32-bits.
Since we know that "Size" is not supported on the target, we limit the value of "EmissionSize" to the greatest power of 2, smaller than "Size".

Diff Detail

Event Timeline

alexandru.guduleasa retitled this revision from to Fix infinite recursion in MCAsmStreamer::EmitValueImpl.
alexandru.guduleasa updated this object.

Can this be tested?

EmissionSize can now go out of the loop.

The comment just before the code you changed needs to be updated.

alexandru.guduleasa updated this object.

I've updated the comment just above the changes.
Also, I've computed the EmissionSize based on the min of (Size - 1) and Remaining.
This is closer to the original implementation.
If Size is a number that is not a power of 2 (e.g. 7), this should result in a 4+2+1 split in normal cases.
If the target does not support 4, instead of looping we will split as 2+2+2+1; the 2 values may be split as 1+1 if required.

Unfortunately, this can't be tested since I don't think there is a target in the official repository that can't emit 4 bytes.

rafael accepted this revision.Jan 18 2016, 8:42 AM
rafael added a reviewer: rafael.

LGTM

This revision is now accepted and ready to land.Jan 18 2016, 8:42 AM

Thank you for the review!
Can someone help me commit this?

rafael closed this revision.Feb 1 2016, 12:41 PM

r259399.