LLVM: lib/CodeGen/MachineStripDebug.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
20
21#define DEBUG_TYPE "mir-strip-debug"
22
23using namespace llvm;
24
25namespace {
27 OnlyDebugifiedDefault("mir-strip-debugify-only",
28 cl::desc("Should mir-strip-debug only strip debug "
29 "info from debugified modules by default"),
31
32struct StripDebugMachineModule : public ModulePass {
33 bool runOnModule(Module &M) override {
34 if (OnlyDebugified) {
35 NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
36 if (!DebugifyMD) {
38 " (debugify metadata not found)?\n");
39 return false;
40 }
41 }
42
44 getAnalysis().getMMI();
45
47 for (Function &F : M.functions()) {
49 if (!MaybeMF)
50 continue;
54 if (MI.isDebugInstr()) {
55
56
57
58
59 if (MI.getNumOperands() > 1) {
63 continue;
64 }
65 }
66 if (MI.getDebugLoc()) {
70 continue;
71 }
73 }
74 }
75 }
76
78
80 }
81
82 StripDebugMachineModule() : StripDebugMachineModule(OnlyDebugifiedDefault) {}
83 StripDebugMachineModule(bool OnlyDebugified)
84 : ModulePass(ID), OnlyDebugified(OnlyDebugified) {}
85
86 void getAnalysisUsage(AnalysisUsage &AU) const override {
90 }
91
92 static char ID;
93
94protected:
95 bool OnlyDebugified;
96};
97char StripDebugMachineModule::ID = 0;
98
99}
100
102 "Machine Strip Debug Module", false, false)
105
107 return new StripDebugMachineModule(OnlyDebugified);
108}
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Representation of each machine instruction.
This class contains meta information specific to a module.
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI ModulePass * createStripDebugMachineModulePass(bool OnlyDebugified)
Creates MIR Strip Debug pass.
Definition MachineStripDebug.cpp:106
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI bool stripDebugifyMetadata(Module &M)
Strip out all of the metadata and debug info inserted by debugify.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.