From 12476d909c37f0b8967172572490dd6a704612e9 Mon Sep 17 00:00:00 2001 From: Quinn Dawkins Date: Fri, 22 Nov 2024 11:46:58 -0500 Subject: [PATCH] Fix GCC dangling pointer warning in ConfigTrackingListener (#19265) Tentative fix for https://github.com/iree-org/iree/issues/19264 --- .../Codegen/Common/ConcretizePadResultShape.cpp | 2 +- .../Common/ConfigTrackingCanonicalizer.cpp | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/src/iree/compiler/Codegen/Common/ConcretizePadResultShape.cpp b/compiler/src/iree/compiler/Codegen/Common/ConcretizePadResultShape.cpp index 89727e482dd9..a18577058fe6 100644 --- a/compiler/src/iree/compiler/Codegen/Common/ConcretizePadResultShape.cpp +++ b/compiler/src/iree/compiler/Codegen/Common/ConcretizePadResultShape.cpp @@ -136,11 +136,11 @@ class ConcretizePadResultShapePass final MLIRContext *context = &getContext(); auto funcOp = getOperation(); + ConfigTrackingListener listener; { RewritePatternSet patterns(context); populateConcretizePadResultShapePatterns(patterns); GreedyRewriteConfig config; - auto listener = ConfigTrackingListener(); config.listener = &listener; if (failed(applyPatternsAndFoldGreedily(funcOp, std::move(patterns), config))) { diff --git a/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp b/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp index 0294d9b43208..54d3cf6d11e1 100644 --- a/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp +++ b/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp @@ -91,13 +91,15 @@ struct ConfigTrackingCanonicalizerPass final void runOnOperation() override { // Canonicalization is best-effort. Non-convergence is not a pass failure. - auto listener = ConfigTrackingListener(); - config.listener = &listener; - LogicalResult didConverge = - applyPatternsAndFoldGreedily(getOperation(), *patterns, config); - if (this->testConvergence && failed(didConverge)) { - getOperation()->emitError("Canonicalizer failed to converge"); - return signalPassFailure(); + ConfigTrackingListener listener; + { + config.listener = &listener; + LogicalResult didConverge = + applyPatternsAndFoldGreedily(getOperation(), *patterns, config); + if (this->testConvergence && failed(didConverge)) { + getOperation()->emitError("Canonicalizer failed to converge"); + return signalPassFailure(); + } } } GreedyRewriteConfig config;