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
16051605 SValue sv;
16061606 sv = *op->vt;
16071607 sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
1608+ sv.type.t = VT_PTR;
16081609 load(out_reg, &sv);
16091610
1611+ sv = *op->vt;
16101612 sv.r = (sv.r & ~VT_VALMASK) | out_reg;
16111613 store(op->reg, &sv);
16121614 }
tests/tcctest.c+9−1
@@ -2909,10 +2909,15 @@ char * get_asm_string (void) · 2908 unmodified lines
29092909
29102910 unsigned int set;
29112911
2912+void fancy_copy (unsigned *in, unsigned *out)
2913+{
2914+ asm volatile ("" : "=r" (*out) : "0" (*in));
2915+}
2916+
29122917 void asm_test(void)
29132918 {
29142919 char buf[128];
2915− unsigned int val;
2920+ unsigned int val, val2;
29162921 struct struct123 s1;
29172922 struct struct1231 s2 = { (unsigned long)&s1 };
29182923 /* Hide the outer base_func, but check later that the inline
@@ -2979,6 +2984,9 @@ void asm_test(void) · 60 unmodified lines
29792984 printf("asmbool: failed\n");
29802985 #endif
29812986 printf("asmstr: %s\n", get_asm_string());
2987+ val = 43;
2988+ fancy_copy (&val, &val2);
2989+ printf ("fancycpy(%d)=%d\n", val, val2);
29822990 return;
29832991 label1:
29842992 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