@@ -42,7 +42,8 @@ bool CheckLoadStore::runOnFunction(Module& M, Function& F)
4242 if (isa<Constant>(pointerOperand))
4343 continue ;
4444 Type* loadType = LI->getType ();
45- Function* checkedLoad = Intrinsic::getDeclaration (&M, Intrinsic::cheerp_checked_load, loadType);
45+ Type* pointerType = pointerOperand->getType ();
46+ Function* checkedLoad = Intrinsic::getDeclaration (&M, Intrinsic::cheerp_checked_load, { loadType, pointerType, pointerType } );
4647 CallInst* CI = CallInst::Create (checkedLoad, { pointerOperand, pointerOperand }, " " , LI);
4748 LI->replaceAllUsesWith (CI);
4849 toDelete.push_back (LI);
@@ -55,9 +56,11 @@ bool CheckLoadStore::runOnFunction(Module& M, Function& F)
5556 Value* pointerOperand = SI->getPointerOperand ();
5657 if (isa<Constant>(pointerOperand))
5758 continue ;
58- Type* storeType = SI->getValueOperand ()->getType ();
59- Function* checkedStore = Intrinsic::getDeclaration (&M, Intrinsic::cheerp_checked_store, { storeType, storeType });
60- CallInst::Create (checkedStore, { pointerOperand, pointerOperand, SI->getValueOperand (), SI->getValueOperand () }, " " , SI);
59+ Value* valueOperand = SI->getValueOperand ();
60+ Type* storeType = valueOperand->getType ();
61+ Type* pointerType = pointerOperand->getType ();
62+ Function* checkedStore = Intrinsic::getDeclaration (&M, Intrinsic::cheerp_checked_store, { pointerType, pointerType, storeType, storeType });
63+ CallInst::Create (checkedStore, { pointerOperand, pointerOperand, valueOperand, valueOperand }, " " , SI);
6164 // No need to replace users, stores are void
6265 toDelete.push_back (SI);
6366 }
0 commit comments