mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Cloning: move arguments to create() into temporary locals
In C++ argument evaluation order is undefined. MSVC and Clang evaluate these in different orders, leading to hilarity when writing tests that expect a deterministic ordering. Pull out all the argument expressions to create() in the clone functions so a cloned program is deterministic in its ordering between compilers. Change-Id: I8e2de31398960c480ce7ee1dfaac4f67652d2dbc Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41544 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
7b6bcb6e0b
commit
545c9742d5
@@ -77,7 +77,9 @@ uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
}
|
||||
|
||||
AccessControl* AccessControl::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<AccessControl>(access_, ctx->Clone(subtype_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<AccessControl>(access_, ty);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -50,7 +50,10 @@ uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
}
|
||||
|
||||
Alias* Alias::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Alias>(ctx->Clone(symbol()), ctx->Clone(subtype_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto sym = ctx->Clone(symbol());
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<Alias>(sym, ty);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -109,8 +109,10 @@ std::string Array::FriendlyName(const SymbolTable& symbols) const {
|
||||
}
|
||||
|
||||
Array* Array::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Array>(ctx->Clone(subtype_), size_,
|
||||
ctx->Clone(decorations()));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
auto decos = ctx->Clone(decorations());
|
||||
return ctx->dst->create<Array>(ty, size_, decos);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -63,7 +63,9 @@ uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
}
|
||||
|
||||
Matrix* Matrix::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Matrix>(ctx->Clone(subtype_), rows_, columns_);
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<Matrix>(ty, rows_, columns_);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -49,7 +49,9 @@ std::string MultisampledTexture::FriendlyName(
|
||||
}
|
||||
|
||||
MultisampledTexture* MultisampledTexture::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<MultisampledTexture>(dim(), ctx->Clone(type_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<MultisampledTexture>(dim(), ty);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -46,7 +46,9 @@ Pointer::Pointer(Pointer&&) = default;
|
||||
Pointer::~Pointer() = default;
|
||||
|
||||
Pointer* Pointer::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Pointer>(ctx->Clone(subtype_), storage_class_);
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<Pointer>(ty, storage_class_);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -47,7 +47,9 @@ std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const {
|
||||
}
|
||||
|
||||
SampledTexture* SampledTexture::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<SampledTexture>(dim(), ctx->Clone(type_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<SampledTexture>(dim(), ty);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -163,8 +163,9 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
|
||||
}
|
||||
|
||||
StorageTexture* StorageTexture::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<StorageTexture>(dim(), image_format_,
|
||||
ctx->Clone(subtype_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<StorageTexture>(dim(), image_format_, ty);
|
||||
}
|
||||
|
||||
type::Type* StorageTexture::SubtypeFor(type::ImageFormat format,
|
||||
|
||||
@@ -87,7 +87,10 @@ uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
}
|
||||
|
||||
Struct* Struct::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Struct>(ctx->Clone(symbol()), ctx->Clone(struct_));
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto sym = ctx->Clone(symbol());
|
||||
auto* str = ctx->Clone(impl());
|
||||
return ctx->dst->create<Struct>(sym, str);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -59,7 +59,9 @@ uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
}
|
||||
|
||||
Vector* Vector::Clone(CloneContext* ctx) const {
|
||||
return ctx->dst->create<Vector>(ctx->Clone(subtype_), size_);
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto* ty = ctx->Clone(type());
|
||||
return ctx->dst->create<Vector>(ty, size_);
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
|
||||
Reference in New Issue
Block a user