llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.98k stars 11.95k forks source link

Error compiling mlir with gcc: `error: call of overloaded 'get()' is ambiguous` #53447

Closed Meinersbur closed 2 years ago

Meinersbur commented 2 years ago

MLIR fails to compile on the alcf-theta-flang. The builder was unavailble for a while, the problem must have been introduced during its downtime. Other buildbots still green seem to use either clang or msvc.

This occurs using gcc 9.3 as well as gcc 11.2

https://lab.llvm.org/buildbot/#/builders/132/builds/7871

/opt/gcc/9.3.0/bin/g++  -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/unittests/Support -Illvm-project/mlir/unittests/Support -Iinclude -Illvm-project/llvm/include -Illvm-project/mlir/include -Itools/mlir/include -Illvm-project/llvm/utils/unittest/googletest/include -Illvm-project/llvm/utils/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG    -Wno-variadic-macros -fno-exceptions -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++17 -MD -MT tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o -MF tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o.d -o tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o -c llvm-project/mlir/unittests/Support/DebugCounterTest.cpp
In file included from llvm-project/mlir/include/mlir/Support/DebugCounter.h:12,
                 from llvm-project/mlir/unittests/Support/DebugCounterTest.cpp:9:
llvm-project/mlir/include/mlir/Support/DebugAction.h: In instantiation of 'static bool mlir::DebugAction<ParameterTs>::Handler::classof(const mlir::DebugActionManager::HandlerBase*) [with ParameterTs = {}]':
llvm-project/llvm/include/llvm/Support/Casting.h:58:23:   required from 'static bool llvm::isa_impl<To, From, Enabler>::doit(const From&) [with To = mlir::DebugAction<>::Handler; From = mlir::DebugActionManager::HandlerBase; Enabler = void]'
llvm-project/llvm/include/llvm/Support/Casting.h:105:36:   required from 'static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = mlir::DebugAction<>::Handler; From = mlir::DebugActionManager::HandlerBase]'
llvm-project/llvm/include/llvm/Support/Casting.h:131:40:   required from 'static bool llvm::isa_impl_wrap<To, FromTy, FromTy>::doit(const FromTy&) [with To = mlir::DebugAction<>::Handler; FromTy = const mlir::DebugActionManager::HandlerBase*]'
llvm-project/llvm/include/llvm/Support/Casting.h:122:60:   required from 'static bool llvm::isa_impl_wrap<To, From, SimpleFrom>::doit(const From&) [with To = mlir::DebugAction<>::Handler; From = mlir::DebugActionManager::HandlerBase* const; SimpleFrom = const mlir::DebugActionManager::HandlerBase*]'
llvm-project/llvm/include/llvm/Support/Casting.h:143:74:   required from 'bool llvm::isa(const Y&) [with X = mlir::DebugAction<>::Handler; Y = mlir::DebugActionManager::HandlerBase*]'
llvm-project/llvm/include/llvm/Support/Casting.h:345:16:   required from 'typename llvm::cast_retty<X, Y*>::ret_type llvm::dyn_cast(Y*) [with X = mlir::DebugAction<>::Handler; Y = mlir::DebugActionManager::HandlerBase; typename llvm::cast_retty<X, Y*>::ret_type = mlir::DebugAction<>::Handler*]'
llvm-project/mlir/include/mlir/Support/DebugAction.h:152:65:   required from 'mlir::FailureOr<ResultT> mlir::DebugActionManager::dispatchToHandler(HandlerCallbackT&&, Args&& ...) [with ActionType = {anonymous}::CounterAction; ResultT = bool; HandlerCallbackT = mlir::DebugActionManager::shouldExecute(Args&& ...) [with ActionType = {anonymous}::CounterAction; Args = {}]::<lambda(auto:2*, auto:3&& ...)>&; Args = {}]'
llvm-project/mlir/include/mlir/Support/DebugAction.h:120:21:   required from 'bool mlir::DebugActionManager::shouldExecute(Args&& ...) [with ActionType = {anonymous}::CounterAction; Args = {}]'
llvm-project/mlir/unittests/Support/DebugCounterTest.cpp:33:3:   required from here
llvm-project/mlir/include/mlir/Support/DebugAction.h:208:61: error: call of overloaded 'get()' is ambiguous
  208 |       return handler->getHandlerID() == TypeID::get<Handler>();
      |                                         ~~~~~~~~~~~~~~~~~~~~^~

https://lab.llvm.org/buildbot/#/builders/132/builds/7895

