[RS6000] PR88614, output_operand: invalid %z value

Programming / Compilers / GCC - amodra [138bc75d-0d04-0410-961f-82ee72b054a4] - 22 January 2019 02:29 EST

The direct cause of this PR is the fact that tls_gdld_nomark didn't handle indirect calls. Also, most indirect calls were being optimised back to direct calls anyway, due to tls_gdld_nomark not checking any of the parallel elements except the first (plus the extra element that distinguishes this call from normal calls). There were other unwanted substitutions too.

So this patch attacks the problem of handling special calls in a different way. Rather than adding another element to the call insn parallel to distinguish -mno-tls-markers __tls_get_addr calls from any other calls, we now inspect the second CALL arg. Each call_value_nonlocal and call_value_indirect insn now checks for the tlsgd/ld unspecs when !TARGET_TLS_MARKERS and emits the arg setup insns. I disallow the local call patterns since we'll only see local calls to __tls_get_addr in testcases, and it doesn't seem a good idea to complicate the patterns just for a minor optimisation. Sibling call insns aren't used for libcalls, so none of these insns need to change.

The patch also fixes a minor problem with -mno-tls-markers __tls_get_addr calls causing a "li 3,0" instruction to be emitted prior to the arg setup instructions, due to using a libcall with one arg. That isn't correct when the call insn itself sets up its arg. Also, I've tidied the V4 secure-plt calls, generating them in rs6000_call_sysv rather than by splitting in rs6000.md. The CALL_INSN_FUNCTION_USAGE added in edit_tls_call_insn is no longer needed (since git commit 0a4b5c66df9).

On the subject of unwanted substitutions, I also saw a _GLOBAL_OFFSET_TABLE_ symbol_ref being substituted for the GOT reg, resulting in code like "addi 3,_GLOBAL_OFFSET_TABLE_,tls_ld@got@tlsld". Fixed by the unspec_tls change.

PR target/88614
- config/rs6000/predicates.md (unspec_tls): Ensure GOT reg stays a reg. Allow a const_int.
- config/rs6000/rs6000-protos.h (rs6000_output_tlsargs): Declare.
- config/rs6000/rs6000.h (IS_V4_FP_ARGS): Define. (IS_NOMARK_TLSGETADDR): Define.
- config/rs6000/rs6000.c (edit_tls_call_insn): Delete. (rs6000_output_tlsargs): New function. (rs6000_legitimize_tls_address): Don't say a !TARGET_TLS_MARKERS __tls_get_addr call takes an arg. (rs6000_call_sysv): Generate sysv4 secure plt call pattern here..
- config/rs6000/rs6000.md (call_nonlocal_sysv): ..rather than here, delete split.. (call_value_nonlocal_sysv): ..or here, delete split. (tls_gdld_nomark): Delete. (call_value_indirect_nonlocal_sysv): Use unspec_tls as operand2 predicate. Call rs6000_output_tlsargs. Adjust length to suit. (call_value_nonlocal_sysv): Likewise. (call_value_nonlocal_sysv_secure): Likewise. (call_value_nonlocal_aix): Likewise. (call_value_indirect_aix): Likewise. (call_value_indirect_elfv2): Likewise. (call_value_local32, call_value_local64): Disable for no-mark tls. (call_value_local_aix): Likewise.

4a1e2ff6733 [RS6000] PR88614, output_operand: invalid %z value
gcc/ChangeLog | 27 +++++
gcc/config/rs6000/predicates.md | 13 ++-
gcc/config/rs6000/rs6000-protos.h | 1 +
gcc/config/rs6000/rs6000.c | 107 ++++++++++----------
gcc/config/rs6000/rs6000.h | 10 ++
gcc/config/rs6000/rs6000.md | 204 ++++++++++++++++++--------------------
6 files changed, 201 insertions(+), 161 deletions(-)

Upstream: gcc.gnu.org

  • Share