[Support][unittests] Enforce alignment in ConvertUTFTest
authorRainer Orth <ro@gcc.gnu.org>
Wed, 7 Oct 2020 07:08:41 +0000 (09:08 +0200)
committerRainer Orth <ro@gcc.gnu.org>
Wed, 7 Oct 2020 07:08:41 +0000 (09:08 +0200)
commit53b3873cf428fd78f1d92504cc20adf11181ead7
treed797a492586c506d7b033a97f800bab827e61888
parentfba42aea438cc4c93233a10703e83f45035ffa64
[Support][unittests] Enforce alignment in ConvertUTFTest

`LLVM-Unit :: Support/./SupportTests/ConvertUTFTest.ConvertUTF16LittleEndianToUTF8String`
`FAIL`s on Solaris/sparcv9:

In `llvm/lib/Support/ConvertUTFWrapper.cpp` (`convertUTF16ToUTF8String`)
the `SrcBytes` arg is reinterpreted/accessed as `UTF16` (`unsigned short`,
which requires 2-byte alignment on strict-alignment targets like Sparc)
without anything guaranteeing the alignment, so the access yields a
`SIGBUS`.

This patch avoids this by enforcing the required alignment in the callers.

Tested on `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D88824
llvm/lib/Support/ConvertUTFWrapper.cpp
llvm/unittests/Support/ConvertUTFTest.cpp