apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.81k stars 3.48k forks source link

[Bug] Compiling in the context of llvm20.0.0git, an error is reported #17526

Open zzyuanyi opened 1 week ago

zzyuanyi commented 1 week ago

Expected behavior

The TVM is built normally

Actual behavior

[804/898] Building CXX object CMakeFil...s.dir/src/target/llvm/llvm_module.cc.o FAILED: CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_module.cc.o /usr/bin/c++ -DDMLC_USE_FOPEN64=0 -DDMLC_USE_LOGGING_LIBRARY="<tvm/runtime/logging.h>" -DNDEBUG -DNDEBUG=1 -DTVM_INDEX_DEFAULT_I64=1 -DTVM_KALLOC_ALIGNMENT=64 -DTVM_LLVM_HAS_AARCH64_TARGET=1 -DTVM_LLVM_VERSION=200 -DTVM_THREADPOOL_USE_OPENMP=0 -DTVM_USE_LIBBACKTRACE=1 -DUSE_FALLBACK_STL_MAP=0 -D_GNU_SOURCE -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DDMLC_ENABLE_RTTI=0 -I/home/yuan/tvm/include -I/home/yuan/tvm/build/libbacktrace/include -I/home/yuan/tvm/3rdparty/libcrc/include -isystem /home/yuan/tvm/3rdparty/dlpack/include -isystem /home/yuan/tvm/3rdparty/dmlc-core/include -isystem /home/yuan/tvm/3rdparty/rang/include -isystem /home/yuan/tvm/3rdparty/compiler-rt -isystem /home/yuan/tvm/3rdparty/picojson -isystem /usr/local/cuda-12.1/include -isystem /home/yuan/llvm-project/llvm/include -isystem /home/yuan/llvm-project/build/include -std=c++17 -faligned-new -O2 -Wall -fPIC -fno-rtti -MD -MT CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_module.cc.o -MF CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_module.cc.o.d -o CMakeFiles/tvm_objs.dir/src/target/llvm/llvm_module.cc.o -c /home/yuan/tvm/src/target/llvm/llvm_module.cc /home/yuan/tvm/src/target/llvm/llvm_module.cc: In lambda function: /home/yuan/tvm/src/target/llvm/llvm_module.cc:645:51: error: ‘lookupIntrinsicID’ is not a member of ‘llvm::Function’ 645 | return static_cast(llvm::Function::lookupIntrinsicID(name)); | ^~~~~ In file included from /home/yuan/tvm/include/tvm/node/reflection.h:33, from /home/yuan/tvm/include/tvm/node/node.h:37, from /home/yuan/tvm/include/tvm/ir/source_map.h:26, from /home/yuan/tvm/include/tvm/ir/expr.h:27, from /home/yuan/tvm/include/tvm/ir/attrs.h:48, from /home/yuan/tvm/include/tvm/relay/runtime.h:28, from /home/yuan/tvm/src/target/llvm/llvm_module.h:30, from /home/yuan/tvm/src/target/llvm/llvm_module.cc:26: /home/yuan/tvm/include/tvm/runtime/packed_func.h: In member function ‘tvm::runtime::TVMPODValueCRTP::operator int64t() const [with Derived = tvm::runtime::TVMMovableArgValue]’: /home/yuan/tvm/include/tvm/runtime/packed_func.h:771:3: warning: control reaches end of non-void function [-Wreturn-type] 771 | } | ^ /home/yuan/tvm/include/tvm/runtime/packed_func.h: In member function ‘tvm::runtime::TVMPODValueCRTP::operator bool() const [with Derived = tvm::runtime::TVMMovableArgValue_]’: /home/yuan/tvm/include/tvm/runtime/packed_func.h:787:3: warning: control reaches end of non-void function [-Wreturn-type] 787 | } | ^ ninja: build stopped: subcommand failed.

Environment

os:ubuntu22.04, cmake version 3.22.1 llvm:20.0.0git

Steps to reproduce

In the process of following the construction manual, the USE_LLVM was changed to set(USE_LLVM /home/yuan/llvm-project/build/bin/llvm-config) and USE-CUDA was enabled. Use Ninja to speed up the build after that.

mshr-h commented 22 hours ago

According to https://github.com/llvm/llvm-project/pull/110125 , Function::lookupIntrinsicID moved to Intrinsic namespace. We need to handle it for LLVM 20. https://github.com/apache/tvm/blob/v0.18.0/src/target/llvm/codegen_amdgpu.cc#L24-L47 is a good reference for LLVM version handling.

@zzyuanyi You can make a PR for the fix if you want.