@@ -934,6 +934,10 @@ def introduce_ssa_variables(
934934
935935 Record addresses associated with a given variable to avoid assigning
936936 constants to variables that appear multiple times.
937+
938+ The ssanames, a map from locations to names, provide an alternative
939+ prefix for the newly introduced name. The default name is ssa_<reg>,
940+ where <reg> is the name of the register being assigned.
937941 """
938942
939943 for (reg , locs ) in rdeflocs .items ():
@@ -980,7 +984,9 @@ def introduce_stack_variables(
980984 tgttypsize = tgttyp .index (self .bytesize_calculator )
981985 if tgttypsize > 0 :
982986 arraysize = size // tgttypsize
983- if arraysize > 0 :
987+ if arraysize == 1 :
988+ vtype = tgttyp
989+ if arraysize > 1 :
984990 vtype = self .astree .mk_int_sized_array_type (
985991 tgttyp , arraysize )
986992 else :
@@ -989,8 +995,7 @@ def introduce_stack_variables(
989995 + "%s does not fit in stack frame; "
990996 + "adjusting stack buffer to size %d" ,
991997 str (offset ), tgttypsize )
992- vtype = self .astree .mk_int_sized_array_type (
993- tgttyp , 1 )
998+ vtype = tgttyp
994999
9951000 self .mk_stack_variable_lval (offset , vtype = vtype )
9961001
@@ -1080,6 +1085,17 @@ def mk_stack_variable_lval(
10801085 if varinfo .vtype is None :
10811086 return lval
10821087
1088+ if varinfo .vtype .is_compound :
1089+ structtyp = cast (AST .ASTTypComp , varinfo .vtype )
1090+ ckey = structtyp .compkey
1091+ compinfo = self .globalsymboltable .compinfo (ckey )
1092+ for (cfoff , fname ) in sorted (compinfo .field_offsets .items ()):
1093+ fieldoffset = self .mk_field_offset (fname , ckey )
1094+ fieldlval = self .astree .mk_vinfo_lval (
1095+ varinfo , offset = fieldoffset )
1096+ self .stack_variables [offset + cfoff ] = fieldlval
1097+ return lval
1098+
10831099 if varinfo .vtype .is_array :
10841100 arraytyp = cast (AST .ASTTypArray , varinfo .vtype )
10851101 eltyp = arraytyp .tgttyp
0 commit comments