This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [cft] rewrite i386 dllimport/dllexport


> From: Richard Henderson 
> Sent: Tuesday, 27 March 2007 4:02 a.m.
> 
> On Sun, Mar 25, 2007 at 10:18:03PM +1200, Danny Smith wrote:
> > Unfortunately the changes appear to force all local functions to be
> > called as indirect refs.
> 
> Arg!  There's a missing "return true":

Hello Richard


Two problems, after the fix to predicates.md.

1)
In winnt.c: i386_pe_encode_section_info: 

When generating the decorated name for stdcall/fastcall symbols, your
patch
does this:
+	      XSTR (symbol, 0) = IDENTIFIER_POINTER (newid);

'symbol' has not yet been initialised,

This change (get the symbol_ref earlier) to your revised
i386_pe_encode_section_info works for me:

*** winnt.c.rth	Thu Mar 29 21:46:20 2007
--- winnt.c	Thu Mar 29 21:50:37 2007
*************** i386_pe_encode_section_info (tree decl, 
*** 221,226 ****
--- 221,232 ----
    /* Do this last, due to our frobbing of DECL_DLLIMPORT_P above.  */
    default_encode_section_info (decl, rtl, first);
  
+   if (!VAR_OR_FUNCTION_DECL_P (decl))
+      return;
+  
+   symbol = XEXP (rtl, 0);
+   gcc_assert (GET_CODE (symbol) == SYMBOL_REF);
+ 
    switch (TREE_CODE (decl))
      {
      case FUNCTION_DECL:
*************** i386_pe_encode_section_info (tree decl, 
*** 270,278 ****
        return;
      }
  
-   symbol = XEXP (rtl, 0);
-   gcc_assert (GET_CODE (symbol) == SYMBOL_REF);
- 
    /* Mark the decl so we can tell from the rtl whether the object is
       dllexport'd or dllimport'd.  tree.c:
merge_dllimport_decl_attributes
       handles dllexport/dllimport override semantics.  */


2)
This testcase:

extern int __attribute__ ((dllimport)) foo;
int* bar () {return &foo;}
int foo;

fails with
foo.c:3: warning: 'foo' redeclared without dllimport attribute after
being referenced with dll linkage
foo.c:3: internal compiler error: in
i386_pe_asm_output_aligned_decl_common, at config/i386/winnt.c:487


The problem is that in tree.c: merge_dllimport_decl_attributes we keep
the DECL_DLLIMPORT_P flag in the above case, but lose the attribute. The
DECL_DLLIMPORT_P flag is kept so that
tree.c:recompute_tree_invariant_for_addr_expr
isn't confused. The dllimport attribute is lost so that we don't change
&foo
into _imp__foo.

Should we just emit an undefined _imp__foo and make the user fix up the
code?

If we always trust DECL_DLLIMPORT_P, the

if (delete_dllimport_p)
{...}

 path in  merge_dllimport_decl_attributes is unnecessary.


Danny

> 
> 
> r~
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]