History

Fix type/r/r2 confusion differently

on i386 111_conversion.c breaks when save_reg_upstack isn't careful about r2 and type mismatches. The bcheck patches fixed this by enlarging the stack slot beyond the natural type, this variant simply avoids saving the second register is the type indicates that it isn't needed. Adds also a comment how this should ideally work, namely that type and r/r2 entries in the vstack are consistent. In the 111_conversion testcase it's specifically gen_cast via gen_cvt_ftoi that breaks this, but there more general code broken as well, so that would deserve a careful fixup based on some additional asserts.

Michael Matz committed 6 years ago

Commit fb22e0c1 parent ac2a61d1 file · +5 −6Browse files

Unified · Split

tccgen.c+5−6
@@ -1193,10 +1193,6 @@ ST_FUNC void save_reg_upstack(int r, int n) · 1192 unmodified lines
1193 type = &int_type;1193 type = &int_type;
1194#endif1194#endif
1195 size = type_size(type, &align);1195 size = type_size(type, &align);
1196 if ((p->r2 & VT_VALMASK) < VT_CONST) {
1197 size *= 2;
1198 align *= 2;
1199 }
1200 l=get_temp_local_var(size,align);1196 l=get_temp_local_var(size,align);
1201 sv.type.t = type->t;1197 sv.type.t = type->t;
1202 sv.r = VT_LOCAL | VT_LVAL;1198 sv.r = VT_LOCAL | VT_LVAL;
@@ -1208,8 +1204,11 @@ ST_FUNC void save_reg_upstack(int r, int n) · 5 unmodified lines
1208 o(0xd8dd); /* fstp %st(0) */1204 o(0xd8dd); /* fstp %st(0) */
1209 }1205 }
1210#endif1206#endif
1211 /* special long long case */1207 /* special long long case. Ideally r2 would always
1212 if ((p->r2 & VT_VALMASK) < VT_CONST) {1208 be VT_CONST is the type is smaller than a double-word
1209 type. Not all routines (e.g. gen_cast with _ftoi) are
1210 careful to clear r2, though. */
1211 if ((p->r2 & VT_VALMASK) < VT_CONST && size > PTR_SIZE) {
1213 sv.c.i += PTR_SIZE;1212 sv.c.i += PTR_SIZE;
1214 store(p->r2, &sv);1213 store(p->r2, &sv);
1215 }1214 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t