diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index ce8dbd5d2..edafffdee 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -69,6 +69,11 @@ class LocalizeVisitor final : public VNVisitor { bool isOptimizable(AstVarScope* nodep) { // Don't want to malloc/free the backing store all the time if (VN_IS(nodep->dtypep(), NBACommitQueueDType)) return false; + // Do not localize strings. They result in unnecessary initialization + // and bloated code size due to destructor calls when unused. + // TODO: Local variables should be pushed into the narrowest scope rather + // than emitted at the top of the function. See discussion in #6969. + if (nodep->dtypep()->skipRefp()->isString()) return false; // Variables used in super constructor call can't be localized, because // in C++ there is no way to declare them before base class constructor call if (nodep->user4()) return false;