This is an archive of the discontinued LLVM Phabricator instance.

[mlir][NFC] Update Operation::getResultTypes to use ArrayRef<Type> instead of iterator_range.
ClosedPublic

Authored by rriddle on Jan 26 2020, 3:05 AM.

Details

Summary

The new internal representation of operation results now allows for accessing the result types to be more efficient. Changing the API to ArrayRef is more efficient and removes the need to explicitly materialize vectors in several places.

Diff Detail

Event Timeline

rriddle created this revision.Jan 26 2020, 3:05 AM

Unit tests: fail. 62150 tests passed, 5 failed and 811 were skipped.

failed: libc++.std/language_support/cmp/cmp_partialord/partialord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongeq/cmp.strongeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_strongord/strongord.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakeq/cmp.weakeq.pass.cpp
failed: libc++.std/language_support/cmp/cmp_weakord/weakord.pass.cpp

clang-tidy: pass.

clang-format: pass.

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

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

bondhugula added inline comments.
mlir/include/mlir/IR/Operation.h
266

Nit: result_type_range -> ArrayRef<Type>

result_type_range has only one use.

bondhugula added inline comments.Jan 26 2020, 3:59 AM
mlir/lib/IR/Operation.cpp
554

result_type_range -> ArrayRef<Type>

mlir/test/lib/TestDialect/TestPatterns.cpp
257

This pattern looks like a concern. Do we get a warning if we didn't use the Type ctor? It's not clear to me why we need it now.

rriddle marked 4 inline comments as done.Jan 26 2020, 9:35 AM
rriddle added inline comments.
mlir/include/mlir/IR/Operation.h
266

It is used in other places, e.g. in multi-result operations. I'd rather not remove at it is consistent with the rest of the ranges.

mlir/test/lib/TestDialect/TestPatterns.cpp
257

It is necessary because the methods on Type are non-const and the result type range now returns const Type elements, instead of a Type.

rriddle marked 2 inline comments as done.Jan 26 2020, 9:35 AM
antiagainst accepted this revision.Jan 27 2020, 11:17 AM
This revision is now accepted and ready to land.Jan 27 2020, 11:17 AM
This revision was automatically updated to reflect the committed changes.
jpienaar added inline comments.Jan 28 2020, 8:15 AM
mlir/test/lib/TestDialect/TestPatterns.cpp
257

Wouldn't this then result in us having multiple of these casts now? It seems like we'll end up adding more const casts just to query the types.