Fix bccLinkBC.

Change-Id: I67d6f1a0dabfb272416a1f89258252facfbb3c00
diff --git a/lib/bcc/Compiler.cpp b/lib/bcc/Compiler.cpp
index e13d989..c011fd8 100644
--- a/lib/bcc/Compiler.cpp
+++ b/lib/bcc/Compiler.cpp
@@ -263,10 +263,13 @@
 }
 
 
+// bitcodeSize == 1: Link against file
+// bitcodeSize > 1: Link against buffer
 int Compiler::linkBC(const char *bitcode, size_t bitcodeSize) {
   llvm::OwningPtr<llvm::MemoryBuffer> MEM;
 
-  if (bitcode == NULL || bitcodeSize <= 0) {
+  if (bitcodeSize = 1) {  // link against file
+  } else if (bitcode == NULL || bitcodeSize <= 0) {
     LOGE("Invalid bitcode for linkBC\n");
     return 1;
   }
diff --git a/lib/bcc/Script.cpp b/lib/bcc/Script.cpp
index 89d6115..f539cc0 100644
--- a/lib/bcc/Script.cpp
+++ b/lib/bcc/Script.cpp
@@ -234,7 +234,8 @@
   }
 
   // Link the source module with the library module
-  if (libraryBC) {
+  if (librarySize == 1 /* link against file */ ||
+      libraryBC        /* link against buffer */) {
     if (mCompiled->linkBC(NULL, libraryBC, librarySize, 0) != 0) {
       return 1;
     }
diff --git a/lib/bcc/rslib.bc b/lib/bcc/rslib.bc
index 034118a..584b2f0 100644
--- a/lib/bcc/rslib.bc
+++ b/lib/bcc/rslib.bc
Binary files differ
diff --git a/lib/bcc/rslib.ll b/lib/bcc/rslib.ll
index 718814c..959e75e 100644
--- a/lib/bcc/rslib.ll
+++ b/lib/bcc/rslib.ll
@@ -5,9 +5,17 @@
   ret <3 x float> %conv
 }
 
-define <3 x i8> @_Z15convert2uchar3Dv3_f(<3 x float> %f3) nounwind readnone {
-  %conv = fptoui <3 x float> %f3 to <3 x i8>
-  ret <3 x i8> %conv
+define <3 x i8> @_Z14convert2uchar3Dv3_f(<3 x float> %v) nounwind {
+  %1 = extractelement <3 x float> %v, i32 0
+  %2 = fptoui float %1 to i8
+  %3 = insertelement <3 x i8> undef, i8 %2, i32 0
+  %4 = extractelement <3 x float> %v, i32 1
+  %5 = fptoui float %4 to i8
+  %6 = insertelement <3 x i8> %3, i8 %5, i32 1
+  %7 = extractelement <3 x float> %v, i32 2
+  %8 = fptoui float %7 to i8
+  %9 = insertelement <3 x i8> %6, i8 %8, i32 2
+  ret <3 x i8> %9
 }
 
 declare float @llvm.powi.f32(float, i32) nounwind readonly