]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Make the test for available cached PCS data more robust.
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 14 Dec 2025 11:24:40 +0000 (11:24 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 16 Dec 2025 15:40:38 +0000 (15:40 +0000)
When we are emitting MI thunks, it can be the case that the
target function of the thunk has already been compiled, and
considered complete, with at least part of the relevant data
freed.

The deal with this, we amend the test for the availability
of the cached PCS value to check for the presence of both the
cfun and the machine content.

Since these functions are in a hot code path, use
gcc_checking_assert().

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_function_abi): Use checking assert.
(aarch64_fndecl_abi): Test for the availability of the
machine content before trying to look up the cached PCS.
Use a checking assert.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/config/aarch64/aarch64.cc

index 4c708f265ef6fa1667eac7a7ee3d70a81a93161a..8b7253b11fef1b7e0cd647251436da19ee177f0d 100644 (file)
@@ -742,7 +742,7 @@ aarch64_merge_string_arguments (tree args, tree old_attr,
 static arm_pcs
 aarch64_function_abi (struct function *fun)
 {
-  gcc_assert (fun);
+  gcc_checking_assert (fun);
   if (fun->machine->pcs == ARM_PCS_UNKNOWN)
     fun->machine->pcs = arm_pcs (fndecl_abi (fun->decl).id ());
 
@@ -755,9 +755,9 @@ aarch64_function_abi (struct function *fun)
 static arm_pcs
 aarch64_fndecl_abi (tree fn)
 {
-  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
+  gcc_checking_assert (TREE_CODE (fn) == FUNCTION_DECL);
   struct function *fun = DECL_STRUCT_FUNCTION (fn);
-  if (!fun)
+  if (!fun || !fun->machine)
     return arm_pcs (fndecl_abi (fn).id ());
 
   return aarch64_function_abi (fun);