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. 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?
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?
Below is a stripped down version of the pass.
The compile line is: clang -O0 -S -emit-llvm -o test.S test.c && opt -S -mem2reg -load -extract < test.S > test_opt.S