Skip to content

[LLDB] Remove high-firing scoped timers from the Swift plugin #10690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ class LLDBExprNameLookup : public LLDBNameLookup {
bool lookupAdditions(swift::DeclBaseName Name, swift::DeclContext *DC,
swift::SourceLoc Loc, bool IsTypeLookup,
ResultVector &RV) override {
LLDB_SCOPED_TIMER();
assert(SwiftASTContext::GetSwiftASTContext(&DC->getASTContext()) ==
m_this_context);
static unsigned counter = 0;
Expand Down Expand Up @@ -402,8 +401,6 @@ class LLDBREPLNameLookup : public LLDBNameLookup {
bool lookupAdditions(swift::DeclBaseName Name, swift::DeclContext *DC,
swift::SourceLoc Loc, bool IsTypeLookup,
ResultVector &RV) override {
LLDB_SCOPED_TIMER();

assert(SwiftASTContext::GetSwiftASTContext(&DC->getASTContext()) ==
m_this_context);
static unsigned counter = 0;
Expand Down Expand Up @@ -462,7 +459,6 @@ class LLDBREPLNameLookup : public LLDBNameLookup {
static CompilerType GetSwiftTypeForVariableValueObject(
lldb::ValueObjectSP valobj_sp, lldb::StackFrameSP &stack_frame_sp,
SwiftLanguageRuntime *runtime, lldb::BindGenericTypes bind_generic_types) {
LLDB_SCOPED_TIMER();
// Check that the passed ValueObject is valid.
if (!valobj_sp || valobj_sp->GetError().Fail())
return {};
Expand Down Expand Up @@ -490,7 +486,6 @@ CompilerType SwiftExpressionParser::ResolveVariable(
lldb::VariableSP variable_sp, lldb::StackFrameSP &stack_frame_sp,
SwiftLanguageRuntime *runtime, lldb::DynamicValueType use_dynamic,
lldb::BindGenericTypes bind_generic_types) {
LLDB_SCOPED_TIMER();
lldb::ValueObjectSP valobj_sp =
stack_frame_sp->GetValueObjectForFrameVariable(variable_sp,
lldb::eNoDynamicValues);
Expand Down Expand Up @@ -555,8 +550,6 @@ AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp,
SwiftASTManipulator &manipulator,
lldb::DynamicValueType use_dynamic,
lldb::BindGenericTypes bind_generic_types) {
LLDB_SCOPED_TIMER();

// Alias builtin types, since we can't use them directly in source code.
auto builtin_ptr_t = swift_ast_context.GetBuiltinRawPointerType();
auto alias = manipulator.MakeTypealias(
Expand Down Expand Up @@ -737,8 +730,6 @@ static void ResolveSpecialNames(
llvm::SmallVectorImpl<swift::Identifier> &special_names,
llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_SCOPED_TIMER();

if (!sc.target_sp)
return;

Expand Down Expand Up @@ -939,7 +930,6 @@ MaterializeVariable(SwiftASTManipulatorBase::VariableInfo &variable,
lldb::StackFrameWP &stack_frame_wp,
DiagnosticManager &diagnostic_manager, Log *log,
bool repl) {
LLDB_SCOPED_TIMER();
uint64_t offset = 0;
bool needs_init = false;

Expand Down Expand Up @@ -1283,9 +1273,6 @@ SwiftExpressionParser::ParseAndImport(
SwiftExpressionParser::SILVariableMap &variable_map, unsigned &buffer_id,
DiagnosticManager &diagnostic_manager) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_SCOPED_TIMER();


bool repl = m_options.GetREPLEnabled();
bool playground = m_options.GetPlaygroundTransformEnabled();
// If we are using the playground, hand import the necessary
Expand Down Expand Up @@ -1747,8 +1734,6 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
SwiftExpressionParser::SILVariableMap variable_map;
using ParseResult = SwiftExpressionParser::ParseResult;
Log *log = GetLog(LLDBLog::Expressions);
LLDB_SCOPED_TIMER();

// Get a scoped diagnostics consumer for all diagnostics produced by
// this expression.
auto expr_diagnostics = m_swift_ast_ctx.getScopedDiagnosticConsumer();
Expand Down Expand Up @@ -2228,7 +2213,6 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
static bool FindFunctionInModule(ConstString &mangled_name,
llvm::Module *module, const char *orig_name,
bool exact) {
LLDB_SCOPED_TIMER();
swift::Demangle::Context demangle_ctx;
for (llvm::Module::iterator fi = module->getFunctionList().begin(),
fe = module->getFunctionList().end();
Expand Down Expand Up @@ -2282,7 +2266,6 @@ Status SwiftExpressionParser::DoPrepareForExecution(
lldb::addr_t &func_addr, lldb::addr_t &func_end,
lldb::IRExecutionUnitSP &execution_unit_sp, ExecutionContext &exe_ctx,
bool &can_interpret, ExecutionPolicy execution_policy) {
LLDB_SCOPED_TIMER();
Status err;
Log *log = GetLog(LLDBLog::Expressions);

Expand Down Expand Up @@ -2340,7 +2323,6 @@ Status SwiftExpressionParser::DoPrepareForExecution(

bool SwiftExpressionParser::RewriteExpression(
DiagnosticManager &diagnostic_manager) {
LLDB_SCOPED_TIMER();
// There isn't a Swift equivalent to clang::Rewriter, so we'll just
// use that.
Log *log = GetLog(LLDBLog::Expressions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ findSwiftSelf(StackFrame &frame, lldb::VariableSP self_var_sp) {
void SwiftUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log, "SwiftUserExpression::ScanContext()");
LLDB_SCOPED_TIMER();

m_target = exe_ctx.GetTargetPtr();
if (!m_target) {
Expand Down Expand Up @@ -304,8 +303,6 @@ static llvm::Error AddVariableInfo(
llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
lldb::DynamicValueType use_dynamic,
lldb::BindGenericTypes bind_generic_types) {
LLDB_SCOPED_TIMER();

StringRef name = variable_sp->GetUnqualifiedName().GetStringRef();
const char *name_cstr = name.data();
assert(StringRef(name_cstr) == name && "missing null terminator");
Expand Down Expand Up @@ -495,7 +492,6 @@ static llvm::Error RegisterAllVariables(
llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
lldb::DynamicValueType use_dynamic,
lldb::BindGenericTypes bind_generic_types) {
LLDB_SCOPED_TIMER();
SwiftLanguageRuntime *language_runtime = nullptr;

if (stack_frame_sp)
Expand Down Expand Up @@ -703,8 +699,6 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
bool keep_result_in_memory,
bool generate_debug_info) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_SCOPED_TIMER();

Status err;

auto error = [&](const char *error_msg, const char *detail = nullptr) {
Expand Down Expand Up @@ -981,7 +975,6 @@ bool SwiftUserExpression::AddArguments(ExecutionContext &exe_ctx,

lldb::ExpressionVariableSP SwiftUserExpression::GetResultAfterDematerialization(
ExecutionContextScope *exe_scope) {
LLDB_SCOPED_TIMER();
lldb::ExpressionVariableSP in_result_sp = m_result_delegate.GetVariable();
lldb::ExpressionVariableSP in_error_sp = m_error_delegate.GetVariable();

Expand Down
15 changes: 0 additions & 15 deletions lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ static bool makeStringGutsSummary(
const TypeSummaryOptions &summary_options,
StringPrinter::ReadStringAndDumpToStreamOptions read_options,
std::optional<StringSlice> slice = std::nullopt) {
LLDB_SCOPED_TIMER();

static ConstString g__object("_object");
static ConstString g__storage("_storage");
static ConstString g__value("_value");
Expand Down Expand Up @@ -518,8 +516,6 @@ bool lldb_private::formatters::swift::StaticString_SummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options,
StringPrinter::ReadStringAndDumpToStreamOptions read_options) {
LLDB_SCOPED_TIMER();

static ConstString g__startPtrOrData("_startPtrOrData");
static ConstString g__byteSize("_utf8CodeUnitCount");
static ConstString g__flags("_flags");
Expand Down Expand Up @@ -574,7 +570,6 @@ bool lldb_private::formatters::swift::SwiftSharedString_SummaryProvider_2(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options,
StringPrinter::ReadStringAndDumpToStreamOptions read_options) {
LLDB_SCOPED_TIMER();
ProcessSP process(valobj.GetProcessSP());
if (!process)
return false;
Expand Down Expand Up @@ -603,7 +598,6 @@ bool lldb_private::formatters::swift::SwiftSharedString_SummaryProvider_2(

bool lldb_private::formatters::swift::SwiftStringStorage_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();
ProcessSP process(valobj.GetProcessSP());
if (!process)
return false;
Expand Down Expand Up @@ -675,7 +669,6 @@ bool lldb_private::formatters::swift::DarwinBoolean_SummaryProvider(
static bool RangeFamily_SummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options,
bool isHalfOpen) {
LLDB_SCOPED_TIMER();
static ConstString g_lowerBound("lowerBound");
static ConstString g_upperBound("upperBound");

Expand Down Expand Up @@ -1610,7 +1603,6 @@ lldb_private::formatters::swift::ActorSyntheticFrontEndCreator(

bool lldb_private::formatters::swift::ObjC_Selector_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();
static ConstString g_ptr("ptr");
static ConstString g__rawValue("_rawValue");

Expand Down Expand Up @@ -1757,7 +1749,6 @@ bool PrintTypePreservingNSNumber(DataBufferSP buffer_sp, ProcessSP process_sp,

bool lldb_private::formatters::swift::TypePreservingNSNumber_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();
lldb::addr_t ptr_value(valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS));
if (ptr_value == LLDB_INVALID_ADDRESS)
return false;
Expand Down Expand Up @@ -2040,8 +2031,6 @@ void PrintMatrix(Stream &stream,

bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();

// SIMD vector contains an inner member `_storage` which is an opaque
// container. Given SIMD is always in the form SIMDX<Type> where X is a
// positive integer, we can calculate the number of elements and the
Expand Down Expand Up @@ -2115,8 +2104,6 @@ bool lldb_private::formatters::swift::SIMDVector_SummaryProvider(

bool lldb_private::formatters::swift::LegacySIMD_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();

Status error;
ProcessSP process_sp(valobj.GetProcessSP());
if (!process_sp)
Expand Down Expand Up @@ -2201,8 +2188,6 @@ bool lldb_private::formatters::swift::LegacySIMD_SummaryProvider(

bool lldb_private::formatters::swift::GLKit_SummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
LLDB_SCOPED_TIMER();

// Get the type name without the "GLKit." prefix.
ConstString full_type_name = valobj.GetTypeName();
llvm::StringRef type_name = full_type_name.GetStringRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2705,7 +2705,6 @@ UnwindPlanSP
SwiftLanguageRuntime::GetRuntimeUnwindPlan(ProcessSP process_sp,
RegisterContext *regctx,
bool &behaves_like_zeroth_frame) {
LLDB_SCOPED_TIMER();
auto log_expected = [](llvm::Error error) {
Log *log = GetLog(LLDBLog::Unwind);
LLDB_LOG_ERROR(log, std::move(error), "{0}");
Expand Down Expand Up @@ -2810,8 +2809,6 @@ SwiftLanguageRuntime::GetRuntimeUnwindPlan(ProcessSP process_sp,
UnwindPlanSP SwiftLanguageRuntime::GetFollowAsyncContextUnwindPlan(
ProcessSP process_sp, RegisterContext *regctx, ArchSpec &arch,
bool &behaves_like_zeroth_frame) {
LLDB_SCOPED_TIMER();

UnwindPlan::RowSP row(new UnwindPlan::Row);
const int32_t ptr_size = 8;
row->SetOffset(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ SwiftLanguageRuntime::GetMemberVariableOffsetRemoteMirrors(
std::optional<uint64_t> SwiftLanguageRuntime::GetMemberVariableOffset(
CompilerType instance_type, ValueObject *instance,
llvm::StringRef member_name, Status *error) {
LLDB_SCOPED_TIMER();
std::optional<uint64_t> offset;

if (!instance_type.IsValid())
Expand Down Expand Up @@ -1581,7 +1580,6 @@ SwiftLanguageRuntime::GetNumFields(CompilerType type,
llvm::Expected<uint32_t> SwiftLanguageRuntime::GetNumChildren(
CompilerType type, ExecutionContextScope *exe_scope,
bool include_superclass, bool include_clang_types) {
LLDB_SCOPED_TIMER();
SwiftRuntimeTypeVisitor visitor(*this, type, exe_scope, !include_superclass,
include_clang_types);
return visitor.CountChildren();
Expand Down Expand Up @@ -1620,7 +1618,6 @@ std::pair<SwiftLanguageRuntime::LookupResult, std::optional<size_t>>
SwiftLanguageRuntime::GetIndexOfChildMemberWithName(
CompilerType type, llvm::StringRef name, ExecutionContext *exe_ctx,
bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) {
LLDB_SCOPED_TIMER();
SwiftRuntimeTypeVisitor visitor(*this, type, exe_ctx, false, false, true);
bool found = false;
unsigned i = 0, last_depth = 0;
Expand Down Expand Up @@ -2547,7 +2544,6 @@ void SwiftLanguageRuntime::ForEachGenericParameter(
CompilerType SwiftLanguageRuntime::BindGenericTypeParameters(
CompilerType unbound_type,
std::function<CompilerType(unsigned, unsigned)> type_resolver) {
LLDB_SCOPED_TIMER();
using namespace swift::Demangle;

auto ts =
Expand Down Expand Up @@ -2633,7 +2629,6 @@ llvm::Expected<CompilerType>
SwiftLanguageRuntime::BindGenericTypeParameters(StackFrame &stack_frame,
TypeSystemSwiftTypeRef &ts,
ConstString mangled_name) {
LLDB_SCOPED_TIMER();
using namespace swift::Demangle;

ThreadSafeReflectionContext reflection_ctx = GetReflectionContext();
Expand Down Expand Up @@ -3161,7 +3156,6 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress(
if (use_dynamic == lldb::eNoDynamicValues)
return false;

LLDB_SCOPED_TIMER();
CompilerType val_type(in_value.GetCompilerType());
Value::ValueType static_value_type = Value::ValueType::Invalid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ SwiftLanguageRuntime::GetDynamicTypeAndAddress_ExistentialRemoteAST(
llvm::Expected<CompilerType>
SwiftLanguageRuntime::BindGenericTypeParametersRemoteAST(
StackFrame &stack_frame, CompilerType base_type) {
LLDB_SCOPED_TIMER();

// If this is a TypeRef type, bind that.
auto sc = stack_frame.GetSymbolContext(lldb::eSymbolContextEverything);
if (auto ts =
Expand Down
Loading