1 //===- StripNonLineTableDebugInfo.cpp -- Strip parts of Debug Info --------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Transforms/Utils/StripNonLineTableDebugInfo.h"
10 #include "llvm/IR/DebugInfo.h"
11 #include "llvm/InitializePasses.h"
12 #include "llvm/Pass.h"
13 #include "llvm/Transforms/Utils.h"
18 /// This pass strips all debug info that is not related line tables.
19 /// The result will be the same as if the program where compiled with
20 /// -gline-tables-only.
21 struct StripNonLineTableDebugLegacyPass
: public ModulePass
{
22 static char ID
; // Pass identification, replacement for typeid
23 StripNonLineTableDebugLegacyPass() : ModulePass(ID
) {
24 initializeStripNonLineTableDebugLegacyPassPass(
25 *PassRegistry::getPassRegistry());
28 void getAnalysisUsage(AnalysisUsage
&AU
) const override
{
32 bool runOnModule(Module
&M
) override
{
33 return llvm::stripNonLineTableDebugInfo(M
);
38 char StripNonLineTableDebugLegacyPass::ID
= 0;
39 INITIALIZE_PASS(StripNonLineTableDebugLegacyPass
,
40 "strip-nonlinetable-debuginfo",
41 "Strip all debug info except linetables", false, false)
43 ModulePass
*llvm::createStripNonLineTableDebugLegacyPass() {
44 return new StripNonLineTableDebugLegacyPass();
48 StripNonLineTableDebugInfoPass::run(Module
&M
, ModuleAnalysisManager
&AM
) {
49 llvm::stripNonLineTableDebugInfo(M
);
50 return PreservedAnalyses::all();