1//===- MachineCheckDebugify.cpp - Check 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/// \file This checks debug info after mir-debugify (+ pass-to-test). Currently 10/// it simply checks the integrity of line info in DILocation and 11/// DILocalVariable which mir-debugifiy generated before. 12//===----------------------------------------------------------------------===// 25#define DEBUG_TYPE "mir-check-debugify" 31structCheckDebugMachineModule :
publicModulePass {
33NamedMDNode *NMD = M.getNamedMetadata(
"llvm.mir.debugify");
35errs() <<
"WARNING: Please run mir-debugify to generate " 36"llvm.mir.debugify metadata first.\n";
41 getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
43auto getDebugifyOperand = [&](
unsignedIdx) ->
unsigned {
48"llvm.mir.debugify should have exactly 2 operands!");
49unsigned NumLines = getDebugifyOperand(0);
50unsigned NumVars = getDebugifyOperand(1);
60// TODO: Avoid meta instructions other than dbg_val. 65if (
DL &&
DL.getLine() != 0) {
66 MissingLines.reset(
DL.getLine() - 1);
71errs() <<
"WARNING: Instruction with empty DebugLoc in function ";
72errs() <<
F.getName() <<
" --";
77// Find missing variables. 78// TODO: Handle DBG_INSTR_REF which is under an experimental option now. 80if (!
MI.isDebugValue())
85 (void)to_integer(LocalVar->getName(), Var, 10);
86assert(Var <= NumVars &&
"Unexpected name for DILocalVariable");
87 MissingVars.reset(Var - 1);
93for (
unsignedIdx : MissingLines.set_bits()) {
94errs() <<
"WARNING: Missing line " <<
Idx + 1 <<
"\n";
98for (
unsignedIdx : MissingVars.set_bits()) {
99errs() <<
"WARNING: Missing variable " <<
Idx + 1 <<
"\n";
102errs() <<
"Machine IR debug info check: ";
103errs() << (
Fail ?
"FAIL" :
"PASS") <<
"\n";
115staticcharID;
// Pass identification. 117char CheckDebugMachineModule::ID = 0;
119}
// end anonymous namespace 122"Machine Check Debug Module",
false,
false)
127returnnew CheckDebugMachineModule();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
COFF::MachineTypes Machine
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some functions that are useful when dealing with strings.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
const MDOperand & getOperand(unsigned I) const
Representation of each machine instruction.
This class contains meta information specific to a module.
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...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
ModulePass * createCheckDebugMachineModulePass()
Creates MIR Check Debug pass.