public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* ICE with x86, PIC, and dwarf2
@ 1999-06-30 23:07 Zack Weinberg
  0 siblings, 0 replies; only message in thread
From: Zack Weinberg @ 1999-06-30 23:07 UTC (permalink / raw)
  To: egcs-bugs

I'm getting an ICE via output_operand_lossage on the appended code, which is
a simplified version of code in GNU libc (malloc.c).

The problem is theoretically present in code as simple as

static int __libc_pagesize;

int fun(void)
{
  int pagesz = __libc_pagesize;
  return pagesz;
}

but the optimizer simplifies this so much that the problem does not occur. 

If you complicate things enough, then we call gen_variable_die on this tree:

 <var_decl 0x8219cb0 pagesz
    type <integer_type 0x821727c long unsigned int allocated from
permanent_obstack
        unsigned asm_written permanent SI
        size <integer_cst 0x8216dd8 constant permanent 32>
        align 32 symtab 136523056 alias set -1 precision 32
        min <integer_cst 0x82172dc constant permanent 0>
        max <integer_cst 0x82172f4 constant permanent 4294967295>>
    allocated from function maybepermanent obstack
    unsigned used common SI file test.c line 12 
	size <integer_cst 0x8216dd8 32>
    align 32 context <function_decl 0x822dfe0 main_trim> 
	initial <error_mark 0x821bab0>
    (mem/f:SI (plus:SI (reg:SI 3 %ebx)
        (const (unspec[ 
                    (symbol_ref/v:SI ("__libc_pagesize"))
                ]  7))) 0)>

gen_variable_die (indirectly) calls addr_const_to_string on the RTL. 
addr_const_to_string can't cope with an UNSPEC, so it aborts.

What's an UNSPEC doing there, anyway?  It's so print_operand_address in
i386.c knows to print `__libc_pagesize@GOTOFF' instead of `__libc_pagesize'. 
Other architectures seem to do this differently.  I'm fairly sure i386 ought
to do it the way they do; getting the print_operand_address logic into
dwarf2out would be awful, and dwarf2out doesn't seem to want @GOT/@GOTOFF
suffixes anyway.

zw

static int main_arena_size;
static unsigned int __libc_pagesize;
static char *sbrk_base = (char *) (-1);

int
main_trim (unsigned int pad)
{
  long top_size;
  long extra;
  char *current_brk;
  char *new_brk;
  unsigned long pagesz = __libc_pagesize;

  extra = ((top_size - pad - (pagesz - 1)) / pagesz - 1) * pagesz;
  if (extra < (long) pagesz)
    return 0;
  if (new_brk == (char *) (0))
    {
      if (top_size >= 32)
        {
          main_arena_size = current_brk - sbrk_base;
        }
      return 0;
    }
  return 1;
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-06-30 23:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-30 23:07 ICE with x86, PIC, and dwarf2 Zack Weinberg

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).