[PATCH] D37166: [builtins] Prevent duplicate definitions for overridden functions

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 13:59:32 PDT 2017


fjricci created this revision.
Herald added a subscriber: mgorny.

Some architecture-specific function overrides (for example, i386/ashrdi3.S)
duplicate generic functions (in that case, ashrdi3.c). Prevent duplicate definitions
by filtering out the generic files before compiling.


https://reviews.llvm.org/D37166

Files:
  cmake/Modules/CompilerRTUtils.cmake
  lib/builtins/CMakeLists.txt


Index: lib/builtins/CMakeLists.txt
===================================================================
--- lib/builtins/CMakeLists.txt
+++ lib/builtins/CMakeLists.txt
@@ -235,8 +235,8 @@
       x86_64/floatdixf.c
       x86_64/floatundidf.S
       x86_64/floatundisf.S
-      x86_64/floatundixf.S
-      ${GENERIC_SOURCES})
+      x86_64/floatundixf.S)
+  append_and_filter_sources("${GENERIC_SOURCES}" "${x86_64_SOURCES}" x86_64_SOURCES)
   set(x86_64h_SOURCES ${x86_64_SOURCES})
 
   if (WIN32)
@@ -262,8 +262,8 @@
       i386/moddi3.S
       i386/muldi3.S
       i386/udivdi3.S
-      i386/umoddi3.S
-      ${GENERIC_SOURCES})
+      i386/umoddi3.S)
+  append_and_filter_sources("${GENERIC_SOURCES}" "${i386_SOURCES}" i386_SOURCES)
 
   if (WIN32)
     set(i386_SOURCES
@@ -281,8 +281,8 @@
   set(x86_64_SOURCES
       x86_64/floatdidf.c
       x86_64/floatdisf.c
-      x86_64/floatdixf.c
-      ${GENERIC_SOURCES})
+      x86_64/floatdixf.c)
+  append_and_filter_sources("${GENERIC_SOURCES}" "${x86_64_SOURCES}" x86_64_SOURCES)
   set(x86_64h_SOURCES ${x86_64_SOURCES})
   set(i386_SOURCES ${GENERIC_SOURCES})
   set(i686_SOURCES ${i386_SOURCES})
@@ -319,15 +319,15 @@
   arm/sync_fetch_and_xor_8.S
   arm/udivmodsi4.S
   arm/udivsi3.S
-  arm/umodsi3.S
-  ${GENERIC_SOURCES})
+  arm/umodsi3.S)
+append_and_filter_sources("${GENERIC_SOURCES}" "${arm_SOURCES}" arm_SOURCES)
 
 set(thumb1_SOURCES
   arm/divsi3.S
   arm/udivsi3.S
   arm/comparesf2.S
-  arm/addsf3.S
-  ${GENERIC_SOURCES})
+  arm/addsf3.S)
+append_and_filter_sources("${GENERIC_SOURCES}" "${thumb1_SOURCES}" thumb1_SOURCES)
 
 set(arm_EABI_SOURCES
   arm/aeabi_cdcmp.S
Index: cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- cmake/Modules/CompilerRTUtils.cmake
+++ cmake/Modules/CompilerRTUtils.cmake
@@ -273,3 +273,21 @@
     set(COMPILER_RT_HAS_EXPLICIT_DEFAULT_TARGET_TRIPLE FALSE)
   endif()
 endmacro()
+
+function(append_and_filter_sources sources filter output)
+  set(base_filter)
+  foreach(source ${filter})
+    get_filename_component(basename ${source} NAME_WE)
+    list(APPEND base_filter ${basename})
+  endforeach()
+
+  foreach(source ${sources})
+    get_filename_component(basename ${source} NAME_WE)
+    list(FIND base_filter ${basename} val)
+    if(${val} EQUAL -1)
+      list(APPEND filter ${source})
+    endif()
+  endforeach()
+
+  set(${output} ${filter} PARENT_SCOPE)
+endfunction()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37166.112743.patch
Type: text/x-patch
Size: 2440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170825/e8ce62b2/attachment.bin>


More information about the llvm-commits mailing list