This is an archive of the discontinued LLVM Phabricator instance.

[mlir][NFC] Remove TypeRange's constructors that cause ambiguity
ClosedPublic

Authored by lipracer on Jul 11 2022, 2:31 AM.

Details

Summary

ArrayRef<Value> can implicit convert to ValueRange,when we call TypeRange(SmallVector<Value>) is ambiguity.
TypeRange(ValueRange values)
TypeRange(ArrayRef<Value> values)

Diff Detail

Event Timeline

lipracer created this revision.Jul 11 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald Transcript
lipracer requested review of this revision.Jul 11 2022, 2:31 AM

The windows failure looks real, can you take a look?

lipracer updated this revision to Diff 444018.Jul 12 2022, 11:19 AM
lipracer edited the summary of this revision. (Show Details)

windows msvc and gcc7 build error

The windows failure looks real, can you take a look?

done.

The windows failure looks real, can you take a look?

done.

The debian failure looks real this time, or is that out-of-date?

The msvc reported error is that: When we pass a parameter MutableArrayRef<BlockArgument> to the following function:

TypeRange(ValueTypeRange<ValueRangeT> values)
    : TypeRange(ValueRangeT(values.begin().getCurrent(),
                            values.end().getCurrent())) {}

then call delegating constructor:
TypeRange(ValueRange values); and TypeRange(const iterator_range<iterator> &range values) inherits from indexed_accessor_range_base
My second update trying to explicit call TypeRange(ValueRange values);
the clang reported error incomplete type 'mlir::ValueRange' and it defined in the OperationSupport.h file, and this file inclue<TypeRange.h>
I wonder if putting the ValueRange definition in a new file will work well.

lipracer updated this revision to Diff 444702.Jul 14 2022, 10:09 AM

build fail

Mogball added inline comments.Jul 18 2022, 9:18 AM
mlir/include/mlir/IR/TypeRange.h
50

I'm not really a fan of adding compiler-specific ifdefs

rriddle requested changes to this revision.Jul 18 2022, 9:19 AM
rriddle added inline comments.
mlir/include/mlir/IR/TypeRange.h
50

Yeah, we really shouldn't be adding these types of checks in regular code.

This revision now requires changes to proceed.Jul 18 2022, 9:19 AM
lipracer added inline comments.Jul 18 2022, 6:26 PM
mlir/include/mlir/IR/TypeRange.h
50

Is it reasonable to move the definition of ValueType from the operationSupport file to a new file?

Mogball added inline comments.Jul 19 2022, 8:44 AM
mlir/include/mlir/IR/TypeRange.h
50

ValueType? You mean TypeRange? Yes, I think it's reasonable to move it to a separate file TypeRange.h.

lipracer marked an inline comment as not done.Jul 19 2022, 6:29 PM
lipracer added inline comments.
mlir/include/mlir/IR/TypeRange.h
50

Sorry,I mean ValueRange.

lipracer updated this revision to Diff 446065.Jul 20 2022, 1:02 AM

Split out ValueRange declare from OperationSupport.h

lipracer marked 3 inline comments as done.Jul 20 2022, 7:41 PM
Mogball requested changes to this revision.Jul 20 2022, 9:08 PM

Can you move the splitting of the files into another patch? It's kind of hard to review the diff otherwise

This revision now requires changes to proceed.Jul 20 2022, 9:08 PM
rriddle requested changes to this revision.Jul 20 2022, 9:19 PM
rriddle added inline comments.
mlir/include/mlir/IR/TypeRange.h
45–46

Why does doing this require moving ValueRange out of OperationSupport?

lipracer added inline comments.Jul 20 2022, 10:15 PM
mlir/include/mlir/IR/TypeRange.h
45–46

The prompt I get with the clang compiler is: ValueRange is imcomplete type,ValueRange is a forward declaration in the file TypeRange.h, and the file OperationSupport.h already includes the file TypeRange.h.The class TypeRange and the class ValueRange depend on each other.

rriddle added inline comments.Jul 20 2022, 10:17 PM
mlir/include/mlir/IR/TypeRange.h
45–46

Where do you get that error though?

lipracer added inline comments.Jul 20 2022, 10:25 PM
mlir/include/mlir/IR/TypeRange.h
45–46

When I change

template <typename ValueRangeT>
  TypeRange(ValueTypeRange<ValueRangeT> values) : TypeRange(ValueRangeT(values.begin().getCurrent(),
                              values.end().getCurrent())) {}

to

template <typename ValueRangeT>
TypeRange(ValueTypeRange<ValueRangeT> values)
    : TypeRange(ValueRange(ValueRangeT(values.begin().getCurrent(), values.end().getCurrent()))) {}

But if I don't change the MSVC compiler like this it will give an error.

lipracer added inline comments.Jul 20 2022, 10:32 PM
mlir/include/mlir/IR/TypeRange.h
45–46

My first change was to remove the following two redundant constructors:

explicit TypeRange(ArrayRef<Value> values);
explicit TypeRange(ArrayRef<BlockArgument> values)
    : TypeRange(ArrayRef<Value>(values.data(), values.size())) {}
lipracer updated this revision to Diff 446708.Jul 21 2022, 10:15 PM

regression

Can you move the splitting of the files into another patch? It's kind of hard to review the diff otherwise

Split ValueRange definitions in this patch:
https://reviews.llvm.org/D130332

Mogball accepted this revision.Jul 22 2022, 12:21 PM

Is the build status up to date?

Is the build status up to date?

This patch needs to be based on another patch: https://reviews.llvm.org/D130332.

Is the build status up to date?

This patch needs to be based on another patch: https://reviews.llvm.org/D130332.

The depends on comment is useful here (https://llvm.org/docs/Phabricator.html#using-patch-summaries), it shows up in the UI as "stack" too.

rriddle accepted this revision.Jul 25 2022, 1:28 PM
This revision is now accepted and ready to land.Jul 25 2022, 1:28 PM
This revision was landed with ongoing or failed builds.Jul 25 2022, 2:38 PM
This revision was automatically updated to reflect the committed changes.