public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105326] New: aarch64: functions affected by irrelevant function changes
@ 2022-04-21  7:10 nobuta.keiya at fujitsu dot com
  2022-04-21  7:11 ` [Bug c/105326] " nobuta.keiya at fujitsu dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: nobuta.keiya at fujitsu dot com @ 2022-04-21  7:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

            Bug ID: 105326
           Summary: aarch64: functions affected by irrelevant function
                    changes
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nobuta.keiya at fujitsu dot com
  Target Milestone: ---

Created attachment 52841
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52841&action=edit
The .i file of original source

When making the Linux kernel with minor change patch, gcc of aarch64 is
unexpectedly changing functions that is not call-related the function affected
by patch.


$ cd github/torvalds/linux
$ git describe
v5.17

To compare functions, add the following options:
$ export KCFLAGS="-ffunction-sections"

Make original object, and rename it to remember original object.
$ make mm/slub.o
$ mv mm/slub.o orig.o

Apply patch the following:
$ cat a.patch
diff -Nupr src.orig/mm/slub.c src/mm/slub.c
--- src.orig/mm/slub.c  2021-11-17 22:21:43.993307847 -0500
+++ src/mm/slub.c       2021-11-17 22:22:01.122335563 -0500
@@ -5910,6 +5910,9 @@ void get_slabinfo(struct kmem_cache *s,
        int node;
        struct kmem_cache_node *n;

+       if (!jiffies)
+               printk("slabinfo\n");
+
        for_each_kmem_cache_node(s, node, n) {
                nr_slabs += node_nr_slabs(n);
                nr_objs += node_nr_objs(n);
$ git apply a.patch

Make patched object, and rename it.
$ make mm/slub.o
$ mv mm/slub.o patched.o

Comparing the results of both objdumps, I can see the difference in the
following functions:
- bit_spin_lock.constprop.0
- add_location.constprop.0.isra.0
- __check_heap_object
- get_slabinfo

For example, diff of bit_spin_lock.constprop.0 is shown:

$ diff -u <(objdump -Dr -j .text.bit_spin_lock_constprop.0 orig.o)
          <(objdump -Dr -j .text.bit_spin_lock_constprop.0 patched.o)
--- /dev/fd/63  2022-04-21 15:52:37.204130000 +0900
+++ /dev/fd/62  2022-04-21 15:52:37.204130000 +0900
@@ -1,37 +1,29 @@

-orig/slub.o:     file format elf64-littleaarch64
+patched/slub.o:     file format elf64-littleaarch64


 Disassembly of section .text.bit_spin_lock.constprop.0:

 0000000000000000 <bit_spin_lock.constprop.0>:
    0:  d503233f        paciasp
-   4:  a9be7bfd        stp     x29, x30, [sp, #-32]!
-   8:  910003fd        mov     x29, sp
-   c:  a90153f3        stp     x19, x20, [sp, #16]
-  10:  aa0003f3        mov     x19, x0
-  14:  d2800034        mov     x20, #0x1                       // #1
-  18:  f9400260        ldr     x0, [x19]
-  1c:  37000140        tbnz    w0, #0, 44 <bit_spin_lock.constprop.0+0x44>
-  20:  94000000        bl      0 <bit_spin_lock.constprop.0>
-                       20: R_AARCH64_CALL26    .text.system_uses_lse_atomics
<..snip..>


I looked at functions other than get_slabinfo(), but it doesn't look like it's
called by get_slabinfo(), or calls get_slabinfo(). Comparing the objects seems
to differ in how the registers are used and whether inline functions are
expanded.

Also, changing the kernel version and doing the same seems to change
percpu_ref_put_many.constprop.0 and memcg_slab_free_hook.

I would like to know why this happens.


Using gcc from Fedora:
$ gcc v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/11/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-aarch64-redhat-linux/isl-install
--enable-gnu-indirect-function --build=aarch64-redhat-linux
--with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)


Full gcc cmdline:
gcc -Wp,-MMD,mm/.slub.o.d -nostdinc -I./arch/arm64/include
-I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi
-I./arch/arm64/include/generated/uapi -I./include/uapi
-I./include/generated/uapi -include ./include/linux/compiler-version.h -include
./include/linux/kconfig.h -include ./include/linux/compiler_types.h
-D__KERNEL__ -mlittle-endian -DCC_USING_PATCHABLE_FUNCTION_ENTRY
-DKASAN_SHADOW_SCALE_SHIFT= -fmacro-prefix-map=./= -Wall -Wundef
-Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-fshort-wchar -fno-PIE -Werror=implicit-function-declaration
-Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89
-mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=1 -Wno-psabi -mabi=lp64
-fno-asynchronous-unwind-tables -fno-unwind-tables
-mbranch-protection=pac-ret+leaf+bti -Wa,-march=armv8.5-a
-DARM64_ASM_ARCH='"armv8.5-a"' -DKASAN_SHADOW_SCALE_SHIFT=
-fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation
-Wno-format-overflow -Wno-address-of-packed-member -O2
-fno-allow-store-data-races -Wframe-larger-than=1024 -fno-stack-protector
-Wimplicit-fallthrough=5 -Wno-main -Wno-unused-but-set-variable
-Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls
-fno-stack-clash-protection -fpatchable-function-entry=2
-fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla
-Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow
-fno-stack-check -fconserve-stack -Werror=date-time
-Werror=incompatible-pointer-types -Werror=designated-init
-Wno-packed-not-aligned -g -gdwarf-4 -ffunction-sections -ffunction-sections
-fdata-sections    -DKBUILD_MODFILE='"mm/slub"' -DKBUILD_BASENAME='"slub"'
-DKBUILD_MODNAME='"slub"' -D__KBUILD_MODNAME=kmod_slub -c -o mm/slub.o
mm/slub.c


I tried the same thing using a cross-compiler builded by yocto, I see same
issue with "aarch64-poky-linux-gcc (GCC) 11.1.0" but I didn't see this issue
with "aarch64-poky-linux-gcc (GCC) 10.3.0". This seems to happen with aarch64
gcc-11.1.0 and later.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
@ 2022-04-21  7:11 ` nobuta.keiya at fujitsu dot com
  2022-04-21  7:20 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: nobuta.keiya at fujitsu dot com @ 2022-04-21  7:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

