Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement