[llvm-commits] PATCH: PR4719 - llvm-gcc should not use duplicate definitions of the same inline function

Shantonu Sen ssen at apple.com
Mon Aug 17 07:24:01 PDT 2009


On Aug 17, 2009, at 3:27 AM, Duncan Sands wrote:

> Hi,
>
>> +/* LLVM LOCAL begin */
>> +/* Don't use ill-defined extern-inline-with-non-inline-definition
>> + */
>> +#if 0
>> #if GCC_VERSION < 3004 || !defined (__cplusplus)
>
> does this mean that llvm-gcc can no longer be built with gcc before
> gcc-3.4?  Also, do you understand why the test checks
> "defined (__cplusplus)"?

My understanding of <http://www.greenend.org.uk/rjk/2003/03/ 
inline.html> is that "static inline" is universally valid and should  
work for all versions of gcc and clang.


>> +/* LLVM LOCAL begin */
>> +/* Use static inline for exact_log2/floor_log2 */
>> +
>> /* Return log2, or -1 if not exact.  */
>> -extern int exact_log2                  (unsigned HOST_WIDE_INT);
>> +static inline int exact_log2                  (unsigned  
>> HOST_WIDE_INT);
>>  /* Return floor of log2, with -1 for zero.  */
>> -extern int floor_log2                  (unsigned HOST_WIDE_INT);
>> +static inline int floor_log2                  (unsigned  
>> HOST_WIDE_INT);
>
> Probably these should only be defined if the same test as above holds
> (GCC_VERSION < 3004 ...).  In which case you wouldn't need the static
> inline changes for this bit.

No, the original source code has an "extern" prototype  
unconditionally, and then for newer GCC's adds an extern inline  
definition underneath it:

/* Return floor of log2, with -1 for zero.  */
extern int floor_log2                  (unsigned HOST_WIDE_INT);

/* Inline versions of the above for speed.  */
#if GCC_VERSION >= 3004

I guess we could eliminate the "extern" prototype" and unconditionally  
convert the "extern inline" to a "static inline" in the header. Also,  
what's the preferred way to delete code that's present in gcc 4.2.1?  
Is it with #if 0, or delete the code block outright?


> Ciao,
>
> Duncan.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090817/0d344e3b/attachment.html>


More information about the llvm-commits mailing list