[Prev][Next][Index]

SgSymbol::declaredInStmt is a dog




Context: I have been working on adding some things to the call graph
module and in that connection I needed to make use of
SgSymbol::declaredInStmt().

I was a little miffed when the running time of my program went from 1
second to 32 seconds to compute the call graph of the poisson benchmark.
Some of this was due to my own ineptitude, but most of the time was
spent in declaredInStmt(), and after really tuning things elsewhere and
caching everything I can, roughly 70% of the remaining running time
(which is acceptable -- 4 seconds or so -- but still more than I'd like,
all things considered) is spent in that procedure. Looking at the
implementation, it is clear that it performs a linear search of the
scope in which the symbol is declared to look for the symbol (the word
'suboptimal' comes to mind :-)... To give you an idea, 330 calls to this
procedure adds 2.8 seconds to the running time of the program, for an
average of roughly 8 ms per call on a lightly loaded Sparc 10.

I am looking for a fix, but I imagine it will be hard, and I will settle
for workarounds, if possible. In one instance I managed to use
SgSymbol::scope() instead, with success, but that does not work in the
last, remaining case.

What I am looking for in the remaining case is really the parameter list
of a function symbol. I can't (or so I believe) use the
SgFunctionSymb::parameter() procedure because I need to know whether the
parameter has a default value. Hence, I have been looking for the
statement and getting at the list that way, and then walking the list.

Suggestions?

--lars