Index: lib/Transforms/Utils/MemorySSA.cpp =================================================================== --- lib/Transforms/Utils/MemorySSA.cpp +++ lib/Transforms/Utils/MemorySSA.cpp @@ -1044,6 +1044,14 @@ if (isa(I)) return StartingAccess; + // Start with the thing we already think clobbers this location + MemoryAccess *DefiningAccess = StartingAccess->getDefiningAccess(); + + // At this point, DefiningAccess may be the live on entry def. + // If it is, we will not get a better result. + if (MSSA->isLiveOnEntryDef(DefiningAccess)) + return DefiningAccess; + UpwardsMemoryQuery Q; Q.OriginalAccess = StartingAccess; Q.IsCall = bool(ImmutableCallSite(I)); @@ -1051,17 +1059,9 @@ Q.StartingLoc = MemoryLocation::get(I); Q.Inst = I; Q.DL = &Q.Inst->getModule()->getDataLayout(); - if (auto CacheResult = doCacheLookup(StartingAccess, Q, Q.StartingLoc)) + if (auto CacheResult = doCacheLookup(DefiningAccess, Q, Q.StartingLoc)) return CacheResult; - // Start with the thing we already think clobbers this location - MemoryAccess *DefiningAccess = StartingAccess->getDefiningAccess(); - - // At this point, DefiningAccess may be the live on entry def. - // If it is, we will not get a better result. - if (MSSA->isLiveOnEntryDef(DefiningAccess)) - return DefiningAccess; - MemoryAccess *Result = getClobberingMemoryAccess(DefiningAccess, Q); doCacheInsert(Q.OriginalAccess, Result, Q, Q.StartingLoc); // TODO: When this implementation is more mature, we may want to figure out