Merge "Preserve generalized reduction combiner function for use by driver."
am: ba87381

* commit 'ba87381eff4539ad6fc7e7c958c01007c26eec78':
  Preserve generalized reduction combiner function for use by driver.

Change-Id: Ia17b0381888ee9547d52d6e93cc28c5b6927e390
diff --git a/lib/Core/Compiler.cpp b/lib/Core/Compiler.cpp
index a9f1df0..7b291f0 100644
--- a/lib/Core/Compiler.cpp
+++ b/lib/Core/Compiler.cpp
@@ -370,12 +370,12 @@
   }
 
   // Expanded foreach and reduce functions should not be internalized;
-  // nor should general reduction initializer and outconverter
-  // functions. keep_funcs keeps the names of these functions around
-  // until createInternalizePass() is finished making its own copy of
-  // the visible symbols.
+  // nor should general reduction initializer, combiner, and
+  // outconverter functions. keep_funcs keeps the names of these
+  // functions around until createInternalizePass() is finished making
+  // its own copy of the visible symbols.
   std::vector<std::string> keep_funcs;
-  keep_funcs.reserve(exportForEachCount + exportReduceCount + exportReduceNewCount*3);
+  keep_funcs.reserve(exportForEachCount + exportReduceCount + exportReduceNewCount*4);
 
   for (i = 0; i < exportForEachCount; ++i) {
     keep_funcs.push_back(std::string(exportForEachNameList[i]) + ".expand");
@@ -388,8 +388,8 @@
   };
   for (i = 0; i < exportReduceNewCount; ++i) {
     keep_funcs.push_back(std::string(exportReduceNewList[i].mAccumulatorName) + ".expand");
-    // Note: driver does not currently use the combiner function
     keepFuncsPushBackIfPresent(exportReduceNewList[i].mInitializerName);
+    keepFuncsPushBackIfPresent(exportReduceNewList[i].mCombinerName);
     keepFuncsPushBackIfPresent(exportReduceNewList[i].mOutConverterName);
   }
 
diff --git a/lib/Renderscript/RSKernelExpand.cpp b/lib/Renderscript/RSKernelExpand.cpp
index aa139f2..674e51f 100644
--- a/lib/Renderscript/RSKernelExpand.cpp
+++ b/lib/Renderscript/RSKernelExpand.cpp
@@ -1651,6 +1651,7 @@
 
     for (size_t i = 0; i < ExportReduceNewCount; ++i) {
       Changed |= PromoteReduceNewFunction(ExportReduceNewList[i].mInitializerName, PromotedFunctions);
+      Changed |= PromoteReduceNewFunction(ExportReduceNewList[i].mCombinerName, PromotedFunctions);
       Changed |= PromoteReduceNewFunction(ExportReduceNewList[i].mOutConverterName, PromotedFunctions);
 
       // Accumulator