tfm_core_ns_ipc_request() in tfm_psa_api_client.c has an inline assembly block which calls SVC with the arguments inside a descriptor struct.
In GCC release the compiler optimizes the code (probably ignores the inline assembly code) and throws the part where the arguments are set inside the descriptor struct.
The result is that the descriptor is all zeroes and sent to the SVC via r0.
Eventually in the SVC handler tfm_psa_veneer_sanity_check() is called which returns TFM_ERROR_INVALID_PARAMETER (becasue desc_ptr->ns_caller is 0).