This is an archive of the discontinued LLVM Phabricator instance.

Make sure BitcodeWriter works with Unicode characters
AbandonedPublic

Authored by loladiro on Nov 9 2014, 1:16 PM.

Details

Reviewers
None
Summary

Previously when a metadata string contained unicode characters,
it would be incorrectly placed in the Record array because chars
are signed by default and hence characters with the high bit set
would get sign extended, but the bitcode writer was attempting
to write the lowest 8 bit of the now sign-extended value. This
caused an assertion failure later on. The fix is just to cast
the pointer to uint8_t* first to prevent sign extension.
This came up in the context for metadata strings, but I did a
quick pass and changed the other instances of this pattern in
the file as well.

Diff Detail

Event Timeline

loladiro updated this revision to Diff 15959.Nov 9 2014, 1:16 PM
loladiro retitled this revision from to Make sure BitcodeWriter works with Unicode characters.
loladiro updated this object.
loladiro edited the test plan for this revision. (Show Details)
loladiro set the repository for this revision to rL LLVM.
loladiro added a subscriber: Unknown Object (MLST).

I'm a bit confused why we're widening chars into 64 bit values - is there a quick explanation for that? (it seems inefficient to put one char in each 64 bit entry in Record, rather than putting 8 of them in there)

If Record is actually bytes, it has the wrong type, doesn't it - it should be SmallString, or SmallVector<uint8_t>, etc...

As far as I understand, the bitcode supports arbitrarily sized fields defined at runtime, so everything goes through uint64_t.

In D6184#6, @loladiro wrote:

As far as I understand, the bitcode supports arbitrarily sized fields defined at runtime, so everything goes through uint64_t.

Seems a bit strange but certainly getting out of my depth - thanks for the explanation :)

loladiro abandoned this revision.Dec 27 2014, 4:58 AM