Commit e39cb48c authored by Raphael Isemann's avatar Raphael Isemann
Browse files

[lldb] Remove ClangASTMetrics

Summary: Not once have I looked at these numbers in a log and considered them useful. Also this should not have been implemented via an unguarded list of globals.

Reviewers: martong, shafik

Reviewed By: shafik

Subscribers: rnkovacs, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71336
parent d6d36ae4
Loading
Loading
Loading
Loading
+0 −51
Original line number Diff line number Diff line
@@ -30,57 +30,6 @@

namespace lldb_private {

class ClangASTMetrics {
public:
  static void DumpCounters(Log *log);
  static void ClearLocalCounters() { local_counters = {0, 0, 0, 0, 0, 0}; }

  static void RegisterVisibleQuery() {
    ++global_counters.m_visible_query_count;
    ++local_counters.m_visible_query_count;
  }

  static void RegisterLexicalQuery() {
    ++global_counters.m_lexical_query_count;
    ++local_counters.m_lexical_query_count;
  }

  static void RegisterLLDBImport() {
    ++global_counters.m_lldb_import_count;
    ++local_counters.m_lldb_import_count;
  }

  static void RegisterClangImport() {
    ++global_counters.m_clang_import_count;
    ++local_counters.m_clang_import_count;
  }

  static void RegisterDeclCompletion() {
    ++global_counters.m_decls_completed_count;
    ++local_counters.m_decls_completed_count;
  }

  static void RegisterRecordLayout() {
    ++global_counters.m_record_layout_count;
    ++local_counters.m_record_layout_count;
  }

private:
  struct Counters {
    uint64_t m_visible_query_count;
    uint64_t m_lexical_query_count;
    uint64_t m_lldb_import_count;
    uint64_t m_clang_import_count;
    uint64_t m_decls_completed_count;
    uint64_t m_record_layout_count;
  };

  static Counters global_counters;
  static Counters local_counters;

  static void DumpCounters(Log *log, Counters &counters);
};

class ClangASTImporter {
public:
  struct LayoutInfo {
+0 −8
Original line number Diff line number Diff line
@@ -524,8 +524,6 @@ void ClangASTSource::FindExternalLexicalDecls(
  } else if (!m_ast_importer_sp)
    return;

  ClangASTMetrics::RegisterLexicalQuery();

  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

  const Decl *context_decl = dyn_cast<Decl>(decl_context);
@@ -671,8 +669,6 @@ void ClangASTSource::FindExternalLexicalDecls(
void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
  assert(m_ast_context);

  ClangASTMetrics::RegisterVisibleQuery();

  const ConstString name(context.m_decl_name.getAsString().c_str());

  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1714,8 +1710,6 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
                                      FieldOffsetMap &field_offsets,
                                      BaseOffsetMap &base_offsets,
                                      BaseOffsetMap &virtual_base_offsets) {
  ClangASTMetrics::RegisterRecordLayout();

  static unsigned int invocation_id = 0;
  unsigned int current_id = invocation_id++;

@@ -2032,8 +2026,6 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
  if (src_ast == nullptr)
    return CompilerType();

  ClangASTMetrics::RegisterLLDBImport();

  SetImportInProgress(true);

  QualType copied_qual_type;
+0 −9
Original line number Diff line number Diff line
@@ -84,8 +84,6 @@ ClangExpressionDeclMap::~ClangExpressionDeclMap() {

bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
                                       Materializer *materializer) {
  ClangASTMetrics::ClearLocalCounters();

  EnableParserVars();
  m_parser_vars->m_exe_ctx = exe_ctx;

@@ -127,11 +125,6 @@ void ClangExpressionDeclMap::InstallCodeGenerator(
}

void ClangExpressionDeclMap::DidParse() {
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

  if (log)
    ClangASTMetrics::DumpCounters(log);

  if (m_parser_vars) {
    for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
         entity_index < num_entities; ++entity_index) {
@@ -685,8 +678,6 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
    NameSearchContext &context) {
  assert(m_ast_context);

  ClangASTMetrics::RegisterVisibleQuery();

  const ConstString name(context.m_decl_name.getAsString().c_str());

  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+0 −38
Original line number Diff line number Diff line
@@ -25,36 +25,6 @@
using namespace lldb_private;
using namespace clang;

ClangASTMetrics::Counters ClangASTMetrics::global_counters = {0, 0, 0, 0, 0, 0};
ClangASTMetrics::Counters ClangASTMetrics::local_counters = {0, 0, 0, 0, 0, 0};

void ClangASTMetrics::DumpCounters(Log *log,
                                   ClangASTMetrics::Counters &counters) {
  LLDB_LOGF(log, "  Number of visible Decl queries by name     : %" PRIu64,
            counters.m_visible_query_count);
  LLDB_LOGF(log, "  Number of lexical Decl queries             : %" PRIu64,
            counters.m_lexical_query_count);
  LLDB_LOGF(log, "  Number of imports initiated by LLDB        : %" PRIu64,
            counters.m_lldb_import_count);
  LLDB_LOGF(log, "  Number of imports conducted by Clang       : %" PRIu64,
            counters.m_clang_import_count);
  LLDB_LOGF(log, "  Number of Decls completed                  : %" PRIu64,
            counters.m_decls_completed_count);
  LLDB_LOGF(log, "  Number of records laid out                 : %" PRIu64,
            counters.m_record_layout_count);
}

void ClangASTMetrics::DumpCounters(Log *log) {
  if (!log)
    return;

  LLDB_LOGF(log, "== ClangASTMetrics output ==");
  LLDB_LOGF(log, "-- Global metrics --");
  DumpCounters(log, global_counters);
  LLDB_LOGF(log, "-- Local metrics --");
  DumpCounters(log, local_counters);
}

clang::QualType ClangASTImporter::CopyType(clang::ASTContext *dst_ast,
                                           clang::ASTContext *src_ast,
                                           clang::QualType type) {
@@ -628,8 +598,6 @@ void ClangASTImporter::CompleteDecl(clang::Decl *decl) {
}

bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
  ClangASTMetrics::RegisterDeclCompletion();

  DeclOrigin decl_origin = GetDeclOrigin(decl);

  if (!decl_origin.Valid())
@@ -651,8 +619,6 @@ bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {

bool ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,
                                                 clang::TagDecl *origin_decl) {
  ClangASTMetrics::RegisterDeclCompletion();

  clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();

  if (!ClangASTContext::GetCompleteDecl(origin_ast_ctx, origin_decl))
@@ -675,8 +641,6 @@ bool ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,

bool ClangASTImporter::CompleteObjCInterfaceDecl(
    clang::ObjCInterfaceDecl *interface_decl) {
  ClangASTMetrics::RegisterDeclCompletion();

  DeclOrigin decl_origin = GetDeclOrigin(interface_decl);

  if (!decl_origin.Valid())
@@ -1037,8 +1001,6 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(

void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
                                                     clang::Decl *to) {
  ClangASTMetrics::RegisterClangImport();

  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

  // Some decls shouldn't be tracked here because they were not created by