Files
revng-revng/lib/FunctionIsolation/StripDebugInfoFromHelpers.cpp
Alessandro Di Federico f8bd4c3bac Move around some files in preparation for libtcg
* Make the following private headers public:
  * Lift/CPUStateAccessAnalysisPass.h
  * Lift/CSVOffsets.h
  * Lift/PTCDump.h
  * Lift/VariableManager.h
* Move from revngSupport to revngLift:
  * IRAnnotators.{h,cpp}
  * SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
  * FunctionTags.{h,cpp}
  * ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
  * OriginalAssemblyAnnotationWriter.{h,cpp}
2025-10-24 15:34:11 +02:00

45 lines
1.2 KiB
C++

//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/IR/DebugInfo.h"
#include "llvm/Pass.h"
#include "revng/Model/FunctionTags.h"
#include "revng/Pipeline/RegisterLLVMPass.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);