aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-14 10:21:33 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-14 10:34:03 -0800
commit9c0197b97dc9b5be2132f8e6ebe9737d0d7dd7c1 (patch)
tree2e91ed6b131d87532e650a5d6c9b6dac042c8936
parent68dd4be42198fae720e6c7a343e4704124bf87d5 (diff)
emit bool constants as unsigned in a consistent manner
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index 174e6b1141..0d83a6a319 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -865,7 +865,9 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) {
}
return S;
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
- if (sign == ASM_SIGNED && CI->getValue().getBitWidth() == 1) sign = ASM_UNSIGNED; // booleans cannot be signed in a meaningful way
+ if (sign != ASM_UNSIGNED && CI->getValue().getBitWidth() == 1) {
+ sign = ASM_UNSIGNED; // bools must always be unsigned: either 0 or 1
+ }
return CI->getValue().toString(10, sign != ASM_UNSIGNED);
} else if (isa<UndefValue>(CV)) {
return CV->getType()->isIntegerTy() ? "0" : getCast("0", CV->getType());