Bug 16497 - IMA changes break linux kernel compile (register vars)
Summary: IMA changes break linux kernel compile (register vars)
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Zack Weinberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-12 13:56 UTC by Michael Matz
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: powerpc-linux
Target: powerpc-linux
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Matz 2004-07-12 13:56:13 UTC
Using current HEAD when compiling this: 
---------------------------------- 
register int *current asm ("r2"); 
int f() 
{ 
  return *current; 
} 
---------------------------------- 
we get this error: 
% ./gcc/cc1 -O2 -quiet r2-test.i 
r2-test.i: In function `f': 
r2-test.i:1: error: register name not specified for 'current' 
 
This was working before.  A CVS hunt identifies this timeframe: 
cvs diff -D "2004-07-08 2000" -D "2004-07-08 2200" ChangeLog, which are Zacks 
patches: 
+2004-07-08  Zack Weinberg  <zack@codesourcery.com> 
+ 
+       * c-decl.c (static_ctors, static_dtors): Make static. 
+       (pop_file_scope): Call c_common_write_pch and 
.... 
+2004-07-08  Zack Weinberg  <zack@codesourcery.com> 
+ 
+       * c-decl.c (pop_scope): Do not set DECL_CONTEXT on file-scope 
+       decls when there is only one input translation unit. 
 
What happens is, that the DECL for 'current' is created twice.  First when 
parsing the declaration with the correct asmspec "r2".  And a second time 
when called again from DECL_RTL macro, because ->decl.rtl was reset in the 
meantime.  This reset happens in check_global_declarations, because of 
      if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) 
          && ! TREE_ASM_WRITTEN (decl)) 
        SET_DECL_RTL (decl, NULL_RTX); 
 
This is called _before_ cgraph_optimize() after Zacks patches.  But this 
compiles the function (and thereby tests the asmspec of the above decl, 
which meanwhile got reset) and therefore emits the error.
Comment 1 Michael Matz 2004-07-12 13:56:58 UTC
Bah.  Sticky keyboards ;)