--- Comment #1 from Keiya Nobuta <nobuta.keiya at fujitsu dot com> ---
Created attachment 52842
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52842&action=edit
The .i file of patched source

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
  2022-04-21  7:11 ` [Bug c/105326] " nobuta.keiya at fujitsu dot com
@ 2022-04-21  7:20 ` rguenth at gcc dot gnu.org
  2022-04-21  7:24 ` [Bug ipa/105326] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |aarch64

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Inline heuristic depend on the CU size, adding the stmt could thus change
inlining in unrelated functions.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ipa/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
  2022-04-21  7:11 ` [Bug c/105326] " nobuta.keiya at fujitsu dot com
  2022-04-21  7:20 ` rguenth at gcc dot gnu.org
@ 2022-04-21  7:24 ` pinskia at gcc dot gnu.org
  2022-04-21  7:34 ` nobuta.keiya at fujitsu dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-21  7:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |ipa
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes inlining heuristics and many some other ipa based ones are based on the
whole translation unit. So changing one minor thing even if it does not look
like it would, can change the whole output and such.
I don't think this is a bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ipa/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
                   ` (2 preceding siblings ...)
  2022-04-21  7:24 ` [Bug ipa/105326] " pinskia at gcc dot gnu.org
@ 2022-04-21  7:34 ` nobuta.keiya at fujitsu dot com
  2023-11-12  3:43 ` sjames at gcc dot gnu.org
  2023-11-12  4:41 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: nobuta.keiya at fujitsu dot com @ 2022-04-21  7:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

--- Comment #4 from Keiya Nobuta <nobuta.keiya at fujitsu dot com> ---
Thank you for the information.
Can it be suppressed by option?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ipa/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
                   ` (3 preceding siblings ...)
  2022-04-21  7:34 ` nobuta.keiya at fujitsu dot com
@ 2023-11-12  3:43 ` sjames at gcc dot gnu.org
  2023-11-12  4:41 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-12  3:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-11-12
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

--- Comment #5 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Keiya Nobuta from comment #4)
> Thank you for the information.
> Can it be suppressed by option?

You can use the noipa function attribute and there's a bunch of -fno-ipa-*
flags (see https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ipa/105326] aarch64: functions affected by irrelevant function changes
  2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
                   ` (4 preceding siblings ...)
  2023-11-12  3:43 ` sjames at gcc dot gnu.org
@ 2023-11-12  4:41 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-12  4:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105326

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---

(In reply to Sam James from comment #5)
> (In reply to Keiya Nobuta from comment #4)
> > Thank you for the information.
> > Can it be suppressed by option?
> 
> You can use the noipa function attribute and there's a bunch of -fno-ipa-*
> flags (see https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html).

Some --param options which talk about TU size and documented there:
ipa-cp-large-unit-insns
inline-unit-growth
ipa-cp-unit-growth
large-unit-insns

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-12  4:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21  7:10 [Bug c/105326] New: aarch64: functions affected by irrelevant function changes nobuta.keiya at fujitsu dot com
2022-04-21  7:11 ` [Bug c/105326] " nobuta.keiya at fujitsu dot com
2022-04-21  7:20 ` rguenth at gcc dot gnu.org
2022-04-21  7:24 ` [Bug ipa/105326] " pinskia at gcc dot gnu.org
2022-04-21  7:34 ` nobuta.keiya at fujitsu dot com
2023-11-12  3:43 ` sjames at gcc dot gnu.org
2023-11-12  4:41 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).