public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "clyon at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/94445] New: gcc.target/arm/cmse/cmse-15.c fails for cortex-m33
Date: Wed, 01 Apr 2020 15:55:51 +0000	[thread overview]
Message-ID: <bug-94445-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94445

            Bug ID: 94445
           Summary: gcc.target/arm/cmse/cmse-15.c fails for cortex-m33
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: clyon at gcc dot gnu.org
  Target Milestone: ---

I've noticed that when GCC is configured --target arm-none-abi
--with-mode=thumb --with-cpu=cortex-m33, the cmse-15.c test fails:

FAIL: gcc.target/arm/cmse/cmse-15.c   -O2   scan-assembler-times
bl\\s+__gnu_cmse_nonsecure_call 6
FAIL: gcc.target/arm/cmse/cmse-15.c   -O3 -g   scan-assembler-times
bl\\s+__gnu_cmse_nonsecure_call 6
FAIL: gcc.target/arm/cmse/cmse-15.c   -Os   scan-assembler-times
bl\\s+__gnu_cmse_nonsecure_call 6


I've looked at the -O2 case, where 8 calls to __gnu_cmse_nonsecure_call instead
of the expected 6.

The testcase can then be reduced to:
=====================================================
typedef int __attribute__ ((cmse_nonsecure_call)) ns_foo_t (void);
typedef int s_bar_t (void);

typedef int (*s_bar_ptr) (void);

int nonsecure0 (ns_foo_t * ns_foo_p)
{
  return ns_foo_p ();
}
int secure0 (s_bar_t * s_bar_p)
{
  return s_bar_p ();
}
int secure2 (s_bar_ptr s_bar_p)
{
  return s_bar_p ();
}
=====================================================

secure0 and secure2 make use of __gnu_cmse_nonsecure_call instead of doing a
normal call.

If I comment out nonsecure0(), then the test passes (only "bx r0" is generated
for secure0/secure2).


With nonsecure0() un-commented as above, I've looked at
arm_function_ok_for_sibcall() which is called 3 times.

The first time (for nonsecure0):
 <call_expr 0x7facbe3ac630
[...]
    fn <ssa_name 0x7facbe586318
        type <pointer_type 0x7facbe670888 type <function_type 0x7facbe670498
ns_foo_t>
            public unsigned SI size <integer_cst 0x7facbe57bfd8 32> unit-size
<integer_cst 0x7facbe58e000 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7facbe670930>
        visited var <parm_decl 0x7facbe39b180 ns_foo_p>
        def_stmt GIMPLE_NOP
        version:2
        ptr-info 0x7facbe39c300>


The next two times (for secure0/secure2):
 <call_expr 0x7facbe3acb10
[...]
    fn <nop_expr 0x7facbe3b34a0
        type <pointer_type 0x7facbe670888 type <function_type 0x7facbe670498
ns_foo_t>
            public unsigned SI size <integer_cst 0x7facbe57bfd8 32> unit-size
<integer_cst 0x7facbe58e000 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7facbe670930>

        arg:0 <ssa_name 0x7facbe586900 type <pointer_type 0x7facbe670b28>
            visited var <parm_decl 0x7facbe39b200 s_bar_p>
            def_stmt GIMPLE_NOP
            version:2
            ptr-info 0x7facbe3b5be8>>


 <call_expr 0x7facbe3ac060
[...]
    fn <nop_expr 0x7facbe3ba800
        type <pointer_type 0x7facbe670888 type <function_type 0x7facbe670498
ns_foo_t>
            public unsigned SI size <integer_cst 0x7facbe57bfd8 32> unit-size
<integer_cst 0x7facbe58e000 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7facbe670930>

        arg:0 <ssa_name 0x7facbe586af8 type <pointer_type 0x7facbe6707e0
s_bar_ptr>
            visited var <parm_decl 0x7facbe39b280 s_bar_p>
            def_stmt GIMPLE_NOP
            version:2
            ptr-info 0x7facbe3b8b28>>


So in the last two cases, the function being called has an incorrect 'ns_foo_t'
type.

The fact that commenting out nonsecure0 makes the test pass makes me think that
some global state is modified when handling the  cmse_nonsecure_call attribute,
but I couldn't find such a problem in arm_handle_cmse_nonsecure_call().


I haven't yet found where that function type is attached to the 'fn' node,
maybe that's where the problem is.

I've also noticed that in the first case 'fn' is an ssa_name, while in the two
other ones, it is a nop_expr.



I've been investigating this for quite some time, so any clue is appreciated.

             reply	other threads:[~2020-04-01 15:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01 15:55 clyon at gcc dot gnu.org [this message]
2020-04-02  9:58 ` [Bug target/94445] " avieira at gcc dot gnu.org
2020-04-02 10:13 ` avieira at gcc dot gnu.org
2020-04-02 11:12 ` clyon at gcc dot gnu.org
2020-04-02 11:42 ` avieira at gcc dot gnu.org
2020-04-02 11:43 ` avieira at gcc dot gnu.org
2020-04-02 12:33 ` avieira at gcc dot gnu.org
2020-04-02 14:03 ` [Bug ipa/94445] " marxin at gcc dot gnu.org
2020-04-03  7:05 ` cvs-commit at gcc dot gnu.org
2020-04-03  7:07 ` marxin at gcc dot gnu.org
2020-04-03 10:34 ` cvs-commit at gcc dot gnu.org
2020-04-03 10:37 ` cvs-commit at gcc dot gnu.org
2020-04-03 10:39 ` marxin at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94445-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).