SHARE
TWEET

Untitled

a guest Feb 9th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace {
  2.   // Hello - The first implementation, without getAnalysisUsage.
  3.   struct Hello : public ModulePass {
  4.     static char ID; // Pass identification, replacement for typeid
  5.     Hello() : ModulePass(ID) {}
  6.  
  7.     bool runOnModule(Module &M) override {
  8.       if (auto main = M.getFunction("main")) {
  9.         ValueToValueMapTy vmap;
  10.         auto newF = CloneFunction(main, vmap, true);
  11.         M.getFunctionList().push_back(newF);
  12.         IRBuilder<> IRB(&*main->getEntryBlock().getFirstInsertionPt());
  13.         IRB.CreateCall(newF, {&main->getArgumentList().front(), &main->getArgumentList().back()});
  14.       }
  15.       return true;
  16.     }                                                                                                                                                                                                                                          
  17.   };
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top