Bad codegen for ARM (and maybe others) when optimizing
    Dan Olson via digitalmars-d-ldc 
    digitalmars-d-ldc at puremagic.com
       
    Fri Feb  6 07:03:11 PST 2015
    
    
  
Dan Olson <zans.is.for.cans at yahoo.com> writes:
>
> I have been looking at IR.  The bug is connected to using the byval
> attribute.  I checked out clang's IR and it does not use byval for
> structs.  It passes structs as an array.  I am wondering if LDC could
> use a abi-arm.cpp to generate something like clang.
>
I think an ARM specific abi class is the right solution.  On a whim, I tried one small change in abi.cpp
    bool passByVal(Type* t)
    {
        // was
        // return t->toBasetype()->ty == Tstruct;
        return false;
    }
This gets rid of LLVM byval attribute and fixes this codegen problem.  The generated instructions are similar to clang.  The parameter is not an array like clang, it is the IR struct type as a value, but it works.
"%badopt.A"  instead of "%badopt.A* byval"
Another thing I noticed about clang is that structs that fit in 32-bits are returned directly in r0 instead of an sret parameter.  There may be more, I need to study clang.
--
Dan
    
    
More information about the digitalmars-d-ldc
mailing list