|
From: Wonjoon S. <kn...@gm...> - 2012-10-01 21:48:09
|
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. Thank you, Wonjoon |
|
From: David C. <dcc...@ac...> - 2012-10-01 23:32:00
|
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 dcc...@ac... Chapman Consulting -- San Jose, CA Software Development Done Right. www.chapman-consulting-sj.com |
|
From: Josef W. <Jos...@gm...> - 2012-10-02 09:17:08
|
Am 01.10.2012 23:47, schrieb Wonjoon Song: > 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? No. VG_REGPARM(x) changes the used calling convention for a given function such that more registers are used for parameters. It is a convention in Valgrind that functions called from generated code have to obey a calling convention using VG_REGPARM(x) if x parameters are to be passed. This will speed up such calls on platforms where the default calling convention uses the stack to pass parameters (most important x86/32bit). As trace_load() is to be called from generated code, it has to use this calling convention. > If it is not, what can i do to inline functions? > because it says I can improve speed using inlining. "Inlining" means embedding of instructions of a function into a caller site. As the caller here always is generated code, "inlining" here means to embed code generated at static time into the dynamically generated code at runtime. This could be done, but Valgrind currently does not support it (Intels PIN tool does). Instead, if you care about such optimizations, the current solution is to directly generate VEX code in your instrumentation function, instead of calling a precompiled function. Josef > > Thank you, > Wonjoon > ------------------------------------------------------------------------------ > 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 > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > |