[tensorexpr] Fix registration of intrinsics on llvm-fb (#47540)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47540
In FB's hybrid llvm 7/8 flavor, we (read: I) forgot to register
intrinsics. It was... a bit annoying to figure out how to do this, and I'm
sure it could be done more efficiently by someone who isn't just cargo-culting
the API from KaleidoscopeJIT. Anyways.
There are kind of 3 independent changes here but they're a bit annoying to separate out, so:
0. (trivial) Add the correct #defines to the internal build to run test_llvm.
1. (easy) add an assertSuccess function to convert llvm::Errors into
`TORCH_INTERNAL_ASSERT`s, for better/easier debugging.
2. (medium) Factor out the gigantic register-all-the-things function into a
helper so we can call it from both the LLVM and LLVM-FB constructors.
3. (hard) Fix the symbol resolver in llvm-fb to do a lookup using the
ExecutionSession. This is the bit I don't really understand; it feels like the
CompileLayer lookup should find these symbols but it doesn't. Whatever.
Test Plan: `buck test //caffe2/test/cpp/tensorexpr:tensorexpr`
Reviewed By: asuhan
Differential Revision: D24807361
fbshipit-source-id: 8bb0d632dff6a065963ed14a600614cd21fbb095