gcc miscompiles csum_tcpudp_magic() on ARMv5

Måns Rullgård mans at mansr.com
Thu Dec 12 09:42:23 EST 2013


Maxime Bizon <mbizon at freebox.fr> writes:

> On Thu, 2013-12-12 at 15:19 +0100, Willy Tarreau wrote:
>
>> I disagree here, since gcc may decide by itself to inline or not, it must
>> not impact the validity of the emitted code. Inline functions have input
>> and output types for a reason!
>
> but the code emitted is completely different for an inlined "occurence"
> of the function and the non-inlined case.
>
> if a function does not use one of its argument, and it is inlined, then
> in the resulting code you see no trace of it

Again, that's an optimisation that does not alter the semantics of the code.
Although the generated code looks very different, it does the same thing.

>> Hmmm aren't you passing a 16-bit register directly to the ASM for being used
>> as a 32-bit one ? This seems hasardous to me since nowhere you tell gcc how
>> you're going to use the register.
>
> this is exactly what I'm complaining about, the arm code for
> csum_tcpudp_nofold() in the kernel does exactly that.
>
>> Could you check if that fixes it :
>> 
>>  static inline uint32_t asm_add(uint16_t len, uint32_t sum)
>>  {
>>          uint32_t len32 = len;
>
> or change the asm_add() proto to take an "uint32_t len" instead, and yes
> of course that fixes it.

It's a bug.  Please report it to the gcc developers.

-- 
Måns Rullgård
mans at mansr.com



More information about the linux-arm-kernel mailing list