From 868381bff6042d7d50e635a40bea2bf8b9011a87 Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Mon, 22 Aug 2016 19:14:16 +0000 Subject: [PATCH] MSSA: Only rename accesses whose defining access is nullptr llvm-svn: 279461 --- llvm/lib/Transforms/Utils/MemorySSA.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp index a99cfa5..af2f954 100644 --- a/llvm/lib/Transforms/Utils/MemorySSA.cpp +++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp @@ -1123,21 +1123,13 @@ MemoryAccess *MemorySSA::renameBlock(BasicBlock *BB, if (It != PerBlockAccesses.end()) { AccessList *Accesses = It->second.get(); for (MemoryAccess &L : *Accesses) { - switch (L.getValueID()) { - case Value::MemoryUseVal: - cast(&L)->setDefiningAccess(IncomingVal); - break; - case Value::MemoryDefVal: - // We can't legally optimize defs, because we only allow single - // memory phis/uses on operations, and if we optimize these, we can - // end up with multiple reaching defs. Uses do not have this - // problem, since they do not produce a value - cast(&L)->setDefiningAccess(IncomingVal); - IncomingVal = &L; - break; - case Value::MemoryPhiVal: + if (MemoryUseOrDef *MUD = dyn_cast(&L)) { + if (MUD->getDefiningAccess() == nullptr) + MUD->setDefiningAccess(IncomingVal); + if (isa(&L)) + IncomingVal = &L; + } else { IncomingVal = &L; - break; } } } -- 2.7.4