Skip to content

Commit

Permalink
Fixes rebase issues, copies fixes from master
Browse files Browse the repository at this point in the history
  • Loading branch information
doe300 committed Dec 20, 2018
1 parent 349985d commit 52a1d7a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/normalization/MemoryMapChecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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<MemoryBarrier>() || it.has<Branch>() || it.has<MutexLock>() || it.has<SemaphoreAdjustment>())
break;
it.nextInBlock();
Expand Down Expand Up @@ -173,7 +180,8 @@ std::pair<MemoryAccessMap, FastSet<InstructionWalker>> 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<const MemoryInstruction>();
if(nextMemInstr != nullptr && !nextIt->hasConditionalExecution() &&
nextMemInstr->op == MemoryOperation::WRITE &&
Expand Down
4 changes: 2 additions & 2 deletions src/normalization/MemoryMappings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 52a1d7a

Please sign in to comment.