2022-06-26 02:44:50 +08:00
|
|
|
#include "RemoveMetadata.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/GlobalValue.h"
|
|
|
|
#include "llvm/IR/IRBuilder.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/Support/ToolOutputFile.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void RemoveMetadata(llvm::Module *M) {
|
|
|
|
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
|
|
|
|
for (Module::iterator i = M->begin(), e = M->end(); i != e; ++i) {
|
|
|
|
Function *F = &(*i);
|
|
|
|
F->getAllMetadata(MDs);
|
|
|
|
for (auto &MD : MDs) {
|
|
|
|
F->setMetadata(MD.first, NULL);
|
|
|
|
}
|
|
|
|
F->removeFnAttr(llvm::Attribute::NoInline);
|
|
|
|
F->removeFnAttr("min-legal-vector-width");
|
|
|
|
F->removeFnAttr("no-trapping-math");
|
|
|
|
F->removeFnAttr(llvm::Attribute::OptimizeNone);
|
|
|
|
}
|
2022-09-08 07:38:21 +08:00
|
|
|
}
|