Thread (13 messages) 13 messages, 5 authors, 2020-10-30

Re: [PATCH] [v2] x86: apic: avoid -Wshadow warning in header

From: Arvind Sankar <hidden>
Date: 2020-10-29 21:35:21
Also in: kvm, linux-iommu, lkml, platform-driver-x86, xen-devel

On Thu, Oct 29, 2020 at 09:41:13PM +0100, Thomas Gleixner wrote:
On Thu, Oct 29 2020 at 17:59, Paolo Bonzini wrote:
quoted
On 29/10/20 17:56, Arvind Sankar wrote:
quoted
quoted
For those two just add:
	struct apic *apic = x86_system_apic;
before all the assignments.
Less churn and much better code.
Why would it be better code?
I think he means the compiler produces better code, because it won't
read the global variable repeatedly.  Not sure if that's true,(*) but I
think I do prefer that version if Arnd wants to do that tweak.
It's not true.

     foo *p = bar;

     p->a = 1;
     p->b = 2;

The compiler is free to reload bar after accessing p->a and with

    bar->a = 1;
    bar->b = 1;

it can either cache bar in a register or reread it after bar->a

The generated code is the same as long as there is no reason to reload,
e.g. register pressure.

Thanks,

        tglx
It's not quite the same.

https://godbolt.org/z/4dzPbM

With -fno-strict-aliasing, the compiler reloads the pointer if you write
to the start of what it points to, but not if you write to later
elements.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help