Screen bitcode for non-RS functions before linking with runtime lib

Bug: 19425238
Bug: 20894432

Perform the screening of non-RenderScript functions in the script before
linking against the runtime lib.  Previously, this used to be done after
linking with the runtime lib, LTO passes and just before code
generation.

This allows vendors to link against a different runtime library that may
not have all the functions as the CPU reference driver and add new
builtins specific to their driver.

Moreover, symbols introduced by LLVM optimizations no longer need any
special handling.

Change-Id: I5628aa15547a9d56ef7e6550fcb45e8ffa821ade
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 942a1f3..21874f2 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -119,6 +119,12 @@
     pScript.getSource().addBuildChecksumMetadata(pBuildChecksum);
   }
 
+  // Verify that the only external functions in pScript are Renderscript
+  // functions.  Fail if verification returns an error.
+  if (mCompiler.screenGlobalFunctions(pScript) != Compiler::kSuccess) {
+    return Compiler::kErrInvalidSource;
+  }
+
   //===--------------------------------------------------------------------===//
   // Link RS script with Renderscript runtime.
   //===--------------------------------------------------------------------===//