More thoroughly copy IRCode
The contents of IRCode get modified in interesting ways all over
the optimizer. The `copy(::IRCode)` function did an incomplete job
of copying everything that gets modified. We don't really use this
function internally much, but it's useful for external tooling, so
let's fix it.