This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Unbreak MSVC build with implicit constructor
AbandonedPublic

Authored by nicolasvasilache on Jan 17 2020, 1:46 PM.

Details

Reviewers
stella.stamenova

Diff Detail

Unit TestsFailed

Event Timeline

nicolasvasilache edited reviewers, added: stella.stamenova; removed: stellaraccident.

@stella.stamenova I am sorry but I do not have a simple way to fire up a Windows machine in a reasonable amount of time at this point.
Let's try to play it by ear, does this help?

Thanks!

Context: @stella.stamenova reported

##[error]mlir\include\mlir\IR\Attributes.h(234,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   304>E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(234): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\4\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
   394>ClCompile:
         CGStmt.cpp
   304>ClCompile:
         E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(234): note: No constructor could take the source type, or constructor overload resolution was ambiguous
         E:\agent\_work\4\s\mlir\lib\Conversion\VectorToLLVM\ConvertVectorToLLVM.cpp(119): note: see reference to function template instantiation 'llvm::iterator_range<mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>> mlir::ArrayAttr::getAsRange<mlir::IntegerAttr>(void)' being compiled
##[error]mlir\include\mlir\IR\Attributes.h(235,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   304>E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(235): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\4\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(235): note: No constructor could take the source type, or constructor overload resolution was ambiguous
##[error]mlir\include\mlir\IR\Attributes.h(234,0): Error C2672: 'llvm::make_range': no matching overloaded function found
   304>E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(234): error C2672: 'llvm::make_range': no matching overloaded function found [E:\agent\_work\4\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
##[error]mlir\include\mlir\IR\Attributes.h(235,0): Error C2780: 'llvm::iterator_range<IteratorT> llvm::make_range(T,T)': expects 2 arguments - 1 provided
   304>E:\agent\_work\4\s\mlir\include\mlir/IR/Attributes.h(235): error C2780: 'llvm::iterator_range<IteratorT> llvm::make_range(T,T)': expects 2 arguments - 1 provided [E:\agent\_work\4\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\4\s\llvm\include\llvm/ADT/iterator_range.h(54): note: see declaration of 'llvm::make_range'

Unit tests: fail. 61983 tests passed, 1 failed and 783 were skipped.

failed: LLVM.Bindings/Go/go.test

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

flaub added a subscriber: flaub.Jan 17 2020, 2:16 PM

No difference (I would have been surprised, really, as the issue doesn't appear to be with the way the constructor is declared, but with how it is used):

         ConvertLoopToStandard.cpp
##[error]mlir\include\mlir\IR\Attributes.h(234,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   303>E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(234): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\8\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(234): note: No constructor could take the source type, or constructor overload resolution was ambiguous
         E:\agent\_work\8\s\mlir\lib\Conversion\VectorToLLVM\ConvertVectorToLLVM.cpp(119): note: see reference to function template instantiation 'llvm::iterator_range<mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>> mlir::ArrayAttr::getAsRange<mlir::IntegerAttr>(void)' being compiled
##[error]mlir\include\mlir\IR\Attributes.h(235,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   433>ClCompile:
         MacOSKeychainAPIChecker.cpp
   303>E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(235): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\8\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(235): note: No constructor could take the source type, or constructor overload resolution was ambiguous
##[error]mlir\include\mlir\IR\Attributes.h(234,0): Error C2672: 'llvm::make_range': no matching overloaded function found
   303>E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(234): error C2672: 'llvm::make_range': no matching overloaded function found [E:\agent\_work\8\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
##[error]mlir\include\mlir\IR\Attributes.h(235,0): Error C2780: 'llvm::iterator_range<IteratorT> llvm::make_range(T,T)': expects 2 arguments - 1 provided
   303>E:\agent\_work\8\s\mlir\include\mlir/IR/Attributes.h(235): error C2780: 'llvm::iterator_range<IteratorT> llvm::make_range(T,T)': expects 2 arguments - 1 provided [E:\agent\_work\8\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\8\s\llvm\include\llvm/ADT/iterator_range.h(54): note: see declaration of 'llvm::make_range'
   303>Done Building Project "E:\agent\_work\8\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj" (default targets) -- FAILED.

@stella.stamenova

I think this is related, see: https://developercommunity.visualstudio.com/content/problem/346421/c-code-with-initializer-list-does-not-compile-in-v.html
In particular:
Both GCC and Clang compile and run this code without any problems.
Note that MSVC 19.20 does compile the code correctly

@aganea mentioned: Visual Studio 2019 16.4.2

Do you have a possibility to try on the latest version on your end?
I do not

Explicitly resolve templated type in call to make_range.

actually I think the link I posted is not relevant, I tried explicitly instantiating the template in make_range, does that help?

Unit tests: fail. 61983 tests passed, 1 failed and 783 were skipped.

failed: LLVM.Bindings/Go/go.test

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Unit tests: fail. 61983 tests passed, 1 failed and 783 were skipped.

failed: LLVM.Bindings/Go/go.test

clang-tidy: unknown.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

With the latest VS 2019, the error is still the same (MSVC 19.24).

With the latest patch, the error is slightly different, but essentially the same problem:

##[error]mlir\include\mlir\IR\Attributes.h(235,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   304>E:\agent\_work\5\s\mlir\include\mlir/IR/Attributes.h(235): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\5\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\5\s\mlir\include\mlir/IR/Attributes.h(235): note: No constructor could take the source type, or constructor overload resolution was ambiguous
         E:\agent\_work\5\s\mlir\lib\Conversion\VectorToLLVM\ConvertVectorToLLVM.cpp(119): note: see reference to function template instantiation 'llvm::iterator_range<mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>> mlir::ArrayAttr::getAsRange<mlir::IntegerAttr>(void)' being compiled
##[error]mlir\include\mlir\IR\Attributes.h(236,0): Error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>'
   304>E:\agent\_work\5\s\mlir\include\mlir/IR/Attributes.h(236): error C2440: '<function-style-cast>': cannot convert from 'mlir::ArrayAttr::iterator' to 'mlir::ArrayAttr::attr_value_iterator<mlir::IntegerAttr>' [E:\agent\_work\5\b\tools\mlir\lib\Conversion\VectorToLLVM\MLIRVectorToLLVM.vcxproj]
         E:\agent\_work\5\s\mlir\include\mlir/IR/Attributes.h(236): note: No constructor could take the source type, or constructor overload resolution was ambiguous

Since you don't have Win machine, I took the liberty to fix it: rGe3d92b7442eaf3319f84bc060492df5b7ac3e9a1 (sorry, I didn't have the time to do it before)

I think I found a solution to this, try:

explicit attr_value_iterator(ArrayAttr::iterator it)
    : llvm::mapped_iterator<ArrayAttr::iterator, AttrTy (*)(Attribute)>(
          it, [](Attribute attr) { return attr.cast<AttrTy>(); }) {}

Apparently MSVC is confused about the unqualified iterator identifier. Qualifying it with ArrayAttr:: seems to clear it up.

Haha, aganea beat me to it :)

nicolasvasilache abandoned this revision.Jan 20 2020, 6:31 PM

Great, thanks @aganea !