28 class ModuleDebugInfoPrinter :
public ModulePass {
36 bool runOnModule(
Module &M)
override;
47 "Decodes module-level debug info",
false,
true)
50 return new ModuleDebugInfoPrinter();
53 bool ModuleDebugInfoPrinter::runOnModule(
Module &M) {
54 Finder.processModule(M);
64 if (!Directory.
empty())
65 O << Directory <<
"/";
76 O <<
"Compile unit: ";
81 O <<
"unknown-language(" << CU->getSourceLanguage() <<
")";
82 printFile(O, CU->getFilename(), CU->getDirectory());
87 O <<
"Subprogram: " << S->getName();
88 printFile(O, S->getFilename(), S->getDirectory(), S->getLine());
89 if (!S->getLinkageName().empty())
90 O <<
" ('" << S->getLinkageName() <<
"')";
94 for (
auto GVU : Finder.global_variables()) {
95 const auto *GV = GVU->getVariable();
96 O <<
"Global variable: " << GV->getName();
97 printFile(O, GV->getFilename(), GV->getDirectory(), GV->getLine());
98 if (!GV->getLinkageName().empty())
99 O <<
" ('" << GV->getLinkageName() <<
"')";
103 for (
const DIType *
T : Finder.types()) {
105 if (!
T->getName().empty())
106 O <<
' ' <<
T->getName();
107 printFile(O,
T->getFilename(),
T->getDirectory(),
T->getLine());
108 if (
auto *
BT = dyn_cast<DIBasicType>(
T)) {
111 if (!Encoding.empty())
114 O <<
"unknown-encoding(" <<
BT->getEncoding() <<
')';
121 O <<
"unknown-tag(" <<
T->getTag() <<
")";
123 if (
auto *CT = dyn_cast<DICompositeType>(
T)) {
124 if (
auto *S = CT->getRawIdentifier())
125 O <<
" (identifier: '" << S->getString() <<
"')";
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
INITIALIZE_PASS(ModuleDebugInfoPrinter,"module-debuginfo","Decodes module-level debug info", false, true) ModulePass *llvm
Utility to find all debug info in a module.
static void printFile(raw_ostream &O, StringRef Filename, StringRef Directory, unsigned Line=0)
StringRef LanguageString(unsigned Language)
void initializeModuleDebugInfoPrinterPass(PassRegistry &)
StringRef AttributeEncodingString(unsigned Encoding)
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ModulePass * createModuleDebugInfoPrinterPass()
StringRef TagString(unsigned Tag)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.