summaryrefslogtreecommitdiff
path: root/src/passes/InstrumentMemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/InstrumentMemory.cpp')
-rw-r--r--src/passes/InstrumentMemory.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/passes/InstrumentMemory.cpp b/src/passes/InstrumentMemory.cpp
index 1180c5183..486bc7c1f 100644
--- a/src/passes/InstrumentMemory.cpp
+++ b/src/passes/InstrumentMemory.cpp
@@ -100,8 +100,9 @@ struct InstrumentMemory : public WalkerPass<PostWalker<InstrumentMemory>> {
void visitLoad(Load* curr) {
id++;
Builder builder(*getModule());
- auto indexType = getModule()->memory.indexType;
- auto offset = builder.makeConstPtr(curr->offset.addr);
+ auto mem = getModule()->getMemory(curr->memory);
+ auto indexType = mem->indexType;
+ auto offset = builder.makeConstPtr(curr->offset.addr, indexType);
curr->ptr = builder.makeCall(load_ptr,
{builder.makeConst(int32_t(id)),
builder.makeConst(int32_t(curr->bytes)),
@@ -132,8 +133,9 @@ struct InstrumentMemory : public WalkerPass<PostWalker<InstrumentMemory>> {
void visitStore(Store* curr) {
id++;
Builder builder(*getModule());
- auto indexType = getModule()->memory.indexType;
- auto offset = builder.makeConstPtr(curr->offset.addr);
+ auto mem = getModule()->getMemory(curr->memory);
+ auto indexType = mem->indexType;
+ auto offset = builder.makeConstPtr(curr->offset.addr, indexType);
curr->ptr = builder.makeCall(store_ptr,
{builder.makeConst(int32_t(id)),
builder.makeConst(int32_t(curr->bytes)),
@@ -246,7 +248,8 @@ struct InstrumentMemory : public WalkerPass<PostWalker<InstrumentMemory>> {
}
void visitModule(Module* curr) {
- auto indexType = curr->memory.indexType;
+ auto indexType =
+ curr->memories.empty() ? Type::i32 : curr->memories[0]->indexType;
// Load.
addImport(