Skip to content

Commit

Permalink
Merge pull request ferrandi#123 from ferrandi/fix/memory_aliasing
Browse files Browse the repository at this point in the history
Fix/memory aliasing
  • Loading branch information
gggg100 authored Feb 23, 2023
2 parents 009cee9 + 5e769ac commit 49f79fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
18 changes: 8 additions & 10 deletions src/HLS/memory/mem_dominator_allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,14 @@ DesignFlowStep_Status mem_dominator_allocation::InternalExec()
{
const auto type_node = tree_helper::CGetType(TM->CGetTreeReindex(var));
const auto is_a_struct_union =
(tree_helper::IsStructType(type_node) && !tree_helper::IsArrayType(type_node)) ||
(tree_helper::IsUnionType(type_node) && !tree_helper::IsArrayType(type_node)) ||
((tree_helper::IsStructType(type_node) || tree_helper::IsUnionType(type_node)) &&
!tree_helper::IsArrayEquivType(type_node)) ||
tree_helper::IsComplexType(type_node);
const auto elmt_bitsize = tree_helper::AccessedMaximumBitsize(type_node, 1);
const auto mim_elmt_bitsize = tree_helper::AccessedMinimunBitsize(type_node, elmt_bitsize);
auto elts_size = elmt_bitsize;
if(tree_helper::IsArrayEquivType(type_node))
{
elts_size = tree_helper::GetArrayElementSize(type_node);
}
const auto min_elmt_bitsize = tree_helper::AccessedMinimunBitsize(type_node, elmt_bitsize);
const auto elts_size = tree_helper::IsArrayEquivType(type_node) ?
tree_helper::GetArrayElementSize(type_node) :
elmt_bitsize;
if(unaligned_access_p)
{
if(assume_aligned_access_p)
Expand All @@ -779,7 +777,7 @@ DesignFlowStep_Status mem_dominator_allocation::InternalExec()
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Variable " + STR(var) + " not sds because unaligned_access option specified");
}
else if(mim_elmt_bitsize != elmt_bitsize || is_a_struct_union || elts_size != elmt_bitsize)
else if(min_elmt_bitsize != elmt_bitsize || is_a_struct_union || elts_size != elmt_bitsize)
{
if(assume_aligned_access_p)
{
Expand All @@ -790,7 +788,7 @@ DesignFlowStep_Status mem_dominator_allocation::InternalExec()
HLSMgr->Rmem->set_sds_var(var, false);
INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level,
"---Variable " + STR(var) + " not sds " + STR(elmt_bitsize) + " vs " +
STR(mim_elmt_bitsize) + " vs " + STR(elts_size));
STR(min_elmt_bitsize) + " vs " + STR(elts_size));
}
else if(value_bitsize != elmt_bitsize)
{
Expand Down
2 changes: 1 addition & 1 deletion src/HLS/simulation/CTestbenchExecution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ DesignFlowStep_Status CTestbenchExecution::Exec()
new CompilerWrapper(parameters, parameters->getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler),
CompilerWrapper_OptimizationSet::O2));

std::string compiler_flags = "-fwrapv -flax-vector-conversions -msse2 -mfpmath=sse "
std::string compiler_flags = "-fwrapv -flax-vector-conversions -msse2 -mfpmath=sse -fno-strict-aliasing "
"-D'__builtin_bambu_time_start()=' -D'__builtin_bambu_time_stop()=' -D__BAMBU_SIM__ ";
if(!CompilerWrapper::isClangCheck(parameters->getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler)))
{
Expand Down
5 changes: 3 additions & 2 deletions src/HLS/simulation/testbench_values_c_generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ DesignFlowStep_Status TestbenchValuesCGeneration::Exec()
const CompilerWrapperConstRef compiler_wrapper(
new CompilerWrapper(parameters, parameters->getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler),
CompilerWrapper_OptimizationSet::O2));
std::string compiler_flags = "-fwrapv -ffloat-store -flax-vector-conversions -msse2 -mfpmath=sse "
"-D'__builtin_bambu_time_start()=' -D'__builtin_bambu_time_stop()=' -D__BAMBU_SIM__ ";
std::string compiler_flags =
"-fwrapv -ffloat-store -flax-vector-conversions -msse2 -mfpmath=sse -fno-strict-aliasing "
"-D'__builtin_bambu_time_start()=' -D'__builtin_bambu_time_stop()=' -D__BAMBU_SIM__ ";
if(!parameters->isOption(OPT_input_format) ||
parameters->getOption<Parameters_FileFormat>(OPT_input_format) == Parameters_FileFormat::FF_C ||
parameters->isOption(OPT_pretty_print))
Expand Down

0 comments on commit 49f79fb

Please sign in to comment.