From: Yizhi Liu Date: Sat, 7 Sep 2019 18:43:29 +0000 (+0800) Subject: Support LLVM trunk (#3907) X-Git-Tag: upstream/0.7.0~1936 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c50469c6d7c56abeddd2c78e93a310040ec0753;p=platform%2Fupstream%2Ftvm.git Support LLVM trunk (#3907) * support LLVM trunk * guard with USE_LLVM in if condition for c++14 * GREATER_EQUAL -> GREATER --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f2c711b..32898e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,15 +90,13 @@ if(MSVC) endforeach(flag_var) endif() else(MSVC) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") message("Build in Debug mode") set(CMAKE_C_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_C_FLAGS} -rdynamic") - set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS} -rdynamic") + set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_CXX_FLAGS} -rdynamic") else() set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC ${CMAKE_CXX_FLAGS}") if (HIDE_PRIVATE_SYMBOLS) message("Hide private symbols...") set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}") @@ -245,6 +243,19 @@ include(cmake/modules/contrib/Sort.cmake) include(cmake/modules/contrib/NNPack.cmake) include(cmake/modules/contrib/HybridDump.cmake) +if(NOT MSVC) + include(CheckCXXCompilerFlag) + if(NOT USE_LLVM STREQUAL "OFF" AND TVM_LLVM_VERSION GREATER 91) + check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14) + message(STATUS "Build with c++14") + set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}") + else() + check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) + message(STATUS "Build with c++11") + set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") + endif() +endif() + add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(tvm_topi SHARED ${TOPI_SRCS}) add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) diff --git a/src/codegen/llvm/codegen_llvm.cc b/src/codegen/llvm/codegen_llvm.cc index 5bc415f..c30ac84 100644 --- a/src/codegen/llvm/codegen_llvm.cc +++ b/src/codegen/llvm/codegen_llvm.cc @@ -423,8 +423,13 @@ void CodeGenLLVM::GetAlignment(Type t, std::unique_ptr CodeGenLLVM::CreateDebugInfo(llvm::Module* module) { +#if TVM_LLVM_VERSION >= 100 + auto debug_info = std::make_unique(); + debug_info->di_builder_ = std::make_unique(*module); +#else auto debug_info = llvm::make_unique(); debug_info->di_builder_ = llvm::make_unique(*module); +#endif // TODO(tulloch): pass this information through relay::Span classes to the LoweredFunc instance? debug_info->file_ = debug_info->di_builder_->createFile("model.tvm", "/tmp/"); debug_info->compilation_unit_ = debug_info->di_builder_->createCompileUnit(