如何在LLVM中打印到字符串

pyt*_*nic 5 c++ compiler-construction llvm

我想将LLVM中的指令打印到字符串而不是屏幕.我I->print( errs() )用来打印到屏幕上.我怎样才能将指令放在字符串中?

Met*_*est 12

像这样,

std::string str;
llvm::raw_string_ostream rso(str);
I->print(rso);
Run Code Online (Sandbox Code Playgroud)