On 11/19/20 8:34 PM, Maciej W. Rozycki wrote:
> The VAX ELF psABI does not permit the use of all hardware operand modes
> for PIC symbol references due to the need to use PC-relative addressing
> for symbols that end up local and the need to make references indirect
> symbols that end up global.
>
> Therefore symbols referred as immediates may only be used with the move
> and push address (MOVA and PUSHA) instructions and their PC-relative
> displacement address mode, as there is no genuine PC-relative immediate
> available that all the other instructions would have to use.
>
> Furthermore global symbol references must not have an offset applied,
> which has to be added with a separate instruction, because there is no
> support now for GOT entries for external `symbol+offset' references, so
> any indirect GOT references made by the static linker from the original
> direct symbol references must not have an addend applied. Consequently
> no addend is allowed even if a given external symbol turns out local,
> for whatever reason, at the static link time.
>
> Define the LEGITIMATE_PIC_OPERAND_P macro then, a corresponding function
> and predicate to exclude the relevant expressions as required, and then
> a constraint so that reloads are produced where needed, and use the new
> facilities in the machine description, folding corresponding duplicated
> patterns for local and external symbols together. Rewrite predicates to
> make use of the new function, rename them to match their sense and also
> remove ones no longer used.
>
> All this fixing an ICE like this:
>
> during RTL pass: postreload
> .../gcc/testsuite/gcc.c-torture/execute/20040709-2.c: In function 'testE':
> .../gcc/testsuite/gcc.c-torture/execute/20040709-2.c:89:1: internal compiler
> error: in reload_combine_note_use, at postreload.c:1559
> .../gcc/testsuite/gcc.c-torture/execute/20040709-2.c:96:65: note: in
> expansion of macro 'T'
> 0x10fe84cb reload_combine_note_use
> .../gcc/postreload.c:1559
> 0x10fe8857 reload_combine_note_use
> .../gcc/postreload.c:1621
> 0x10fe8303 reload_combine_note_use
> .../gcc/postreload.c:1517
> 0x10fe7c7b reload_combine
> .../gcc/postreload.c:1408
> 0x10fe3417 reload_cse_regs
> .../gcc/postreload.c:67
> 0x10feaf9f execute
> .../gcc/postreload.c:2358
>
> due to the presence of a pseudo register post-reload:
>
> (insn 435 228 229 13 (set (reg:SI 1 %r1)
> (mem/c:SI (reg/f:SI 341) [25 sE+12 S4 A8]))
> ".../gcc/testsuite/gcc.c-torture/execute/20040709-2.c":96:65 12 {movsi_2}
> (nil))
>
> (due to the use of an offset `sE+12' symbol reference) and removing
> these regressions:
>
> FAIL: gcc.c-torture/execute/20040709-2.c -O2 (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-2.c -O2 (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-2.c -O3 -fomit-frame-pointer
> -funroll-loops -fpeel-loops -ftracer -finline-functions (internal compiler
> error)
> FAIL: gcc.c-torture/execute/20040709-2.c -O3 -fomit-frame-pointer
> -funroll-loops -fpeel-loops -ftracer -finline-functions (test for excess
> errors)
> FAIL: gcc.c-torture/execute/20040709-2.c -O3 -g (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-2.c -O3 -g (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-2.c -Os (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-2.c -Os (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-2.c -O2 -flto -fno-use-linker-plugin
> -flto-partition=none (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-2.c -O2 -flto -fno-use-linker-plugin
> -flto-partition=none (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-3.c -O2 (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-3.c -O2 (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-3.c -O3 -g (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-3.c -O3 -g (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-3.c -Os (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-3.c -Os (test for excess errors)
> FAIL: gcc.c-torture/execute/20040709-3.c -O2 -flto -fno-use-linker-plugin
> -flto-partition=none (internal compiler error)
> FAIL: gcc.c-torture/execute/20040709-3.c -O2 -flto -fno-use-linker-plugin
> -flto-partition=none (test for excess errors)
> FAIL: gcc.dg/torture/pr52028.c -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects (internal compiler error)
> FAIL: gcc.dg/torture/pr52028.c -O2 -flto -fuse-linker-plugin
> -fno-fat-lto-objects (test for excess errors)
>
> gcc/
> * config/vax/constraints.md (A): New constraint.
> * config/vax/predicates.md (external_symbolic_operand)
> (external_const_operand): Remove predicates.
> (local_symbolic_operand): Rename to...
> (pic_symbolic_operand): ... this, and rework.
> (external_memory_operand): Rename to...
> (non_pic_external_memory_operand): ... this, and rework.
> (illegal_blk_memory_operand, illegal_addsub_di_memory_operand):
> Update accordingly.
> * config/vax/vax-protos.h (vax_acceptable_pic_operand_p): New
> prototype.
> * config/vax/vax.c (vax_acceptable_pic_operand_p): New function.
> (vax_output_int_add): Update according to predicate rework.
> * config/vax/vax.h (LEGITIMATE_PIC_OPERAND_P): New macro.
> * config/vax/vax.md (pushlclsymreg, pushextsymreg): Fold
> together, and rename to...
> (*pushsymreg): ... this. Use the `pic_symbolic_operand'
> predicate and the `A' constraint for the displacement operand.
> (movlclsymreg, movextsymreg): Fold together, and rename to...
> (*movsymreg): ... this. Use the `pic_symbolic_operand'
> predicate and the `A' constraint for the displacement operand.
> (pushextsym, pushlclsym): Fold together, and rename to...
> (*pushsym): ... this. Use the `pic_symbolic_operand' predicate
> and the `A' constraint for the displacement operand.
> (movextsym, movlclsym): Fold together, and rename to...
> (*movsym): ... this. Use the `pic_symbolic_operand' predicate
> and the `A' constraint for the displacement operand.
OK
jeff