I'm having some grief attempting to get at the local definitions in LTO (more about the options used later.)
Here's the sequence of code in my optimization (part of attempt at structure reorganization optimizations.) cgraph_node* node; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node) { tree decl; unsigned i; struct function *fn = DECL_STRUCT_FUNCTION ( node->decl); // I'm assuming it's obvious what my debugging macros do... DEBUG( "fn %p\n", fn); DEBUG_F( print_generic_decl, stderr, node->decl, (dump_flags_t)-1); DEBUG( "\n"); // I don't know why this is coming up null.... but I'll // skip it for now because causes a crash. if( fn == NULL ) { continue; } FOR_EACH_LOCAL_DECL ( fn, i, decl) { : What it returns is: fn 0xffffb0fc9210 static intD.xxxx max1.constprop.0D.xxxx (struct type_t *); fn 0xffffb0fc9370 static doubleD.xxxx max2.constprop.0D.xxxx (struct type_t *); fn (nil) static intD.xxxx mainD.xxxx (void); fn (nil) static struct type_t * setupD.xxxx (size_t); Here's the test case: aux.h ----- #include "stdlib.h" typedef struct type type_t; struct type { int i; double x; }; #define MAX(x,y) ((x)>(y) ? (x) : (y)) extern int max1( type_t *, size_t); extern double max2( type_t *, size_t); extern type_t *setup( size_t); main.c ------ #include "aux.h" #include "stdio.h" int main(void) { type_t *data1 = setup(100); type_t *data2 = setup(200); printf("First %d\n" , max1(data1,100)); printf("Second %e\n", max2(data2,200)); } aux.c ----- #include "aux.h" #include "stdlib.h" type_t * setup( size_t size) { type_t *data = (type_t *)malloc( size * sizeof(type_t)); size_t i; for( i = 0; i < size; i++ ) { data[i].i = rand(); data[i].x = drand48(); } return data; } int max1( type_t *array, size_t len) { size_t i; int result = array[0].i; for( i = 1; i < len; i++ ) { result = MAX( array[i].i, result); } return result; } double max2( type_t *array, size_t len) { size_t i; double result = array[0].x; for( i = 1; i < len; i++ ) { result = MAX( array[i].x, result); } return result; } Here is how I compile them: GCC=/home/goblock/str-reorg-gcc-build-dir/install/bin/gcc OPTIONS="-O2 -flto -flto-partition=one -fipa-structure-reorg" $GCC $OPTIONS -c main.c $GCC $OPTIONS -c aux.c $GCC $OPTIONS -o exe main.o aux.o ./exe I'm wondering if this is a fundamental issue, if there's a bug or perhaps I'm doing something dumb. I any advice is appreciated here because my only real alternative here is insanely ugly. Thanks, Gary Oblock