Issue Details (XML | Word | Printable)

Key: PCC-430
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

problem passing char-sized arguments to function tagged with regparm attribute

Created: 11/May/14 09:42 AM   Updated: 27/May/14 10:03 PM
Component/s: C frontend, i386 target
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386


 Description  « Hide
I see problems passing char-sized arguments to functions tagged with regparm attribute. The following code

void __attribute__((__regparm__(3)))
foo(char a)
{
}

void
bar(const char *p)
{
        foo(*p);

        foo(1);
}

fails to compile with pcc. The first call (passing a pointed-to char), causes a compiler error

test.c, line 10: compiler error: Coalesce: src class 2, dst class 1

and the second call (passing an integer value) produces incorrect code

/tmp/ctm.23177b: Assembler messages:
/tmp/ctm.23177b:10: Warning: using `%al' instead of `%eax' due to `b' suffix
/tmp/ctm.23177b:24: Warning: using `%al' instead of `%eax' due to `b' suffix

(and the same result if an explicit cast is used)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 11/May/14 11:07 AM
Now regparms are at least INT to avoid this.

Iain Hibbert added a comment - 27/May/14 07:21 PM
I still see variations of this (in libexpat), with the following code

  int foo;

  void __attribute__((__regparm__(3)))
  bar(int a, char b)
  {
        foo = b;
  }

when compiled with "pcc -c" produces warnings from the assembler

/tmp/ctm.20092b: Assembler messages:
/tmp/ctm.20092b:9: Warning: using `%dl' instead of `%edx' due to `b' suffix

and when compiled with "pcc -c -O2" results in a compiler error

regparm.c, line 6: compiler error: Coalesce: src class 1, dst class 2
/usr/libexec/ccom terminated with status 1


Anders Magnusson added a comment - 27/May/14 10:03 PM
Fixed again. This time by setting specific regs for char arguments.