[PATCH 7/8] stdlib: Avoid strlen plt with clang

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Dec 18 12:41:38 GMT 2025



On 17/12/25 21:02, H.J. Lu wrote:
> On Thu, Dec 18, 2025 at 1:56 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> The clang-21 LoopIdiomRecognizePass replaces some loops in
>> __xpg_basename with a strlen call.
> 
> Should it be optimized to a strlen call?

I did not dig into whether this is really beneficial, and I need to
check if we have test to check if the code generation is really ok.

But in any case, the LoopIdiomRecognizePass from clang-21 might
potentially transform other patterns to internal strlen calls. 

> 
>> ---
>>  sysdeps/generic/symbol-hacks.h | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
>> index 58398d33a5..0d728cce91 100644
>> --- a/sysdeps/generic/symbol-hacks.h
>> +++ b/sysdeps/generic/symbol-hacks.h
>> @@ -20,6 +20,7 @@ asm ("__strcpy_chk = __GI___strcpy_chk");
>>  asm ("strcpy = __GI_strcpy");
>>  asm ("strncpy = __GI_strncpy");
>>  asm ("strcat = __GI_strcat");
>> +asm ("strlen = __GI_strlen");
>>
>>  /* Some targets do not use __stack_chk_fail_local.  In libc.so,
>>     redirect __stack_chk_fail to a hidden reference
>> --
>> 2.43.0
>>
> 
> 



More information about the Libc-alpha mailing list