diff options
-rw-r--r-- | llvm/lib/Transforms/Utils/MemorySSA.cpp | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/Util/MemorySSA/livein.ll | 23 |
2 files changed, 25 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp index f49d666d1a0..a794406da15 100644 --- a/llvm/lib/Transforms/Utils/MemorySSA.cpp +++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp @@ -253,17 +253,13 @@ MemorySSAWalker *MemorySSA::buildMemorySSA(AliasAnalysis *AA, // Go through each block, figure out where defs occur, and chain together all // the accesses. for (BasicBlock &B : F) { - bool InsertIntoDefUse = false; bool InsertIntoDef = false; AccessListType *Accesses = nullptr; for (Instruction &I : B) { MemoryUseOrDef *MUD = createNewAccess(&I, true); if (!MUD) continue; - if (isa<MemoryDef>(MUD)) - InsertIntoDef = true; - else - InsertIntoDefUse = true; + InsertIntoDef |= isa<MemoryDef>(MUD); if (!Accesses) Accesses = getOrCreateAccessList(&B); @@ -271,7 +267,7 @@ MemorySSAWalker *MemorySSA::buildMemorySSA(AliasAnalysis *AA, } if (InsertIntoDef) DefiningBlocks.insert(&B); - if (InsertIntoDefUse) + if (Accesses) DefUseBlocks.insert(&B); } diff --git a/llvm/test/Transforms/Util/MemorySSA/livein.ll b/llvm/test/Transforms/Util/MemorySSA/livein.ll index c6d78149a67..92d09f9c681 100644 --- a/llvm/test/Transforms/Util/MemorySSA/livein.ll +++ b/llvm/test/Transforms/Util/MemorySSA/livein.ll @@ -27,3 +27,26 @@ merge: %c = load i8, i8* %0 ret void } + +; Ensure we treat def-only blocks as though they have uses for phi placement. +; CHECK-LABEL: define void @F3 +define void @F3() { + %a = alloca i8 +; CHECK: 1 = MemoryDef(liveOnEntry) +; CHECK-NEXT: store i8 0, i8* %a + store i8 0, i8* %a + br i1 undef, label %if.then, label %if.end + +if.then: +; CHECK: 2 = MemoryDef(1) +; CHECK-NEXT: store i8 1, i8* %a + store i8 1, i8* %a + br label %if.end + +if.end: +; CHECK: 4 = MemoryPhi({%0,1},{if.then,2}) +; CHECK: 3 = MemoryDef(4) +; CHECK-NEXT: store i8 2, i8* %a + store i8 2, i8* %a + ret void +} |