[LLVMdev] Adding function attributes

Arnaldo arnaldo.cruz at upr.edu
Sun Nov 4 20:48:16 PST 2012


Hello everyone,

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?

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121105/a4216e20/attachment.html>


More information about the llvm-dev mailing list