On Mon, Jan 22, 2018 at 7:55 AM, David Brown <da...@westcontrol.com> wrote: > On 22/01/18 16:46, Manuel Rigger wrote: >> Hi everyone, >> >> As part of my research, we have been analyzing the usage of GCC builtins >> in 5,000 C GitHub projects. One of our findings is that many of these >> builtins are unused, even though they are described in the documentation >> (see https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html#C-Extensions) >> and obviously took time to develop and maintain. I’ve uploaded a CSV >> file with the unused builtins to >> http://ssw.jku.at/General/Staff/ManuelRigger/unused-builtins.csv. >> >> Details: We downloaded all C projects from GitHub that had more than 80 >> GitHub stars, which yielded almost 5,000 projects with a total of more >> than one billion lines of C code. We filtered GCC, forks of GCC, and >> other compilers as we did not want to incorporate internal usages of GCC >> builtins or test cases. We extracted all builtin names from the GCC >> docs, and also tried to find such names in the source code, which we >> considered as builtin usages. We excluded subdirectories with GCC or >> Clang, and removed other false positives. In total, we found 320k >> builtin usages in these projects, and 3030 unused builtins out of a >> total of 6039 builtins. >> >> What is your take on this? Do you believe that some of these unused >> builtins could be removed from the GCC docs or deprecated? Or are they >> used in special "niche" domains that we did not consider? If yes, do you >> think it is worth to maintain them? Are some of them only used in C++ >> projects? Might it be possible to remove their implementations (which >> has already happened for the Cilk Plus builtins)? >> >> We would be glad for any feedback. >> >> - Manuel >> > > Many of these are going to be used automatically by the compiler. You > write "strdup" in your code, and the compiler treats it as > "__builtin_strdup". I don't know that such functions need to be > documented as extensions, but they are certainly in use. > > You will also find that a large number of the builtins are for specific > target processors, and projects using them are not going to turn up on > GitHub. They will be used in embedded software that is not open source.
And the many of the target ones are used indirectly via another function/macro (e.g. __builtin_ia32_ptestc256). The function/macro is defined in a header that GCC provides too. Thanks, Andrew > > I am sure there are builtins that are rarely or never used - but I doubt > if it is anything like as many as you have identified from this survey. > > >