/opt/gcc/11.2.0/bin/g++  -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=0 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/unittests/Support -Illvm-project/mlir/unittests/Support -Iinclude -Illvm-project/llvm/include -Illvm-project/mlir/include -Itools/mlir/include -Illvm-project/llvm/utils/unittest/googletest/include -Illvm-project/llvm/utils/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Werror=mismatched-tags -O3 -DNDEBUG    -Wno-variadic-macros -fno-exceptions -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++17 -MD -MT tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o -MF tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o.d -o tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugActionTest.cpp.o -c llvm-project/mlir/unittests/Support/DebugActionTest.cpp
In file included from llvm-project/mlir/unittests/Support/DebugActionTest.cpp:9:
llvm-project/mlir/include/mlir/Support/DebugAction.h: In instantiation of 'mlir::DebugAction<ParameterTs>::Handler::Handler() [with ParameterTs = {bool}]':
llvm-project/mlir/unittests/Support/DebugActionTest.cpp:54:10:   required from 'typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = {anonymous}::DebugActionTest_ActionSpecificHandler_Test::TestBody()::ActionSpecificHandler; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<{anonymous}::DebugActionTest_ActionSpecificHandler_Test::TestBody()::ActionSpecificHandler, std::default_delete<{anonymous}::DebugActionTest_ActionSpecificHandler_Test::TestBody()::ActionSpecificHandler> >]'
llvm-project/mlir/include/mlir/Support/DebugAction.h:99:46:   required from 'void mlir::DebugActionManager::registerActionHandler() [with T = {anonymous}::DebugActionTest_ActionSpecificHandler_Test::TestBody()::ActionSpecificHandler]'
llvm-project/mlir/unittests/Support/DebugActionTest.cpp:59:55:   required from here
llvm-project/mlir/include/mlir/Support/DebugAction.h:196:49: error: call of overloaded 'get()' is ambiguous
  196 |     Handler() : HandlerBase(TypeID::get<Handler>()) {}
      |                             ~~~~~~~~~~~~~~~~~~~~^~
In file included from llvm-project/mlir/include/mlir/Support/DebugAction.h:21,
                 from llvm-project/mlir/unittests/Support/DebugActionTest.cpp:9:
llvm-project/mlir/include/mlir/Support/TypeID.h:133:8: note: candidate: 'static mlir::TypeID mlir::TypeID::get() [with T = mlir::DebugAction<bool>::Handler]'
  133 | TypeID TypeID::get() {
      |        ^~~~~~
llvm-project/mlir/include/mlir/Support/TypeID.h:137:8: note: candidate: 'static mlir::TypeID mlir::TypeID::get() [with Trait = mlir::DebugAction<ParameterTs>::Handler]'
  137 | TypeID TypeID::get() {
      |        ^~~~~~
llvmbot commented 2 years ago

@llvm/issue-subscribers-mlir-core

Meinersbur commented 2 years ago

@joker-eph I "assigned" the bug to you, not sure what the equivalent of adding someone's email to the CC field in bugzilla is. Maybe just mention someone via @ in comment, but did not know what to write. Well, now I do.

joker-eph commented 2 years ago

Thanks! Our gcc5 and gcc10 bots are happy, so something seems specific to these particular gcc versions.

joker-eph commented 2 years ago

I built locally with gcc 11.2 and gcc 9.4 and I can't reproduce right now. There has to be something else involved.

joker-eph commented 2 years ago

Invocation looks like:

g++-9 -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -DMLIR_CUDA_CONVERSIONS_ENABLED=1 -DMLIR_INCLUDE_TESTS -DMLIR_ROCM_CONVERSIONS_ENABLED=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/mlir/unittests/Support -Imlir/unittests/Support -Iinclude -Illvm/include -Imlir/include -Itools/mlir/include -Illvm/utils/unittest/googletest/include -Illvm/utils/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wno-variadic-macros -fno-exceptions -fno-rtti -UNDEBUG -Wno-suggest-override -std=c++14 -MD -MT tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o -MF tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o.d -o tools/mlir/unittests/Support/CMakeFiles/MLIRSupportTests.dir/DebugCounterTest.cpp.o -c mlir/unittests/Support/DebugCounterTest.cpp
joker-eph commented 2 years ago

Tried to run the invocation of the bot, this is only a C++17 problem apparently : only flang hits this because the project builds in c++14 mode by default.

We build with C++17 at Google, but we're using Clang, this is likely why we haven't hit this right now.

Meinersbur commented 2 years ago

What is the outlook to get this fixed?

joker-eph commented 2 years ago

Someone will have to prioritize trying to debug this, unfortunately this isn't a combination of a config that most core developers are focusing on at the moment I think.

Maybe if you can bisect to the pointer when the bug was introduced that could help by hinting more at the issue?

Meinersbur commented 2 years ago

Bijection points to 4fe5cfe53e86dbfb4ad4ad05f7c19c0929433e16, which unfortunately does not help to identify the cause.

@gkistanova contacted me to move the flang-x86_64-knl-linux builder to staging because of its ongoing fail status.

Meinersbur commented 2 years ago

Cause is 72d5afa4acc3cb7fdeb6ead90cc8f446a48c1f9d where DebugActionTest.cpp and DebugAction.h were first introduced. Because of the reasons mentioned in 4fe5cfe53e86dbfb4ad4ad05f7c19c0929433e16, the unittests never ran. This is also the reason why D116027 was already once reverted in 2132906836cf0618e76485c67a60305bf1557ffc.

Meinersbur commented 2 years ago

It complains about an ambiguity of the following two functions:

  template <typename T>
  static TypeID get();
  template <template <typename> class Trait>
  static TypeID get();

which were introduced in https://reviews.llvm.org/D77768. The second indeed looks redundant to me (any template-instantiated class should also match template T). After removing it, unfortunately it again fails with gcc.

joker-eph commented 2 years ago

This is also the reason why D116027 was already once reverted in https://github.com/llvm/llvm-project/commit/2132906836cf0618e76485c67a60305bf1557ffc.

The revert linked here was bogus in itself, and the commit was re-landed as-is if I followed correctly.