Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <sstream>
- #include "llvm/Pass.h"
- #include "llvm/IR/Function.h"
- #include "llvm/Support/raw_ostream.h"
- #include "llvm/ADT/STLExtras.h"
- #include "llvm/ADT/SmallString.h"
- #include "llvm/IR/DerivedTypes.h"
- #include "llvm/IR/Module.h"
- #include "llvm/IR/Type.h"
- #include "llvm/IR/TypeFinder.h"
- #include "llvm/Transforms/IPO.h"
- #include "llvm/IR/Argument.h"
- #include "llvm/IR/GlobalValue.h"
- using namespace llvm;
- namespace {
- struct FunctionRename : public ModulePass {
- static char ID; // Pass identification
- FunctionRename() : ModulePass(ID) {}
- bool runOnModule(Module &M) override {
- // Rename all functions
- for (auto &F : M) {
- StringRef Name = F.getName();
- // Leave library functions alone because their presence or absence
- // could affect the behaviour of other passes.
- if (F.isDeclaration())
- continue;
- F.setLinkage(GlobalValue::LinkOnceAnyLinkage);
- F.setName(Name + "_renamed");
- }
- return true;
- }
- };
- }
- char FunctionRename::ID = 0;
- static RegisterPass<FunctionRename> X("functionrename", "Function Rename Pass");
- // ===-------------------------------------------------------==//
- //
- // Function Renamer - Renames all functions
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement