LLVM without AMDGPU throws an error

I am trying to build TVM with setting USE_LLVM in config.cmake. I have llvm-v10 which I compiled from source for Arm Cortex-M7. I am also interested in using TVM only for Arm Cortex-M7. However, when I try to compile TVM with specifying the LLVM path in config.cmake, it throws this following error:

/home/deb/src/tvm/src/target/llvm/llvm_common.h:42:10: fatal error: llvm/IR/IntrinsicsAMDGPU.h: No such file or directory

The 42th line is: #include <llvm/IR/IntrinsicsAMDGPU.h>

When I compiled LLVM, I disabled all the backends I would not use (due to size) and it does not support AMDGPU. I think the error is because of that. Is there a simple way to specify the backend target when building TVM so that I can bypass AMDGPU, and other backends that my LLVM does not support? I would prefer not to compile LLVM with all the backends enabled, due to the compilation time and size.

I already tried commenting out the line and removing the codegen files (e.g., src/target/llvm/codegen_amdgpu.cc) as mentioned here (Make fails during installation on ARM error: ‘amdgcn_s_barrier’ is not a member of ‘llvm::Intrinsic’), but it just kept throwing errors for different files. I tried removing other files the compiler complains about but I got stuck as it started to complain about it cannot find “llvm::CGFT_AssemblyFile”. (which is weird because my LLVM source has llvm::TargetMachine::CGFT_AssemblyFile instead. It seems like TVM thinks that the TargetMachine namespace is only for llvm-v9? Is my llvm version messed up?)

I wonder if there is a simple way to disable AMDGPU backend. If not, can someone help me out in figuring out exactly which files I should remove to make it compile correctly?

I was able to compile with the following modifications. Leaving them for future references:

  1. commented out line 42-45 in src/target/llvm/llvm_common.h (include to the intrinsics).
  2. deleted codegen_amdgpu.cc, codegen_arm.cc, codegen_hexagon.cc, and codegen_nvptx.cc under src/target/llvm/
  3. In line 106, 127, 172 of src/target/llvm/llvm_module.cc, changed #elif TVM_LLVM_VERSION <= 90 to #elif TVM_LLVM_VERSION <= 100.

I wasn’t sure why I needed 3. Maybe my LLVM version is messed up. Anyways, now it builds and I can run TVM. Haven’t done a full test yet.

Let me know if there is an easier way for all this, or if I am doing something problematic! Thank you.

1 Like