From 52a1d7a4bb4e39ea7b8a82c8dc71a9c135f5dfc9 Mon Sep 17 00:00:00 2001 From: doe300 Date: Fri, 16 Nov 2018 11:57:15 +0100 Subject: [PATCH] Fixes rebase issues, copies fixes from master --- src/normalization/MemoryMapChecks.cpp | 12 ++++++++++-- src/normalization/MemoryMappings.h | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/normalization/MemoryMapChecks.cpp b/src/normalization/MemoryMapChecks.cpp index 428c1f3d..3c87b394 100644 --- a/src/normalization/MemoryMapChecks.cpp +++ b/src/normalization/MemoryMapChecks.cpp @@ -97,7 +97,8 @@ static bool isMemoryOnlyRead(const Local* local) } // Finds the next instruction writing the given value into memory -static InstructionWalker findNextValueStore(InstructionWalker it, const Value& src, std::size_t limit) +static InstructionWalker findNextValueStore( + InstructionWalker it, const Value& src, std::size_t limit, const Local* sourceLocation) { while(!it.isEndOfBlock() && limit > 0) { @@ -106,6 +107,12 @@ static InstructionWalker findNextValueStore(InstructionWalker it, const Value& s { return it; } + if(memInstr != nullptr && memInstr->getDestination().local()->getBase(true) == sourceLocation) + { + // there is some other instruction writing into the memory we read, it could have been changed -> abort + // TODO can we be more precise and abort only if the same index is written?? How to determine?? + return it.getBasicBlock()->walkEnd(); + } if(it.has() || it.has() || it.has() || it.has()) break; it.nextInBlock(); @@ -173,7 +180,8 @@ std::pair> normalization::determineM if(memInstr->op == MemoryOperation::READ && !memInstr->hasConditionalExecution() && memInstr->getDestination().local()->getUsers(LocalUse::Type::READER).size() == 1) { - auto nextIt = findNextValueStore(it, memInstr->getDestination(), 16 /* TODO */); + auto nextIt = findNextValueStore( + it, memInstr->getDestination(), 16 /* TODO */, memInstr->getSource().local()->getBase(true)); auto nextMemInstr = nextIt.isEndOfBlock() ? nullptr : nextIt.get(); if(nextMemInstr != nullptr && !nextIt->hasConditionalExecution() && nextMemInstr->op == MemoryOperation::WRITE && diff --git a/src/normalization/MemoryMappings.h b/src/normalization/MemoryMappings.h index 933f8793..424824f6 100644 --- a/src/normalization/MemoryMappings.h +++ b/src/normalization/MemoryMappings.h @@ -71,7 +71,7 @@ namespace vc4c */ InstructionWalker mapMemoryAccess(Method& method, InstructionWalker it, intermediate::MemoryInstruction* mem, const MemoryInfo& srcInfo, const MemoryInfo& destInfo); - } -} + } // namespace normalization +} // namespace vc4c #endif /* VC4C_NORMALIZATION_MEMORY_MAPPING_H */ \ No newline at end of file