From f3aba255f6d69ddbf255b33d0eb0f391908e60a8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 12 Jul 2023 19:55:41 -0700 Subject: Pool inst worklists and hashsets to avoid rehashing. (#2982) Co-authored-by: Yong He --- source/slang/slang-ir-lower-binding-query.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-ir-lower-binding-query.cpp') diff --git a/source/slang/slang-ir-lower-binding-query.cpp b/source/slang/slang-ir-lower-binding-query.cpp index d0128d365..116dcff61 100644 --- a/source/slang/slang-ir-lower-binding-query.cpp +++ b/source/slang/slang-ir-lower-binding-query.cpp @@ -76,8 +76,12 @@ namespace Slang // itself is straightforward, and not anything // that hasn't been seen in other files. - List workList; - HashSet workListSet; + InstWorkList workList; + InstHashSet workListSet; + + WorkListPass(IRModule* inModule) + : module(inModule), workList(inModule), workListSet(inModule), toBeDeleted(inModule), toBeDeletedSet(inModule) + {} void addToWorkList(IRInst* inst) { @@ -111,8 +115,8 @@ namespace Slang // frequent need to buffer up instructions to // be deleted when a pass is complete. - List toBeDeleted; - HashSet toBeDeletedSet; + InstWorkList toBeDeleted; + InstHashSet toBeDeletedSet; void addToBeDeleted(IRInst* inst) { @@ -139,6 +143,10 @@ namespace Slang // struct BindingQueryLoweringContext : public WorkListPass { + BindingQueryLoweringContext(IRModule* inModule) + : WorkListPass(inModule) + {} + // All of the intrinsics we will be processing use // the same result type (`uint`), so it is helpful // to cache a pointer to the IR type at the start @@ -602,8 +610,7 @@ namespace Slang IRModule* module, DiagnosticSink* sink) { - BindingQueryLoweringContext context; - context.module = module; + BindingQueryLoweringContext context(module); context.sink = sink; context.processModule(); } -- cgit v1.2.3