[PATCH] D32276: [AsmWriter/APFloat] FP constant printing: Avoid usage of locale dependent snprinf
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 01:11:15 PDT 2017
skatkov created this revision.
This should fix the bug https://bugs.llvm.org/show_bug.cgi?id=12906
To print the FP constant AsmWriter does the following:
1. convert FP value to String (actually using snprintf function which is locale dependent).
2. Convert String back to FP Value
3. Compare original and got FP values. If they are not equal just dump as hex.
The problem happens on the 2nd step when APFloat does not expect group delimiter or
fraction delimiter other than period symbol and so on, which can be produced on the
first step if LLVM library is used in an environment with corresponding locale set.
To fix this issue the locale independent APFloat:toString function is used.
However it prints FP values slightly differently than snprintf does. Specifically
it suppress trailing zeros in significant, use capital E and so on.
It results in 117 test failures during make check.
To avoid this I've also updated APFloat.toString a bit to pass make check at least.
https://reviews.llvm.org/D32276
Files:
include/llvm/ADT/APFloat.h
lib/IR/AsmWriter.cpp
lib/Support/APFloat.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32276.95901.patch
Type: text/x-patch
Size: 7954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170420/5616ffdf/attachment-0001.bin>
More information about the llvm-commits
mailing list