From 3fb2543d659205774dbc75a9bc0dd7cae71753d9 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Tue, 23 Mar 2021 15:51:08 -0700 Subject: [PATCH 1/3] Use the pass->getName() StringRef directly instead of std::string. --- iree/compiler/Utils/TracingUtils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iree/compiler/Utils/TracingUtils.h b/iree/compiler/Utils/TracingUtils.h index 2d7b9e66bf56..7df9e8e23edb 100644 --- a/iree/compiler/Utils/TracingUtils.h +++ b/iree/compiler/Utils/TracingUtils.h @@ -34,8 +34,8 @@ struct PassTracing : public PassInstrumentation { // Note: we could also trace pipelines and analyses. void runBeforePass(Pass *pass, Operation *op) override { - std::string passName = pass->getName().str(); - IREE_TRACE_ZONE_BEGIN_NAMED_DYNAMIC(z0, passName.data(), passName.size()); + IREE_TRACE_ZONE_BEGIN_NAMED_DYNAMIC(z0, pass->getName().data(), + pass->getName().size()); passTraceZonesStack.push_back(z0); } void runAfterPass(Pass *pass, Operation *op) override { From 452ec985aa0a0f9f91c7432a6462e79c1159da29 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 24 Mar 2021 09:55:39 -0700 Subject: [PATCH 2/3] Switch compiler tracing to use IREE_TRACE_ZONE_BEGIN_EXTERNAL. This copies "function_name" strings and omits the optional "name" strings, which allows Tracy to aggregate statistics for these zones. --- iree/compiler/Utils/TracingUtils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iree/compiler/Utils/TracingUtils.h b/iree/compiler/Utils/TracingUtils.h index 7df9e8e23edb..5bf0f4881912 100644 --- a/iree/compiler/Utils/TracingUtils.h +++ b/iree/compiler/Utils/TracingUtils.h @@ -34,8 +34,10 @@ struct PassTracing : public PassInstrumentation { // Note: we could also trace pipelines and analyses. void runBeforePass(Pass *pass, Operation *op) override { - IREE_TRACE_ZONE_BEGIN_NAMED_DYNAMIC(z0, pass->getName().data(), - pass->getName().size()); + static std::string fileName = __FILE__; + IREE_TRACE_ZONE_BEGIN_EXTERNAL(z0, fileName.data(), fileName.size(), + __LINE__, pass->getName().data(), + pass->getName().size(), NULL, 0); passTraceZonesStack.push_back(z0); } void runAfterPass(Pass *pass, Operation *op) override { From aeaa54e36870363c0c47d16b5f6b472762bab917 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 24 Mar 2021 11:05:29 -0700 Subject: [PATCH 3/3] Use strlen instead of a static std::string to get `__FILE__` length. --- iree/compiler/Utils/TracingUtils.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iree/compiler/Utils/TracingUtils.h b/iree/compiler/Utils/TracingUtils.h index 5bf0f4881912..c81cbb2dca1a 100644 --- a/iree/compiler/Utils/TracingUtils.h +++ b/iree/compiler/Utils/TracingUtils.h @@ -34,9 +34,8 @@ struct PassTracing : public PassInstrumentation { // Note: we could also trace pipelines and analyses. void runBeforePass(Pass *pass, Operation *op) override { - static std::string fileName = __FILE__; - IREE_TRACE_ZONE_BEGIN_EXTERNAL(z0, fileName.data(), fileName.size(), - __LINE__, pass->getName().data(), + IREE_TRACE_ZONE_BEGIN_EXTERNAL(z0, __FILE__, strlen(__FILE__), __LINE__, + pass->getName().data(), pass->getName().size(), NULL, 0); passTraceZonesStack.push_back(z0); }