public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&)
@ 2022-04-12  2:28 raj.khem at gmail dot com
  2022-04-12  2:49 ` [Bug c++/105234] inlining " raj.khem at gmail dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: raj.khem at gmail dot com @ 2022-04-12  2:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105234
           Summary: nlining failed in call to 'always_inline'
                    'fmt::v8::basic_format_string<Char,
                    Args>::basic_format_string(const S&)
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: raj.khem at gmail dot com
  Target Milestone: ---

Created attachment 52786
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52786&action=edit
test case

Attached testcase fails to compile with gcc-12/mips but it works ok with gcc
11.2

$ mips-yoe-linux-musl-g++  -O0  AtomicFile.cpp.i

In file included from
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/util/Tokenizer.hpp:23,
                 from
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/Util.hpp:22,
                 from
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/AtomicFile.cpp:22:
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/third_party/fmt/core.h:
In constructor 'core::Error::Error(T&& ...) [with T = {const char (&)[31],
const std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, char*}]':
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/third_party/fmt/core.h:3057:41:
error: inlining failed in call to 'always_inline'
'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) [with
S = char [31]; typename std::enable_if<std::is_convertible<const S&,
fmt::v8::basic_string_view<Char> >::value, int>::type <anonymous> = 0; Char =
char; Args = {const std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, char*}]': target specific option mismatch
 3057 |   FMT_CONSTEVAL FMT_INLINE basic_format_string(const S& s) : str_(s) {
      |                                         ^~~~~~~~~~~~~~~~~~~
In file included from
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/AtomicFile.cpp:25:
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/core/exceptions.hpp:57:52:
note: called from here
   57 |   : ErrorBase(fmt::format(std::forward<T>(args)...))
      |                                                    ^
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/third_party/fmt/core.h:3117:45:
error: inlining failed in call to 'always_inline' 'std::string
fmt::v8::format(format_string<T ...>, T&& ...) [with T = {const
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>&, char*}]': target specific option mismatch
 3117 | FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&...
args)
      |                                             ^~~~~~
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/ccache/4.6-r0/ccache-4.6/src/core/exceptions.hpp:57:52:
note: called from here
   57 |   : ErrorBase(fmt::format(std::forward<T>(args)...))
      |                                                    ^

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

* [Bug c++/105234] inlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&)
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
@ 2022-04-12  2:49 ` raj.khem at gmail dot com
  2022-04-12  2:49 ` raj.khem at gmail dot com
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: raj.khem at gmail dot com @ 2022-04-12  2:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Khem Raj <raj.khem at gmail dot com> ---
here is another testcase from gnupg on mips with gcc12 failing

$ mips-yoe-linux-gcc dirmngr.i 
In file included from
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux/gnupg/2.3.4-r0/recipe-sysroot/usr/include/string.h:535,
                 from ../../gnupg-2.3.4/dirmngr/dirmngr.c:29:
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux/gnupg/2.3.4-r0/recipe-sysroot/usr/include/bits/string_fortified.h:
In function 'start_connection_thread':
/mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux/gnupg/2.3.4-r0/recipe-sysroot/usr/include/bits/string_fortified.h:57:42:
error: inlining failed in call to 'always_inline' 'memset': target specific
option mismatch
   57 | __NTH (memset (void *__dest, int __ch, size_t __len))
      |                                          ^~~~~~
../../gnupg-2.3.4/dirmngr/dirmngr.c:2183:3: note: called from here
 2183 |   memset (&argval, 0, sizeof argval);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

* [Bug c++/105234] inlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&)
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
  2022-04-12  2:49 ` [Bug c++/105234] inlining " raj.khem at gmail dot com
