Messages in this thread |  | | From | Linus Torvalds <> | Date | Sun, 17 Jul 2022 13:56:55 -0700 | Subject | Re: mainline build failure of powerpc allmodconfig for prom_init_check |
| |
On Sun, Jul 17, 2022 at 1:38 PM Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote: > > I have also tried adding volatile to all the members of that struct. :(
Can you read the code to figure otu what the memcpy is all about?
Or maybe there is something that disables 'volatile' with pre-processor hackery.
Because a compiler that turns a loop over volatile members into 'memset()' isn't a C compiler, it's just a random noise generator. 'volatile' is fundamental enough that I really doubt both gcc and clang can be that broken.
I just tested this
struct hello { volatile int array[100]; };
void test(void) { int i; struct hello hello; for (i = 0; i < 100; i++) hello.array[i] = 0; }
on x86-64, and sure enough, gcc-12 turns turns it into a memset without the volatile (in fact, the above will just be optimized away entirely since it has no user), but with the volatile it's a proper regular loop that does 32-byte accesses one by one (and in the proper ascending oder). Something that memset() most definitely does not guarantee:
.L2: movslq %eax, %rdx addl $1, %eax movl $0, -120(%rsp,%rdx,4) cmpl $100, %eax jne .L2
and honestly, anything else sounds completely unacceptable.
So I suspect there is something wrong with your testing, because gcc simply isn't that incredibly broken. Clang is interesting in that it seems to unroll the loop five times, but it still does the proper "write individual 32-bit entities in ascending order".
The other alternative is that it's something else than that 'struct prom_args'. Again, I don't read powerpc asm good.
Linus
|  |