Skip to content

Commit de7ac0d

Browse files
avoid calling vtr::strdup() for t_logical_block_type.name and call c_str() when needed
1 parent f0e8378 commit de7ac0d

14 files changed

+24
-24
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
535535

536536
t_logical_block_type get_empty_logical_type(const char* name /*=EMPTY_BLOCK_NAME*/) {
537537
t_logical_block_type type;
538-
type.name = vtr::strdup(name);
538+
type.name = name;
539539
type.pb_type = nullptr;
540540

541541
return type;

libs/libarchfpga/src/physical_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool t_physical_tile_type::is_empty() const {
141141
*/
142142

143143
bool t_logical_block_type::is_empty() const {
144-
return std::string(name) == std::string(EMPTY_BLOCK_NAME);
144+
return name == std::string(EMPTY_BLOCK_NAME);
145145
}
146146

147147
/**

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,10 @@ struct ArchReader {
10761076
continue;
10771077

10781078
// Check for duplicates
1079-
auto is_duplicate = [name](t_logical_block_type l) { return std::string(l.name) == name; };
1079+
auto is_duplicate = [name](const t_logical_block_type& l)-> bool { return l.name == name; };
10801080
VTR_ASSERT(std::find_if(ltypes_.begin(), ltypes_.end(), is_duplicate) == ltypes_.end());
10811081

1082-
ltype.name = vtr::strdup(name.c_str());
1082+
ltype.name = name;
10831083
ltype.index = ++index;
10841084

10851085
auto pb_type = new t_pb_type;
@@ -2089,7 +2089,7 @@ struct ArchReader {
20892089
// Create constant complex block
20902090
t_logical_block_type block;
20912091

2092-
block.name = vtr::strdup(const_block_.c_str());
2092+
block.name = (const_block_;
20932093
block.index = ltypes_.size();
20942094

20952095
auto pb_type = new t_pb_type;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3613,7 +3613,7 @@ static void ProcessComplexBlocks(pugi::xml_node Node,
36133613

36143614
/* Load type name */
36153615
auto Prop = get_attribute(CurBlockType, "name", loc_data).value();
3616-
LogicalBlockType.name = vtr::strdup(Prop);
3616+
LogicalBlockType.name = Prop;
36173617

36183618
auto [_, success] = pb_type_descriptors.insert(LogicalBlockType.name);
36193619
if (!success) {

vpr/src/pack/cluster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
250250
VTR_LOGV(verbosity > 2,
251251
"Complex block %d: '%s' (%s) ", total_clb_num,
252252
cluster_legalizer.get_cluster_pb(legalization_cluster_id)->name,
253-
cluster_legalizer.get_cluster_type(legalization_cluster_id)->name);
253+
cluster_legalizer.get_cluster_type(legalization_cluster_id)->name.c_str());
254254
VTR_LOGV(verbosity > 2, ".");
255255
//Progress dot for seed-block
256256
fflush(stdout);

vpr/src/pack/cluster_router.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ bool try_intra_lb_route(t_lb_router_data* router_data,
507507
--inet;
508508
auto& atom_ctx = g_vpr_ctx.atom();
509509
VTR_LOGV(verbosity > 3, "Net '%s' is impossible to route within proposed %s cluster\n",
510-
atom_ctx.nlist.net_name(lb_nets[inet].atom_net_id).c_str(), router_data->lb_type->name);
510+
atom_ctx.nlist.net_name(lb_nets[inet].atom_net_id).c_str(), router_data->lb_type->name.c_str());
511511
is_routed = false;
512512
}
513513
router_data->pres_con_fac *= router_data->params.pres_fac_mult;

vpr/src/pack/cluster_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,13 +1061,13 @@ void start_new_cluster(ClusterLegalizer& cluster_legalizer,
10611061
}
10621062

10631063
if (success) {
1064-
VTR_LOGV(verbosity > 2, "\tPASSED_SEED: Block Type %s\n", type->name);
1064+
VTR_LOGV(verbosity > 2, "\tPASSED_SEED: Block Type %s\n", type->name.c_str());
10651065
// If clustering succeeds return the new_cluster_id and type.
10661066
legalization_cluster_id = new_cluster_id;
10671067
block_type = type;
10681068
break;
10691069
} else {
1070-
VTR_LOGV(verbosity > 2, "\tFAILED_SEED: Block Type %s\n", type->name);
1070+
VTR_LOGV(verbosity > 2, "\tFAILED_SEED: Block Type %s\n", type->name.c_str());
10711071
}
10721072
}
10731073

vpr/src/pack/constraints_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool floorplan_constraints_regions_overfull(const ClusterLegalizer& cluster_lega
4646
floorplanning_ctx.overfull_partition_regions.push_back(pr);
4747
VTR_LOG("\n\nA partition including the following regions has been assigned %d blocks of type %s, "
4848
"but only has %d tiles of that type\n",
49-
num_assigned_blocks, block_type.name, num_tiles);
49+
num_assigned_blocks, block_type.name.c_str(), num_tiles);
5050
for (const Region& reg : regions) {
5151
const vtr::Rect<int>& rect = reg.get_rect();
5252
const auto [layer_low, layer_high] = reg.get_layer_range();

vpr/src/pack/pack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ bool try_pack(t_packer_opts* packer_opts,
214214
resource_avail += ", ";
215215
}
216216

217-
resource_reqs += std::string(iter->first->name) + ": " + std::to_string(iter->second);
217+
resource_reqs += iter->first->name + ": " + std::to_string(iter->second);
218218

219219
int num_instances = 0;
220220
for (auto type : iter->first->equivalent_tiles)
221221
num_instances += grid.num_instances(type, -1);
222222

223-
resource_avail += std::string(iter->first->name) + ": " + std::to_string(num_instances);
223+
resource_avail += iter->first->name + ": " + std::to_string(num_instances);
224224
}
225225

226226
VPR_FATAL_ERROR(VPR_ERROR_OTHER, "Failed to find device which satisfies resource requirements required: %s (available %s)", resource_reqs.c_str(), resource_avail.c_str());
@@ -352,7 +352,7 @@ static bool try_size_device_grid(const t_arch& arch,
352352
if (util > 1.) {
353353
fits_on_device = false;
354354
}
355-
VTR_LOG("\tBlock Utilization: %.2f Type: %s\n", util, type.name);
355+
VTR_LOG("\tBlock Utilization: %.2f Type: %s\n", util, type.name.c_str());
356356
}
357357
VTR_LOG("\n");
358358

vpr/src/pack/pack_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void report_packing_pin_usage(std::ostream& os, const VprContext& ctx) {
6666
if (total_input_pins[type] != 0) {
6767
os << "\t\tHistogram:\n";
6868
auto input_histogram = build_histogram(inputs_used[type], 10, 0, total_input_pins[type]);
69-
for (auto line : format_histogram(input_histogram)) {
69+
for (const std::string& line : format_histogram(input_histogram)) {
7070
os << "\t\t" << line << "\n";
7171
}
7272
}

0 commit comments

Comments
 (0)