Hi all, Could a gatekeeper review the attached patch for bug 826, which is an output difference failure in accessing union member for the attached test case?
Bug description: ---------------- When the test case is compiled with the following command, $ opencc name.c the execution fails as follows. $ ./a.out failed As shown below, 'function' just returns the dereferenced value of the passed pointer to a structure. struct mystruct { char aa[32]; }; struct mystruct function( struct mystruct *p) { return *p; } However, a problem occurs if the addresses of the passed function argument and the structure variable being defined by the function call overlap, because the fix for revision 3659 removes a copy into the intermediate buffer. Without this intermediate buffer, in the attached test case, the content of my_uni.un1.st1(function argument) is overwritten when 'function' is called to define my_uni.un2.st2. This is similar to a case where a call to memcpy(&my_uni.un2.st2, &my_uni.un1.st1, sizeof(struct mystruct) has two overlapping addresses. struct container1 { struct mystruct st1; int bi; }; struct container2 { int ci; struct mystruct st2; }; union myunion { struct container1 un1; struct container2 un2; }; my_uni.un2.st2 = function(&my_uni.un1.st1); Before revision 3659, the caller reserved an intermediate space on stack and passed the address as the first 'hidden' argument together with the actual argument. Then, the callee copies the return value (the content of my_uni.un1.st1 in the example) to this intermediate buffer and then the caller copies the intermediate buffer to the variable being defined (my_uni.un2.st2 in the example). The fix for revision 3659 removes this intermediate buffer by passing the address of the variable being defined (my_uni.un2.st2 in the example) directly as the hidden first argument. This is a nice optimization but problem occurs if the function reads data from the variable being defined as in the above example. This optimization of removing the intermediate buffer can be done if the variable being defined is a local variable and its address is not taken. However, this couldn't be done in the current implementation location, which is 'wgen', without adding another pass through the input programs, because the 'address taken' information is not complete at that point. Patch: ------ The fix is to partially undo the change for revision 3659. The change for revision 3659 includes other fix in addition to the one for removing 'structure copies'. This fix undoes only the part for optimization of removing structure copies. -- yongchong
826.patch
Description: Binary data
------------------------------------------------------------------------------ Using storage to extend the benefits of virtualization and iSCSI Virtualization increases hardware utilization and delivers a new level of agility. Learn what those decisions are and how to modernize your storage and backup environments for virtualization. http://www.accelacomm.com/jaw/sfnl/114/51434361/
_______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel