OSDN Git Service

Fix loading uninitialized data in loops.
authorNicolas Capens <capn@google.com>
Wed, 18 Jan 2017 15:18:03 +0000 (10:18 -0500)
committerNicolas Capens <capn@google.com>
Wed, 18 Jan 2017 16:28:38 +0000 (16:28 +0000)
When we have an uninitialized variable that is declared outside of a
loop and is read and written to inside the loop, we should not eliminate
the load and replace it with an undefined value, because in the next
iteration we want the value from the previous iteration.

Change-Id: Ic996c796307f62fc835079af6c58adf1eb288259
Reviewed-on: https://swiftshader-review.googlesource.com/8488
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Reactor/Optimizer.cpp

index ffd29bb..ca3d7a3 100644 (file)
@@ -328,7 +328,10 @@ namespace
                                                        continue;
                                                }
 
-                                               replace(load, storeValue);
+                                               if(storeValue)
+                                               {
+                                                       replace(load, storeValue);
+                                               }
                                        }
                                }
                        }