Skip to content

Commit a915143

Browse files
committed
ice40: fix IdString memory leak
1 parent c48bc56 commit a915143

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

techlibs/ice40/ice40_opt.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void run_ice40_opts(Module *module)
117117

118118
if (GetSize(replacement_output)) {
119119
optimized_co.insert(sigmap(cell->getPort(ID::CO)[0]));
120-
auto it = cell->attributes.find(ID(SB_LUT4.name));
120+
auto it = cell->attributes.find(IdString{"\\SB_LUT4.name"});
121121
if (it != cell->attributes.end()) {
122122
module->rename(cell, it->second.decode_string());
123123
decltype(Cell::attributes) new_attr;
@@ -126,7 +126,7 @@ static void run_ice40_opts(Module *module)
126126
new_attr[a.first.c_str() + strlen("\\SB_LUT4.")] = a.second;
127127
else if (a.first == ID::src)
128128
new_attr.insert(std::make_pair(a.first, a.second));
129-
else if (a.first.in(ID(SB_LUT4.name), ID::keep, ID::module_not_derived))
129+
else if (a.first.in(IdString{"\\SB_LUT4.name"}, ID::keep, ID::module_not_derived))
130130
continue;
131131
else if (a.first.begins_with("\\SB_CARRY.\\"))
132132
continue;

techlibs/ice40/ice40_wrapcarry.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void create_ice40_wrapcarry(ice40_wrapcarry_pm &pm)
6262
cell->attributes[stringf("\\SB_CARRY.%s", a.first)] = a.second;
6363
for (const auto &a : st.lut->attributes)
6464
cell->attributes[stringf("\\SB_LUT4.%s", a.first)] = a.second;
65-
cell->attributes[ID(SB_LUT4.name)] = Const(st.lut->name.str());
65+
cell->attributes[IdString{"\\SB_LUT4.name"}] = Const(st.lut->name.str());
6666
if (st.carry->get_bool_attribute(ID::keep) || st.lut->get_bool_attribute(ID::keep))
6767
cell->attributes[ID::keep] = true;
6868

@@ -122,7 +122,7 @@ struct Ice40WrapCarryPass : public Pass {
122122
carry->setPort(ID::CI, cell->getPort(ID::CI));
123123
carry->setPort(ID::CO, cell->getPort(ID::CO));
124124
module->swap_names(carry, cell);
125-
auto lut_name = cell->attributes.at(ID(SB_LUT4.name), Const(NEW_ID.str())).decode_string();
125+
auto lut_name = cell->attributes.at(IdString{"\\SB_LUT4.name"}, Const(NEW_ID.str())).decode_string();
126126
auto lut = module->addCell(lut_name, ID($lut));
127127
lut->setParam(ID::WIDTH, 4);
128128
lut->setParam(ID::LUT, cell->getParam(ID::LUT));
@@ -138,7 +138,7 @@ struct Ice40WrapCarryPass : public Pass {
138138
lut->attributes[a.first.c_str() + strlen("\\SB_LUT4.")] = a.second;
139139
else if (a.first == ID::src)
140140
src = a.second;
141-
else if (a.first.in(ID(SB_LUT4.name), ID::keep, ID::module_not_derived))
141+
else if (a.first.in(IdString{"\\SB_LUT4.name"}, ID::keep, ID::module_not_derived))
142142
continue;
143143
else
144144
log_abort();

0 commit comments

Comments
 (0)