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
11931193 type = &int_type;
11941194 #endif
11951195 size = type_size(type, &align);
1196− if ((p->r2 & VT_VALMASK) < VT_CONST) {
1197− size *= 2;
1198− align *= 2;
1199− }
12001196 l=get_temp_local_var(size,align);
12011197 sv.type.t = type->t;
12021198 sv.r = VT_LOCAL | VT_LVAL;
@@ -1208,8 +1204,11 @@ ST_FUNC void save_reg_upstack(int r, int n) · 5 unmodified lines
12081204 o(0xd8dd); /* fstp %st(0) */
12091205 }
12101206 #endif
1211− /* special long long case */
1212− if ((p->r2 & VT_VALMASK) < VT_CONST) {
1207+ /* special long long case. Ideally r2 would always
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) {
12131212 sv.c.i += PTR_SIZE;
12141213 store(p->r2, &sv);
12151214 }

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