Fix some places where we were assuming that memory type had been legalized