[Re-submitting to cfe-commits]
Hi All,
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.
I have attached the patch along with a simple test case to reproduce the
problem.
patch.llvm - clang fix to handle wide string literal alignment correctly.
patch.test - patch to a test case problem in llvm/test regression directory.
wstr_main.c - declares a string "ab" and a wide string L"AZ" and calls foo.
String "ab" causes string literal "AZ" to start from an offset of 3 ('a',
'b', '\0').
wstr_copy.c - attempts to copy a single wide char from L"AZ" into a global
wide string array. This results in unaligned load exception since it tries
to load 4 bytes from an address which is 3 byte aligned.
makefile - makefile to reproduce the problem.
failures.txt - failure report and explanation from running llvm/test and
projects/test-suite.
This is my first attempt to commit into LLVM repository. I followed
guidelines from "LLVM Developer Policy". Please let me know if I missed
something or if you guys need any additional information.
Thanks,
Sundeep
patch.llvm
Description: Binary data
patch.test
Description: Binary data
makefile
Description: Binary data
wstr_copy.c
Description: Binary data
wstr_main.c
Description: Binary data
1. Existing llvm/test failures svn (revision 135914)
Clang :: Analysis/iterators.cpp
Clang :: Driver/hello.c
Clang :: Preprocessor/macro_paste_c_block_comment.c
2. New llvm/test failures after patch
Clang :: CodeGen/string-literal.c
Reason for the failure: test case problem.
Patch for the test case: patch.test
3. Existing llvm/projects/test-suite failures from svn (revision 135914)
MultiSource/Applications/Burg/burg | pass
6.3200 * 0.0000
MultiSource/Applications/ClamAV/clamscan | pass
89.7900 * 0.1300
MultiSource/Applications/SPASS/SPASS | pass
84.2100 * 0.5900
MultiSource/Applications/d/make_dparser | pass
20.2500 * 0.0200
MultiSource/Applications/kimwitu++/kc | pass
100.7500 * 0.0300
MultiSource/Applications/lemon/lemon | pass
6.0100 * 1.1800
MultiSource/Applications/obsequi/Obsequi | pass
6.1600 * 3.0800
MultiSource/Benchmarks/FreeBench/distray/distray | pass
0.5600 * 0.1200
MultiSource/Benchmarks/McCat/01-qbsort/qbsort | pass
0.4600 * 0.0800
MultiSource/Benchmarks/McCat/08-main/main | pass
1.6100 * 0.0400
MultiSource/Benchmarks/MiBench/automotive-basicmath/automotive-basicmath | pass
0.7300 * 0.3900
MultiSource/Benchmarks/MiBench/automotive-bitcount/automotive-bitcount | pass
1.0600 * 0.0900
MultiSource/Benchmarks/MiBench/automotive-susan/automotive-susan | pass
5.7800 * 0.0400
MultiSource/Benchmarks/MiBench/network-patricia/network-patricia | pass
0.4400 * 0.1000
MultiSource/Benchmarks/MiBench/security-rijndael/security-rijndael | pass
4.8200 * 0.0200
MultiSource/Benchmarks/MiBench/telecomm-FFT/telecomm-fft | pass
0.6000 * 0.0500
MultiSource/Benchmarks/MiBench/telecomm-gsm/telecomm-gsm | pass
7.2800 * 0.2200
MultiSource/Benchmarks/Olden/voronoi/voronoi | pass
1.3400 * 0.0300
MultiSource/Benchmarks/Prolangs-C++/employ/employ | pass
2.5800 * 0.0100
MultiSource/Benchmarks/Prolangs-C/agrep/agrep | pass
6.7600 * 0.0000
MultiSource/Benchmarks/Prolangs-C/gnugo/gnugo | pass
2.8900 * 0.0500
MultiSource/Benchmarks/Ptrdist/anagram/anagram | pass
0.4600 * 0.9100
MultiSource/Benchmarks/Ptrdist/bc/bc | pass
6.6100 * 0.5300
MultiSource/Benchmarks/Ptrdist/ft/ft | pass
0.9500 * 1.0300
MultiSource/Benchmarks/Ptrdist/yacr2/yacr2 | pass
3.8600 * 0.7800
MultiSource/Benchmarks/VersaBench/beamformer/beamformer | pass
0.5800 * 0.2500
MultiSource/Benchmarks/mediabench/adpcm/rawdaudio/rawdaudio | pass
0.1900 * 0.0000
SingleSource/Benchmarks/BenchmarkGame/Large/fasta | pass
0.2200 * 0.9000
SingleSource/Benchmarks/BenchmarkGame/puzzle | pass
0.1800 * 0.4400
SingleSource/Benchmarks/Misc-C++/Large/ray | pass
2.6100 * 0.2300
SingleSource/Benchmarks/Misc-C++/Large/sphereflake | pass
2.4900 * 0.1600
SingleSource/UnitTests/SignlessTypes/Large/cast | pass
0.3400 * 0.0000
4. New llvm/projects/test-suite failures after patch
None
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
