https://github.com/wenju-he created 
https://github.com/llvm/llvm-project/pull/135710

llvm-diff shows this PR has no changes to amdgcn--amdhsa.bc.

Motivation is that in our downstream the same category of target built-ins, 
e.g. math, are organized in several different folders. For example, in target 
SOURCES we have math-common/cos.cl, while in generic SOURCES it is math/cos.cl. 
Based on current check rule that compares both folder name and base filename, 
target math-common/cos.cl won't override math/cos.cl when collecting source 
files from SOURCES files in cmake function libclc_configure_lib_source.

With this PR, we allow folder name to be different in the process.

A notable change of this PR is that two entries in SOURCES with the same base 
filename must not implements the same built-in.

>From 1a05195eb897f93c84f6c6bc22f211ad7457fc27 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju...@intel.com>
Date: Mon, 14 Apr 2025 17:17:15 -0700
Subject: [PATCH] [liblc] only check filename part of the source for avoiding
 duplication

llvm-diff shows this PR has no changes to amdgcn--amdhsa.bc.

Motivation is that in our downstream the same category of target
built-ins, e.g. math, are organized in several different folders.
For example, in target SOURCES we have math-common/cos.cl, while in
generic SOURCES it is math/cos.cl. Based on current check rule that
compares both folder name and base filename, target math-common/cos.cl
won't override math/cos.cl when collecting source files from SOURCES
files in cmake function libclc_configure_lib_source.

With this PR, we allow folder name to be different in the process.

A notable change of this PR is that two entries in SOURCES with the same
base filename must not implements the same built-in.
---
 libclc/cmake/modules/AddLibclc.cmake | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index 154f4ea8f6cf5..3be2bf231eb30 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -466,16 +466,22 @@ function(libclc_configure_lib_source LIB_FILE_LIST)
   ## Add the generated convert files here to prevent adding the ones listed in
   ## SOURCES
   set( rel_files ${${LIB_FILE_LIST}} ) # Source directory input files, 
relative to the root dir
-  set( objects ${${LIB_FILE_LIST}} )   # A "set" of already-added input files
+  # A "set" of already-added input files
+  set( objects )
+  foreach( f ${${LIB_FILE_LIST}} )
+    get_filename_component( name ${f} NAME )
+    list( APPEND objects ${name} )
+  endforeach()
 
   foreach( l ${source_list} )
     file( READ ${l} file_list )
     string( REPLACE "\n" ";" file_list ${file_list} )
     get_filename_component( dir ${l} DIRECTORY )
     foreach( f ${file_list} )
+      get_filename_component( name ${f} NAME )
       # Only add each file once, so that targets can 'specialize' builtins
-      if( NOT ${f} IN_LIST objects )
-        list( APPEND objects ${f} )
+      if( NOT ${name} IN_LIST objects )
+        list( APPEND objects ${name} )
         list( APPEND rel_files ${dir}/${f} )
       endif()
     endforeach()

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to