@ 2022-04-12  2:49 ` raj.khem at gmail dot com
  2022-04-12  2:58 ` [Bug c++/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch raj.khem at gmail dot com
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: raj.khem at gmail dot com @ 2022-04-12  2:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Khem Raj <raj.khem at gmail dot com> ---
Created attachment 52787
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52787&action=edit
test case 2

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

* [Bug c++/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
  2022-04-12  2:49 ` [Bug c++/105234] inlining " raj.khem at gmail dot com
  2022-04-12  2:49 ` raj.khem at gmail dot com
@ 2022-04-12  2:58 ` raj.khem at gmail dot com
  2022-04-12  8:51 ` [Bug target/105234] " marxin at gcc dot gnu.org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: raj.khem at gmail dot com @ 2022-04-12  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Khem Raj <raj.khem at gmail dot com> ---
Second sample works when I do not use _FORTIFY_SOURCES=2, so perhaps gcc-12
needs to adjust some glibc headers ?

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

* [Bug target/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (2 preceding siblings ...)
  2022-04-12  2:58 ` [Bug c++/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch raj.khem at gmail dot com
@ 2022-04-12  8:51 ` marxin at gcc dot gnu.org
  2022-04-12  8:51 ` marxin at gcc dot gnu.org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced test-case:

$ cat ~/Programming/testcases/AtomicFile.cpp.i
namespace std {
typedef char string;
class runtime_error {
public:
  runtime_error(string);
};
} // namespace std
#pragma GCC push_options
namespace fmt {
namespace {
__attribute__((always_inline)) auto format() -> std::string {}
#pragma GCC pop_options
} // namespace
} // namespace fmt
namespace core {
class ErrorBase : std::runtime_error {
  runtime_error::runtime_error;
};
class Error : ErrorBase {
public:
  template <typename... T> Error(T &&...);
};
template <typename... T> Error::Error(T &&...) : ErrorBase(fmt::format()) {}
} // namespace core
void commit() { core::Error(); }

$ ./xg++ -B. ~/Programming/testcases/AtomicFile.cpp.i -c
/home/marxin/Programming/testcases/AtomicFile.cpp.i: In function ‘std::string
fmt::{anonymous}::format()’:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:11:62: warning: no return
statement in function returning non-void [-Wreturn-type]
   11 | __attribute__((always_inline)) auto format() -> std::string {}
      |                                                              ^
/home/marxin/Programming/testcases/AtomicFile.cpp.i: At global scope:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:17:3: warning: access
declarations are deprecated in favour of using-declarations; suggestion: add
the ‘using’ keyword [-Wdeprecated]
   17 |   runtime_error::runtime_error;
      |   ^~~~~~~~~~~~~
/home/marxin/Programming/testcases/AtomicFile.cpp.i:11:37: warning:
‘always_inline’ function might not be inlinable [-Wattributes]
   11 | __attribute__((always_inline)) auto format() -> std::string {}
      |                                     ^~~~~~
/home/marxin/Programming/testcases/AtomicFile.cpp.i: In constructor
‘core::Error::Error(T&& ...) [with T = {}]’:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:11:37: error: inlining
failed in call to ‘always_inline’ ‘std::string fmt::{anonymous}::format()’:
target specific option mismatch
/home/marxin/Programming/testcases/AtomicFile.cpp.i:23:73: note: called from
here
   23 | template <typename... T> Error::Error(T &&...) :
ErrorBase(fmt::format()) {}
      |                                                                        
^

Note it crashes if I enable inlined dumps:

$ ./xg++ -B. ~/Programming/testcases/AtomicFile.cpp.i -c -fdump-tree-einline
/home/marxin/Programming/testcases/AtomicFile.cpp.i: In function ‘std::string
fmt::{anonymous}::format()’:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:11:62: warning: no return
statement in function returning non-void [-Wreturn-type]
   11 | __attribute__((always_inline)) auto format() -> std::string {}
      |                                                              ^
/home/marxin/Programming/testcases/AtomicFile.cpp.i: At global scope:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:17:3: warning: access
declarations are deprecated in favour of using-declarations; suggestion: add
the ‘using’ keyword [-Wdeprecated]
   17 |   runtime_error::runtime_error;
      |   ^~~~~~~~~~~~~
/home/marxin/Programming/testcases/AtomicFile.cpp.i:11:37: warning:
‘always_inline’ function might not be inlinable [-Wattributes]
   11 | __attribute__((always_inline)) auto format() -> std::string {}
      |                                     ^~~~~~
during GIMPLE pass: einline
dump file: AtomicFile.cpp.i.031t.einline
/home/marxin/Programming/testcases/AtomicFile.cpp.i: In constructor
‘core::Error::Error(T&& ...) [with T = {}]’:
/home/marxin/Programming/testcases/AtomicFile.cpp.i:25:32: internal compiler
error: Segmentation fault
   25 | void commit() { core::Error(); }
      |                                ^
0x183066f crash_signal
        /home/marxin/Programming/gcc/gcc/toplev.cc:322
0x7ffff78b93cf ???
       
/usr/src/debug/glibc-2.35-2.1.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x1699c8c cl_target_option_print_diff(_IO_FILE*, int, cl_target_option*,
cl_target_option*)
        /dev/shm/objdir2/gcc/options-save.cc:9319
0x262d142 report_inline_failed_reason
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:249
0x262d6e4 can_inline_edge_p
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:401
0x262eb19 can_early_inline_edge_p
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:656
0x2635fac inline_always_inline_functions
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:2866
0x2636516 early_inliner(function*)
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:2976
0x263696f execute
        /home/marxin/Programming/gcc/gcc/ipa-inline.cc:3110
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

I'll take a look.

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

* [Bug target/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-12  8:51 ` [Bug target/105234] " marxin at gcc dot gnu.org
@ 2022-04-12  8:51 ` marxin at gcc dot gnu.org
  2022-04-12  9:45 ` [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2022-04-12
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-12  8:51 ` marxin at gcc dot gnu.org
@ 2022-04-12  9:45 ` marxin at gcc dot gnu.org
  2022-04-12 10:32 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12  9:45 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |linkw at gcc dot gnu.org
            Summary|inlining failed in call to  |[12 Regression] inlining
                   |'always_inline' 'memset':   |failed in call to
                   |target specific option      |'always_inline' 'memset':
                   |mismatch                    |target specific option
                   |                            |mismatch since
                   |                            |r12-5920-g01ad8c54fdca1d
             Status|ASSIGNED                    |NEW
           Assignee|marxin at gcc dot gnu.org          |unassigned at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-5920-g01ad8c54fdca1d.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (5 preceding siblings ...)
  2022-04-12  9:45 ` [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d marxin at gcc dot gnu.org
@ 2022-04-12 10:32 ` jakub at gcc dot gnu.org
  2022-04-12 10:33 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-12 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
>From what I can see, push_options creates a new target node because there
wasn't one before, pop_options makes that the current node and the mismatch is
in between that node (containing just the mips_lra_flag set, which is the
default) and NULL.
I think the main problem is that mips doesn't initialize
target_option_default_node.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (6 preceding siblings ...)
  2022-04-12 10:32 ` jakub at gcc dot gnu.org
@ 2022-04-12 10:33 ` jakub at gcc dot gnu.org
  2022-04-12 10:45 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-12 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
   Target Milestone|---                         |12.0

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (7 preceding siblings ...)
  2022-04-12 10:33 ` jakub at gcc dot gnu.org
@ 2022-04-12 10:45 ` jakub at gcc dot gnu.org
  2022-04-12 10:49 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-12 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
On the other side, most of the targets actually don't initialize
target_option_default_node.  List of targets that do so:
aarch64/aarch64.cc:  target_option_default_node = target_option_current_node
arm/arm.cc:  target_option_default_node = target_option_current_node
csky/csky.cc:  target_option_default_node = target_option_current_node
i386/i386-options.cc:      target_option_default_node =
target_option_current_node
nios2/nios2.cc:  target_option_default_node = target_option_current_node
pru/pru.cc:  target_option_default_node = target_option_current_node
rs6000/rs6000.cc:    target_option_default_node = target_option_current_node
s390/s390.cc:  target_option_default_node = build_target_option_node
(&global_options, &global_options_set);
v850/v850.cc:  target_option_default_node = target_option_current_node
and list of targets that actually support target attribute:
aarch64/aarch64.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P
aarch64_option_valid_attribute_p
arm/arm.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P arm_valid_target_attribute_p
i386/i386.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P
ix86_valid_target_attribute_p
nios2/nios2.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P
nios2_valid_target_attribute_p
rs6000/rs6000.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P
rs6000_valid_attribute_p
s390/s390.cc:#define TARGET_OPTION_VALID_ATTRIBUTE_P
s390_valid_target_attribute_p

So perhaps the generic r12-5920 change should be guarded on
target_option_default_node being non-NULL, so that targets that don't care can
stay as is?
The question is what to do with csky, pru and v850 that initialize it but don't
support target attributes?

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (8 preceding siblings ...)
  2022-04-12 10:45 ` jakub at gcc dot gnu.org
@ 2022-04-12 10:49 ` redi at gcc dot gnu.org
  2022-04-12 11:00 ` marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-12 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #4)
> Reduced test-case:

Slightly less reduced, avoiding the warnings about invalid/deprecated features:


namespace std {
typedef char string;
class runtime_error {
public:
  runtime_error(string);
};
} // namespace std
#pragma GCC push_options
namespace fmt {
namespace {
__attribute__((always_inline)) inline auto format() -> std::string { return {};
}
#pragma GCC pop_options
} // namespace
} // namespace fmt
namespace core {
class ErrorBase : std::runtime_error {
  using runtime_error::runtime_error;
};
class Error : ErrorBase {
public:
  template <typename... T> Error(T &&...);
};
template <typename... T> Error::Error(T &&...) : ErrorBase(fmt::format()) {}
} // namespace core
void commit() { core::Error(); }

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (9 preceding siblings ...)
  2022-04-12 10:49 ` redi at gcc dot gnu.org
@ 2022-04-12 11:00 ` marxin at gcc dot gnu.org
  2022-04-12 11:03 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
I can take a look.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (10 preceding siblings ...)
  2022-04-12 11:00 ` marxin at gcc dot gnu.org
@ 2022-04-12 11:03 ` jakub at gcc dot gnu.org
  2022-04-12 11:09 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-12 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
2022-04-12  Jakub Jelinek  <jakub@redhat.com>

        PR target/105234
        * attribs.cc (decl_attributes): Don't set
        DECL_FUNCTION_SPECIFIC_TARGET if target_option_default_node is
        NULL.

--- gcc/attribs.cc.jj   2022-02-04 14:36:53.947620076 +0100
+++ gcc/attribs.cc      2022-04-12 12:52:36.630967329 +0200
@@ -636,15 +636,20 @@ decl_attributes (tree *node, tree attrib
       && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node))
     {
       DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node;
-      tree cur_tree
-       = build_target_option_node (&global_options, &global_options_set);
-      tree old_tree = DECL_FUNCTION_SPECIFIC_TARGET (*node);
-      if (!old_tree)
-       old_tree = target_option_default_node;
-      /* The changes on optimization options can cause the changes in
-        target options, update it accordingly if it's changed.  */
-      if (old_tree != cur_tree)
-       DECL_FUNCTION_SPECIFIC_TARGET (*node) = cur_tree;
+      /* Don't set DECL_FUNCTION_SPECIFIC_TARGET for targets that don't
+        support #pragma GCC target or target attribute.  */
+      if (target_option_default_node)
+       {
+         tree cur_tree
+           = build_target_option_node (&global_options, &global_options_set);
+         tree old_tree = DECL_FUNCTION_SPECIFIC_TARGET (*node);
+         if (!old_tree)
+           old_tree = target_option_default_node;
+         /* The changes on optimization options can cause the changes in
+            target options, update it accordingly if it's changed.  */
+         if (old_tree != cur_tree)
+           DECL_FUNCTION_SPECIFIC_TARGET (*node) = cur_tree;
+       }
     }

   /* If this is a function and the user used #pragma GCC target, add the

certainly works for me.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (11 preceding siblings ...)
  2022-04-12 11:03 ` jakub at gcc dot gnu.org
@ 2022-04-12 11:09 ` jakub at gcc dot gnu.org
  2022-04-12 11:16 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-12 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 52790
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52790&action=edit
gcc12-pr105234.patch

Now with a testcase.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (12 preceding siblings ...)
  2022-04-12 11:09 ` jakub at gcc dot gnu.org
@ 2022-04-12 11:16 ` marxin at gcc dot gnu.org
  2022-04-13  1:50 ` linkw at gcc dot gnu.org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-12 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|marxin at gcc dot gnu.org          |jakub at gcc dot gnu.org

--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
The patch seems fine to me.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (13 preceding siblings ...)
  2022-04-12 11:16 ` marxin at gcc dot gnu.org
@ 2022-04-13  1:50 ` linkw at gcc dot gnu.org
  2022-04-13  8:14 ` cvs-commit at gcc dot gnu.org
  2022-04-13  8:36 ` jakub at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: linkw at gcc dot gnu.org @ 2022-04-13  1:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Kewen Lin <linkw at gcc dot gnu.org> ---
Just noticed this, many thanks for triaging and fixing!

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (14 preceding siblings ...)
  2022-04-13  1:50 ` linkw at gcc dot gnu.org
@ 2022-04-13  8:14 ` cvs-commit at gcc dot gnu.org
  2022-04-13  8:36 ` jakub at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-13  8:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:41f8f8b8a4ffcf28961cdc077fd7f0770f4bb7cc

commit r12-8135-g41f8f8b8a4ffcf28961cdc077fd7f0770f4bb7cc
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Apr 13 10:12:56 2022 +0200

    attribs: Restrict decl_attributes DECL_FUNCTION_SPECIFIC_TARGET changes to
targets that care about target attributes/pragmas [PR105234]

    The following code is rejected e.g. on mips64el-linux (but I think many
    other targets which don't support target attribute or pragma).
    The problem is that the change to decl_attributes below is done
    unconditionally and with just #pragma GCC push_options/pop_options pair
    we have target_option_default_node NULL, but after popping options
    target_option_current_node becomes non-NULL and this decl_attribute
    spot fills in DECL_FUNCTION_SPECIFIC_TARGET of a subset of a functions.
    Those appearing before push_options/pop_options will have it NULL and
    as target_option_default_node is also NULL on those targets, the default
    can_inline_p will refuse to inline any functions defined with NULL
    DECL_FUNCTION_SPECIFIC_TARGET into any function with non-NULL
    DECL_FUNCTION_SPECIFIC_TARGET (even when nothing in the options really
    changed).

    The following patch restricts that snippet to targets that care (initialize
    target_option_default_node to non-NULL to the command line options early)
    which include all targets that actually implement target attribute and/or
    pragma.

    2022-04-13  Jakub Jelinek  <jakub@redhat.com>

            PR target/105234
            * attribs.cc (decl_attributes): Don't set
            DECL_FUNCTION_SPECIFIC_TARGET if target_option_default_node is
            NULL.

            * gcc.c-torture/compile/pr105234.c: New test.

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

* [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d
  2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
                   ` (15 preceding siblings ...)
  2022-04-13  8:14 ` cvs-commit at gcc dot gnu.org
@ 2022-04-13  8:36 ` jakub at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-13  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed now.

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

end of thread, other threads:[~2022-04-13  8:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12  2:28 [Bug c++/105234] New: nlining failed in call to 'always_inline' 'fmt::v8::basic_format_string<Char, Args>::basic_format_string(const S&) raj.khem at gmail dot com
2022-04-12  2:49 ` [Bug c++/105234] inlining " raj.khem at gmail dot com
2022-04-12  2:49 ` raj.khem at gmail dot com
2022-04-12  2:58 ` [Bug c++/105234] inlining failed in call to 'always_inline' 'memset': target specific option mismatch raj.khem at gmail dot com
2022-04-12  8:51 ` [Bug target/105234] " marxin at gcc dot gnu.org
2022-04-12  8:51 ` marxin at gcc dot gnu.org
2022-04-12  9:45 ` [Bug target/105234] [12 Regression] inlining failed in call to 'always_inline' 'memset': target specific option mismatch since r12-5920-g01ad8c54fdca1d marxin at gcc dot gnu.org
2022-04-12 10:32 ` jakub at gcc dot gnu.org
2022-04-12 10:33 ` jakub at gcc dot gnu.org
2022-04-12 10:45 ` jakub at gcc dot gnu.org
2022-04-12 10:49 ` redi at gcc dot gnu.org
2022-04-12 11:00 ` marxin at gcc dot gnu.org
2022-04-12 11:03 ` jakub at gcc dot gnu.org
2022-04-12 11:09 ` jakub at gcc dot gnu.org
2022-04-12 11:16 ` marxin at gcc dot gnu.org
2022-04-13  1:50 ` linkw at gcc dot gnu.org
2022-04-13  8:14 ` cvs-commit at gcc dot gnu.org
2022-04-13  8:36 ` jakub 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).