2018-07-24 02:41:28 +02:00
|
|
|
//===- Debugify.h - Attach synthetic debug info to everything -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file Interface to the `debugify` synthetic debug info testing utility.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TOOLS_OPT_DEBUGIFY_H
|
|
|
|
#define LLVM_TOOLS_OPT_DEBUGIFY_H
|
|
|
|
|
2018-07-24 02:41:29 +02:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/ADT/MapVector.h"
|
2018-07-24 02:41:28 +02:00
|
|
|
#include "llvm/IR/PassManager.h"
|
2018-07-24 02:41:29 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2018-07-24 02:41:28 +02:00
|
|
|
|
|
|
|
llvm::ModulePass *createDebugifyModulePass();
|
|
|
|
llvm::FunctionPass *createDebugifyFunctionPass();
|
|
|
|
|
|
|
|
struct NewPMDebugifyPass : public llvm::PassInfoMixin<NewPMDebugifyPass> {
|
|
|
|
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
|
|
|
|
};
|
|
|
|
|
2018-07-24 02:41:29 +02:00
|
|
|
/// Track how much `debugify` information has been lost.
|
|
|
|
struct DebugifyStatistics {
|
|
|
|
/// Number of missing dbg.values.
|
|
|
|
unsigned NumDbgValuesMissing = 0;
|
|
|
|
|
|
|
|
/// Number of dbg.values expected.
|
|
|
|
unsigned NumDbgValuesExpected = 0;
|
|
|
|
|
|
|
|
/// Number of instructions with empty debug locations.
|
|
|
|
unsigned NumDbgLocsMissing = 0;
|
|
|
|
|
|
|
|
/// Number of instructions expected to have debug locations.
|
|
|
|
unsigned NumDbgLocsExpected = 0;
|
|
|
|
|
|
|
|
/// Get the ratio of missing/expected dbg.values.
|
|
|
|
float getMissingValueRatio() const {
|
|
|
|
return float(NumDbgValuesMissing) / float(NumDbgLocsExpected);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the ratio of missing/expected instructions with locations.
|
|
|
|
float getEmptyLocationRatio() const {
|
|
|
|
return float(NumDbgLocsMissing) / float(NumDbgLocsExpected);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Map pass names to a per-pass DebugifyStatistics instance.
|
|
|
|
using DebugifyStatsMap = llvm::MapVector<llvm::StringRef, DebugifyStatistics>;
|
|
|
|
|
|
|
|
/// Export per-pass debugify statistics to the file specified by \p Path.
|
|
|
|
void exportDebugifyStats(llvm::StringRef Path, const DebugifyStatsMap &Map);
|
|
|
|
|
2018-07-24 02:41:28 +02:00
|
|
|
llvm::ModulePass *
|
|
|
|
createCheckDebugifyModulePass(bool Strip = false,
|
2018-07-24 02:41:29 +02:00
|
|
|
llvm::StringRef NameOfWrappedPass = "",
|
|
|
|
DebugifyStatsMap *StatsMap = nullptr);
|
2018-07-24 02:41:28 +02:00
|
|
|
|
|
|
|
llvm::FunctionPass *
|
|
|
|
createCheckDebugifyFunctionPass(bool Strip = false,
|
2018-07-24 02:41:29 +02:00
|
|
|
llvm::StringRef NameOfWrappedPass = "",
|
|
|
|
DebugifyStatsMap *StatsMap = nullptr);
|
2018-07-24 02:41:28 +02:00
|
|
|
|
|
|
|
struct NewPMCheckDebugifyPass
|
|
|
|
: public llvm::PassInfoMixin<NewPMCheckDebugifyPass> {
|
|
|
|
llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LLVM_TOOLS_OPT_DEBUGIFY_H
|