OSDN Git Service

Fix materialization of function arguments
authorNicolas Capens <capn@google.com>
Tue, 2 Apr 2019 16:05:40 +0000 (12:05 -0400)
committerNicolas Capens <nicolascapens@google.com>
Tue, 2 Apr 2019 18:05:15 +0000 (18:05 +0000)
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>
src/Reactor/Reactor.cpp
src/Reactor/Reactor.hpp

index b022533..80d12e0 100644 (file)
@@ -89,6 +89,7 @@ namespace rr
 
        Bool::Bool(Argument<Bool> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -164,6 +165,7 @@ namespace rr
 
        Byte::Byte(Argument<Byte> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -421,6 +423,7 @@ namespace rr
 
        SByte::SByte(Argument<SByte> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -666,6 +669,7 @@ namespace rr
 
        Short::Short(Argument<Short> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -904,6 +908,7 @@ namespace rr
 
        UShort::UShort(Argument<UShort> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -2119,6 +2124,7 @@ namespace rr
 
        Int::Int(Argument<Int> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -2503,6 +2509,7 @@ namespace rr
 
        UInt::UInt(Argument<UInt> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
@@ -3662,6 +3669,7 @@ namespace rr
 
        Float::Float(Argument<Float> argument)
        {
+               materialize();  // FIXME(b/129757459)
                storeValue(argument.value);
        }
 
index ee473a6..a0064b9 100644 (file)
@@ -2626,6 +2626,7 @@ namespace rr
        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);
        }