mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
2760599483
During this phase (EnforceABI) the binary is not meant to be run so the debug info is not useful anymore, so we are striping them now in order to avoid taking care of them during the pipeline.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
//
|
|
// Copyright rev.ng Labs Srl. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/IR/DebugInfo.h"
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "revng/Pipeline/RegisterLLVMPass.h"
|
|
#include "revng/Support/FunctionTags.h"
|
|
|
|
using namespace llvm;
|
|
|
|
/// Debug Info on helpers is not very useful after this phase, since the binary
|
|
/// cannot be run after this phase.
|
|
static bool stripDebugInfoFromHelpers(Module &M) {
|
|
for (llvm::Function &F : M) {
|
|
if (not FunctionTags::Isolated.isTagOf(&F)) {
|
|
// TODO: If we really want to preserve this info, we should make proper
|
|
// location here.
|
|
stripDebugInfo(F);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
struct StripDebugInfoFromHelpersPass : public llvm::ModulePass {
|
|
public:
|
|
static char ID;
|
|
|
|
StripDebugInfoFromHelpersPass() : ModulePass(ID) {}
|
|
|
|
bool runOnModule(Module &M) override { return stripDebugInfoFromHelpers(M); }
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
|
AU.setPreservesAll();
|
|
}
|
|
};
|
|
|
|
char StripDebugInfoFromHelpersPass::ID = 0;
|
|
static constexpr const char *Flag = "strip-debug-info-from-helpers";
|
|
using Register = RegisterPass<StripDebugInfoFromHelpersPass>;
|
|
static Register
|
|
X(Flag, "Pass that removes debug info from helpers. ", false, false);
|