public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
@ 2022-07-20 6:29 ` sen2403 at hotmail dot com
2022-07-20 7:23 ` amonakov at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: sen2403 at hotmail dot com @ 2022-07-20 6:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Eason Lai <sen2403 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sen2403 at hotmail dot com
--- Comment #8 from Eason Lai <sen2403 at hotmail dot com> ---
This problem can be reproduced by arm-none-eabi-gcc 10.2.1-q4 toolchain.
The weak definition in LTO object is been inline directly even there is a
strong definition in normal object. And, the problem is gone if changing
optimization from (-Os) to (-O1 or -O0).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
2022-07-20 6:29 ` [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file sen2403 at hotmail dot com
@ 2022-07-20 7:23 ` amonakov at gcc dot gnu.org
2022-07-20 10:44 ` sen2403 at hotmail dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-07-20 7:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #9 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
I can reproduce it with gcc-10.2. Why is main 'overwritable', but foo is
'available'?
cat /tmp/cchaUSjV.ltrans0.o.079i.inline
;; Function main (main, funcdef_no=0, decl_uid=4385, cgraph_uid=1,
symbol_order=1) (executed once)
weakdef.c:5:5: note: Inlining foo/0 to main/1 with frequency 1.00
foo/0 (foo) @0x7f51a512d168
Type: function definition analyzed
Visibility: preempted_reg external public weak
References:
Referring:
Function foo/0 is inline copy in main/1
Availability: available
Unit id: 2
Function flags: count:1073741824 (estimated locally) body nonfreeing_fn
Called by: main/1 (inlined) (1073741824 (estimated locally),1.00 per call)
Calls:
main/1 (main) @0x7f51a512d000
Type: function definition analyzed
Visibility: externally_visible prevailing_def public
References:
Referring:
Availability: overwritable
Unit id: 2
Function flags: count:1073741824 (estimated locally) body
only_called_at_startup nonfreeing_fn executed_once
Called by:
Calls: foo/0 (inlined) (1073741824 (estimated locally),1.00 per call)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
2022-07-20 6:29 ` [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file sen2403 at hotmail dot com
2022-07-20 7:23 ` amonakov at gcc dot gnu.org
@ 2022-07-20 10:44 ` sen2403 at hotmail dot com
2022-07-26 12:27 ` amonakov at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: sen2403 at hotmail dot com @ 2022-07-20 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
--- Comment #10 from Eason Lai <sen2403 at hotmail dot com> ---
Add my test program.
$cat boo.c
#include "boo.h"
int get_t(void)
{
return 1;
}
$cat main.c
#include "boo.h"
__attribute__((weak)) int get_t(void)
{
return 0;
}
int a;
int main(void)
{
a = get_t();
return a;
}
$arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m33 -Os -flto -c main.c
-o main.o
#arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m33 -Os -fno-lto -c
boo.c -o boo.o
#arm-none-eabi-gcc --specs=nano.specs -lnosys -nostartfiles -Wl,--gc-sections
-Wl,-Ttest.ld boo.o main.o -o main -save-temps
$arm-none-eabi-objdump -d main
main: file format elf32-littlearm
Disassembly of section .test:
00001000 <main>:
1000: 2000 movs r0, #0
1002: 4770 bx lr
$cat "./-lm.res"
1
main.o 3
190 a62a5458565feecb PREEMPTED_REG get_t
192 a62a5458565feecb PREVAILING_DEF main
196 a62a5458565feecb PREVAILING_DEF_IRONLY a
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2022-07-20 10:44 ` sen2403 at hotmail dot com
@ 2022-07-26 12:27 ` amonakov at gcc dot gnu.org
2022-08-25 13:01 ` sen2403 at hotmail dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-07-26 12:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
--- Comment #11 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Marxin, you've marked this as WAITING, can you please re-evaluate? The nice
testcase from comment #2 is reproducible on trunk as well.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2022-07-26 12:27 ` amonakov at gcc dot gnu.org
@ 2022-08-25 13:01 ` sen2403 at hotmail dot com
2022-08-25 13:22 ` sen2403 at hotmail dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: sen2403 at hotmail dot com @ 2022-08-25 13:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
--- Comment #12 from Eason Lai <sen2403 at hotmail dot com> ---
Hope this information could help.
I added "-fopt-info-inline-optimized-missed=inline.txt" in the CFLAGS to see
what happens between -Os and -O1.
Here is the output when using "-O1":
missed: not inlinable: main/5 -> get_t/4, function not inline candidate
Here is the output when using "-Os":
main.c:13:9: missed: not inlinable: main/5 -> get_t/4, function body can be
overwritten at link time
optimized: Inlined get_t/4 into main/5 which now has time 3.000000 and size 4,
net change of +0.
It happens in ipa-inline.c::inline_small_functions when using "-O2" or above.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2022-08-25 13:01 ` sen2403 at hotmail dot com
@ 2022-08-25 13:22 ` sen2403 at hotmail dot com
2022-09-06 7:20 ` [Bug lto/91299] [10/11/12/13 Regression] " amonakov at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: sen2403 at hotmail dot com @ 2022-08-25 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
--- Comment #13 from Eason Lai <sen2403 at hotmail dot com> ---
The inline rule in ipa-inline.c::inline_small_functions can be bypassed by
adding "noinline" attribute as shown below.
__attribute__((weak, noinline)) int get_t(void)
{
return 0;
}
It's an alternative solution for me.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] [10/11/12/13 Regression] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2022-08-25 13:22 ` sen2403 at hotmail dot com
@ 2022-09-06 7:20 ` amonakov at gcc dot gnu.org
2022-10-18 7:50 ` rguenth at gcc dot gnu.org
2023-07-07 10:35 ` [Bug lto/91299] [11/12/13/14 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 9+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-09-06 7:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Summary|LTO inlines a weak |[10/11/12/13 Regression]
|definition in presence of a |LTO inlines a weak
|non-weak definition from an |definition in presence of a
|ELF file |non-weak definition from an
| |ELF file
--- Comment #14 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
gcc-4.9 used to get this right, so let's play the regression card? This should
not be in WAITING.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] [10/11/12/13 Regression] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2022-09-06 7:20 ` [Bug lto/91299] [10/11/12/13 Regression] " amonakov at gcc dot gnu.org
@ 2022-10-18 7:50 ` rguenth at gcc dot gnu.org
2023-07-07 10:35 ` [Bug lto/91299] [11/12/13/14 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Target Milestone|--- |10.5
CC| |hubicka at gcc dot gnu.org
Priority|P3 |P2
--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
1
a-weakdef.o 2
195 5359582ee909af0f PREEMPTED_REG foo
198 5359582ee909af0f PREVAILING_DEF main
Considering foo/0 with 3 size
to be inlined into main/1 in unknown:-1
Estimated badness is -inf, frequency 1.00.
Badness calculation for main/1 -> foo/0
size growth -1, time 0.000000 unspec 2.000000 big_speedup
-inf: Growth -1 <= 0
Adjusted by hints -inf
Updated mod-ref summary for main/1
loads:
Limits: 32 bases, 16 refs
stores:
Limits: 32 bases, 16 refs
optimized: Inlined foo/0 into main/1 which now has time 2.000000 and size 3,
net change of -1.
but
foo/0 (foo) @0x7ffff65b5110
Type: function definition analyzed
Visibility: externally_visible preempted_reg external public weak
References:
Referring:
Read from file: a-weakdef.o
Availability: available
Unit id: 1
Function flags: count:1073741824 (estimated locally)
Called by: main/1 (1073741824 (estimated locally),1.00 per call)
Calls:
Honza? This looks like a bug in handling of PREEMTED_REG? Or do we apply
some sort of ODR argument here? We also see 'foo' as 'const' at IPA time
(but at local time we see it's interposable and thus do not analyze it)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug lto/91299] [11/12/13/14 Regression] LTO inlines a weak definition in presence of a non-weak definition from an ELF file
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2022-10-18 7:50 ` rguenth at gcc dot gnu.org
@ 2023-07-07 10:35 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91299
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-07-07 10:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-91299-4@http.gcc.gnu.org/bugzilla/>
2022-07-20 6:29 ` [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file sen2403 at hotmail dot com
2022-07-20 7:23 ` amonakov at gcc dot gnu.org
2022-07-20 10:44 ` sen2403 at hotmail dot com
2022-07-26 12:27 ` amonakov at gcc dot gnu.org
2022-08-25 13:01 ` sen2403 at hotmail dot com
2022-08-25 13:22 ` sen2403 at hotmail dot com
2022-09-06 7:20 ` [Bug lto/91299] [10/11/12/13 Regression] " amonakov at gcc dot gnu.org
2022-10-18 7:50 ` rguenth at gcc dot gnu.org
2023-07-07 10:35 ` [Bug lto/91299] [11/12/13/14 " rguenth 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).