Enable parallel llvm code-gen
Change-Id: I963b11769921d7f235aa1b196665e2ef0e083083
Conflicts:
tests/abcc/jni/Android.mk
diff --git a/tests/abcc/jni/Android.mk b/tests/abcc/jni/Android.mk
index 51fd885..aeebf4a 100644
--- a/tests/abcc/jni/Android.mk
+++ b/tests/abcc/jni/Android.mk
@@ -31,10 +31,15 @@
LOCAL_SHARED_LIBRARIES := liblog libstlport
include external/stlport/libstlport.mk
+include $(BUILD_SHARED_LIBRARY)
else # SYSTEM_PREBUILT_PACKAGE
+LOCAL_CFLAGS += -DENABLE_PARALLEL_LLVM_CG=1
LOCAL_LDLIBS := -llog
+LOCAL_STATIC_LIBRARIES := cpufeatures
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,android/cpufeatures)
endif
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/abcc/jni/main.cpp b/tests/abcc/jni/main.cpp
index 2a804ba..d7b2751 100644
--- a/tests/abcc/jni/main.cpp
+++ b/tests/abcc/jni/main.cpp
@@ -26,6 +26,10 @@
#include <vector>
#include <fstream>
#include <pthread.h>
+#if ENABLE_PARALLEL_LLVM_CG
+#include <sstream>
+#include <cpu-features.h>
+#endif
#define LOG_TAG "AbccNative"
#define LOGE(format, ...) do {\
@@ -440,6 +444,11 @@
#endif
cmd += " -filetype=obj -relocation-model=pic -code-model=small";
cmd += " -use-init-array -mc-relax-all -float-abi=soft -O2";
+#if ENABLE_PARALLEL_LLVM_CG
+ std::ostringstream stream;
+ stream << android_getCpuCount();
+ cmd += " -thread=" + stream.str();
+#endif
cmd += std::string(" ") + target_data[abi][target_extra_cflags];
cmd += std::string(" -o ") + obj;
cmd += std::string(" ") + target_bc;