From: 陳韋任 <che...@g2...> - 2015-03-06 03:05:57
|
Hi All, I once posted the question on sdcc-user [1], but I think I need more technical support here. ;-) Let me explain what I have observed first. When I enable #pragma stackauto, I see the local variables' stack offset different from time to time. For example, if function foobar has the following local variables: a, b, c, and d Then the stack offset of them might be: sp + 2, sp + 4, sp + 6, sp + 8 or sp + 2, sp + 6, sp + 4, sp + 8 Although the difference doesn't affect the correctness, it does change the binary checksum (we use checksum to do verification). The problem comes from redoStackOffsets [2], or more specifically, the "BTREE_STACK" macro. After reading the code, I think the root cause might be the following, 1. When BTREE_STACK is off, a linked list of stack variables is traversed and assigned the stack offset. The allocation order is same each time. 2. When BTREE_STACK is on, the allocation is done in btree_alloc_subtree [3], and a "set" of stack variables is traversed and assigned the stack offset. The order become inconsistent here. The set of pointers might be the culprit. Could I just change the VertexProperties of btree from std::pair<std::set<symbol *>, int> to std::pair<std::list<symbol *>, int> to make the allocation order to be consistent? Thanks. [1] http://comments.gmane.org/gmane.comp.compilers.sdcc.user/5145 [2] http://code.metager.de/source/xref/sdcc/sdcc/src/SDCCmem.c [3] http://code.metager.de/source/xref/sdcc/sdcc/src/SDCCbtree.cc -- Wei-Ren Chen (陳韋任) Homepage: http://people.cs.nctu.edu.tw/~chenwj |