remove optnone metadata
This commit is contained in:
parent
57367c8348
commit
fc1ed8d224
|
@ -2,6 +2,7 @@
|
|||
#include "ReplaceConstantMemory.h"
|
||||
#include "ReplaceCudaBuiltin.h"
|
||||
#include "ReplaceKernelArgs.h"
|
||||
#include "RemoveMetadata.h"
|
||||
#include "tool.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
|
@ -26,6 +27,8 @@ int main(int argc, char **argv) {
|
|||
// load LLVM module(s)
|
||||
llvm::Module *hostModule = LoadModuleFromFilr(input_host_path);
|
||||
VerifyModule(hostModule);
|
||||
// remove metadata
|
||||
RemoveMetadata(hostModule);
|
||||
// replace const memory
|
||||
ReplaceConstantMemory(hostModule, fin);
|
||||
// process host module
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __NVVM2x86_REMOVE_METADATA__
|
||||
#define __NVVM2x86_REMOVE_METADATA__
|
||||
|
||||
#include "llvm/IR/Module.h"
|
||||
|
||||
// remove metadata, e.g., optnone
|
||||
void RemoveMetadata(llvm::Module *M);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
#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);
|
||||
}
|
||||
}
|
|
@ -173,6 +173,10 @@ void remove_metadata(llvm::Module *M) {
|
|||
}
|
||||
F->removeFnAttr("target-features");
|
||||
F->removeFnAttr("target-cpu");
|
||||
F->removeFnAttr(llvm::Attribute::NoInline);
|
||||
F->removeFnAttr("min-legal-vector-width");
|
||||
F->removeFnAttr("no-trapping-math");
|
||||
F->removeFnAttr(llvm::Attribute::OptimizeNone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue