Skip to content

Commit b08b9a5

Browse files
committed
MappedMemory: Fix typing of intrinsics
1 parent 1959157 commit b08b9a5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

llvm/include/llvm/IR/IntrinsicsCheerp.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def int_cheerp_local_store : Intrinsic<[],
156156
[llvm_ptr_ty, llvm_any_ty]>;
157157

158158
def int_cheerp_checked_load : Intrinsic<[llvm_any_ty],
159-
[llvm_i32_ty, llvm_i32_ty]>;
159+
[llvm_anyptr_ty, llvm_anyptr_ty]>;
160160

161161
def int_cheerp_checked_store : Intrinsic<[],
162-
[llvm_i32_ty, llvm_i32_ty, llvm_any_ty, llvm_any_ty]>;
162+
[llvm_anyptr_ty, llvm_anyptr_ty, llvm_any_ty, llvm_any_ty]>;
163163

164164
def int_cheerp_func_id : Intrinsic<[llvm_i32_ty],
165165
[]>;

llvm/lib/CheerpUtils/CheckedLoadStore.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)