The previous patch no longer applies due to the my unicode string literal patch that went in last week. I took a stab at a new patch. Rather than using the different string kinds to get the proper alignment, I queried ASTContext for the alignment of the type contained in the StringLiteral. I push the alignment as an argument down to the functions that actually look up the string in the map. If we find a match in the map, I max the old alignment and the new alignment.
~Craig >> I have been working on a bug in clang dealing with alignment of wide >> strings. Clang is aligning wide string literals to 1 byte boundary. However, >> LLVM treats wide strings as 4 byte aligned and generates memory operations >> accessing 4 bytes at a time. This works fine on architectures that allow >> unaligned access. But for architectures which don't allow unaligned access, >> this results in an exception and segfault. > > + unsigned Align = TI.getWCharAlign() / TI.getCharAlign(); > > This should be dividing by the bit-width of char, not by its alignment. > > Also, there are multiple kinds of wide strings ? official wide strings (L), > and then UTF-16 (u) and UTF-32 (U) wide strings. It would be good if > this worked for all of them. You should also make sure that you never > *decrease* the alignment of a string, as you might if there were a > utf32 string literal followed by a utf16 string literal which expanded > to the same sequence of bytes. > > Also, in the future, please give your patch files some sort of sensible > file extension, preferably ".txt". > > John.
string_alignment.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
