dawn-cmake/test/tint/bug/oss-fuzz/57795.spv.expected.msl
James Price ae39e6d628 spirv-reader: Declare multiuse constant composites
When an OpConstantComposite result is used by multiple instructions,
declare it as a module-scope `const` instead of inlining the constant
at each use site. This fixes an issue whereby the spirv-reader was
massively inflating the size of the WGSL it produces, which was caught
via an OOM fuzzer bug.

Bug: oss-fuzz:57795
Change-Id: Iac8c6a2147a7e2ebfddbaacae9fcb1dbe0b59e9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128881
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2023-04-25 19:16:25 +00:00

65 lines
1.3 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
struct S_6 {
tint_array<tint_array<float3, 18>, 13> field0;
};
struct tint_private_vars_struct {
tint_array<float4x4, 58> x_75;
tint_array<S_6, 46> x_82;
tint_array<float3, 37> x_85;
};
struct S {
float3x3 field0;
};
struct S_1 {
tint_array<tint_array<tint_array<S, 83>, 21>, 47> field0;
};
struct S_2 {
tint_array<tint_array<float3, 37>, 95> field0;
};
struct S_3 {
S_2 field0;
};
struct S_4 {
tint_array<int2, 56> field0;
};
struct S_5 {
S_4 field0;
};
struct S_7 {
tint_array<int2, 88> field0;
};
void main_1() {
uint const x_88 = 58u;
return;
}
fragment void tint_symbol() {
main_1();
return;
}