History

x86_64-asm: fix copy-out registers

If the destination is an indirect pointer access (which ends up as VT_LLOCAL) the intermediate pointer must be loaded as VT_PTR, not as whatever the pointed to type is.

Michael Matz committed 10 years ago

Commit 0bca6ca1 parent ad723a42 files · +11 −1Browse files

Unified · Split

2 files
  1. i386-asm.c +2 −0
  2. tests/tcctest.c +9 −1
i386-asm.c+2−0
@@ -1605,8 +1605,10 @@ ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, · 1604 unmodified lines
1605 SValue sv;1605 SValue sv;
1606 sv = *op->vt;1606 sv = *op->vt;
1607 sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;1607 sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
1608 sv.type.t = VT_PTR;
1608 load(out_reg, &sv);1609 load(out_reg, &sv);
1609 1610
1611 sv = *op->vt;
1610 sv.r = (sv.r & ~VT_VALMASK) | out_reg;1612 sv.r = (sv.r & ~VT_VALMASK) | out_reg;
1611 store(op->reg, &sv);1613 store(op->reg, &sv);
1612 }1614 }
tests/tcctest.c+9−1
@@ -2909,10 +2909,15 @@ char * get_asm_string (void) · 2908 unmodified lines
2909 2909
2910unsigned int set;2910unsigned int set;
2911 2911
2912void fancy_copy (unsigned *in, unsigned *out)
2913{
2914 asm volatile ("" : "=r" (*out) : "0" (*in));
2915}
2916
2912void asm_test(void)2917void asm_test(void)
2913{2918{
2914 char buf[128];2919 char buf[128];
2915 unsigned int val;2920 unsigned int val, val2;
2916 struct struct123 s1;2921 struct struct123 s1;
2917 struct struct1231 s2 = { (unsigned long)&s1 };2922 struct struct1231 s2 = { (unsigned long)&s1 };
2918 /* Hide the outer base_func, but check later that the inline2923 /* Hide the outer base_func, but check later that the inline
@@ -2979,6 +2984,9 @@ void asm_test(void) · 60 unmodified lines
2979 printf("asmbool: failed\n");2984 printf("asmbool: failed\n");
2980#endif2985#endif
2981 printf("asmstr: %s\n", get_asm_string());2986 printf("asmstr: %s\n", get_asm_string());
2987 val = 43;
2988 fancy_copy (&val, &val2);
2989 printf ("fancycpy(%d)=%d\n", val, val2);
2982 return;2990 return;
2983 label1:2991 label1:
2984 goto label2;2992 goto label2;

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