>From 0e824d0ab59dc42b9c4252e2b5f9c6ac5acdfc0f Mon Sep 17 00:00:00 2001 From: Balazs Kezes Date: Mon, 22 Aug 2016 22:21:35 +0100 Subject: [PATCH 2/2] Fix long long dereference during argument passing on ARMv6 For some reason the code spills the register to the stack. copy_params in arm-gen.c doesn't expect this so bad code is generated. It's not entirely clear why the saving part is necessary. It was added in commit 59c35638 with the comment "fixed long long code gen bug" with no further clarification. Given that tcctest.c passes without this, maybe it's no longer needed? Let's remove it. Also add a new testcase just for this. After I've managed to make the tests compile on a raspberry pi, I get the following diff without this patch: --- test.ref 2016-08-22 22:12:43.380000000 +0100 +++ test.out3 2016-08-22 22:12:49.990000000 +0100 @@ -499,7 +499,7 @@ 2 1 0 1 0 4886718345 -shift: 9 9 9312 +shift: 291 291 291 shiftc: 36 36 2328 shiftc: 0 0 9998683865088 manyarg_test: More discussion on this thread: https://lists.nongnu.org/archive/html/tinycc-devel/2016-08/msg00004.html --- tccgen.c | 5 ----- tests/tcctest.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tccgen.c b/tccgen.c index 9ebd80a..b83d319 100644 --- a/tccgen.c +++ b/tccgen.c @@ -854,11 +854,6 @@ ST_FUNC int gv(int rc) #endif if (r >= VT_CONST || /* XXX: test to VT_CONST incorrect ? */ (vtop->r & VT_LVAL)) { - /* We do not want to modifier the long long - pointer here, so the safest (and less - efficient) is to save all the other registers - in the stack. XXX: totally inefficient. */ - save_regs(1); /* load from memory */ vtop->type.t = load_type; load(r, vtop); diff --git a/tests/tcctest.c b/tests/tcctest.c index 6ec23a1..9a4d0ef 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -2010,6 +2010,11 @@ void longlong_test(void) printf("%d %d %d %d\n", a > b, a < b, a >= b, a <= b); printf(LONG_LONG_FORMAT "\n", 0x123456789LLU); + + /* long long pointer deref in argument passing test */ + a = 0x123; + long long *p = &a; + llshift(*p, 5); } void manyarg_test(void) -- 2.9.3