Should Clang verify IR when passing a LLVM IR file?

At the moment, Clang doesn’t verify LLVM IR modules, which can cause crashes in optimization passes due to the input module being invalid.

AFAIK Clang accepting LLVM IR files is mostly a convenience feature for LLVM developers, but recently we had a few of bug reports of crashes that were down to invalid modules.

Those could be avoided if clang would just run the IR verifier first, like opt and llc do. Should we just do that in clang as well?

This makes sense to me. Sony licensees in particular have sometimes wanted to use non-Clang frontends, but we require they use our Clang for code generation, so they generate IR however they like and then feed that through our compiler. Verification seems like a very useful validation step!

Yes, sounds very useful, even if the error messages won’t be great for users. The cost should be negligible.