build: Add ModuleName per-subdir variable as a way to organize the different
sets of functions/objects into high level groups. Currently we have "builtins"
(the main compiler-rt code), "profile", and "asan".
 - Use this to define CommonFunctions and ArchFunctions to only reference the
   builtins functions.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@145674 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/make/lib_info.mk b/make/lib_info.mk
index 095b1e8..2e85f64 100644
--- a/make/lib_info.mk
+++ b/make/lib_info.mk
@@ -14,6 +14,14 @@
 #   AvailableIn.<function> - The list of subdir keys where 'function' is
 #                            defined.
 
+# Determine the set of available modules.
+AvailableModules := $(sort $(foreach key,$(SubDirKeys),\
+	$($(key).ModuleName)))
+
+# Build a per-module map of subdir keys.
+$(foreach key,$(SubDirKeys),\
+	$(call Append,ModuleSubDirKeys.$($(key).ModuleName),$(key)))
+
 AvailableArchs := $(sort $(foreach key,$(SubDirKeys),\
 	$($(key).OnlyArchs)))
 
@@ -21,12 +29,12 @@
 	$(basename $($(key).ObjNames))))
 
 CommonFunctions := $(sort\
-  $(foreach key,$(SubDirKeys),\
+  $(foreach key,$(ModuleSubDirKeys.builtins),\
     $(if $(call strneq,,$(strip $($(key).OnlyArchs) $($(key).OnlyConfigs))),,\
          $(basename $($(key).ObjNames)))))
 
 # Compute common arch functions.
-$(foreach key,$(SubDirKeys),\
+$(foreach key,$(ModuleSubDirKeys.builtins),\
   $(if $(call strneq,,$($(key).OnlyConfigs)),,\
     $(foreach arch,$($(key).OnlyArchs),\
       $(call Append,ArchFunctions.$(arch),$(sort \