@@ -873,6 +873,14 @@ CheerpWriter::COMPILE_INSTRUCTION_FEEDBACK CheerpWriter::handleBuiltinCall(const
873873 compileBitCast (&callV, PA.getPointerKindAssert (&callV), HIGHEST);
874874 return COMPILE_OK;
875875 }
876+ else if (intrinsicId==Intrinsic::cheerp_typed_ptrcast)
877+ {
878+ if (callV.use_empty ())
879+ return COMPILE_EMPTY;
880+
881+ compileBitCast (&callV, PA.getPointerKindAssert (&callV), HIGHEST);
882+ return COMPILE_OK;
883+ }
876884 else if (intrinsicId==Intrinsic::cheerp_pointer_base)
877885 {
878886 compilePointerBase (*it, true );
@@ -2008,6 +2016,7 @@ void CheerpWriter::compilePointerBaseTyped(const Value* p, Type* elementType, bo
20082016 switch (II->getIntrinsicID ())
20092017 {
20102018 case Intrinsic::cheerp_upcast_collapsed:
2019+ case Intrinsic::cheerp_typed_ptrcast:
20112020 case Intrinsic::cheerp_cast_user:
20122021 return compilePointerBaseTyped (II->getOperand (0 ), II->getParamElementType (0 ));
20132022 case Intrinsic::cheerp_make_regular:
@@ -2213,6 +2222,7 @@ void CheerpWriter::compilePointerOffset(const Value* p, PARENT_PRIORITY parentPr
22132222 switch (II->getIntrinsicID ())
22142223 {
22152224 case Intrinsic::cheerp_upcast_collapsed:
2225+ case Intrinsic::cheerp_typed_ptrcast:
22162226 case Intrinsic::cheerp_cast_user:
22172227 compilePointerOffset (II->getOperand (0 ), parentPrio);
22182228 return ;
@@ -4575,7 +4585,7 @@ void CheerpWriter::compileLoadElem(const LoadInst& li, Type* Ty, StructType* STy
45754585 assert (!STy);
45764586 // Optimize loads of single values from unions
45774587 compilePointerBase (ptrOp);
4578- assert (ptrOp->getType ()== Ty->getPointerTo ());
4588+ assert (ptrOp->getType ()== Ty->getPointerTo (ptrOp-> getType ()-> getPointerAddressSpace () ));
45794589 if (Ty->isIntegerTy (8 ))
45804590 stream << " .getUint8(" ;
45814591 else if (Ty->isIntegerTy (16 ))
0 commit comments