Don't attempt bogus common subexpression elimination when loading structures on the stack.

Previously, the structure load would be treated as a common subexpression eligible for elimination, but the structure would always be treated as if it had a size of 4 bytes. If it did not, this would generally lead to a crash. (I'm also not sure if dependency analysis was being performed properly for these structures.)

The following program illustrates the problem:

#pragma optimize 17
struct mystruct { char x; } ms;
static void foo(struct mystruct pk) {}
int main(void)
{
    struct mystruct *p = &ms;
    foo(*p);
    foo(*p);
}
This commit is contained in:
Stephen Heumann 2017-07-19 00:12:07 -05:00
parent c46cf79c79
commit e242f03501
1 changed files with 2 additions and 0 deletions

View File

@ -2420,6 +2420,8 @@ var
end {else if}
else if opcode = pc_stk then
Block := true
else if opcode = pc_psh then
Block := true
else if opcode = pc_cnv then
if op^.q & $000F = ord(cgVoid) then
Block := true;