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