1311116Sdim//===- StripNonLineTableDebugInfo.cpp -- Strip parts of Debug Info --------===// 2311116Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6311116Sdim// 7311116Sdim//===----------------------------------------------------------------------===// 8311116Sdim 9311116Sdim#include "llvm/IR/DebugInfo.h" 10360784Sdim#include "llvm/InitializePasses.h" 11311116Sdim#include "llvm/Pass.h" 12341825Sdim#include "llvm/Transforms/Utils.h" 13311116Sdimusing namespace llvm; 14311116Sdim 15311116Sdimnamespace { 16311116Sdim 17311116Sdim/// This pass strips all debug info that is not related line tables. 18311116Sdim/// The result will be the same as if the program where compiled with 19311116Sdim/// -gline-tables-only. 20311116Sdimstruct StripNonLineTableDebugInfo : public ModulePass { 21311116Sdim static char ID; // Pass identification, replacement for typeid 22311116Sdim StripNonLineTableDebugInfo() : ModulePass(ID) { 23311116Sdim initializeStripNonLineTableDebugInfoPass(*PassRegistry::getPassRegistry()); 24311116Sdim } 25311116Sdim 26311116Sdim void getAnalysisUsage(AnalysisUsage &AU) const override { 27311116Sdim AU.setPreservesAll(); 28311116Sdim } 29311116Sdim 30311116Sdim bool runOnModule(Module &M) override { 31311116Sdim return llvm::stripNonLineTableDebugInfo(M); 32311116Sdim } 33311116Sdim}; 34311116Sdim} 35311116Sdim 36311116Sdimchar StripNonLineTableDebugInfo::ID = 0; 37311116SdimINITIALIZE_PASS(StripNonLineTableDebugInfo, "strip-nonlinetable-debuginfo", 38311116Sdim "Strip all debug info except linetables", false, false) 39311116Sdim 40311116SdimModulePass *llvm::createStripNonLineTableDebugInfoPass() { 41311116Sdim return new StripNonLineTableDebugInfo(); 42311116Sdim} 43