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

--- Comment #5 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #4)
> Cloud also get rid of all the globals:
> 
> static void printChar() {}
> static void emit(void Print()) { Print(); }
> struct S {
>   __attribute__((noinline)) static void sm() {
>     emit(printChar);
>   }
> };
> void run() { S::sm(); }

The crash looks this way:

$ gcc/xg++ -Bgcc -O1 -fchecking=1 -c a.cpp -o a.o -fopt-info-all
a.cpp:8:19: missed:   not inlinable: void run()/3 -> static void S::sm()/2,
function not inlinable
a.cpp:5:9: missed:   not inlinable: static void S::sm()/2 -> void emit(void
(*)())/1, function not inline candidate
Unit growth for small function inlining: 18->18 (0%)

Inlined 1 calls, eliminated 1 functions

a.cpp: In static member function ‘static void S::sm()’:
a.cpp:4:41: error: invalid calls_comdat_local flag calls_comdat_local=0
check_calls_comdat_local_p ()=1
    4 |   __attribute__((noinline)) static void sm() {
      |                                         ^~
_ZN1S2smEv/2 (static void S::sm())
  Type: function definition analyzed
  Visibility: externally_visible semantic_interposition public weak comdat
comdat_group:_ZN1S2smEv one_only
  Same comdat group as: _ZL9printCharv/0
  References:
  Referring:
  Availability: available
  Function flags: count:1073741824 (estimated locally) body
  Called by: _Z3runv/3 (1073741824 (estimated locally),1.00 per call) (can
throw external)
  Calls: _ZL9printCharv/0 (1073741824 (estimated locally),1.00 per call) (can
throw external)
during IPA pass: inline
a.cpp:4:41: internal compiler error: verify_cgraph_node failed

It looks like `ipa-inline` was able to optimize `S::sm()` into `{ printChar();
}` (I'm assuming `Calls:` are all direct callees). But `ipa-inline` did not
update `calls_comdat_local` (yet?).

Reply via email to