As pointed out in https://github.com/llvm/llvm-project/issues/54155#issuecomment-1057465479, there was a crash when loop info was being outlined. It was not being properly stripped and adjusted, so would point to the wrong location. This uses similar logic found in the CodeExtractor to adjust the loop debug info.
Is all the complexity needed in the test case? IIUC it would be sufficient to have a function with a simple outline-able loop + !llvm.loop metadata with debug info.