Skip to content

Commit

Permalink
[MemorySSA] Properly handle liveOnEntry in the walker printer
Browse files Browse the repository at this point in the history
Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D109177
  • Loading branch information
aeubanks committed Sep 2, 2021
1 parent 92b94a6 commit 813a7f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions llvm/lib/Analysis/MemorySSA.cpp
Expand Up @@ -95,6 +95,8 @@ static cl::opt<bool, true>
VerifyMemorySSAX("verify-memoryssa", cl::location(VerifyMemorySSA),
cl::Hidden, cl::desc("Enable verification of MemorySSA."));

const static char LiveOnEntryStr[] = "liveOnEntry";

namespace {

/// An assembly annotator class to print Memory SSA information in
Expand Down Expand Up @@ -133,8 +135,13 @@ class MemorySSAWalkerAnnotatedWriter : public AssemblyAnnotationWriter {
if (MemoryAccess *MA = MSSA->getMemoryAccess(I)) {
MemoryAccess *Clobber = Walker->getClobberingMemoryAccess(MA);
OS << "; " << *MA;
if (Clobber)
OS << " - clobbered by " << *Clobber;
if (Clobber) {
OS << " - clobbered by ";
if (MSSA->isLiveOnEntryDef(Clobber))
OS << LiveOnEntryStr;
else
OS << *Clobber;
}
OS << "\n";
}
}
Expand Down Expand Up @@ -2154,8 +2161,6 @@ bool MemorySSA::dominates(const MemoryAccess *Dominator,
return dominates(Dominator, cast<MemoryAccess>(Dominatee.getUser()));
}

const static char LiveOnEntryStr[] = "liveOnEntry";

void MemoryAccess::print(raw_ostream &OS) const {
switch (getValueID()) {
case MemoryPhiVal: return static_cast<const MemoryPhi *>(this)->print(OS);
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Analysis/MemorySSA/print-walker.ll
@@ -1,15 +1,15 @@
; RUN: opt -passes='print<memoryssa-walker>' -disable-output < %s 2>&1 | FileCheck %s

; CHECK: define void @test
; CHECK: 1 = MemoryDef(liveOnEntry)->liveOnEntry - clobbered by 0 = MemoryDef(liveOnEntry)
; CHECK: 1 = MemoryDef(liveOnEntry)->liveOnEntry - clobbered by liveOnEntry
; CHECK: store i8 42, i8* %a1
; CHECK: 2 = MemoryDef(1)->liveOnEntry - clobbered by 0 = MemoryDef(liveOnEntry)
; CHECK: 2 = MemoryDef(1)->liveOnEntry - clobbered by liveOnEntry
; CHECK: store i8 42, i8* %a2
; CHECK: MemoryUse(1) MustAlias - clobbered by 1 = MemoryDef(liveOnEntry)->liveOnEntry
; CHECK: %l1 = load i8, i8* %a1
; CHECK: MemoryUse(2) MustAlias - clobbered by 2 = MemoryDef(1)->liveOnEntry
; CHECK: %l2 = load i8, i8* %a2
; CHECK: 3 = MemoryDef(2)->liveOnEntry - clobbered by 0 = MemoryDef(liveOnEntry)
; CHECK: 3 = MemoryDef(2)->liveOnEntry - clobbered by liveOnEntry
; CHECK: store i8 42, i8* %p
; CHECK: 4 = MemoryDef(3)->3 MustAlias - clobbered by 3 = MemoryDef(2)->liveOnEntry
; CHECK: store i8 42, i8* %p
Expand Down

0 comments on commit 813a7f1

Please sign in to comment.