<div dir="ltr"><div>The basic goal is the support low-cost parallelism when necessary.</div><div>The wrapper function provides some glue which allows the original</div><div>function to be invoked as a micro-thread.</div><div><br></div><div>So, either the original function or the wrapper function will be</div><div>called, depending on certain conditions. There are no "ignorant"</div><div>translation units. (In fact, as an extra, I would like the attribute</div><div>to be attached to both definitions and declarations so I can check the</div><div>use proper use of these functions.)</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><br></div><div>--------------</div><div>Seth Copen Goldstein</div><div>Carnegie Mellon University</div><div>Computer Science Dept</div><div>7111 GHC</div><div>412-268-3828</div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Nov 15, 2017 at 11:14 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Nov 15, 2017, at 10:32 PM, Seth Goldstein via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="m_3181211099063230633Apple-interchange-newline"><div><div dir="ltr"><div>I am wondering what the best approach would be to generate a wrapper</div><div>function for functions with a particular attribute. I.e.,</div><div><br></div><div>When the compiler sees</div><div><br></div><div>__attribute__ ((wrapthis)) int foo(args) {}</div><div><br></div><div>I want to generate foo as usual and also generate a function</div><div><br></div><div>int</div><div>foo_wrapper(args)</div><div>{</div><div><span style="white-space:pre-wrap"> </span>// do some stuff here</div><div><span style="white-space:pre-wrap"> </span>int result = foo(args);</div><div><span style="white-space:pre-wrap"> </span>// do some more stuff here</div><div><span style="white-space:pre-wrap"> </span>return result;</div><div>}</div><div><br></div><div>I am not sure where to generate the wrapper function, e.g., in clang,</div><div>in llvm? And, what pass could I look at that might provide me with</div><div>some hints about how to go about this. Any help would be appreciated.</div></div></div></blockquote><div><br></div></span>A feature like this could be implemented in many different ways, so it's hard to answer</div><div>your question without more basic information. How are you anticipating this wrapper</div><div>function being used? Are all existing uses of the function re-routed to it? Is it important</div><div>that "ignorant" translation units use the wrapper function? Is it important that ignorant</div><div>translation units <i>not</i> use the wrapper function? What's the basic goal here?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>John.</div></font></span></div></blockquote></div><br></div>