Fix materialization of function arguments

Subzero does not appear to preserve function arguments passed in as
registers onto the stack by itself. Any scratch registers can get reused
for local variable register allocation.

This workaround simply materializes each concrete Reactor variable
constructed from an argument on definition. It does not ensure that
arguments turned into variables at a later point are properly preserved.
Also this solution does not centralize the materialization, making it
bug prone when new concrete Reactor types are implemented.

Bug b/129757459

Change-Id: I1007ea0e7204d05e60203b2e896589a03fc515a9
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28309
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index b022533..80d12e0 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -89,6 +89,7 @@
 
 	Bool::Bool(Argument<Bool> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -164,6 +165,7 @@
 
 	Byte::Byte(Argument<Byte> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -421,6 +423,7 @@
 
 	SByte::SByte(Argument<SByte> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -666,6 +669,7 @@
 
 	Short::Short(Argument<Short> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -904,6 +908,7 @@
 
 	UShort::UShort(Argument<UShort> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -2119,6 +2124,7 @@
 
 	Int::Int(Argument<Int> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -2503,6 +2509,7 @@
 
 	UInt::UInt(Argument<UInt> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
@@ -3662,6 +3669,7 @@
 
 	Float::Float(Argument<Float> argument)
 	{
+		materialize();  // FIXME(b/129757459)
 		storeValue(argument.value);
 	}
 
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index ee473a6..a0064b9 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2626,6 +2626,7 @@
 	template<class T>
 	Pointer<T>::Pointer(Argument<Pointer<T>> argument) : alignment(1)
 	{
+		LValue<Pointer<T>>::materialize();  // FIXME(b/129757459)
 		LValue<Pointer<T>>::storeValue(argument.value);
 	}