LLVM ERROR: unable to legalize instruction (in function: foo)
llc without the -global-isel option works fine.
I built clang/llc using the sources with the following tips:
LLVM
761e543ac73 (HEAD → master, origin/master, origin/HEAD) [Transforms] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
clang
9563977e8b (HEAD → master, origin/master, origin/HEAD) [X86] Add support for ‘amdfam17h’ to __builtin_cpu_is to match gcc.
I spent a little bit of time debugging the failure. It appears that X86LegalizerInfo does not (yet?) set up the required actions and tables for the opcode G_SDIV. I have not looked at GlobalISel phase earlier, but am curious to learn of the reasons for G_SDIV not being supported, yet. Are there any pointers that give some background? Of course, I hope to continue to dig irrespectively (albeit slowly :-)).