Hi Duncan, thanks for the quick answer.<br><br>Yes I'm sure the runOnModule is being called, and when I dump the functions before exiting the method I can see the AlwaysInline attribute.<br><br>I'll check InlineAlways.cpp and will reimplement as last resource but I still wonder why this is not working.<br>
<br><br><div class="gmail_quote">On Mon, Nov 5, 2012 at 5:03 PM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Arnaldo,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am coding a ModulePass in which I want to add an AlwaysInline attribute to<br>
every function so that they can be later inlined by the -always-inline pass.<br>
</blockquote>
<br></div>
why not just do the inlining yourself.  The always inliner code is at<br>
lib/Transforms/IPO/<u></u>InlineAlways.cpp, and it's pretty short.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
However, the changes to the function seem to be lost after exiting my pass<br>
because the AlwaysInline attribute is not in the output LLVM IR.<br>
<br>
Maybe the function iterator passed by the module object actually points to<br>
copies of the functions?<br>
</blockquote>
<br></div>
As far as I can see your code should work.  Most likely it isn't being run<br>
at all - did you check that your runOnModule method is actually being called?<br>
<br>
Ciao, Duncan.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
Any help is much appreciated<br>
<br>
<br>
Code<br>
====<br>
virtual bool runOnModule(Module& m)<br>
{<br>
     Module* module = &m;<br>
<br>
     for (Module::iterator functionIter = module->begin(); functionIter !=<br>
module->end(); functionIter++)<br>
         functionIter->addFnAttr(llvm::<u></u>Attributes::AlwaysInline);<br>
<br>
     return true;<br>
}<br>
<br>
<br>
Command line<br>
===========<br>
clang -O0 -S -emit-llvm -o test.S test.c && opt -S -mem2reg -load <path to lib><br>
-mypass < test.S > test_opt.S<br>
<br>
<br>
<br></div>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div><br>