On 10/1/2012 2:47 PM, Wonjoon Song wrote:
> In the example lackey, there is
>
> static VG_REGPARM(2) void trace_load(Addr addr, SizeT size);
>
> I saw a pdf http://valgrind.org/docs/iiswc2006.pdf that VG_REGPARM passes 
> arguments using registers instead of stack. Is this inlining? If it is not, 
> what can i do to inline functions? because it says I can improve speed using 
> inlining.
>
>

Marking a variable or parameter "register" is a hint to the compiler 
that a value will be used often, and so it should be kept in a register 
as much as possible instead of being stored in the stack frame.  It is 
only a hint; the compiler may ignore it, especially if it is overused in 
a function (there are relatively few visible registers in a typical 
processor architecture).

In C++ you can make a function (especially a class member function) 
inline by prefixing it with "inline", e.g.

inline int square(int x) { return x * x; }

Whenever the function is called, the compiler may choose to embed the 
code of the called function into the calling function rather than 
generate code to push parameters onto the stack and perform a function call.

This means the definition (with the body) of the function must be 
visible to callers, not just the declaration.

In C you would have to do this with a macro, with all the complications 
that entails.

The "inline" prefix, like the "register" marker, is a hint to the 
compiler.  The compiler may choose to ignore it, especially if the code 
block to be inlined is complex or if the program is being compiled 
debuggable with optimization disabled.

There is no guarantee that either flag will speed up your code; they are 
experiments to try.  You may find that adding the flags will slow down 
some portions of your code.

-- 
     David Chapman      [email protected]
     Chapman Consulting -- San Jose, CA
     Software Development Done Right.
     www.chapman-consulting-sj.com


------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to