This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

call_graph shows wrong stack consumption (considers called functions to be orphaned)

call_graph (Linux, executable version, v2_30_00) shows me functions to be orphaned though they are not.

In the optimizer interlist file one can see that these functions are called with CALLRET, maybe this has something to do with it.

Here is a simple example:

twofuncs.cpp:

#include <assert.h>

static
void called_func1(int *restrict x)
{
  int y[4]={0,1,2,3};
  x[2]+=y[3];
}


static
void called_func2(int *restrict x)
{
  int y[8]={1,2,4,8,16,32,64,128};
  x[2]+=y[3];
}

void calling_func(int *restrict x, const int b)
{

  switch (b)
  {
    case 4:
      called_func1(x);
      break;
    case 5:
      called_func2(x);
      break;
    default:
      assert(0);
      break;
  }
}

I compiled it using the following lines (using Code Generation Tools v7.3.2, but the error occurs with other versions as well):

cl6x -c --auto_inline=0 --optimizer_interlist -o0 --symdebug:skeletal -mv6740 --abi=coffabi twofuncs.cpp
ar6x rvu twofuncs.lib twofuncs.obj

A workaround is to hand in a .txt file with indirect function calls (as mentioned in the call_graph documentation). However, this does not make sense in large projects, especially because I do not know what call_graph wrongly considers to be an inderenct function call.

Thanks for any help on this!

  • Someone more knowledgable on the call_graph tool than myself would need to comment on this. The person best equipped to answer this is out of the office for a couple of weeks so there may be some delay in reply.

  • Thank you for your patience.

    I have found the cause of the problem.  Unfortunately, I have not found a workaround.  

    The script call_graph.pl uses the Dwarf debug information on function calls to build the call graph.  This Dwarf debug information is encoded in the object file by the compiler.  The compiler has a bug where, when a CALLRET instruction is used, the name of the function being called is not present in the Dwarf debug information.  This causes two problems for call_graph.pl.  One, it thinks a function is being called indirectly.  Two, it does not record a normal direct function call.  

    I entered SDSCM00044670 in the SDOWP system to have this issue addressed.  Feel free to track it with the SDOWP link below in my signature.  I recorded this problem against compiler version 7.3.2.  As far as I can tell, it is present in all versions of the compiler.  

    I have not thought of any reliable workarounds.  It comes down to avoiding the CALLRET instruction.  I cannot think of a way to avoid it that always works.

    Thanks and regards,

    -George 

  • Thank you for you reply and the detailed information. As this seems to be only an issue in cgt 7.3.2, I'll change to another compiler version.

    Thanks,

    Tobias

  • Tobias Chalupka said:
    As this seems to be only an issue in cgt 7.3.2, I'll change to another compiler version.

    As far as I can tell, the problem is present in all versions of the compiler.  Thus, changing versions is unlikely to help.

    Thanks and regards,

    -George

  • Yes, of course - I misread your former comment.

    Thanks for the correction,

    Tobias