[LLVMdev] Adding function attributes
Arnaldo
arnaldo.cruz at upr.edu
Mon Nov 5 01:02:01 PST 2012
Hi Duncan, thanks for the quick answer.
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.
I'll check InlineAlways.cpp and will reimplement as last resource but I
still wonder why this is not working.
On Mon, Nov 5, 2012 at 5:03 PM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Arnaldo,
>
>
> I am coding a ModulePass in which I want to add an AlwaysInline attribute
>> to
>> every function so that they can be later inlined by the -always-inline
>> pass.
>>
>
> why not just do the inlining yourself. The always inliner code is at
> lib/Transforms/IPO/**InlineAlways.cpp, and it's pretty short.
>
>
> However, the changes to the function seem to be lost after exiting my pass
>> because the AlwaysInline attribute is not in the output LLVM IR.
>>
>> Maybe the function iterator passed by the module object actually points to
>> copies of the functions?
>>
>
> As far as I can see your code should work. Most likely it isn't being run
> at all - did you check that your runOnModule method is actually being
> called?
>
> Ciao, Duncan.
>
>
>> Any help is much appreciated
>>
>>
>> Code
>> ====
>> virtual bool runOnModule(Module& m)
>> {
>> Module* module = &m;
>>
>> for (Module::iterator functionIter = module->begin(); functionIter !=
>> module->end(); functionIter++)
>> functionIter->addFnAttr(llvm::**Attributes::AlwaysInline);
>>
>> return true;
>> }
>>
>>
>> Command line
>> ===========
>> clang -O0 -S -emit-llvm -o test.S test.c && opt -S -mem2reg -load <path
>> to lib>
>> -mypass < test.S > test_opt.S
>>
>>
>>
>> ______________________________**_________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>>
>>
> ______________________________**_________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121105/74daf7a6/attachment.html>
More information about the llvm-dev
mailing list