[cfe-dev] Can't compile MLIR with clang on windows

Mehdi AMINI via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 20 12:12:34 PDT 2021

On Mon, Sep 20, 2021 at 11:01 AM David Blaikie <dblaikie at gmail.com> wrote:
> +Mehdi AMINI in case he's got any ideas

I'd take the easy route and change the call site to cast the
SmallVector to ArrayRef so that it selects the overload, or I'd add an
overload for SmallVector as well :)

+River Riddle for a more principled fix in how we declare the `tgfmt` functions.


> On Mon, Sep 20, 2021 at 3:36 AM Diana Picus via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>> Hi,
>> I'm trying to compile MLIR on Windows on Arm with a clang-cl.exe that I compiled at commit 945df8bc4cf.
>> I'm running into an issue in mlir-tblgen\RewriterGen.cpp [1]. I'm attaching the whole error dump, but here's the TL;DR version:
>> error: implicit instantiation of undefined template 'llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>'
>> [...]
>> llvm-project\mlir\tools\mlir-tblgen\RewriterGen.cpp(303,37): note: in instantiation of template class 'mlir::tblgen::FmtObject<std::tuple<llvm::detail::missing_format_adapter<llvm::SmallVector<std::basic_string<char>, 8> &>>>' requested here
>>   auto nativeCodeCall = std::string(tgfmt(
>> I'm not sure I understand the issue correctly, but in any case here's my interpretation:
>> There are 2 versions of tgfmt, a templated one with a parameter pack [2], and a non-templated one that takes an ArrayRef<std::string> as a parameter. I would expect a call with SmallVector<std::string, 8> to just use the non-templated overload, but we never get to that part because we're erroring out while trying to find a format adapter. I think SFINAE doesn't kick in in this case, because the error is not in "an immediate context of the function type". However, removing the build_format_adapter definition that uses the missing_format_adapter [3] makes it work, because I guess in that case the error is pushed into the immediate context (i.e. we error out because we don't have a suitable build_format_adapter, not later on because we don't have a missing_format_adapter).
>> Am I understanding this right? Is it reasonable to remove missing_format_adapter in order to make build_format_adapter more SFINAE-friendly? Or is there a more principled fix?
>> Thanks,
>> Diana
>> [1] https://github.com/llvm/llvm-project/blob/951f362e2560fe1c9c05f487107fd9882d45d867/mlir/tools/mlir-tblgen/RewriterGen.cpp#L303
>> [2] https://github.com/llvm/llvm-project/blob/5bc9cc1332aa042b68fb5efa9fb50eaaf2d54f79/mlir/include/mlir/TableGen/Format.h#L255
>> [3] https://github.com/llvm/llvm-project/blob/d480f968ad8b56d3ee4a6b6df5532d485b0ad01e/llvm/include/llvm/Support/FormatVariadicDetails.h#L156
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list