aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-10-03 05:34:01 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:12 +0100
commit0bca6cab06405ede5343bc22f8571b1a88aa8c22 (patch)
tree08df6f6336ce1db7e0d4c282195d1967e3e5cb73
parentad723a419fd956d984a0956713566453ba8f6a12 (diff)
downloadtinycc-0bca6cab06405ede5343bc22f8571b1a88aa8c22.tar.gz
tinycc-0bca6cab06405ede5343bc22f8571b1a88aa8c22.tar.bz2
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.
-rw-r--r--i386-asm.c2
-rw-r--r--tests/tcctest.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/i386-asm.c b/i386-asm.c
index 336ef1b..1d1ebcf 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -1605,8 +1605,10 @@ ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands,
SValue sv;
sv = *op->vt;
sv.r = (sv.r & ~VT_VALMASK) | VT_LOCAL;
+ sv.type.t = VT_PTR;
load(out_reg, &sv);
+ sv = *op->vt;
sv.r = (sv.r & ~VT_VALMASK) | out_reg;
store(op->reg, &sv);
}
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 7bdffff..496de3a 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -2909,10 +2909,15 @@ char * get_asm_string (void)
unsigned int set;
+void fancy_copy (unsigned *in, unsigned *out)
+{
+ asm volatile ("" : "=r" (*out) : "0" (*in));
+}
+
void asm_test(void)
{
char buf[128];
- unsigned int val;
+ unsigned int val, val2;
struct struct123 s1;
struct struct1231 s2 = { (unsigned long)&s1 };
/* Hide the outer base_func, but check later that the inline
@@ -2979,6 +2984,9 @@ void asm_test(void)
printf("asmbool: failed\n");
#endif
printf("asmstr: %s\n", get_asm_string());
+ val = 43;
+ fancy_copy (&val, &val2);
+ printf ("fancycpy(%d)=%d\n", val, val2);
return;
label1:
goto label2;