GLES: Add tests to exersise sparse labels.

Reproduces the issues reported by b/125183107.

Bug: b/125183107
Change-Id: If0f2ab3fcc8c065409fdbbc6df670f78a78fa3f7
Reviewed-on: https://swiftshader-review.googlesource.com/c/25169
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/tests/GLESUnitTests/unittests.cpp b/tests/GLESUnitTests/unittests.cpp
index 55813b3..33fbaf6 100644
--- a/tests/GLESUnitTests/unittests.cpp
+++ b/tests/GLESUnitTests/unittests.cpp
@@ -1578,6 +1578,22 @@
 	);
 }
 
+// Test that the compiler correctly handles functions being stripped.
+// The frontend will strip the Dead functions, but may keep the their function
+// labels reserved. This produces labels that are greater than the number of
+// live functions.
+TEST_F(SwiftShaderTest, CompilerLimits_SparseLabels)
+{
+	checkCompiles(
+		"void Dead1() {}\n"
+		"void Dead2() {}\n"
+		"void Dead3() {}\n"
+		"void Dead4() {}\n"
+		"void Dead5() { Dead1(); Dead2(); Dead3(); Dead4(); }\n"
+		"float F(float f) { for(int i = 0; i < -1; ++i) { Dead5(); } return f; }\n"
+	);
+}
+
 #ifndef EGL_ANGLE_iosurface_client_buffer
 #define EGL_ANGLE_iosurface_client_buffer 1
 #define EGL_IOSURFACE_ANGLE 0x3454