Hi, I’m a beginner of LLVM and trying to learn MemorySSA. I explored the Homepage of MemorySSA, and different behavior shows up when I print the Memory SSA of the official example. I used opt memoryssa.ll -passes='print<memoryssa>' -disable-output -o /dev/null
to print the SSA form and below is the outcome.
MemorySSA for function: foo
define void @foo() {
entry:
%p1 = alloca i8, align 1
%p2 = alloca i8, align 1
%p3 = alloca i8, align 1
; 1 = MemoryDef(liveOnEntry)
store i8 0, i8* %p3, align 1
br label %while.cond
while.cond: ; preds = %if.end, %entry
; 6 = MemoryPhi({entry,1},{if.end,4})
br i1 undef, label %if.then, label %if.else
if.then: ; preds = %while.cond
; 2 = MemoryDef(6)
store i8 0, i8* %p1, align 1
br label %if.end
if.else: ; preds = %while.cond
; 3 = MemoryDef(6)
store i8 1, i8* %p2, align 1
br label %if.end
if.end: ; preds = %if.else, %if.then
; 5 = MemoryPhi({if.then,2},{if.else,3})
; MemoryUse(5) MayAlias
%0 = load i8, i8* %p1, align 1
; 4 = MemoryDef(5)
store i8 2, i8* %p2, align 1
; MemoryUse(4) MayAlias
%1 = load i8, i8* %p3, align 1
br label %while.cond
}
Everything is good exept the statement %1 = load i8, i8* %p3, align 1
. The corresponding MemoryAccess is MemoryUse(4)
but it should be MemoryUse(1)
in term of the homepage of MemorySSA.
did I miss something? My llvm version is 11.0.0.
If anyone has the same outcome, please let me know.