This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

variable-arrays problem

I'm looking at a problem in code similar to the following:

int y;
{ int a[f()];
y = a[0];
...reference to y...

The scheduler can move the load of a[0] across the code that
pops a[] from the stack; there is no dependency telling it
not to do that. Areas below the stack pointer are subject
to random clobbering by context switches on many targets, so
this is not a good thing. RTL for ppc below; x86 has the
same basic problem. Note there's no dependency, direct or
indirect, between 117 and 120. I'm not sure how to fix this.
Will adding a clobber(MEM(a)) at the end of the block suffice?

; r29 was set equal to &a[0] much earlier in the block...

; load a[0]
(insn 117 113 119 (set (reg/v:SI 3 r3 [116])
(mem/j:SI (reg/f:SI 29 r29 [134]) [0 a+0 S4 A32])) 311 {*movsi_internal\
1} (insn_list 56 (insn_list:REG_DEP_ANTI 113 (nil)))
(expr_list:REG_DEAD (reg/f:SI 29 r29 [134])

; load previous frame pointer from current stack bottom
; (part of ppc calling convention, ymmv, and not really
; relevant to the problem)
(insn:TI 119 117 120 (set (reg:SI 0 r0 [152])
(mem:SI (reg/f:SI 1 r1) [0 S4 A8])) 311 {*movsi_internal1} (insn_list:R\
EG_DEP_OUTPUT 87 (insn_list 89 (insn_list:REG_DEP_ANTI 113 (nil))))

; restore old stack bottom
(insn 120 119 121 (set (reg/f:SI 1 r1)
(reg/f:SI 28 r28 [117])) 311 {*movsi_internal1} (insn_list:REG_DEP_ANTI\
118 (insn_list:REG_DEP_ANTI 112 (insn_list:REG_DEP_ANTI 113 (insn_list:REG_DEP\
_ANTI 119 (insn_list:REG_DEP_OUTPUT 89 (insn_list 14 (nil)))))))
(expr_list:REG_DEAD (reg/f:SI 28 r28 [117])

; store previous frame pointer into new stack bottom
(insn:TI 121 120 174 (set (mem:SI (reg/f:SI 1 r1) [0 S4 A8])
(reg:SI 0 r0 [152])) 311 {*movsi_internal1} (insn_list 120 (insn_list:R\
EG_DEP_ANTI 113 (insn_list 119 (insn_list:REG_DEP_ANTI 117 (nil)))))
(expr_list:REG_DEAD (reg:SI 0 r0 [152])

(note 174 121 132 0xe61180 NOTE_INSN_BLOCK_END)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]