Michael Schmitt wrote:
>What do you expect to get when the compiler optimizer inlines the call?

A fair question. If it's a compile-time thing, I'd say it would be an option as 
to whether such non-calls "count" or not. Or maybe you compile without inlining 
if it's enabled. I'd expect there to at least be a way to make it pretend it 
called the function. This does make me lean slightly toward compile-time, since 
otherwise it's inserting code that it will be skipping around in normal 
operation. Though I suppose it could be something as simple as the following, 
which is sort of assembler pseudo-code:
          TM    someflag,set    Tracing calls?
          BNO   around
          BAS   R14,traceit     Yes, I'm playing fast and loose with R14 here
          DC    A(C'THINGBEINGTRACED')  And yes, I realize this line doesn't 
work
around DS       0H

That bogus DC is a pointer to a constant with the function name. So the traceit 
function knows that that such a constant will be at 4 past R14, and to return 
to the instruction after that. This way you're not generating a DC for every 
call to the same function in a module. This would add a TM/BNO for every call 
in normal operation; on modern hardware, that seems like it would be 
insignificant. But it's probably still a compile-time option whether even THAT 
gets put in, since otherwise a new compiler that adds this capability will 
suddenly generate larger modules for the same code (16 bytes per function call, 
if I'm counting it right, which could add up).

The point, of course, is for debugging, so you (might) want to know even about 
those inlined calls. If it's a trivial function (strlen or something), maybe 
not. Also, if it's a compile-time thing, you'd want to be able to select "all" 
or "not stdlib stuff". These are things the compiler knows, yes? (Well, I guess 
if you replaced strlen with your own function, the compiler might not know, but 
that's your problem!)

This is fun...


Sorta related, I was just reading a novel in which a "hacker" has decompiled 
some code and can tell the programmer was highly skilled. Clearly the author 
knows nothing of compiler optimization, since even a HELLO WORLD program looks 
like something complex when it's optimized!

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to