I looked into this more and the issue seems to have been due to an incorrect relocation for the std::basic_ifstream when calling the destructor. This seems to have been a bug in the X86FastISel fixed in this commit <https://github.com/llvm/llvm-project/commit/687b83ceabafe81970cd4639e7f0c89036402081>.