diff mbox

[2/2,MSP430] Fix issues handling .persistent attribute (PR 78818)

Message ID 6d51c0e4-3c0c-6d9b-78a0-241078c19a87@somniumtech.com
State New
Headers show

Commit Message

Jozef Lawrynowicz June 8, 2017, 3:50 p.m. UTC
On 30/05/2017 12:50, Nick Clifton wrote:
> When I applied this patch to the sources and ran the new test, I encountered
> an internal compiler error:
> 
>   msp430-elf/gcc/xgcc [...] pr78818-auto-warn.c [...]
>   [...]
>   gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c: In function 'main':
> 
>   gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c:10:3: internal compiler error: in get, at cgraph.h:403
> 
>    0xd30d3b symtab_node::get(tree_node const*)
> 	gcc/current/gcc/cgraph.h:400
> 
>    0xd30d3b decl_section_name(tree_node const*)
> 	gcc/current/gcc/tree.c:700
> 
>    0xd9ff22 msp430_data_attr
>                       gcc/current/gcc/config/msp430/msp430.c:1998
> 
> 
>   It seems that there is a problem with calling the DECL_SECTION_NAME macro on the
>   line just before your new code.  Are you able to reproduce this problem ?
> 

Hi Nick,

Apologies for the delay in replying.
I have reproduced this issue with current trunk and on the gcc-7-branch,
but it does not reproduce on the gcc-6-branch.

The ICE isn't caused by my patch but the pr78818-auto-warn.c test does
expose it.

I've attached an additional patch to fix the ICE (0001*). The ICE was
caused by a new gcc_checking_assert added in GCC7 that checks that
"symtab_node" has been called on a sane object. Added some additional
check in msp430.c:data_attr that prevent section names being looked up
on variables that can't have a section.

The 0002* patch has been updated as this also caused an ICE when running
the test case for the same reason as above, which was exposed when the
first ICE was fixed.

I have tested these patches on trunk this time (previous testing was
done on performed on gcc-6-branch only) and can confirm there are no
regressions and the new tests build successfully.

Ok for trunk and gcc-7-branch?

Thanks,
Jozef
From 8a41a45f2f771ae540b16ec007ded499a9ed5244 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Mon, 5 Jun 2017 18:07:22 +0000
Subject: [PATCH 1/3] MSP430: Check if a variable can have a section before
 checking for a section name

2017-06-XX	Jozef Lawrynowicz	<jozef.l@somniumtech.com>

	gcc/
	* config/msp430/msp430.c (msp430_data_attr): Check that it's possible
	for a variable to have a section before checking if the section has a
	name.
---
 gcc/config/msp430/msp430.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Nick Clifton June 13, 2017, 3:54 p.m. UTC | #1
Hi Jozef,

> Ok for trunk and gcc-7-branch?

Approved - please apply (to both).

Cheers
  Nick
Jozef Lawrynowicz June 13, 2017, 5:46 p.m. UTC | #2
On 13/06/2017 16:54, Nick Clifton wrote:
> Hi Jozef,
> 
>> Ok for trunk and gcc-7-branch?
> 
> Approved - please apply (to both).
> 
> Cheers
>    Nick
> 
> 

Sorry, didn't mention in that last post that I don't have write access,
could someone please apply this for me.

Thanks,
Jozef
Nick Clifton June 15, 2017, 1:39 p.m. UTC | #3
Hi Jozef,

> Sorry, didn't mention in that last post that I don't have write access,
> could someone please apply this for me.

Applied.  Sorry about the delay (again).

Cheers
  Nick
diff mbox

Patch

diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index dd53dea..cdd765b 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -1995,8 +1995,10 @@  msp430_data_attr (tree * node,
   if (TREE_CODE (* node) != VAR_DECL)
     message = "%qE attribute only applies to variables";
 
-  if (DECL_SECTION_NAME (* node))
-    message = "%qE attribute cannot be applied to variables with specific sections";
+  /* Check that it's possible for the variable to have a section.  */
+  if ((TREE_STATIC (* node) || DECL_EXTERNAL (* node) || in_lto_p)
+      && DECL_SECTION_NAME (* node))
+      message = "%qE attribute cannot be applied to variables with specific sections";
 
   /* If this var is thought to be common, then change this.  Common variables
      are assigned to sections before the backend has a chance to process them.  */