27#define DEBUG_TYPE "mir-check-debugify"
33bool checkDebugMachineModuleImpl(
35 NamedMDNode *NMD = M.getNamedMetadata(
"llvm.mir.debugify");
37 errs() <<
"WARNING: Please run mir-debugify to generate "
38 "llvm.mir.debugify metadata first.\n";
42 auto getDebugifyOperand = [&](
unsigned Idx) ->
unsigned {
47 "llvm.mir.debugify should have exactly 2 operands!");
48 unsigned NumLines = getDebugifyOperand(0);
49 unsigned NumVars = getDebugifyOperand(1);
61 if (
MI.isDebugValue())
64 if (
DL &&
DL.getLine() != 0) {
65 MissingLines.
reset(
DL.getLine() - 1);
70 errs() <<
"WARNING: Instruction with empty DebugLoc in function ";
71 errs() <<
F.getName() <<
" --";
79 if (!
MI.isDebugValue())
84 (void)
to_integer(LocalVar->getName(), Var, 10);
85 assert(Var <= NumVars &&
"Unexpected name for DILocalVariable");
86 MissingVars.
reset(Var - 1);
92 for (
unsigned Idx : MissingLines.
set_bits()) {
93 errs() <<
"WARNING: Missing line " << Idx + 1 <<
"\n";
97 for (
unsigned Idx : MissingVars.
set_bits()) {
98 errs() <<
"WARNING: Missing variable " << Idx + 1 <<
"\n";
101 errs() <<
"Machine IR debug info check: ";
102 errs() << (
Fail ?
"FAIL" :
"PASS") <<
"\n";
107struct CheckDebugMachineModuleLegacy :
public ModulePass {
108 bool runOnModule(
Module &M)
override {
110 getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
111 return checkDebugMachineModuleImpl(
126char CheckDebugMachineModuleLegacy::ID = 0;
131 "Machine Check Debug Module",
false,
false)
136 return new CheckDebugMachineModuleLegacy();
146 return MFA ? &MFA->
getMF() :
nullptr;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This file contains the declaration of the CheckDebugMachineModulePass class, used by the new pass man...
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
BitVector & reset()
Reset all bits in the bitvector.
iterator_range< const_set_bits_iterator > set_bits() const
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
const MDOperand & getOperand(unsigned I) const
MachineFunction & getMF()
This analysis create MachineFunction for given Function.
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.
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI unsigned getNumOperands() const
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
An efficient, type-erasing, non-owning reference to a callable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI ModulePass * createCheckDebugMachineModuleLegacyPass()
Creates MIR Check Debug pass.
bool to_integer(StringRef S, N &Num, unsigned Base=0)
Convert the string S to an integer of the specified type using the radix Base. If Base is 0,...
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.