[Issue 9969] dmd ABI mistake (cfloat static array initialisation)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 20 15:18:57 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9969



--- Comment #5 from John Colvin <john.loughran.colvin at gmail.com> 2013-04-20 23:18:54 BST ---
(In reply to comment #4)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Looks like an issue 9449.
> > > 
> > > I think the problem isn't  "ABI mistake" (or a codegen bug as often mentioned
> > > here - many people who can spot an error from asm output tend to blame backend)
> > > but absence of crosstalk between how dmd assumes memset functions look like and
> > > how they are actually defined in druntime.
> > 
> > I'm confused as to how trying to pass a variable on the stack to an extern(C)
> > function with less than 6 arguments on linux x64 is not a codegen error of some
> > sorts. It's using the wrong calling convention...
> 
> I do not think that if you can see that compiler passes arguments wrong you may
> conclude that it is codegen or ABI bug. That is what actually often happens:
> somebody see error in asm output and blames backend while the problem is really
> in frontend. From what I know after debugging issue 9449 there is likely error
> in scope of AssignExp::toElem
> (https://github.com/D-Programming-Language/dmd/blob/master/src/e2ir.c#L2688)
> (or setArray()) which does not handle properly cases like this. The problem is
> in frontend assumption that druntime defines memset function as taking dynamic
> array. The backend just does what it is told to generate.

I concede that there may well be a frontend problem as well, but in my limited
experience a properly functioning backend should never emit the code we see
here.

System V dictates that the first 6 integer/pointer arguments passed in RDI,
RSI, RDX, RCX, R8, and R9, the first 8 floating point arguments are passed in
XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6 and XMM7 an any further arguments are
passed on the stack.

If the compiler emits code passing 3 arguments to an extern(C) function, 2 in
ESI and EDI and 1 on the stack, then it's a problem relating to the ABI. The
actual signature/behaviour of the target function is irrelevant, AFAIK there is
no possible System V compliant target function for which that argument passing
would be correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list