When we change the leader to a store:
Changing leader of congruence class 6 from %2 = load i32, i32* %d, align 4 to store i32 %1, i32* %d, align 4 because store joined class
we don't update the memory leader so later, when trying to process a load
Setting 2 = MemoryDef(6) equivalent to congruence class 6 with current MemoryAccess leader 7 = MemoryPhi({for.body,2},{if.then,3}) Erasing expression 0x44014f0 from table Processing MemoryPhi 7 = MemoryPhi({for.body,2},{if.then,3}) Memory Phi value numbered to 3 = MemoryDef(7) Setting 7 = MemoryPhi({for.body,2},{if.then,3}) equivalent to congruence class 8 with current MemoryAccess leader 3 = MemoryDef(7) Processing instruction %2 = load i32, i32* %d, align 4
we crash while looking up the memory leader for the class
opt: ../lib/Transforms/Scalar/NewGVN.cpp:1048: const llvm::MemoryAccess* {anonymous}::NewGVN::lookupMemoryLeader(const llvm::MemoryAccess*) const: Assertion `CC->getMemoryLeader() && "Every MemoryAccess should be mapped to a " "congruence class with a represenative memory " "access"' failed.