ir: Replace some asserts with panics.