We can get the llvm assembler for a Module with something as simple as std::ofstream f("code.llvm"); f << *M; Is there a method for obtaining the llvm assembler of a given Function? -- Óscar
On Wed, Aug 19, 2009 at 10:30 PM, Óscar Fuentes<ofv at wanadoo.es> wrote:> We can get the llvm assembler for a Module with something as simple as > > std::ofstream f("code.llvm"); > f << *M; > > Is there a method for obtaining the llvm assembler of a given Function?I think something like "F->print(f);" will do the right thing. -Eli
Hello Eli. Eli Friedman <eli.friedman at gmail.com> writes:>> Is there a method for obtaining the llvm assembler of a given Function? > > I think something like "F->print(f);" will do the right thing.Nope. It prints nothing at all. mainF->print(std::cout); -- Óscar
On Aug 19, 2009, at 10:30 PM, Óscar Fuentes wrote:> We can get the llvm assembler for a Module with something as simple as > > std::ofstream f("code.llvm"); > f << *M; > > Is there a method for obtaining the llvm assembler of a given > Function? >I've been using F.dump(). -Jim
Eli Friedman <eli.friedman at gmail.com> writes:> I think something like "F->print(f);" will do the right thing.BTW, what's the reason for `print' and `dump' not being listed on the doxygen page of Function? -- Óscar
On Aug 19, 2009, at 10:30 PM, Óscar Fuentes wrote:> We can get the llvm assembler for a Module with something as simple as > > std::ofstream f("code.llvm"); > f << *M; > > Is there a method for obtaining the llvm assembler of a given > Function?In addition to the other answers, f << *F works too. Dan
Hello Dan. Dan Gohman <gohman at apple.com> writes:>> Is there a method for obtaining the llvm assembler of a given >> Function? > > In addition to the other answers, f << *F works too.>From that code, I expected to see the declaration of the function. Sochecked and it prints the declaration if the function is empty (no instructions added yet) and the disassembly if it has instructions. That makes sense, but sometimes it is useful to output just the declaration. I guess there is a method for that somewhere. In the meantime, outputting the function's type and name can do the job. -- Óscar