Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. #include <sstream>
  6.  
  7. #include "llvm/Pass.h"
  8. #include "llvm/IR/Function.h"
  9. #include "llvm/Support/raw_ostream.h"
  10. #include "llvm/ADT/STLExtras.h"
  11. #include "llvm/ADT/SmallString.h"
  12. #include "llvm/IR/DerivedTypes.h"
  13. #include "llvm/IR/Module.h"
  14. #include "llvm/IR/Type.h"
  15. #include "llvm/IR/TypeFinder.h"
  16. #include "llvm/Transforms/IPO.h"
  17. #include "llvm/IR/Argument.h"
  18. #include "llvm/IR/GlobalValue.h"
  19.  
  20. using namespace llvm;
  21.  
  22. namespace {
  23.  
  24. struct FunctionRename : public ModulePass {
  25. static char ID; // Pass identification
  26. FunctionRename() : ModulePass(ID) {}
  27.  
  28. bool runOnModule(Module &M) override {
  29. // Rename all functions
  30. for (auto &F : M) {
  31. StringRef Name = F.getName();
  32. // Leave library functions alone because their presence or absence
  33. // could affect the behaviour of other passes.
  34. if (F.isDeclaration())
  35. continue;
  36. F.setLinkage(GlobalValue::LinkOnceAnyLinkage);
  37. F.setName(Name + "_renamed");
  38. }
  39. return true;
  40. }
  41. };
  42. }
  43.  
  44. char FunctionRename::ID = 0;
  45. static RegisterPass<FunctionRename> X("functionrename", "Function Rename Pass");
  46. // ===-------------------------------------------------------==//
  47. //
  48. // Function Renamer - Renames all functions
  49. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement