diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-10 17:26:38 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-10 17:26:38 -0800 |
commit | ec23adbe311396b12ff8c8c488b087012a8f73d5 (patch) | |
tree | 5d681b90c9d2b71227b92989a4b645383e7c28ef /lib/Target/JSBackend/JSBackend.cpp | |
parent | 198c1370934c988cff7262df5845a05c7feef0ab (diff) |
handle some more odd constants that exception code can contain
Diffstat (limited to 'lib/Target/JSBackend/JSBackend.cpp')
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 9ec4e64641..08aa6a1acf 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -750,11 +750,15 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) { } else if (isa<UndefValue>(CV)) { return CV->getType()->isIntegerTy() ? "0" : "+0"; // XXX fround, refactor this } else if (isa<ConstantAggregateZero>(CV)) { - const VectorType *VT = cast<VectorType>(CV->getType()); - if (VT->getElementType()->isIntegerTy()) { - return "int32x4.splat(0)"; + if (VectorType *VT = dyn_cast<VectorType>(CV->getType())) { + if (VT->getElementType()->isIntegerTy()) { + return "int32x4.splat(0)"; + } else { + return "float32x4.splat(0)"; + } } else { - return "float32x4.splat(0)"; + // something like [0 x i8*] zeroinitializer, which clang can emit for landingpads + return "0"; } } else if (const ConstantDataVector *DV = dyn_cast<ConstantDataVector>(CV)) { const VectorType *VT = cast<VectorType>(CV->getType()); @@ -773,10 +777,9 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) { // handle things like [i8* bitcast (<{ i32, i32, i32 }>* @_ZTISt9bad_alloc to i8*)] which clang can emit for landingpads assert(CA->getNumOperands() == 1); CV = CA->getOperand(0); - if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { - CV = CE->getOperand(0); // ignore bitcasts - } - return getConstant(CV, sign); + const ConstantExpr *CE = cast<ConstantExpr>(CV); + CV = CE->getOperand(0); // ignore bitcast + return getPtrAsStr(CV); } else { dumpIR(CV); assert(false); |