Test case:
define void @foo(i1 %b, i8* %ext) { %a = alloca i8, align 1 %sink = alloca i8, align 1 ; 1 = MemoryDef(liveOnEntry) <<<<<<<< store i8 1, i8* %a, align 1 br i1 %b, label %if.b, label %end if.b: ; 2 = MemoryDef(1) store i8 1, i8* %sink br label %end end: ; 3 = MemoryPhi({if.b,2},{%0,1}) ; MemoryUse(liveOnEntry) <<<<<<<<<<<<< load i8, i8* %a, align 1 ret void }
...This happens because because of how we recursively walk phis, and how we cache the results afterward. Both of these problems are (hopefully) fixed by this patch.
I plan to move the code around in the loop a bit (because break; as the last statement in a for is kind of dumb), but I’ve separated that from this patch because the refactor adds a fair amount of noise, and should be NFC.