Anybody have any idea about why local_decls would go missing?

Gary Oblock
Fri Jan 10 00:54:00 GMT 2020

This is at LTO time and the function in question is this:

#include "stdlib.h"
typedef struct bogus type_ta;

struct bogus {
  int i;
  double x;
  int j;

helper( void *x)
  type_ta *y = (type_ta*)x;
  y->i =  rand();

and I'm checking the local_decls it like this:

  cgraph_node* node;
    tree decl;
    unsigned i;

    node->get_untransformed_body ();

    struct function *fn = DECL_STRUCT_FUNCTION ( node->decl);
    DEBUG( "L# %d, fuction name = %s\n", __LINE__, lang_hooks.decl_printable_name ( node->decl, 2));
    if( fn == NULL )
      DEBUG( "  EMPTY\n");

    FOR_EACH_LOCAL_DECL ( fn, i, decl)
      tree base = base_type_of ( decl);
      DEBUG( "L# %d Consider local var decl\n", __LINE__);

Needless to sat I get the function name "helper" but no variables.
I suspected the LTO streaming process but that seems bullet proof
and if local_decls are there when streaming out it should be restored when
streaming in. I also suspected inlining but it still happened with
"-fno-inline" present.

If you'll note the get_untransformed_body call above (which David Malcolm
suggested to cure a NULL fn) I suspect I'm lacking some other call
which will make all things right.


Gary Oblock

More information about the Gcc mailing list