blob: 97a4533fabe5a69a74db4a6e1e767de9eac038f5 [file] [log] [blame]
Michael Ilsemane5428042016-10-25 18:44:13 +00001//===- StripNonLineTableDebugInfo.cpp -- Strip parts of Debug Info --------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Michael Ilsemane5428042016-10-25 18:44:13 +00006//
7//===----------------------------------------------------------------------===//
8
Michael Ilsemane5428042016-10-25 18:44:13 +00009#include "llvm/IR/DebugInfo.h"
10#include "llvm/Pass.h"
David Blaikief4230622018-03-29 22:42:08 +000011#include "llvm/Transforms/Utils.h"
Michael Ilsemane5428042016-10-25 18:44:13 +000012using namespace llvm;
13
14namespace {
15
16/// This pass strips all debug info that is not related line tables.
17/// The result will be the same as if the program where compiled with
18/// -gline-tables-only.
19struct StripNonLineTableDebugInfo : public ModulePass {
20 static char ID; // Pass identification, replacement for typeid
21 StripNonLineTableDebugInfo() : ModulePass(ID) {
22 initializeStripNonLineTableDebugInfoPass(*PassRegistry::getPassRegistry());
23 }
24
25 void getAnalysisUsage(AnalysisUsage &AU) const override {
26 AU.setPreservesAll();
27 }
28
29 bool runOnModule(Module &M) override {
30 return llvm::stripNonLineTableDebugInfo(M);
31 }
32};
33}
34
35char StripNonLineTableDebugInfo::ID = 0;
36INITIALIZE_PASS(StripNonLineTableDebugInfo, "strip-nonlinetable-debuginfo",
37 "Strip all debug info except linetables", false, false)
38
39ModulePass *llvm::createStripNonLineTableDebugInfoPass() {
40 return new StripNonLineTableDebugInfo();
41}