This avoids initializating "uninitialized" hardregs like SP.
2021-10-04 Richard Biener <rguenther@suse.de>
* gimplify.c (is_var_need_auto_init): DECL_HARD_REGISTER
variables are not to be initialized.
* gcc.dg/auto-init-hardreg-1.c: New testcase.
is_var_need_auto_init (tree decl)
{
if (auto_var_p (decl)
+ && (TREE_CODE (decl) != VAR_DECL
+ || !DECL_HARD_REGISTER (decl))
&& (flag_auto_var_init > AUTO_INIT_UNINITIALIZED)
&& (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl)))
&& !is_empty_type (TREE_TYPE (decl)))
--- /dev/null
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-ftrivial-auto-var-init=zero" } */
+
+int
+main ()
+{
+ register long *sp __asm__("sp");
+ return 0;
+}