Files
revng-revng/lib/BasicAnalyses/RemoveDbgMetadata.cpp
Alessandro Di Federico 2e9c2ee275 Introduce FunctionTags
FunctionTags goal is to solve the long-standing problem of identifying
what type of function are we dealing with. Is it a lifted function? An
helper?

Now we have a sane way to determine this using Metadata and a proper
API.
2021-04-22 18:07:24 +02:00

33 lines
856 B
C++

/// \file RemoveDbgMetadata.cpp
/// \brief A simple pass to remove debug metadata from a function.
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Metadata.h"
#include "revng/BasicAnalyses/RemoveDbgMetadata.h"
#include "revng/Support/FunctionTags.h"
using namespace llvm;
char RemoveDbgMetadata::ID = 0;
using Register = RegisterPass<RemoveDbgMetadata>;
static Register X("remove-dbg-metadata", "Removes dbg metadata from Functions");
bool RemoveDbgMetadata::runOnFunction(llvm::Function &F) {
if (not FunctionTags::Lifted.isTagOf(&F))
return false;
F.setMetadata(LLVMContext::MD_dbg, nullptr);
for (BasicBlock &BB : F)
for (Instruction &I : BB)
I.setMetadata(LLVMContext::MD_dbg, nullptr);
return true;
}