Skip to content

Commit b60b014

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:9370271ec5de into amd-gfx:a9743de9eb8f
Local branch amd-gfx a9743de Merged main:427f120f60be into amd-gfx:551632636316 Remote branch main 9370271 [Support] Redefine endianness::native (llvm#67876)
2 parents a9743de + 9370271 commit b60b014

File tree

23 files changed

+153
-52
lines changed

23 files changed

+153
-52
lines changed

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,16 @@ void CodeGenVTables::addRelativeComponent(ConstantArrayBuilder &builder,
640640
// want the stub/proxy to be emitted for properly calculating the offset.
641641
// Examples where there would be no symbol emitted are available_externally
642642
// and private linkages.
643-
auto stubLinkage = vtableHasLocalLinkage ? llvm::GlobalValue::InternalLinkage
644-
: llvm::GlobalValue::ExternalLinkage;
643+
//
644+
// `internal` linkage results in STB_LOCAL Elf binding while still manifesting a
645+
// local symbol.
646+
//
647+
// `linkonce_odr` linkage results in a STB_DEFAULT Elf binding but also allows for
648+
// the rtti_proxy to be transparently replaced with a GOTPCREL reloc by a
649+
// target that supports this replacement.
650+
auto stubLinkage = vtableHasLocalLinkage
651+
? llvm::GlobalValue::InternalLinkage
652+
: llvm::GlobalValue::LinkOnceODRLinkage;
645653

646654
llvm::Constant *target;
647655
if (auto *func = dyn_cast<llvm::Function>(globalVal)) {

clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,14 @@ void NullabilityChecker::checkPostCall(const CallEvent &Call,
899899
const NullabilityState *TrackedNullability =
900900
State->get<NullabilityMap>(Region);
901901

902+
// ObjCMessageExpr gets the actual type through
903+
// Sema::getMessageSendResultType, instead of using the return type of
904+
// MethodDecl directly. The final type is generated by considering the
905+
// nullability of receiver and MethodDecl together. Thus, The type of
906+
// ObjCMessageExpr is prefer.
907+
if (const Expr *E = Call.getOriginExpr())
908+
ReturnType = E->getType();
909+
902910
if (!TrackedNullability &&
903911
getNullabilityAnnotation(ReturnType) == Nullability::Nullable) {
904912
State = State->set<NullabilityMap>(Region, Nullability::Nullable);
@@ -1053,7 +1061,7 @@ void NullabilityChecker::checkPostObjCMessage(const ObjCMethodCall &M,
10531061
}
10541062

10551063
// No tracked information. Use static type information for return value.
1056-
Nullability RetNullability = getNullabilityAnnotation(RetType);
1064+
Nullability RetNullability = getNullabilityAnnotation(Message->getType());
10571065

10581066
// Properties might be computed, which means the property value could
10591067
// theoretically change between calls even in commonly-observed cases like

clang/test/Analysis/nullability.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ - (void)takesUnspecified:(int *)p;
5555
@property(readonly, nullable) void (^propReturnsNullableBlock)(void);
5656
@property(readonly, nullable) int *propReturnsNullable;
5757
@property(readonly) int *propReturnsUnspecified;
58+
+ (nullable TestObject *)getNullableObject;
5859
@end
5960

6061
TestObject * getUnspecifiedTestObject();
@@ -256,6 +257,12 @@ void testObjCPropertyReadNullability() {
256257
case 8:
257258
[o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
258259
break;
260+
case 9:
261+
[o takesNonnull:getNullableTestObject().propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
262+
break;
263+
case 10:
264+
[o takesNonnull:[TestObject getNullableObject].propReturnsNonnull]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
265+
break;
259266
}
260267
}
261268

clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// CHECK-DAG: $_ZTS1B = comdat any
99
// CHECK-DAG: $_ZTI1B = comdat any
1010
// CHECK-DAG: $_ZTI1B.rtti_proxy = comdat any
11-
// CHECK-DAG: $_ZTI1A.rtti_proxy = comdat any
1211

1312
// VTable for B is emitted here since we access it when creating an instance of B. The VTable is also linkonce_odr and in its own comdat.
1413
// CHECK-DAG: @_ZTV1B.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1B), align 4
@@ -18,7 +17,7 @@
1817
// CHECK-DAG: @_ZTS1B =
1918
// CHECK-DAG: @_ZTI1A =
2019
// CHECK-DAG: @_ZTI1B =
21-
// CHECK-DAG: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, comdat
20+
// CHECK-DAG: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, comdat
2221

2322
// We will emit a vtable for B here, so it does have an alias, but we will not
2423
// emit one for A.

clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]
1919
// CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1
2020
// CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8
21-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
21+
// CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
2222
// CHECK: @_ZTV1A = linkonce_odr unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
2323

2424
// CHECK: define linkonce_odr void @_ZN1A3fooEv(ptr {{.*}}%this) unnamed_addr #{{[0-9]+}} comdat

clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/// hwasan-instrumented.
77
// CHECK-DAG: @_ZTV1A.local = private unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, no_sanitize_hwaddress, align 4
88
// CHECK-DAG: @_ZTV1A = unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local
9-
// CHECK-DAG: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, no_sanitize_hwaddress, comdat
9+
// CHECK-DAG: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, no_sanitize_hwaddress, comdat
1010

1111
class A {
1212
public:
@@ -22,7 +22,7 @@ void A_foo(A *a) {
2222
/// If the vtable happens to be hidden, then the alias is not needed. In this
2323
/// case, the original vtable struct itself should be unsanitized.
2424
// CHECK-DAG: @_ZTV1B = hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32)] }, no_sanitize_hwaddress, align 4
25-
// CHECK-DAG: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, no_sanitize_hwaddress, comdat
25+
// CHECK-DAG: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, no_sanitize_hwaddress, comdat
2626

2727
class __attribute__((visibility("hidden"))) B {
2828
public:

clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// CHECK: @_ZTI1A ={{.*}} constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, align 8
1515

1616
// The rtti should be in a comdat
17-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
17+
// CHECK: @_ZTI1A.rtti_proxy = {{.*}}comdat
1818

1919
// The vtable symbol is exposed through an alias.
2020
// @_ZTV1A = dso_local unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local

clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// CHECK: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr]
1414
// CHECK: @_ZTS1B ={{.*}} constant [3 x i8] c"1B\00", align 1
1515
// CHECK: @_ZTI1B ={{.*}} constant { ptr, ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i32 8), ptr @_ZTS1B, ptr @_ZTI1A }, align 8
16-
// CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat
17-
// CHECK: @_ZTI1B.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1B, comdat
16+
// CHECK: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, comdat
17+
// CHECK: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, comdat
1818

1919
// CHECK: define {{.*}}ptr @_Z11getTypeInfov() local_unnamed_addr
2020
// CHECK-NEXT: entry:

libcxx/test/libcxx/ranges/range.adaptors/range.lazy.split/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
10-
11-
// clang-cl and cl currently don't support [[no_unique_address]]
12-
// XFAIL: msvc
10+
// XFAIL: msvc && (clang-16 || clang-17)
1311

1412
// class lazy_split_view {
1513
// _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();

libcxx/test/libcxx/ranges/range.adaptors/range.split/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17
10-
11-
// clang-cl and cl currently don't support [[no_unique_address]]
12-
// XFAIL: msvc
10+
// XFAIL: msvc && (clang-16 || clang-17)
1311

1412
// class split_view {
1513
// _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();

libcxx/test/libcxx/ranges/range.factories/range.istream.view/no_unique_address.compile.pass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
// UNSUPPORTED: no-localization
1010
// UNSUPPORTED: c++03, c++11, c++14, c++17
11-
12-
// clang-cl and cl currently don't support [[no_unique_address]]
13-
// XFAIL: msvc
11+
// XFAIL: msvc && (clang-16 || clang-17)
1412

1513
// Test the libc++ extension that the value stored in `std::ranges::istream_view` has been marked
1614
// as _LIBCPP_NO_UNIQUE_ADDRESS

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476714
19+
#define LLVM_MAIN_REVISION 476721
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/Support/Endian.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
namespace llvm {
2525
namespace support {
2626

27-
enum endianness {big, little, native};
27+
enum endianness {
28+
big,
29+
little,
30+
native = llvm::sys::IsBigEndianHost ? big : little
31+
};
2832

2933
// These are named values for common alignments.
3034
enum {aligned = 0, unaligned = 1};
@@ -47,7 +51,7 @@ constexpr endianness system_endianness() {
4751

4852
template <typename value_type>
4953
[[nodiscard]] inline value_type byte_swap(value_type value, endianness endian) {
50-
if ((endian != native) && (endian != system_endianness()))
54+
if (endian != native)
5155
sys::swapByteOrder(value);
5256
return value;
5357
}

llvm/include/llvm/Support/HashBuilder.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,8 @@ template <typename HasherT> class HashBuilderBase {
8686
};
8787

8888
/// Implementation of the `HashBuilder` interface.
89-
///
90-
/// `support::endianness::native` is not supported. `HashBuilder` is
91-
/// expected to canonicalize `support::endianness::native` to one of
92-
/// `support::endianness::big` or `support::endianness::little`.
9389
template <typename HasherT, support::endianness Endianness>
9490
class HashBuilderImpl : public HashBuilderBase<HasherT> {
95-
static_assert(Endianness != support::endianness::native,
96-
"HashBuilder should canonicalize endianness");
97-
9891
public:
9992
explicit HashBuilderImpl(HasherT &Hasher)
10093
: HashBuilderBase<HasherT>(Hasher) {}
@@ -395,10 +388,7 @@ class HashBuilderImpl : public HashBuilderBase<HasherT> {
395388
/// Specifiying a non-`native` `Endianness` template parameter allows to compute
396389
/// stable hash across platforms with different endianness.
397390
template <class HasherT, support::endianness Endianness>
398-
using HashBuilder =
399-
HashBuilderImpl<HasherT, (Endianness == support::endianness::native
400-
? support::endian::system_endianness()
401-
: Endianness)>;
391+
using HashBuilder = HashBuilderImpl<HasherT, Endianness>;
402392

403393
namespace hashbuilder_detail {
404394
class HashCodeHasher {

llvm/lib/ExecutionEngine/JITLink/aarch32.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ void writeImmediate(WritableArmRelocation &R, uint32_t Imm) {
306306

307307
Expected<int64_t> readAddendData(LinkGraph &G, Block &B, const Edge &E) {
308308
support::endianness Endian = G.getEndianness();
309-
assert(Endian != support::native && "Declare as little or big explicitly");
310309

311310
Edge::Kind Kind = E.getKind();
312311
const char *BlockWorkingMem = B.getContent().data();
@@ -404,7 +403,6 @@ Error applyFixupData(LinkGraph &G, Block &B, const Edge &E) {
404403
char *FixupPtr = BlockWorkingMem + E.getOffset();
405404

406405
auto Write32 = [FixupPtr, Endian = G.getEndianness()](int64_t Value) {
407-
assert(Endian != native && "Must be explicit: little or big");
408406
assert(isInt<32>(Value) && "Must be in signed 32-bit range");
409407
uint32_t Imm = static_cast<int32_t>(Value);
410408
if (LLVM_LIKELY(Endian == little))

mlir/include/mlir/IR/StorageUniquerSupport.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,21 @@ class StorageUserBase : public BaseT, public Traits<ConcreteT>... {
175175
/// function is guaranteed to return a non null object and will assert if
176176
/// the arguments provided are invalid.
177177
template <typename... Args>
178-
static ConcreteT get(MLIRContext *ctx, Args... args) {
178+
static ConcreteT get(MLIRContext *ctx, Args &&...args) {
179179
// Ensure that the invariants are correct for construction.
180180
assert(
181181
succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...)));
182-
return UniquerT::template get<ConcreteT>(ctx, args...);
182+
return UniquerT::template get<ConcreteT>(ctx, std::forward<Args>(args)...);
183183
}
184184

185185
/// Get or create a new ConcreteT instance within the ctx, defined at
186186
/// the given, potentially unknown, location. If the arguments provided are
187187
/// invalid, errors are emitted using the provided location and a null object
188188
/// is returned.
189189
template <typename... Args>
190-
static ConcreteT getChecked(const Location &loc, Args... args) {
191-
return ConcreteT::getChecked(getDefaultDiagnosticEmitFn(loc), args...);
190+
static ConcreteT getChecked(const Location &loc, Args &&...args) {
191+
return ConcreteT::getChecked(getDefaultDiagnosticEmitFn(loc),
192+
std::forward<Args>(args)...);
192193
}
193194

194195
/// Get or create a new ConcreteT instance within the ctx. If the arguments

mlir/include/mlir/Support/StorageUniquer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/DenseSet.h"
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/Support/Allocator.h"
19+
#include <utility>
1920

2021
namespace mlir {
2122
namespace detail {
@@ -207,7 +208,7 @@ class StorageUniquer {
207208

208209
// Generate a constructor function for the derived storage.
209210
auto ctorFn = [&](StorageAllocator &allocator) {
210-
auto *storage = Storage::construct(allocator, derivedKey);
211+
auto *storage = Storage::construct(allocator, std::move(derivedKey));
211212
if (initFn)
212213
initFn(storage);
213214
return storage;
@@ -300,9 +301,9 @@ class StorageUniquer {
300301
static typename ImplTy::KeyTy getKey(Args &&...args) {
301302
if constexpr (llvm::is_detected<detail::has_impltype_getkey_t, ImplTy,
302303
Args...>::value)
303-
return ImplTy::getKey(args...);
304+
return ImplTy::getKey(std::forward<Args>(args)...);
304305
else
305-
return typename ImplTy::KeyTy(args...);
306+
return typename ImplTy::KeyTy(std::forward<Args>(args)...);
306307
}
307308

308309
//===--------------------------------------------------------------------===//

mlir/test/lib/Dialect/Test/TestAttrDefs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,5 +323,16 @@ def Test_IteratorTypeArrayAttr
323323
: TypedArrayAttrBase<Test_IteratorTypeEnum,
324324
"Iterator type should be an enum.">;
325325

326+
def TestParamCopyCount : AttrParameter<"CopyCount", "", "const CopyCount &"> {}
327+
328+
// Test overridding attribute builders with a custom builder.
329+
def TestCopyCount : Test_Attr<"TestCopyCount"> {
330+
let mnemonic = "copy_count";
331+
let parameters = (ins TestParamCopyCount:$copy_count);
332+
let assemblyFormat = "`<` $copy_count `>`";
333+
}
334+
335+
336+
326337

327338
#endif // TEST_ATTRDEFS

mlir/test/lib/Dialect/Test/TestAttributes.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "llvm/ADT/TypeSwitch.h"
2323
#include "llvm/ADT/bit.h"
2424
#include "llvm/Support/ErrorHandling.h"
25+
#include "llvm/Support/raw_ostream.h"
2526

2627
using namespace mlir;
2728
using namespace test;
@@ -175,6 +176,45 @@ static void printTrueFalse(AsmPrinter &p, std::optional<int> result) {
175176
p << (*result ? "true" : "false");
176177
}
177178

179+
//===----------------------------------------------------------------------===//
180+
// CopyCountAttr Implementation
181+
//===----------------------------------------------------------------------===//
182+
183+
CopyCount::CopyCount(const CopyCount &rhs) : value(rhs.value) {
184+
CopyCount::counter++;
185+
}
186+
187+
CopyCount &CopyCount::operator=(const CopyCount &rhs) {
188+
CopyCount::counter++;
189+
value = rhs.value;
190+
return *this;
191+
}
192+
193+
int CopyCount::counter;
194+
195+
static bool operator==(const test::CopyCount &lhs, const test::CopyCount &rhs) {
196+
return lhs.value == rhs.value;
197+
}
198+
199+
llvm::raw_ostream &test::operator<<(llvm::raw_ostream &os,
200+
const test::CopyCount &value) {
201+
return os << value.value;
202+
}
203+
204+
template <>
205+
struct mlir::FieldParser<test::CopyCount> {
206+
static FailureOr<test::CopyCount> parse(AsmParser &parser) {
207+
std::string value;
208+
if (parser.parseKeyword(value))
209+
return failure();
210+
return test::CopyCount(value);
211+
}
212+
};
213+
namespace test {
214+
llvm::hash_code hash_value(const test::CopyCount &copyCount) {
215+
return llvm::hash_value(copyCount.value);
216+
}
217+
} // namespace test
178218
//===----------------------------------------------------------------------===//
179219
// Tablegen Generated Definitions
180220
//===----------------------------------------------------------------------===//

mlir/test/lib/Dialect/Test/TestAttributes.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929

3030
namespace test {
3131
class TestDialect;
32+
// Payload class for the CopyCountAttr.
33+
class CopyCount {
34+
public:
35+
CopyCount(std::string value) : value(value) {}
36+
CopyCount(const CopyCount &rhs);
37+
CopyCount &operator=(const CopyCount &rhs);
38+
CopyCount(CopyCount &&rhs) = default;
39+
CopyCount &operator=(CopyCount &&rhs) = default;
40+
static int counter;
41+
std::string value;
42+
};
43+
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
44+
const test::CopyCount &value);
3245

3346
/// A handle used to reference external elements instances.
3447
using TestDialectResourceBlobHandle =

mlir/test/mlir-tblgen/attrdefs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
8282
// Check that AttributeSelfTypeParameter is handled properly.
8383
// DEF-LABEL: struct CompoundAAttrStorage
8484
// DEF: CompoundAAttrStorage(
85-
// DEF-SAME: inner(inner)
85+
// DEF-SAME: inner(std::move(inner))
8686

8787
// DEF: bool operator==(const KeyTy &tblgenKey) const {
8888
// DEF-NEXT: return
@@ -94,7 +94,7 @@ def B_CompoundAttrA : TestAttr<"CompoundA"> {
9494

9595
// DEF: static CompoundAAttrStorage *construct
9696
// DEF: return new (allocator.allocate<CompoundAAttrStorage>())
97-
// DEF-SAME: CompoundAAttrStorage(widthOfSomething, exampleTdType, apFloat, dims, inner);
97+
// DEF-SAME: CompoundAAttrStorage(std::move(widthOfSomething), std::move(exampleTdType), std::move(apFloat), std::move(dims), std::move(inner));
9898

9999
// DEF: ::mlir::Type CompoundAAttr::getInner() const {
100100
// DEF-NEXT: return getImpl()->inner;

0 commit comments

Comments
 (0)