The stack protector implementation hides symbols in a const unspec, which means
movdi/movsi patterns must always support const on symbol operands and
explicitly strip away the unspec. Do this for the recently added GOT
alternatives. Add a test to ensure stack-protector tests GOT accesses as well.
2021-11-05 Wilco Dijkstra <wdijkstr@arm.com>
PR target/103085
* config/aarch64/aarch64.c (aarch64_mov_operand_p): Strip the salt
first.
* config/aarch64/constraints.md: Support const in Usw.
gcc/testsuite/
PR target/103085
* gcc.target/aarch64/pr103085.c: New test
return aarch64_simd_valid_immediate (x, NULL);
}
+ /* Remove UNSPEC_SALT_ADDR before checking symbol reference. */
+ x = strip_salt (x);
+
/* GOT accesses are valid moves. */
if (SYMBOL_REF_P (x)
&& aarch64_classify_symbolic_expression (x) == SYMBOL_SMALL_GOT_4G)
return true;
- x = strip_salt (x);
if (SYMBOL_REF_P (x) && mode == DImode && CONSTANT_ADDRESS_P (x))
return true;
(match_test "aarch64_symbolic_address_p (op)")
(match_test "aarch64_mov_operand_p (op, GET_MODE (op))")))
+;; const is needed here to support UNSPEC_SALT_ADDR.
(define_constraint "Usw"
"@internal
A constraint that matches a small GOT access."
- (and (match_code "symbol_ref")
+ (and (match_code "const,symbol_ref")
(match_test "aarch64_classify_symbolic_expression (op)
== SYMBOL_SMALL_GOT_4G")))
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-protector-strong -fPIC" } */
+
+void g(int*);
+void
+f (int x)
+{
+ int arr[10];
+ g (arr);
+}
+