Hello, In discussion of proposed fix for PR 44281 Michael said: [ https://gcc.gnu.org/ml/gcc-patches/2016-02/msg01963.html ] > [...] What I mean to say is, the following is currently proper use of > global reg vars: > > ---- > register uint64_t ugh __asm__("rbx"); //r11, whatever > void write_into_ugh (void) > { > asm volatile ("mov 1, %%rbx" :::); > assert (ugh == 1); > } > ---- > > %rbx would have to be implicitly used/clobbered by the asm. [...]
I am skeptical. It is not documented and it's not hard to come up with examples where optimizations break this sort of usage, e.g.: register int r asm("ebx"); int f(int x, int y) { int t = x/y/r; asm("#asm xor %ebx, %ebx"); return t-x; } This produces: f: #APP #asm xor %ebx, %ebx #NO_APP movl %edi, %eax cltd idivl %esi cltd idivl %ebx subl %edi, %eax ret i.e. assembly obviously divides by zero. In this particular example cprop_hardreg makes the offending propagation. In general it is impossible to make GCC "think" that asms may access arbitrary global register variables by only patching DF. There's GIMPLE, and on RTL there are other scanners beside DF (in fact PR 79985 that I intend to close this way is due to sched-deps having other ideas than DF). So this never worked anywhere near reliably and we should simply adjust the documentation to say that asms must use constraints to say how they are accessing global reg vars. The ad-hoc dependency injection in DF can then go. Patch 1 implements doc/extend.texi changes to reflect the status quo. I hope it can go in now. Patch 2 removes df-scan handling. It is for stage 1. Alexander Monakov (2): extend.texi: update Global Register Variables section df-scan: remove ad-hoc handling of global regs in asms gcc/df-scan.c | 11 ----------- gcc/doc/extend.texi | 29 +++++++++++++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) -- 2.13.3