Merge "Preserve generalized reduction combiner function for use by driver." into nyc-dev
diff --git a/lib/Core/Compiler.cpp b/lib/Core/Compiler.cpp
index fe16b71..4062294 100644
--- a/lib/Core/Compiler.cpp
+++ b/lib/Core/Compiler.cpp
@@ -358,12 +358,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");
@@ -376,8 +376,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 12f0b28..8bf5a75 100644
--- a/lib/Renderscript/RSKernelExpand.cpp
+++ b/lib/Renderscript/RSKernelExpand.cpp
@@ -1565,6 +1565,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