summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2015-08-11 00:49:20 +0000
committerJF Bastien <jfb@google.com>2015-08-11 00:49:20 +0000
commite73ce68225f26586c7ee1445161a2cb0a5741955 (patch)
tree4c8a3757129c9eaa7970d2bfc3d36696aeb7381c /llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
parent2d5802f38d064b54f6895154309289bf36927738 (diff)
downloadbcm5719-llvm-e73ce68225f26586c7ee1445161a2cb0a5741955.tar.gz
bcm5719-llvm-e73ce68225f26586c7ee1445161a2cb0a5741955.zip
WebAssembly: simply assert on SNaN and NaNs with payloads
Summary: convertToHexString doesn't represent them correctly at this point in time. This is a follow-up to sunfish's suggestion in D11914. Subscribers: llvm-commits, sunfish, jfb Differential Revision: http://reviews.llvm.org/D11925 llvm-svn: 244551
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index 35a4be3805d..1c24e445a92 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -117,10 +117,11 @@ void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
static const size_t BufBytes = 128;
char buf[BufBytes];
APFloat FP = MO.getFPImm()->getValueAPF();
- const APFloat CanonicalNaN = APFloat::getQNaN(FP.getSemantics());
- if (FP.isNaN() && !FP.bitwiseIsEqual(CanonicalNaN))
- // WebAssembly only has NaNs that are positive, quiet, without payload.
- FP = CanonicalNaN;
+ if (FP.isNaN())
+ assert((FP.bitwiseIsEqual(APFloat::getQNaN(FP.getSemantics())) ||
+ FP.bitwiseIsEqual(
+ APFloat::getQNaN(FP.getSemantics(), /*Negative=*/true))) &&
+ "convertToHexString handles neither SNaN nor NaN payloads");
// Use C99's hexadecimal floating-point representation.
auto Written =
FP.convertToHexString(buf, /*hexDigits=*/0, /*upperCase=*/false,
OpenPOWER on IntegriCloud