Skip to content

Commit 753f296

Browse files
committed
Address more comments and use -verify-roundtrip
1 parent dd8aa3d commit 753f296

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialectBytecode.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,21 @@ static LogicalResult writeAttribute(Attribute attribute,
3939
template <class EntryTy>
4040
static void writeOptionalArrayRef(DialectBytecodeWriter &writer,
4141
ArrayRef<EntryTy> storage) {
42-
if (!storage.empty()) {
43-
writer.writeOwnedBool(true);
44-
writer.writeList(storage, [&](EntryTy val) {
45-
if constexpr (std::is_base_of_v<Attribute, EntryTy>) {
46-
(void)writer.writeOptionalAttribute(val);
47-
} else if constexpr (std::is_integral_v<EntryTy>) {
48-
(void)writer.writeVarInt(val);
49-
} else
50-
static_assert(true, "EntryTy not supported");
51-
});
52-
} else {
42+
if (storage.empty()) {
5343
writer.writeOwnedBool(false);
44+
return;
5445
}
46+
47+
writer.writeOwnedBool(true);
48+
writer.writeList(storage, [&](EntryTy val) {
49+
if constexpr (std::is_base_of_v<Attribute, EntryTy>) {
50+
(void)writer.writeOptionalAttribute(val);
51+
} else if constexpr (std::is_integral_v<EntryTy>) {
52+
(void)writer.writeVarInt(val);
53+
} else {
54+
static_assert(true, "EntryTy not supported");
55+
}
56+
});
5557
}
5658

5759
template <class EntryTy>
@@ -72,8 +74,9 @@ static LogicalResult readOptionalArrayRef(DialectBytecodeReader &reader,
7274
} else if constexpr (std::is_integral_v<EntryTy>) {
7375
if (succeeded(reader.readVarInt(temp)))
7476
return temp;
75-
} else
77+
} else {
7678
static_assert(true, "EntryTy not supported");
79+
}
7780
return failure();
7881
};
7982

0 commit comments

Comments
 (0)